/* WIN Pilot v2 - design system
   Dark, mobile-first internal tool. One accent colour, self-hosted Be Vietnam Pro,
   44px minimum touch targets, bottom tab bar on phones, sidebar from 960px. */

@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 400; font-display: swap; src: url("/static/fonts/be-vn-400.woff2") format("woff2"); }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 500; font-display: swap; src: url("/static/fonts/be-vn-500.woff2") format("woff2"); }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 700; font-display: swap; src: url("/static/fonts/be-vn-700.woff2") format("woff2"); }

:root {
  --bg: #0b0f14;
  --bg-elev: #10151c;
  --card: #151c25;
  --card-2: #1a2330;
  --line: #232d3a;
  --line-strong: #2f3b4b;
  --text: #e8edf4;
  --muted: #8b98a9;
  --faint: #5f6b7b;
  /* WN Technology palette: logo blue #2C4EA0, red #DE232A; lifted blue for the dark UI */
  --accent: #3b5fc4;
  --accent-press: #2c4ea0;
  --accent-soft: rgba(59, 95, 196, 0.18);
  --accent-ink: #9db4f2;
  --brand-blue: #2c4ea0;
  --brand-red: #de232a;
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.14);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --tabbar-h: 62px;
  --topbar-h: 56px;
  --sidebar-w: 236px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden], .hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- login (WN Technology identity, light) ---------- */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  background: #f4f6fb;
  color-scheme: light;
}
.login-hero { display: none; }
.login-panel {
  /* light tokens scoped to the sign-in panel; shared components read these */
  --bg: #f4f6fb; --bg-elev: #ffffff; --card: #ffffff; --card-2: #f4f6fb;
  --line: #d6dce8; --line-strong: #b9c2d3; --text: #1e2424; --muted: #4f5866; --faint: #6b7380;
  --accent: #2c4ea0; --accent-press: #213d80; --accent-ink: #2c4ea0; --red: #c41d23;
  color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(28px, var(--safe-t)) 16px max(20px, var(--safe-b));
  min-height: 100dvh;
}
.login-card {
  width: min(100%, 400px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px 22px;
  /* brand bar as an inset shadow so it follows the rounded corners */
  box-shadow: inset 0 4px 0 var(--brand-blue), 0 18px 48px rgba(28, 44, 92, 0.12);
}
.login-logo { display: block; width: 112px; height: auto; margin: 0 auto 12px; }
.login-card h1 { font-size: 26px; font-weight: 700; margin: 0 0 6px; text-align: center; color: var(--text); letter-spacing: -0.015em; }
.login-card .sub { color: var(--muted); text-align: center; margin: 0 0 22px; font-size: 14.5px; text-wrap: balance; }
.login-card .hint, .login-hero h2, .login-hero p.lead { text-wrap: balance; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; width: 100%; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.pw-toggle:hover { color: var(--text); background: rgba(44, 78, 160, 0.08); }
.pw-toggle svg { width: 20px; height: 20px; }
.login-card .hint { color: var(--faint); font-size: 12.5px; margin: 14px 0 0; text-align: center; }
.login-card input { background: #fff; color: var(--text); border-color: var(--line-strong); }
.login-card input::placeholder { color: #8a92a0; }
.login-card .btn.primary { background: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }
.login-card .btn.primary:hover { background: var(--accent-press); border-color: var(--accent-press); }
.login-card .btn.ghost { color: var(--muted); }
.login-lang { display: flex; justify-content: center; margin-top: 14px; }
.login-foot { margin-top: 18px; font-size: 12px; color: var(--faint); text-align: center; line-height: 1.6; }
.login-foot a { color: var(--accent-ink); }
.login-foot .dot { color: var(--brand-red); padding: 0 6px; }
@media (min-width: 960px) {
  .login-wrap { grid-template-columns: minmax(420px, 46%) 1fr; }
  .login-hero {
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 48px 52px; color: #fff;
    background:
      radial-gradient(520px 360px at 85% 12%, rgba(222, 35, 42, 0.22), transparent 70%),
      linear-gradient(160deg, #2c4ea0 0%, #1d3473 55%, #13224d 100%);
  }
  .login-hero .tile {
    width: 64px; height: 64px; border-radius: 16px; background: #fff;
    display: grid; place-items: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  }
  .login-hero .tile img { width: 44px; height: auto; }
  .login-hero h2 { font-size: 30px; line-height: 1.25; margin: 28px 0 14px; letter-spacing: -0.015em; max-width: 15em; }
  .login-hero p.lead { font-size: 15.5px; line-height: 1.6; color: rgba(255, 255, 255, 0.86); margin: 0 0 26px; max-width: 30em; }
  .login-hero ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
  .login-hero li { display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; line-height: 1.5; color: rgba(255, 255, 255, 0.92); }
  .login-hero li svg { flex: none; width: 20px; height: 20px; margin-top: 1px; stroke: #fff; }
  .login-hero li .ic { flex: none; width: 30px; height: 30px; border-radius: 9px; background: rgba(255, 255, 255, 0.12); display: grid; place-items: center; }
  .login-hero .hero-foot { font-size: 12.5px; color: rgba(255, 255, 255, 0.7); display: flex; align-items: center; gap: 8px; }
  .login-hero .hero-foot i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-red); display: inline-block; }
}

/* ---------- shell ---------- */
.shell { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) 12px 0;
  display: flex; align-items: center; gap: 10px;
  background: rgba(11, 15, 20, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .brand-sm { width: 32px; height: 32px; border-radius: 10px; font-size: 15px; margin: 0; }
.main {
  padding: 14px 12px calc(var(--tabbar-h) + var(--safe-b) + 20px);
  max-width: 1100px;
  margin: 0 auto;
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(16, 21, 28, 0.97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.tabbar button {
  background: none; border: 0; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 500; cursor: pointer; min-height: 44px;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button[aria-current="page"] { color: var(--accent); }
.sidebar { display: none; }

@media (min-width: 960px) {
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column;
    position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w);
    background: var(--bg-elev); border-right: 1px solid var(--line);
    padding: 16px 12px; gap: 4px; z-index: 25;
  }
  .sidebar .side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; font-size: 17px; }
  .sidebar .side-brand .brand-mark {
  width: 56px; height: 56px; border-radius: 16px; background: #fff;
  display: grid; place-items: center; margin: 0 auto 14px; overflow: hidden;
}
.brand-mark img { width: 72%; height: auto; display: block; }
.brand-mark.brand-sm { width: 32px; height: 32px; border-radius: 9px; margin: 0; }
  .sidebar button.nav {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 10px 12px; border-radius: 10px; border: 0; background: none;
    color: var(--muted); font-weight: 500; cursor: pointer; text-align: left; min-height: 42px;
  }
  .sidebar button.nav svg { width: 20px; height: 20px; flex: none; }
  .sidebar button.nav:hover { background: var(--card); color: var(--text); }
  .sidebar button.nav[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
  .sidebar .side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
  .shell { padding-left: var(--sidebar-w); }
  .topbar .brand-sm { display: none; }
  .main { padding: 20px 24px 40px; }
}

/* ---------- typography + layout helpers ---------- */
h2.section { font-size: 15px; font-weight: 700; margin: 22px 2px 10px; display: flex; align-items: center; gap: 8px; }
h2.section:first-child { margin-top: 4px; }
h2.section .grow { flex: 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) {
  .grid.cols-3-md { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.cols-2-md { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-4-md { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prewrap { white-space: pre-wrap; word-break: break-word; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.tight { padding: 10px 12px; }
.card.click { cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.card.click:hover { background: var(--card-2); border-color: var(--line-strong); }
.stat { padding: 14px; }
.stat .v { font-size: 26px; font-weight: 700; line-height: 1.15; }
.stat .k { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; }
.item .meta { flex: 1; min-width: 0; }
.item .t1 { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t2 { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: var(--card-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-weight: 700; color: var(--muted); overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 60px; height: 60px; font-size: 22px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.badge.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.green { color: var(--green); background: var(--green-soft); border-color: transparent; }
.badge.amber { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.badge.red { color: var(--red); background: var(--red-soft); border-color: transparent; }
.badge.blue { color: #7fb0ff; background: var(--accent-soft); border-color: transparent; }

/* ---------- forms ---------- */
label.field { display: block; }
label.field > span.lbl { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 6px 2px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text); outline: none; transition: border-color 0.15s;
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--faint); }
.help { font-size: 12.5px; color: var(--faint); margin: 6px 2px 0; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.seg { display: flex; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-weight: 500; cursor: pointer; padding: 0 8px; }
.seg button[aria-pressed="true"] { background: var(--card-2); color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 36px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--muted);
  cursor: pointer; font-size: 13.5px; font-weight: 500;
}
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--card-2); color: var(--text);
  font-weight: 500; cursor: pointer; white-space: nowrap; transition: background 0.15s, opacity 0.15s;
}
.btn:hover { background: #212c3b; text-decoration: none; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-press); }
.btn.danger { color: var(--red); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--card); color: var(--text); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.icon { width: 44px; padding: 0; }
.btn .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tool tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 78px; padding: 10px 6px; border-radius: var(--radius-sm);
  background: var(--bg-elev); border: 1px solid var(--line); color: var(--text);
  cursor: pointer; font-size: 12.5px; font-weight: 500; text-align: center;
}
.tile svg { width: 22px; height: 22px; color: var(--accent); }
.tile:hover { border-color: var(--line-strong); background: var(--card-2); }
.tile[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ---------- sheet / modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.15s ease-out;
}
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh; overflow: auto;
  background: var(--bg-elev); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(18px + var(--safe-b));
  animation: up 0.2s ease-out;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 4px auto 10px; }
.sheet .sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet .sheet-head h3 { margin: 0; font-size: 17px; flex: 1; }
@media (min-width: 720px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 20px; border-bottom: 1px solid var(--line); padding-bottom: 20px; }
  .sheet .grab { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: 0.6; } }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
@media (min-width: 960px) { .toasts { bottom: 20px; left: var(--sidebar-w); } }
.toast {
  pointer-events: auto; max-width: 520px; width: fit-content;
  padding: 11px 16px; border-radius: 12px; background: #1f2937; border: 1px solid var(--line-strong);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); font-size: 14px; animation: up 0.2s ease-out;
}
.toast.err { border-color: rgba(239, 68, 68, 0.5); }
.toast.ok { border-color: rgba(34, 197, 94, 0.45); }

/* ---------- live view ---------- */
.live { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); background: #000; }
.live img { display: block; width: 100%; height: auto; }
.live .ts { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, 0.65); padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.qr { display: grid; place-items: center; padding: 14px; background: #fff; border-radius: 12px; }
.qr img { width: 220px; height: 220px; image-rendering: pixelated; }

/* ---------- tables (desktop) ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; }

/* ---------- misc ---------- */
.progress { height: 6px; border-radius: 6px; background: var(--card-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.result-box { max-height: 420px; overflow: auto; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.pill-count { background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; margin-left: 4px; font-weight: 700; }
.thumb { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
.fab-row { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px); z-index: 10; }
@media (min-width: 960px) { .fab-row { bottom: 12px; } }
.skeleton { height: 64px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card) 0%, var(--card-2) 50%, var(--card) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
