/* ============================================================
   LOTHAMILK – giao diện web quản lý cân hàng
   ============================================================ */
:root {
  --brand: #0B3296;
  --brand-700: #082571;
  --brand-900: #061a52;
  --brand-100: #dfe8fb;
  --brand-50: #f0f4fd;
  --accent: #0f9d6b;
  --accent-50: #e7f6ef;
  --warn: #c77700;
  --warn-50: #fdf3df;
  --danger: #d1383d;
  --danger-50: #fdecec;
  --ink: #101a36;
  --ink-2: #47526b;
  --muted: #76809a;
  --line: #e3e8f1;
  --line-2: #eef1f7;
  --bg: #f3f5fa;
  --card: #ffffff;
  --series: #2a78d6;       /* màu cột biểu đồ */
  --series-soft: #cde2fb;
  --edit: #fffbe6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 26, 54, .05), 0 6px 20px rgba(16, 26, 54, .05);
  --side-w: 248px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
svg.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------- nút, ô nhập ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--brand-50); border-color: #cfd9ee; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .inp:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, .nav a:focus-visible {
  outline: 3px solid rgba(42, 120, 214, .35); outline-offset: 1px;
}
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn-green { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-green:hover { background: #0c8459; border-color: #0c8459; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-lg { height: 46px; font-size: 15px; border-radius: 12px; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border: 0; border-radius: 10px;
  background: transparent; cursor: pointer; color: inherit;
}
.icon-btn:hover { background: rgba(127, 140, 170, .16); }

.inp {
  height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-width: 0; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
select.inp { padding-right: 30px; appearance: none; -webkit-appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%2376809a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 11px center; }
.inp:hover { border-color: #c9d3e6; }
.inp:focus { border-color: var(--series); box-shadow: 0 0 0 3px rgba(42, 120, 214, .16); outline: 0; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }

.chip {
  height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-weight: 500; font-size: 13px; white-space: nowrap; color: var(--ink-2);
}
.chip:hover { border-color: #c9d3e6; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--accent-50); color: #0b7a53; }
.badge.warn { background: var(--warn-50); color: #9a5b00; }
.badge.off { background: #eef0f5; color: var(--muted); }
.badge.blue { background: var(--brand-100); color: var(--brand); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #b9c1d3; flex: none; }
.dot.on { background: #12b76a; box-shadow: 0 0 0 3px rgba(18, 183, 106, .18); }

/* ---------------- đăng nhập ---------------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: #fff; }
.login-art {
  position: relative; overflow: hidden; color: #fff; display: grid; align-items: center; padding: 56px;
  background:
    radial-gradient(900px 500px at 110% -10%, rgba(92, 160, 255, .45), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(15, 157, 107, .35), transparent 60%),
    linear-gradient(150deg, #0B3296 0%, #061a52 100%);
}
.login-art::after {
  content: ""; position: absolute; right: -120px; bottom: -160px; width: 520px; height: 520px; border-radius: 50%;
  border: 80px solid rgba(255, 255, 255, .05);
}
.login-art-inner { position: relative; z-index: 1; max-width: 460px; }
.login-art-logo { width: 190px; margin-bottom: 40px; display: block; }
.login-art h2 { font-size: 34px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.login-art p { margin-top: 16px; font-size: 15px; color: rgba(255, 255, 255, .82); }
.login-art ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.login-art li { padding-left: 30px; position: relative; color: rgba(255, 255, 255, .92); }
.login-art li::before {
  content: ""; position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255, 255, 255, .16) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 9.5l2.5 2.5L13 6.5'/%3E%3C/svg%3E") center/18px no-repeat;
}
.login-pane { display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: min(380px, 100%); display: grid; gap: 16px; }
.login-logo { width: 150px; margin-bottom: 6px; }
.login-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.login-card .inp { height: 46px; font-size: 15px; border-radius: 12px; }
.pw { position: relative; }
.pw .inp { padding-right: 62px; }
.pw-eye { position: absolute; right: 6px; top: 6px; height: 34px; padding: 0 10px; border: 0; background: transparent; color: var(--brand); font-weight: 600; font-size: 13px; cursor: pointer; border-radius: 8px; }
.form-err { background: var(--danger-50); color: #a3262b; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: .04em; margin-top: 8px; }

/* ---------------- khung ứng dụng ---------------- */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; color: #fff; z-index: 40;
  background: linear-gradient(180deg, #0B3296 0%, #061a52 100%);
}
.side-logo { display: block; padding: 22px 22px 18px; }
.side-logo img { width: 132px; display: block; }
.nav { flex: 1; overflow-y: auto; padding: 6px 12px; display: grid; gap: 2px; align-content: start; }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 10px;
  color: rgba(255, 255, 255, .78); font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.on { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.nav .nav-sep { margin: 12px 12px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .45); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 14px 14px 18px; border-top: 1px solid rgba(255, 255, 255, .1); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: rgba(255, 255, 255, .16); display: grid; place-items: center; font-weight: 700; flex: none; }
.side-user-text { flex: 1; min-width: 0; line-height: 1.25; }
.side-user-text b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.side-user-text span { font-size: 12px; color: rgba(255, 255, 255, .6); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 30; height: 64px; padding: 0 28px; display: flex; align-items: center; gap: 12px;
  background: rgba(243, 245, 250, .86); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
.top h1 { font-size: 21px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-menu, .top-logo { display: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 0 12px; height: 32px; white-space: nowrap; }

.filters { padding: 0 28px 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters:empty { display: none; }
.filters .inp { width: auto; }
.f-station { min-width: 190px; }
.f-dates { display: flex; align-items: center; gap: 6px; }
.f-dates .inp { width: 146px; }
.f-chips { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.f-chips::-webkit-scrollbar { display: none; }

.view { padding: 4px 28px 40px; outline: 0; flex: 1; }
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2 { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.g-2e { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.stack > *, .grid > * { min-width: 0; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid rgba(227, 232, 241, .7); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px 0; }
.card-h h2 { font-size: 15px; font-weight: 600; }
.card-h .sub { color: var(--muted); font-size: 12.5px; }
.card-h .sp { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-b { padding: 14px 18px 18px; }
.card-b.flush { padding: 8px 0 6px; }

/* ---------------- ô số liệu ---------------- */
.kpi { padding: 18px; display: grid; gap: 6px; position: relative; overflow: hidden; }
.kpi-label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.kpi-ico svg { width: 17px; height: 17px; }
.kpi-val { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi-val small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpi-sub { font-size: 12.5px; color: var(--muted); min-height: 19px; }
.kpi.hero { background: linear-gradient(140deg, #0B3296 0%, #1a4fc4 100%); color: #fff; border: 0; }
.kpi.hero .kpi-label, .kpi.hero .kpi-sub, .kpi.hero .kpi-val small { color: rgba(255, 255, 255, .78); }
.kpi.hero .kpi-ico { background: rgba(255, 255, 255, .16); color: #fff; }
.kpi.hero .kpi-val { font-size: 34px; }
.delta { font-weight: 600; }
.delta.up { color: #0b7a53; } .delta.down { color: #b3373b; }
.kpi.hero .delta.up { color: #8ff0c4; } .kpi.hero .delta.down { color: #ffb3b5; }

/* ---------------- biểu đồ ---------------- */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-l { stroke: var(--line-2); stroke-width: 1; }
.chart .axis-t { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--series); transition: fill .12s; }
.chart .bar.dim { fill: var(--series-soft); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hover { fill: #1c5cab; }
.hbar { display: grid; gap: 12px; }
.hbar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.hbar-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-name small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.hbar-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.hbar-track { grid-column: 1 / -1; height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--series); border-radius: 0 4px 4px 0; min-width: 2px; }
.tip {
  position: fixed; z-index: 100; pointer-events: none; background: #101a36; color: #fff; border-radius: 10px; padding: 8px 11px;
  font-size: 12.5px; line-height: 1.45; box-shadow: 0 8px 24px rgba(16, 26, 54, .28); max-width: 240px;
}
.tip b { font-size: 13.5px; }
.tip span { color: rgba(255, 255, 255, .7); }

/* ---------------- bảng ---------------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  position: sticky; top: 0; text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); background: #f7f9fc;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--brand-50); }
.tbl th.right, .tbl td.right { text-align: right; }
.tbl th.center, .tbl td.center { text-align: center; }
.tbl tfoot td { background: #f7f9fc; font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; }
.tbl .name b { font-weight: 600; display: block; }
.tbl .name span { color: var(--muted); font-size: 12.5px; }
.minibar { display: inline-block; height: 6px; border-radius: 3px; background: var(--series); vertical-align: middle; margin-right: 8px; min-width: 2px; }
.empty { padding: 44px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.toolbar .inp { width: auto; }
.toolbar .search { flex: 1 1 220px; min-width: 160px; }
.toolbar .sp { margin-left: auto; display: flex; gap: 8px; }
.sumbar { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 12px 18px; background: #f7f9fc; border-bottom: 1px solid var(--line-2); font-size: 13px; color: var(--ink-2); }
.sumbar b { color: var(--ink); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line-2); color: var(--muted); font-size: 13px; }
.pager .pg { display: flex; gap: 6px; align-items: center; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.tabs::-webkit-scrollbar { display: none; }

/* ---------------- trạm ---------------- */
.st-card { padding: 18px; display: grid; gap: 14px; }
.st-head { display: flex; align-items: center; gap: 12px; }
.st-code { width: 46px; height: 46px; border-radius: 12px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.st-head h3 { font-size: 15.5px; font-weight: 600; }
.st-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.st-stats div { background: #f7f9fc; border-radius: 10px; padding: 10px; }
.st-stats b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.st-stats span { font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ---------------- hộp thoại ---------------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(10, 18, 40, .5); animation: fade .15s; }
.modal-box { background: #fff; border-radius: 18px; width: min(880px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(10, 18, 40, .35); animation: pop .18s; }
.modal-h { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal-h h2 { font-size: 17px; font-weight: 700; }
.modal-h .sp { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.modal-b { padding: 18px 20px 22px; overflow-y: auto; display: grid; gap: 18px; }
.sig-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.sig { border: 1px dashed #cfd7e6; border-radius: 12px; padding: 10px; text-align: center; background: #fbfcfe; }
.sig h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.sig img { max-width: 100%; height: 84px; object-fit: contain; display: block; margin: 0 auto; }
.sig .none { height: 84px; display: grid; place-items: center; color: #a9b2c6; font-size: 13px; }
.sig b { display: block; margin-top: 6px; font-size: 13.5px; }
.sig-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sig-row.three .sig img, .sig-row.three .sig .none { height: 110px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 120; background: #101a36; color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(16, 26, 54, .3); font-weight: 500; max-width: calc(100vw - 32px); }
.toast.err { background: #b3373b; }

/* ---------------- bảng kê ---------------- */
.bk-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px 28px; padding: 16px 18px; align-items: center; border-bottom: 1px solid var(--line-2); }
.bk-head > div:first-child { min-width: 0; flex: 1 1 320px; }
.bk-head h3 { font-size: 16px; font-weight: 700; }
.bk-totals { display: flex; gap: 22px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.bk-totals b { display: block; font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.bk-totals .pay b { color: var(--brand); }
.bk-tbl input { width: 100%; height: 32px; border: 1px solid transparent; background: var(--edit); border-radius: 7px; padding: 0 8px; text-align: center; min-width: 58px; }
.bk-tbl input.r { text-align: right; }
.bk-tbl input.l { text-align: left; min-width: 110px; }
.bk-tbl input:hover { border-color: #e6d98a; }
.bk-tbl input:focus { border-color: var(--series); background: #fff; box-shadow: 0 0 0 3px rgba(42, 120, 214, .16); outline: 0; }
.bk-tbl td { padding: 6px 8px; }
.bk-tbl td.auto { padding: 10px 12px; white-space: nowrap; }
.bk-tbl th.e { background: #fff8d6; }
.bk-note { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; padding: 10px 18px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line-2); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; background: var(--edit); border: 1px solid #e6d98a; }
.bk-sec { padding: 14px 18px 4px; font-weight: 700; font-size: 13.5px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-weight: 500; white-space: nowrap; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }

/* ---------------- nhập liệu từ web ---------------- */
.btn-danger { color: #a3262b; border-color: #f1c9cb; background: #fff; }
.btn-danger:hover { background: var(--danger-50); border-color: #e7a9ac; }
.modal-box.narrow { width: min(560px, 100%); }
.form { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.form > *, .modal-b > * { min-width: 0; }
.modal-b { grid-template-columns: minmax(0, 1fr); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; align-items: end; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid .check { height: 38px; }
.form .inp[readonly] { background: #f3f5fa; color: var(--ink-2); }
.with-btn { display: flex; gap: 8px; }
.with-btn .inp { flex: 1; }
.with-btn .btn { flex: none; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 4px; }
.form-actions .grow { flex: 1; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pick-i { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; user-select: none; background: #fff; font-size: 13.5px; }
.pick-i:hover { border-color: #c9d3e6; }
.pick-i:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.pick-i input { width: 16px; height: 16px; accent-color: var(--brand); }
.pick-i b { color: var(--brand); }
.pick-i .badge { font-style: normal; }
.note-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 18px; font-size: 13.5px; border-bottom: 1px solid var(--line-2); }
.note-bar.wait { background: var(--brand-50); }
.note-bar.warn { background: var(--warn-50); }
.note-bar.ok { background: var(--accent-50); border-radius: 10px; border: 0; }
.form .note-bar, .modal-b > .note-bar { border-radius: 10px; border: 0; padding: 10px 14px; }
.note-bar > span { flex: 1 1 260px; min-width: 0; }
.note-bar.wait > span:nth-child(2) { display: block; }
.warn-t { color: #9a5b00; font-weight: 500; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #b9c9ee; border-top-color: var(--brand); animation: spin 1s linear infinite; flex: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.sigpad { display: block; width: 100%; height: auto; aspect-ratio: 5 / 2; border: 1.5px dashed #b9c5dc; border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair; }
.sg-tools { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 8px; font-size: 13px; }
.im-err { background: var(--warn-50); color: #7a4a00; border-radius: 10px; padding: 10px 12px; font-size: 12.5px; max-height: 120px; overflow: auto; }
.lic { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 18px; }
.lic > div { display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: center; min-width: 0; }
.lic span { color: var(--ink-2); }
.lic span b { color: var(--ink); }

/* ---------------- thanh dưới (điện thoại) ---------------- */
.tabbar { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(10, 18, 40, .45); z-index: 35; }

/* ============================================================
   MÀN HÌNH VỪA
   ============================================================ */
@media (max-width: 1180px) {
  .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2 { grid-template-columns: minmax(0, 1fr); }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ============================================================
   ĐIỆN THOẠI
   ============================================================ */
@media (max-width: 860px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .sig-row.three { grid-template-columns: minmax(0, 1fr); }
  .form-actions .btn { flex: 1 1 auto; }
  body { font-size: 14.5px; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-pane { align-items: start; padding-top: 12vh; background: linear-gradient(180deg, var(--brand-50), #fff 42%); }

  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; height: auto; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .side.open { transform: none; }
  .top { height: 56px; padding: 0 12px 0 6px; background: #fff; border-bottom: 1px solid var(--line); backdrop-filter: none; gap: 6px; }
  .top-menu { display: inline-grid; }
  .top h1 { font-size: 17px; }
  .live { padding: 0 9px; height: 28px; font-size: 12px; }
  .live .live-text { display: none; }
  .filters { padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line); gap: 8px; position: sticky; top: 56px; z-index: 25; }
  .f-station { flex: 1 1 100%; }
  .f-dates { flex: 1 1 100%; }
  .f-dates .inp { flex: 1; width: auto; padding: 0 8px; }
  .f-chips { flex: 1 1 100%; }
  .view { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }
  .grid, .stack { gap: 12px; }
  .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2e, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .kpi { padding: 14px; }
  .kpi-val { font-size: 22px; }
  .kpi.hero { grid-column: 1 / -1; }
  .g-kpi .kpi:last-child:nth-child(even) { grid-column: 1 / -1; }
  .kpi.hero .kpi-val { font-size: 32px; }
  .card-h { padding: 14px 14px 0; }
  .card-b { padding: 12px 14px 14px; }
  .toolbar { padding: 12px 14px; }
  .toolbar .sp { margin-left: 0; flex: 1 1 100%; }
  .toolbar .sp .btn { flex: 1; }
  .sumbar { padding: 10px 14px; gap: 6px 16px; }
  .pager { padding: 10px 14px; }

  /* bảng -> thẻ */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { padding: 12px 14px; border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline; }
  table.cards td { padding: 0; border: 0; text-align: left !important; }
  table.cards td.c-main { grid-column: 1; order: -2; font-weight: 600; }
  table.cards td.c-side { grid-column: 2; order: -1; text-align: right !important; font-weight: 700; font-size: 15px; white-space: nowrap; }
  table.cards td.c-sub { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
  table.cards td.c-hide { display: none; }
  table.cards td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-weight: 400; }
  table.cards tfoot { display: none; }

  .modal { padding: 0; place-items: end stretch; }
  .modal-box { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; animation: up .22s; }
  @keyframes up { from { transform: translateY(40px); opacity: 0; } }
  .sig-row { grid-template-columns: minmax(0, 1fr); }
  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }

  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a, .tabbar button { display: grid; justify-items: center; gap: 2px; padding: 4px 2px; border: 0; background: none; color: var(--muted); font-size: 10.5px; font-weight: 500; border-radius: 10px; cursor: pointer; }
  .tabbar a.on { color: var(--brand); font-weight: 700; }
  .tabbar svg.ic { width: 22px; height: 22px; }
}
@media (max-width: 380px) {
  .kpi-val { font-size: 20px; }
  .kpi.hero .kpi-val { font-size: 28px; }
}
@media (hover: none) { .tbl tbody tr.click:hover td { background: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  .side, .top, .filters, .tabbar, .toolbar, .pager { display: none !important; }
  .app { display: block; } .view { padding: 0; } .card { box-shadow: none; border: 0; }
}
