/* Shared design tokens & components */
:root {
  --brand: #0e7c86; --brand-ink: #ffffff; --brand-soft: #e3f3f2;
  --ink: #142329; --ink-2: #3d5159; --ink-3: #6b7f86; --line: #dfe7ea; --line-2: #eef3f5;
  --bg: #f6f9fa; --surface: #ffffff; --surface-2: #f0f5f6;
  --ok: #148a5c; --ok-soft: #e1f4ea; --warn: #b86e00; --warn-soft: #fdf1dc; --bad: #c8374a; --bad-soft: #fbe6e9; --info: #2c63c9; --info-soft: #e5edfb; --violet: #6f4bd8; --violet-soft: #eee8fc;
  --r-s: 8px; --r-m: 12px; --r-l: 18px; --shadow: 0 1px 2px rgba(20, 35, 41, .06), 0 4px 16px rgba(20, 35, 41, .06);
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; font-feature-settings: 'tnum' 1; }
a { color: var(--brand); }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; } h2 { font-size: 20px; font-weight: 700; } h3 { font-size: 16px; font-weight: 600; }
p { margin: 0 0 .6em; }
.muted { color: var(--ink-3); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; } .wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; } .between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; } .grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 760px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } .grid4.keep2, .grid3.keep2 { grid-template-columns: 1fr 1fr; } }
.hide { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 2px; border-radius: 6px; }

/* buttons */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; padding: 9px 14px; border-radius: var(--r-s); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-content: center; text-decoration: none; min-height: 40px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, white); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn.lg { padding: 14px 18px; min-height: 54px; font-size: 17px; border-radius: var(--r-m); }
.btn.block { width: 100%; white-space: normal; text-align: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* forms */
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; width: 100%; min-height: 42px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); }
label.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
input[type=color] { padding: 2px; height: 42px; }
.pwwrap { position: relative; display: block; width: 100%; }
.pwwrap > input { padding-right: 48px; }
.pwtog { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: transparent; color: var(--ink-3); border-radius: 8px; cursor: pointer; display: grid; place-items: center; padding: 0; }
.pwtog:hover { color: var(--ink); background: var(--surface-2); }
.pwtog svg { width: 20px; height: 20px; }
input[type=password]::-ms-reveal, input[type=password]::-ms-clear { display: none; }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; }
.card.flat { border: 0; background: var(--surface-2); }
.card h3 + * { margin-top: 10px; }
.sec { margin: 22px 0 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sec h2 { font-size: 17px; }
.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line-2); }
.item:last-child { border-bottom: 0; }
.empty { text-align: center; padding: 34px 16px; color: var(--ink-3); }
.empty svg { width: 40px; height: 40px; margin: 0 auto 8px; opacity: .55; display: block; }

/* status pills – color encodes status only */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.info { background: var(--info-soft); color: var(--info); } .pill.violet { background: var(--violet-soft); color: var(--violet); } .pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.plain::before { display: none; }

/* table */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:hover td { background: #fafcfc; }
.tbl .num { text-align: right; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* toast, modal, drawer */
#toasts { position: fixed; z-index: 1000; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--r-s); font-size: 14px; box-shadow: var(--shadow); animation: tin .2s ease-out; pointer-events: auto; }
.toast.err { background: var(--bad); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.overlay { position: fixed; inset: 0; background: rgba(15, 28, 33, .45); z-index: 900; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fin .15s; }
@keyframes fin { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--r-l); width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(900px, 100%); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-b { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-f { padding: 14px 18px; border-top: 1px solid var(--line-2); display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface); }
@media (max-width: 600px) { .overlay { align-items: flex-end; padding: 0; } .modal { border-radius: var(--r-l) var(--r-l) 0 0; max-height: 94vh; } }
.x { width: 36px; height: 36px; border: 0; background: transparent; border-radius: 50%; cursor: pointer; font-size: 22px; color: var(--ink-3); }
.x:hover { background: var(--surface-2); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--ink-3); padding: 10px 12px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-color: var(--brand); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--r-s); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600; padding: 6px 11px; border-radius: 6px; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; } .kv > :nth-child(odd) { color: var(--ink-3); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.av { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.bar { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.note { background: var(--warn-soft); color: #6d4300; padding: 10px 12px; border-radius: var(--r-s); font-size: 13.5px; }
.note.info { background: var(--info-soft); color: #1d3f80; } .note.ok { background: var(--ok-soft); color: #0b5a3b; } .note.bad { background: var(--bad-soft); color: #7d1d2a; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---- narrow screens (shared) ---- */
.ph .row { flex-wrap: wrap; }
@media (max-width: 600px) {
  .ph > .row { width: 100%; }
  .ph .row input:not([type=checkbox]):not([type=radio]):not([type=color]), .ph .row select { flex: 1 1 140px; min-width: 0; width: auto !important; }
  .ph .row > .btn { flex: 1 1 auto; justify-content: center; }
  .modal { max-width: calc(100vw - 16px); }
}
img, video, canvas, svg { max-width: 100%; }
