/* Matrix Line Export Cloud – PRO */
:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --ink: #16202e;
  --muted: #6b7a8f;
  --line: #dde5ee;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --purple: #7c3aed;
  --side: #0f1b2d;
  --side-2: #16263d;
  --radius: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14.5px; line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: "Cascadia Mono", Consolas, Menlo, monospace; }
code { background: #f1f5fb; border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; font-size: 12.5px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 232px; flex: 0 0 232px; background: linear-gradient(180deg, var(--side), var(--side-2));
  color: #cdd9ea; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo { font-size: 26px; color: #7db4ff; }
.brand-name { font-weight: 700; color: #fff; letter-spacing: .3px; }
.brand-sub { font-size: 11.5px; color: #8fa5c0; }
.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 10px; color: #b9c8dc; padding: 9px 12px;
  border-radius: 8px; margin-bottom: 2px; font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-ic { width: 20px; text-align: center; }
.side-user { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.side-user-name { color: #fff; font-weight: 600; }
.side-user-role { font-size: 12px; color: #8fa5c0; margin-bottom: 8px; }

.main { flex: 1; min-width: 0; }
.content { padding: 22px 26px 60px; max-width: 1280px; }
.impersonate-bar {
  background: #7c3aed; color: #fff; padding: 8px 26px; font-size: 13.5px;
}
.impersonate-bar a { color: #fff; font-weight: 600; margin-left: 10px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; }

/* ---------- cards / grids ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(22,32,46,.04);
}
.card h2 { font-size: 16px; margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.card-head h2 { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: block; color: var(--ink);
}
.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat-num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 13px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: #f7fafd; }
.table-sm td, .table-sm th { padding: 6px 8px; font-size: 13px; }
.kv td { padding: 5px 8px 5px 0; vertical-align: top; }
.kv td:first-child { color: var(--muted); width: 42%; }
.ta-r { text-align: right; }
.ta-c { text-align: center; }
.actions form.inline, .inline { display: inline-block; }
.actions { white-space: nowrap; }
.actions .btn { margin-left: 4px; }
.code-cell { max-width: 340px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: middle; white-space: nowrap; }

/* ---------- buttons / badges ---------- */
.btn {
  display: inline-block; background: #fff; color: var(--ink); border: 1px solid #c9d5e3;
  padding: 8px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); color: #fff; }
.btn-danger { color: var(--err); border-color: #f3c1c1; }
.btn-danger:hover { background: var(--err); border-color: var(--err); color: #fff; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.25); color: #cdd9ea; }
.btn-ghost:hover { border-color: #fff; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

.badge {
  display: inline-block; font-size: 11.5px; font-weight: 700; border-radius: 20px;
  padding: 2px 10px; vertical-align: middle;
}
.badge-gray   { background: #eceff4; color: #5b6b7f; }
.badge-blue   { background: #dbe7ff; color: #1d4ed8; }
.badge-green  { background: #d9f2e2; color: #15803d; }
.badge-red    { background: #fde2e2; color: #b91c1c; }
.badge-orange { background: #fdeacc; color: #b45309; }
.badge-purple { background: #eadcfd; color: #6d28d9; }
.text-red { color: var(--err); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hint { color: var(--muted); font-size: 13px; margin-bottom: 10px; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.field input[type=text], .field input[type=password], .field input[type=number],
.field input[type=date], .field input[type=file], .field select, .field textarea {
  width: 100%; border: 1px solid #c9d5e3; border-radius: 8px; padding: 9px 11px;
  font-size: 14px; background: #fff; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.field-check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 22px; }
.form-grid .field-wide { grid-column: 1 / -1; }
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } }
.form-narrow { max-width: 480px; }
.input-sm { border: 1px solid #c9d5e3; border-radius: 8px; padding: 5px 8px; }
.append-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.append-form label { font-weight: 600; font-size: 13px; }

/* ---------- flash / progress ---------- */
.flash { border-radius: 10px; padding: 11px 15px; margin-bottom: 16px; font-weight: 500; }
.err-list { margin: 8px 0 2px 20px; }
.err-list li { margin-bottom: 3px; }
.flash-ok { background: #d9f2e2; color: #15603d; border: 1px solid #b3e4c5; }
.flash-error { background: #fde2e2; color: #991b1b; border: 1px solid #f5bcbc; }

.progress { position: relative; background: #e4eaf2; border-radius: 20px; height: 20px; overflow: hidden; min-width: 120px; }
.progress-lg { height: 26px; }
.progress-fill { background: linear-gradient(90deg, #3b82f6, #2563eb); height: 100%; transition: width .3s; }
.progress-fill-green { background: linear-gradient(90deg, #34d399, #16a34a); }
.progress-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; color: #223; mix-blend-mode: normal;
}

/* ---------- auth ---------- */
.auth-body { background: linear-gradient(135deg, #0f1b2d, #1e3a5f 60%, #2563eb); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { background: #fff; border-radius: 16px; padding: 34px 36px 26px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-logo { font-size: 40px; color: var(--primary); text-align: center; }
.auth-title { font-size: 20px; text-align: center; margin-top: 6px; }
.auth-sub { text-align: center; color: var(--muted); margin-bottom: 20px; font-size: 13px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }

/* ---------- operator task cards ---------- */
.task-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.task-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.task-card-done { opacity: .7; }
.task-card-top { display: flex; justify-content: space-between; margin-bottom: 6px; }
.task-card-name { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.task-card-meta { font-size: 13px; margin-bottom: 10px; }
.task-card-actions { margin-top: 12px; }

/* ---------- aggregation screen ---------- */
.agg-topbar { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; }
.agg-stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.agg-stat-num { font-size: 24px; font-weight: 800; }
.agg-progress { flex: 1; min-width: 220px; }
.agg-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .agg-grid { grid-template-columns: 1fr; } }
.agg-buffer-num { font-size: 26px; font-weight: 800; color: var(--ok); }
.scan-input-wrap { display: flex; gap: 8px; margin: 14px 0 4px; }
.scan-input {
  flex: 1; font-size: 17px; padding: 12px 14px; border: 2px solid var(--primary); border-radius: 10px;
  font-family: "Cascadia Mono", Consolas, monospace;
}
.scan-input:focus { outline: none; box-shadow: 0 0 0 4px rgba(37,99,235,.18); }
.scan-log { margin-top: 12px; max-height: 320px; overflow-y: auto; }
.scan-log-item { padding: 5px 9px; border-radius: 7px; font-size: 13px; font-family: Consolas, monospace; margin-bottom: 3px; }
.log-ok { background: #eefaf2; color: #166534; }
.log-err { background: #fdf0f0; color: #b91c1c; }
.log-time { color: #8898aa; font-size: 11px; margin-right: 6px; }
.pallet-sscc { font-size: 19px; font-weight: 700; letter-spacing: 1px; margin: 4px 0 6px; word-break: break-all; }
.pallet-groups { color: var(--muted); margin-bottom: 8px; }
.conn-dot { width: 12px; height: 12px; border-radius: 50%; background: #cbd5e1; display: inline-block; }
.conn-dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(22,163,74,.7); }

/* ---------- modals & toasts ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,18,30,.62); display: flex;
  align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.modal { background: #fff; border-radius: 16px; padding: 26px 28px; width: 100%; max-width: 460px; box-shadow: 0 24px 80px rgba(0,0,0,.4); }
.modal-wide { max-width: 620px; }
.modal h2 { margin-bottom: 8px; }
.modal p { color: var(--muted); margin-bottom: 12px; }
.modal-err { color: var(--err); font-weight: 700; min-height: 20px; margin-top: 6px; }
.expected-code { background: #f4f8fd; border: 1px dashed #b9cce4; border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.expected-code-val { font-size: 17px; font-weight: 700; word-break: break-all; }
.gs-mark { color: var(--purple); font-weight: 400; opacity: .8; }

.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #16202e; color: #fff; border-radius: 10px; padding: 11px 16px; max-width: 380px;
  opacity: 0; transform: translateY(8px); transition: all .3s; font-weight: 500; box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.toast.show { opacity: 1; transform: none; }
.toast-err { background: #b91c1c; }
.toast-ok { background: #15803d; }

/* ---------- task view pallet blocks ---------- */
.pallet-block { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.pallet-block summary {
  cursor: pointer; padding: 10px 14px; background: #f7fafd; display: flex; gap: 12px;
  align-items: center; flex-wrap: wrap; font-weight: 600;
}
.pallet-block[open] summary { border-bottom: 1px solid var(--line); }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .side { width: 100%; flex: none; height: auto; position: static; }
  .nav { display: flex; flex-wrap: wrap; }
  .content { padding: 16px; }
}
