:root {
  --bg: #F8FAFC; --surface: #FFFFFF; --muted-bg: #F1F5F9; --line: #E2E8F0; --line-strong: #94A3B8;
  --ink: #1C1917; --ink-2: #44403C; --muted: #57534E;
  --brand: #2563EB; --brand-dark: #1D4ED8; --brand-deep: #1E40AF; --brand-soft: #EFF6FF; --brand-tint: #DBEAFE;
  --yellow: #FACC15;
  --ok: #15803D; --ok-bg: #DCFCE7;
  --warn: #92400E; --warn-bg: #FEF3C7; --warn-line: #FCD34D; --warn-strong: #EA580C;
  --danger: #B91C1C; --danger-bg: #FEE2E2;
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--brand-dark); }
a:hover { color: var(--brand-deep); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
svg.i { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; transition: background-color 150ms ease, border-color 150ms ease; white-space: nowrap; }
.btn:hover { background: var(--muted-bg); color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #FCA5A5; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.soft { background: var(--brand-soft); border-color: var(--brand-tint); color: var(--brand-dark); }
.btn.big { min-height: 56px; font-size: 16px; border-radius: 14px; width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }

/* form */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 14px; font-weight: 600; }
.input, select.input, textarea.input { height: 48px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 0 12px; font-size: 16px; background: var(--surface); width: 100%; min-width: 0; }
textarea.input { height: auto; padding: 12px; resize: vertical; }
.input.sm { height: 44px; font-size: 14px; border-radius: 10px; }
.input.warn { border: 2px solid var(--warn-strong); }
.hint { font-size: 12px; color: var(--muted); }
.err-text { font-size: 13px; color: var(--danger); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 15px; font-weight: 600; cursor: pointer; transition: background-color 150ms ease; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--muted-bg); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; padding: 0 10px; }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.radio-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; text-align: left; min-height: 56px; width: 100%; }
.radio-card .dot { width: 20px; height: 20px; border-radius: 999px; border: 2px solid var(--line-strong); flex-shrink: 0; }
.radio-card[aria-checked="true"] { background: var(--brand-soft); border: 2px solid var(--brand); }
.radio-card[aria-checked="true"] .dot { border: 6px solid var(--brand); }
.money { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 12px; height: 48px; padding: 0 12px; gap: 8px; background: var(--surface); }
.money input { border: 0; outline: none; flex: 1; min-width: 0; font-size: 18px; font-weight: 600; background: transparent; }

/* cards & badges */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h2 { font-size: 16px; font-weight: 700; }
fieldset.card { margin: 0; display: flex; flex-direction: column; gap: 14px; }
fieldset.card legend { padding: 0 6px; font-size: 15px; font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.info { color: var(--brand-deep); background: var(--brand-tint); }
.badge.gray { color: #475569; background: var(--muted-bg); }
.alert { display: flex; gap: 10px; align-items: flex-start; border-radius: 12px; padding: 12px; font-size: 14px; line-height: 1.45; }
.alert.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: #78350F; }
.alert.info { background: var(--brand-soft); border: 1px solid var(--brand-tint); color: var(--brand-deep); }
.alert.err { background: var(--danger-bg); border: 1px solid #FCA5A5; color: #7F1D1D; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .v { font-size: 28px; font-weight: 800; line-height: 1.15; }
.kpi .l { font-size: 13px; color: var(--muted); }
.kpi.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.kpi.warn .v, .kpi.warn .l { color: var(--warn); }
.ph { background: repeating-linear-gradient(135deg, #E2E8F0 0 8px, #CBD5E1 8px 16px); }
.thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--muted-bg); }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px; background: var(--brand); }

/* tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; color: var(--muted); font-size: 13px; font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 11px 8px; border-bottom: 1px solid var(--muted-bg); vertical-align: middle; }
table.t td.r, table.t th.r { text-align: right; }
table.t tbody tr.click { cursor: pointer; transition: background-color 150ms ease; }
table.t tbody tr.click:hover { background: var(--muted-bg); }
table.t tbody tr.sel { background: var(--brand-soft); }
table.t tfoot td, table.t tfoot th { font-weight: 800; padding: 12px 8px; color: var(--ink); }

/* ===== mobile (receiver) shell ===== */
.m-shell { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.m-top { background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 5; }
.m-top h1 { font-size: 17px; font-weight: 700; }
.m-hero { background: var(--brand); color: #fff; padding: 20px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.m-hero .sub { font-size: 13px; color: var(--brand-soft); }
.m-hero h1 { font-size: 20px; font-weight: 700; }
.m-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.m-stats > div { background: var(--brand-dark); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.m-stats .v { font-size: 26px; font-weight: 800; }
.m-stats .l { font-size: 12px; color: var(--brand-soft); }
.m-stats > div.warn { background: var(--warn-bg); }
.m-stats > div.warn .v { color: #B45309; }
.m-stats > div.warn .l { color: var(--warn); }
.m-main { padding: 16px; display: flex; flex-direction: column; gap: 16px; flex: 1; }
.m-cta { text-decoration: none; background: var(--brand); color: #fff; border-radius: 16px; padding: 18px; display: flex; align-items: center; gap: 16px; transition: background-color 150ms ease; }
.m-cta:hover { background: var(--brand-dark); color: #fff; }
.m-cta .ic { width: 52px; height: 52px; border-radius: 14px; background: rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; }
.m-cta .ic svg { width: 28px; height: 28px; }
.m-nav { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); z-index: 5; }
.m-nav a { text-decoration: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; min-height: 48px; font-size: 12px; font-weight: 500; }
.m-nav a[aria-current="page"] { color: var(--brand); font-weight: 700; }
.m-bar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 10px; z-index: 5; }
.trip-row { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; text-decoration: none; color: inherit; }
.trip-row:hover { background: var(--muted-bg); color: inherit; }
.photo-slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.photo-slot { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.photo-slot label.box { aspect-ratio: 1; border-radius: 12px; border: 2px dashed var(--line-strong); background: #FAFAF9; color: var(--brand); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; position: relative; overflow: hidden; font-size: 12px; font-weight: 700; }
.photo-slot label.box.has { border: 0; }
.photo-slot label.box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-slot label.box .tick { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 999px; background: var(--ok); color: #fff; display: flex; align-items: center; justify-content: center; }
.photo-slot label.box .tick svg { width: 14px; height: 14px; stroke-width: 3; }
.photo-slot input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-slot .cap { font-size: 12px; font-weight: 600; text-align: center; }
/* login: stacked on phones, split screen on desktop */
.login-page { min-height: 100vh; display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; }
.login-hero { background: var(--brand); color: #fff; padding: 48px 24px 32px; display: flex; flex-direction: column; gap: 20px; border-radius: 0 0 28px 28px; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand-name { font-size: 22px; font-weight: 800; }
.login-pitch h1 { font-size: 20px; font-weight: 700; line-height: 1.35; }
.login-pitch p { margin: 8px 0 0; color: var(--brand-soft); line-height: 1.55; }
.login-feats { display: none; }
.login-side { flex: 1; display: flex; justify-content: center; }
.login-card { width: 100%; padding: 28px 24px; display: flex; flex-direction: column; gap: 16px; }
.login-card h2 { font-size: 24px; font-weight: 800; }
@media (min-width: 900px) {
  .login-page { max-width: none; flex-direction: row; }
  .login-hero { flex: 1 1 55%; border-radius: 0; padding: 48px 64px; justify-content: space-between;
    background: linear-gradient(160deg, var(--brand) 0%, var(--brand-deep) 100%); }
  .login-pitch { max-width: 560px; margin-bottom: 8vh; }
  .login-pitch h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; }
  .login-pitch p { font-size: 17px; margin-top: 16px; }
  .login-feats { display: flex; flex-direction: column; gap: 14px; list-style: none; padding: 0; margin: 32px 0 0; }
  .login-feats li { display: flex; align-items: center; gap: 12px; font-size: 16px; color: var(--brand-soft); }
  .login-feats .ic { width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.14); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .login-feats .ic svg { width: 18px; height: 18px; }
  .login-side { flex: 1 1 45%; align-items: center; padding: 48px; background: var(--bg); }
  .login-card { max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 36px; box-shadow: 0 12px 40px rgba(15, 23, 42, .08); }
}
.logo { width: 56px; height: 56px; border-radius: 16px; background: var(--yellow); color: var(--ink); display: flex; align-items: center; justify-content: center; }
.logo svg { width: 30px; height: 30px; }

/* ===== office shell ===== */
.o-shell { display: flex; flex-wrap: wrap; min-height: 100vh; align-items: stretch; }
.o-side { flex: 1 1 232px; max-width: 100%; background: var(--brand-deep); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; }
.o-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 800; font-size: 16px; }
.o-brand .logo { width: 34px; height: 34px; border-radius: 9px; }
.o-brand .logo svg { width: 20px; height: 20px; }
.o-brand > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.o-brand-name { font-weight: 800; font-size: 16px; line-height: 1.2; }
.o-brand-sub { font-weight: 500; font-size: 12px; color: rgba(255,255,255,.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.o-cta { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border-radius: 10px; background: var(--yellow); color: var(--ink); font-weight: 700; font-size: 14px; text-decoration: none; }
.o-cta:hover, .o-cta.on { background: #FDE047; color: var(--ink); }
.o-group { display: flex; flex-direction: column; gap: 2px; }
.o-group + .o-group { margin-top: 12px; }
.o-group-title { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.6); padding: 0 12px 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 8px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; }
.swatch .dot { width: 26px; height: 26px; border-radius: 999px; }
.swatch[aria-checked="true"] { border: 2px solid var(--ink); }
.perm-table td.c, .perm-table th.c { text-align: center; width: 120px; }
.perm-table input[type=checkbox] { width: 20px; height: 20px; cursor: pointer; }
.toggle-row { display: flex; align-items: center; gap: 12px; min-height: 48px; border-top: 1px solid var(--muted-bg); cursor: pointer; }
.toggle-row:first-child { border-top: 0; }
.toggle-row input { width: 20px; height: 20px; }
.o-nav { display: flex; flex-direction: column; gap: 2px; }
.o-nav a { text-decoration: none; display: flex; align-items: center; gap: 10px; padding: 0 12px; height: 44px; border-radius: 10px; color: var(--brand-tint); font-weight: 500; font-size: 14px; }
.o-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.o-nav a[aria-current="page"] { background: var(--brand); color: #fff; font-weight: 600; }
.o-nav svg.i { width: 18px; height: 18px; }
.o-user { margin-top: auto; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.o-user button { background: transparent; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 8px; min-height: 36px; cursor: pointer; font-weight: 600; }
.o-main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.o-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.o-head h1 { font-size: 26px; font-weight: 800; }
.o-head .sub { font-size: 14px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.filters .field > label { font-size: 12px; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.col-main { flex: 3 1 540px; min-width: 0; }
.col-side { flex: 2 1 340px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.bars { display: grid; gap: 6px; align-items: end; height: 170px; border-bottom: 1px solid #CBD5E1; }
.bars > div { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.bars .b { width: 100%; max-width: 26px; border-radius: 6px 6px 0 0; background: var(--brand); }
.bars .b.zero { background: #CBD5E1; }
.bar-labels { display: grid; gap: 6px; font-size: 12px; color: var(--muted); text-align: center; }
.gallery-main { width: 100%; aspect-ratio: 16 / 10; object-fit: contain; background: #0F172A; border-radius: 12px; }
.gallery-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.gallery-thumbs button { padding: 0; border: 1px solid #CBD5E1; border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; cursor: pointer; background: var(--muted-bg); }
.gallery-thumbs button[aria-pressed="true"] { border: 3px solid var(--brand); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
dl.info { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
dl.info dt { font-size: 13px; color: var(--muted); }
dl.info dd { margin: 0; font-size: 15px; font-weight: 600; }
.steps { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.steps li { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.steps li .bar { height: 6px; border-radius: 999px; background: var(--line); }
.steps li.done .bar, .steps li.cur .bar { background: var(--brand); }
.steps li.done { color: var(--ink); font-weight: 600; }
.steps li.cur { color: var(--brand-dark); font-weight: 700; }
.tabs-btn { display: flex; flex-wrap: wrap; gap: 8px; }
.tab-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 16px; min-height: 56px; border-radius: 12px; border: 1px solid #CBD5E1; background: var(--surface); cursor: pointer; text-align: left; }
.tab-card[aria-selected="true"] { background: var(--brand-soft); border: 2px solid var(--brand); }
.site-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.site-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; }
.site-card[aria-pressed="true"] { border: 2px solid var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.mini-stats > span { background: var(--muted-bg); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; }
.mini-stats b { font-size: 18px; font-weight: 800; }
.mini-stats small { font-size: 11px; color: var(--muted); }
.avatar { width: 40px; height: 40px; border-radius: 999px; background: var(--brand-tint); color: var(--brand-deep); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--muted-bg); }

/* modal & toast */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px; padding: 20px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal h2 { font-size: 18px; font-weight: 800; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: #0F172A; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 60; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--danger); }
.loading { padding: 48px; text-align: center; color: var(--muted); }

@media (max-width: 860px) {
  .o-side { flex-basis: 100%; padding: 12px; gap: 10px; }
  .o-nav { flex-direction: row; overflow-x: auto; gap: 8px; }
  .o-group { flex-direction: row; }
  .o-group + .o-group { margin-top: 0; }
  .o-group-title { display: none; }
  .o-nav a { white-space: nowrap; }
  .o-user { display: none; }
  .o-main { padding: 20px 16px 40px; }
  .o-head h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
