/* ============================================================
   Ejay Logistics Weekly Dispatch — theme + layout
   ============================================================ */

:root,
[data-theme="dark"] {
  --bg:            #0a0f1a;
  --bg-grid:       #0c1322;
  --surface:       #111827;
  --surface-2:     #161f31;
  --surface-3:     #1d2840;
  --border:        #233047;
  --border-soft:   #1a2435;
  --text:          #e8eef8;
  --text-dim:      #92a1bb;
  --text-faint:    #5c6c87;
  --accent:        #3b82f6;
  --accent-2:      #60a5fa;
  --accent-strong: #2563eb;
  --accent-soft:   rgba(59,130,246,0.14);
  --accent-ring:   rgba(59,130,246,0.35);

  --green:   #22c55e;  --green-soft:  rgba(34,197,94,0.14);
  --blue:    #38bdf8;  --blue-soft:   rgba(56,189,248,0.14);
  --amber:   #f59e0b;  --amber-soft:  rgba(245,158,11,0.15);
  --gray:    #64748b;  --gray-soft:   rgba(100,116,139,0.16);
  --red:     #ef4444;  --red-soft:    rgba(239,68,68,0.14);
  --teal:    #2dd4bf;

  --shadow:   0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.28);
  --shadow-sm:0 1px 2px rgba(0,0,0,0.35);
}

[data-theme="light"] {
  --bg:            #eef2f7;
  --bg-grid:       #e8edf4;
  --surface:       #ffffff;
  --surface-2:     #f7f9fc;
  --surface-3:     #eef2f8;
  --border:        #dce3ec;
  --border-soft:   #e7ecf3;
  --text:          #0f1a2c;
  --text-dim:      #54637a;
  --text-faint:    #8a98ad;
  --accent:        #2563eb;
  --accent-2:      #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft:   rgba(37,99,235,0.10);
  --accent-ring:   rgba(37,99,235,0.28);

  --green:   #16a34a;  --green-soft:  rgba(22,163,74,0.12);
  --blue:    #0284c7;  --blue-soft:   rgba(2,132,199,0.12);
  --amber:   #d97706;  --amber-soft:  rgba(217,119,6,0.14);
  --gray:    #64748b;  --gray-soft:   rgba(100,116,139,0.12);
  --red:     #dc2626;  --red-soft:    rgba(220,38,38,0.10);
  --teal:    #0d9488;

  --shadow:   0 1px 2px rgba(15,26,44,0.08), 0 10px 26px rgba(15,26,44,0.08);
  --shadow-sm:0 1px 2px rgba(15,26,44,0.07);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: var(--accent-ring); }

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------- App shell ---------------- */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  overflow: hidden;
}
.app.collapsed { grid-template-columns: 72px 1fr; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border-soft);
  min-height: 64px;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(140deg, var(--accent-2), var(--accent-strong));
  display: grid; place-items: center;
  box-shadow: 0 2px 10px var(--accent-ring);
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-text { min-width: 0; }
.brand-text .b1 { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-text .b2 { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; }
.collapsed .brand-text { display: none; }
.collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }

.nav { padding: 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.13em; color: var(--text-faint); font-weight: 700; padding: 14px 10px 6px; }
.collapsed .nav-label { text-align: center; font-size: 8px; padding: 12px 0 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px; cursor: pointer;
  color: var(--text-dim); font-weight: 500; font-size: 13.5px;
  border: 1px solid transparent; position: relative;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-ring); font-weight: 600; }
.nav-item .badge-count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--text-dim);
  border-radius: 20px; padding: 1px 8px; min-width: 22px; text-align: center;
}
.nav-item.active .badge-count { background: var(--accent); color: #fff; }
.nav-item .badge-count.alert { background: var(--red); color: #fff; animation: pulse 1.6s infinite; }
.collapsed .nav-item { justify-content: center; padding: 11px 0; }
.collapsed .nav-item span, .collapsed .nav-item .badge-count { display: none; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border-soft); }
.sim-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-weight: 600; font-size: 13px;
}
.sim-toggle:hover { border-color: var(--accent-ring); }
.sim-toggle.live { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.sim-toggle svg { width: 16px; height: 16px; }
.collapsed .sim-toggle span { display: none; }
.collapsed .sim-toggle { justify-content: center; }

/* ---------------- Main ---------------- */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 26px; min-height: 64px; height: 64px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; flex: none;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn svg { width: 18px; height: 18px; }
.page-title { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; }
.page-sub { font-size: 12.5px; color: var(--text-faint); margin-top: 1px; }
.topbar-spacer { flex: 1; }

.week-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 7px 13px; border-radius: 10px; font-size: 13px;
}
.week-chip .lbl { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.week-chip .val { font-weight: 600; }
.week-chip svg { width: 15px; height: 15px; color: var(--accent-2); }

.nc-clock { display: flex; align-items: center; gap: 9px; padding: 5px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.nc-clock svg { width: 16px; height: 16px; color: var(--accent-2); flex: none; }
.nc-clock-txt { display: flex; flex-direction: column; line-height: 1.15; }
.nc-clock .nc-time { font-weight: 700; font-size: 13px; }
.nc-clock .nc-day { font-size: 10.5px; color: var(--text-faint); }

.live-pill {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--green);
  background: var(--green-soft); border: 1px solid var(--green);
  padding: 5px 11px; border-radius: 20px;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.content { flex: 1; overflow-y: auto; padding: 26px; background:
  radial-gradient(1200px 400px at 80% -10%, var(--bg-grid), transparent 70%); }
.view { max-width: 1320px; margin: 0 auto; }
.view-head { margin-bottom: 20px; }
.view-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.view-head p { color: var(--text-dim); margin: 4px 0 0; font-size: 13.5px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  transition: background .12s, border-color .12s, transform .06s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-danger { color: var(--red); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border-soft); }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.card-head .sub { font-size: 12px; color: var(--text-faint); }
.card-body { padding: 18px; }

/* KPI grid */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 16px 15px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
}
.kpi::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent); opacity: .9; }
.kpi.k-green::after { background: var(--green); }
.kpi.k-blue::after { background: var(--blue); }
.kpi.k-amber::after { background: var(--amber); }
.kpi.k-gray::after { background: var(--gray); }
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .k-label { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.kpi .k-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-2); }
.kpi.k-green .k-ic { background: var(--green-soft); color: var(--green); }
.kpi.k-blue .k-ic { background: var(--blue-soft); color: var(--blue); }
.kpi.k-amber .k-ic { background: var(--amber-soft); color: var(--amber); }
.kpi.k-gray .k-ic { background: var(--gray-soft); color: var(--gray); }
.kpi .k-ic svg { width: 17px; height: 17px; }
.kpi .k-val { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; margin-top: 10px; line-height: 1; }
.kpi .k-foot { font-size: 11.5px; color: var(--text-faint); margin-top: 7px; }
.kpi .k-foot b { color: var(--text-dim); font-weight: 600; }

/* ---------------- Tables ---------------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); font-weight: 700; padding: 11px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }

/* avatar / id chip */
.idchip {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex: none;
  background: var(--accent-soft); color: var(--accent-2); font-family: "IBM Plex Mono", monospace;
}
.cell-driver { display: flex; align-items: center; gap: 11px; }
.cell-driver .nm { font-weight: 600; }
.cell-driver .ph { font-size: 11.5px; color: var(--text-faint); }

/* ---------------- Badges / status ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.b-green { background: var(--green-soft); color: var(--green); } .b-green .dot { background: var(--green); }
.b-blue  { background: var(--blue-soft);  color: var(--blue);  } .b-blue .dot  { background: var(--blue); }
.b-amber { background: var(--amber-soft); color: var(--amber); } .b-amber .dot { background: var(--amber); }
.b-gray  { background: var(--gray-soft);  color: var(--gray);  } .b-gray .dot  { background: var(--gray); }
.b-accent{ background: var(--accent-soft);color: var(--accent-2);} .b-accent .dot{ background: var(--accent); }

.route { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-family: "IBM Plex Mono", monospace; font-size: 12.5px; }
.route svg { width: 14px; height: 14px; color: var(--text-faint); }
.route .reg { padding: 1px 7px; border-radius: 6px; background: var(--surface-3); }

/* ---------------- Dispatch board ---------------- */
.board-wrap { overflow-x: auto; }
.board {
  display: grid; gap: 8px; min-width: 760px;
}
.board-col-head, .board-row-head { font-size: 11.5px; }
.board-cell {
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 10px; min-height: 78px; padding: 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; transition: border-color .1s, background .1s;
}
.board-cell:hover { border-color: var(--accent-ring); }
.board-cell.empty { background: transparent; border-style: dashed; cursor: default; }
.board-cell.empty:hover { border-color: var(--border-soft); }
.board-corner { }
.board-day { text-align: center; padding: 8px 4px; }
.board-day .wd { font-weight: 700; font-size: 12px; }
.board-day .dt { font-size: 11px; color: var(--text-faint); font-family: "IBM Plex Mono", monospace; }
.board-day.weekend .wd { color: var(--amber); }
.board-truck { display: flex; align-items: center; gap: 9px; padding: 0 4px; }
.board-truck .t-ic { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-dim); }
.board-truck .t-ic svg { width: 15px; height: 15px; }
.board-truck .t-nm { font-weight: 700; font-size: 13px; }
.board-truck .t-pl { font-size: 11px; color: var(--text-faint); font-family: "IBM Plex Mono", monospace; }

.load-chip {
  border-radius: 8px; padding: 6px 8px; font-size: 11.5px; font-weight: 600;
  border-left: 3px solid var(--gray); background: var(--surface);
  display: flex; flex-direction: column; gap: 2px; position: relative;
}
.load-chip.l-out  { border-left-color: var(--green); background: var(--green-soft); }
.load-chip.l-back { border-left-color: var(--blue);  background: var(--blue-soft); }
.load-chip.l-delayed { border-left-color: var(--amber); background: var(--amber-soft); }
.load-chip .lc-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.load-chip .lc-drv { color: var(--text); }
.load-chip .lc-route { font-family: "IBM Plex Mono", monospace; font-size: 10.5px; color: var(--text-dim); font-weight: 600; }
.load-chip .lc-st { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.04em; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 16px; }
.legend .li { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); }
.legend .sw { width: 12px; height: 12px; border-radius: 4px; }

/* ---------------- Utilization chart ---------------- */
.util-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.util-row:last-child { margin-bottom: 0; }
.util-label { width: 120px; flex: none; }
.util-label .tn { font-weight: 700; font-size: 13px; }
.util-label .ts { font-size: 11px; color: var(--text-faint); font-family: "IBM Plex Mono", monospace; }
.util-bar-track { flex: 1; height: 26px; background: var(--surface-3); border-radius: 7px; overflow: hidden; position: relative; }
.util-bar-fill { height: 100%; border-radius: 7px; background: linear-gradient(90deg, var(--accent-strong), var(--accent-2)); display: flex; align-items: center; justify-content: flex-end; padding-right: 9px; color: #fff; font-weight: 700; font-size: 12px; transition: width .6s cubic-bezier(.4,0,.2,1); min-width: 34px; }

/* ---------------- Forms / modal ---------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(4,8,16,0.62); backdrop-filter: blur(3px); padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  width: 100%; max-width: 480px; box-shadow: var(--shadow); overflow: hidden;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 15px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border-soft); background: var(--surface-2); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.input, .select {
  width: 100%; padding: 10px 12px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* popover for cell edit */
.popover {
  position: fixed; z-index: 110; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 8px; min-width: 220px;
}
.popover .pop-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); font-weight: 700; padding: 6px 8px 8px; }
.pop-opt { display: flex; align-items: center; gap: 9px; padding: 8px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; }
.pop-opt:hover { background: var(--surface-2); }
.pop-opt.sel { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.pop-opt .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* misc */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { padding: 6px 13px; border-radius: 7px; border: none; background: transparent; color: var(--text-dim); cursor: pointer; font-weight: 600; font-size: 12.5px; }
.seg button.on { background: var(--accent-strong); color: #fff; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-faint); }
.empty-state svg { width: 38px; height: 38px; opacity: 0.5; margin-bottom: 12px; }
.divider { height: 1px; background: var(--border-soft); margin: 4px 0; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text);
  padding: 11px 18px; border-radius: 11px; box-shadow: var(--shadow); z-index: 200;
  font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 9px;
  animation: pop .18s ease-out;
}
.toast svg { width: 16px; height: 16px; color: var(--green); }

.two-col { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 18px; }

.activity-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center; }
.activity-dot svg { width: 15px; height: 15px; }
.activity-item .ai-main { font-size: 13px; }
.activity-item .ai-main b { font-weight: 600; }
.activity-item .ai-time { font-size: 11.5px; color: var(--text-faint); font-family: "IBM Plex Mono", monospace; }

.mobile-only { display: none; }

/* ---------------- Dispatcher's Work checklist ---------------- */
.dispatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.day-card { display: flex; flex-direction: column; }
.day-card.done { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), var(--shadow-sm); }
.day-card.missed { border-color: var(--red); box-shadow: 0 0 0 1px var(--red), var(--shadow-sm); }
.day-head { display: flex; align-items: center; gap: 12px; padding: 15px 16px; border-bottom: 1px solid var(--border-soft); }
.day-head .dh-day { font-weight: 700; font-size: 15px; }
.day-head .dh-date { font-size: 11.5px; color: var(--text-faint); font-family: "IBM Plex Mono", monospace; }
.day-head .dh-prog { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--text-dim); font-family: "IBM Plex Mono", monospace; }
.day-done-badge {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
  font-size: 11.5px; font-weight: 700; color: var(--green);
  background: var(--green-soft); border: 1px solid var(--green);
  padding: 4px 11px; border-radius: 20px;
}
.day-done-badge svg { width: 13px; height: 13px; }
.day-missed-badge {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
  font-size: 11.5px; font-weight: 700; color: var(--red);
  background: var(--red-soft); border: 1px solid var(--red);
  padding: 4px 11px; border-radius: 20px;
}
.day-missed-badge svg { width: 13px; height: 13px; }
.dh-today {
  margin-left: 8px; font-size: 10px; font-weight: 700; color: var(--accent-2);
  background: var(--accent-soft); border: 1px solid var(--accent-ring);
  padding: 1px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.06em;
  vertical-align: middle;
}
.day-tasks { padding: 6px; }
.task-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 10px;
  border-radius: 10px; cursor: pointer; transition: background .1s;
  border: 1px solid transparent;
}
.task-row:hover { background: var(--surface-2); }
.task-check {
  width: 22px; height: 22px; border-radius: 7px; flex: none;
  border: 2px solid var(--border); display: grid; place-items: center;
  transition: background .12s, border-color .12s; background: var(--surface-2);
}
.task-check svg { width: 14px; height: 14px; color: #fff; opacity: 0; transform: scale(.6); transition: opacity .12s, transform .12s; }
.task-row.done .task-check { background: var(--green); border-color: var(--green); }
.task-row.done .task-check svg { opacity: 1; transform: scale(1); }
.task-body { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.task-id {
  width: 26px; height: 26px; border-radius: 7px; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 12px; font-family: "IBM Plex Mono", monospace;
}
.task-id.t-out  { background: var(--green-soft); color: var(--green); }
.task-id.t-back { background: var(--blue-soft);  color: var(--blue); }
.task-text { min-width: 0; }
.task-text .tt-main { font-weight: 600; font-size: 13.5px; }
.task-text .tt-sub { font-size: 11.5px; color: var(--text-faint); }
.task-row.done .task-text .tt-main { color: var(--text-faint); text-decoration: line-through; }
.task-row.missed { background: var(--red-soft); }
.task-row.missed .task-check { border-color: var(--red); background: var(--red-soft); }
.task-row.missed .task-check svg { color: var(--red); opacity: 1; transform: scale(1); }
.task-row.missed .task-text .tt-main { color: var(--red); }
.task-leg-dot { width: 8px; height: 8px; border-radius: 50%; margin-left: auto; flex: none; }
.task-leg-dot.t-out { background: var(--green); }
.task-leg-dot.t-back { background: var(--blue); }

.all-done-banner {
  display: flex; align-items: center; gap: 14px; padding: 18px 20px; margin-bottom: 18px;
  background: var(--green-soft); border: 1px solid var(--green); border-radius: 14px;
}
.missed-banner {
  display: flex; align-items: center; gap: 14px; padding: 16px 20px; margin-bottom: 18px;
  background: var(--red-soft); border: 1px solid var(--red); border-radius: 14px;
}
.missed-banner .mb-ic { width: 40px; height: 40px; border-radius: 11px; background: var(--red); display: grid; place-items: center; flex: none; }
.missed-banner .mb-ic svg { width: 20px; height: 20px; color: #fff; }
.missed-banner .mb-title { font-size: 15px; font-weight: 700; color: var(--red); }
.missed-banner .mb-sub { font-size: 12.5px; color: var(--text-dim); }
.all-done-banner .adb-ic { width: 42px; height: 42px; border-radius: 11px; background: var(--green); display: grid; place-items: center; flex: none; }
.all-done-banner .adb-ic svg { width: 22px; height: 22px; color: #fff; }
.all-done-banner .adb-title { font-size: 16px; font-weight: 700; color: var(--green); }
.all-done-banner .adb-sub { font-size: 12.5px; color: var(--text-dim); }

.save-note { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-faint); }
.save-note svg { width: 14px; height: 14px; color: var(--green); }

/* ---------------- Login gate ---------------- */
.gate {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center; padding: 24px;
  background: var(--bg);
  overflow: hidden;
}
.gate-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(900px 500px at 78% -8%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 500px at 10% 110%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%);
}
.gate-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow);
  padding: 30px 28px 22px;
  display: flex; flex-direction: column; gap: 12px;
}
.gate-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.gate-title { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.gate-sub { font-size: 13px; color: var(--text-dim); margin-top: -6px; margin-bottom: 4px; }
.gate-input {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 0 12px; transition: border-color .12s, box-shadow .12s;
}
.gate-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.gate-input.err { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.gate-input input {
  flex: 1; border: none; background: transparent; outline: none;
  padding: 12px 0; font-size: 14px; letter-spacing: 0.02em;
}
.gate-eye { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 4px; display: grid; place-items: center; }
.gate-eye:hover { color: var(--text); }
.gate-err { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--red); font-weight: 500; }
.gate-foot { text-align: center; font-size: 11px; color: var(--text-faint); margin-top: 8px; letter-spacing: 0.02em; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 260px; z-index: 60;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 55; }
  .mobile-only { display: grid; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 18px; }
  .topbar { padding: 0 16px; }
  .week-chip .lbl { display: none; }
  .nc-clock .nc-day { display: none; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-sub { display: none; }
}
