/* HOTWAVE 越南财务 — 账本风格界面
   设计稿：Claude Design「越南财务系统 · 新界面设计」 */

:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --line: #E3E6EB;
  --line-soft: #EEF0F3;
  --ink: #16191F;
  --ink-2: #2A3038;
  --muted: #5B6472;
  --faint: #687180;
  --accent: #1D4ED8;
  --accent-ink: #1E3A8A;
  --accent-soft: #EEF2FF;
  --accent-line: #DCE4FB;
  --ok: #0F766E;
  --ok-soft: #ECFDF5;
  --warn: #9A3412;
  --warn-2: #B45309;
  --warn-soft: #FFF7ED;
  --warn-line: #F5D0A9;
  --danger: #B91C1C;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 32px rgba(17, 24, 39, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { text-align: right; white-space: nowrap; }
.inc { color: var(--accent); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 登录 ---------- */
.lock {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: var(--bg);
}
.lock-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 16px;
}
.lock-card .brand { justify-content: center; }
.lock-error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); min-width: 0; }
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--ink); color: #fff; flex: none;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text b { font-size: 14px; }
.brand-text span { font-size: 11px; color: var(--muted); }
.month-switch { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.month-switch button {
  width: 36px; height: 36px; border: 0; background: transparent; border-radius: 8px; font-size: 18px;
  color: var(--muted); cursor: pointer;
}
.month-switch button:hover { background: var(--surface-2); color: var(--ink); }
.month-switch .label { font-weight: 600; font-size: 15px; padding: 0 6px; min-width: 112px; white-space: nowrap; text-align: center; cursor: pointer; border: 0; background: none; }
.month-switch input[type="month"] { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.search { position: relative; flex: 1 1 280px; min-width: 200px; }
.search label {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.search label:focus-within { border-color: var(--accent); background: var(--surface); }
.search input { border: 0; outline: none; background: transparent; flex: 1; min-width: 0; font-size: 14px; }
.search-panel {
  position: absolute; top: 46px; left: 0; right: 0; z-index: 60; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px;
}
.search-group { padding: 6px 8px 2px; font-size: 12px; color: var(--muted); }
.search-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer;
}
.search-item:hover, .search-item:focus { background: var(--accent-soft); outline: none; }
.search-item small { display: block; color: var(--faint); font-size: 12px; }
.search-empty { padding: 16px; color: var(--muted); text-align: center; }

/* ---------- 布局 ---------- */
.shell { display: flex; align-items: stretch; min-height: calc(100vh - 61px); }
.sidenav {
  flex: 0 0 200px; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.sidenav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 8px; color: var(--ink-2); font-size: 14px; min-height: 40px;
}
.sidenav a:hover { background: var(--surface-2); color: var(--ink); }
.sidenav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidenav .sep { height: 1px; background: var(--line-soft); margin: 8px 6px; }
.badge-count {
  font-size: 11px; font-weight: 700; color: #fff; background: var(--warn-2); border-radius: 999px;
  padding: 1px 7px; min-width: 20px; text-align: center;
}
.main { flex: 1 1 auto; min-width: 0; padding: 22px 24px 48px; }
.page { max-width: 1320px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.page-head .sub { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bottomnav { display: none; }

/* ---------- 卡片 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; padding: 16px 20px 8px; }
.grid { display: grid; gap: 12px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s { font-size: 12px; color: var(--faint); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stat-big .v { font-size: 22px; }
.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.strip > .stat { padding: 14px 18px; border-right: 1px solid var(--line-soft); }
.strip > .stat:last-child { border-right: 0; }
.progress { height: 8px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); font-size: 13px; min-width: 0; }
.list-row:first-child { border-top: 0; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #C9CED6; color: var(--ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: #F2B8B5; color: var(--danger); }
.btn-outline-accent { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; }
.linklike { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: inherit; }
.linklike:hover { color: var(--accent-ink); }

/* ---------- 筛选芯片 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: #C9CED6; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.select-inline {
  height: 34px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; font-size: 13px;
}

/* ---------- 标签 ---------- */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; border-radius: 4px; padding: 2px 6px; white-space: nowrap; }
.tag-ok { color: var(--ok); background: var(--ok-soft); }
.tag-miss { color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-line); padding: 1px 6px; font-weight: 700; }
.tag-na { color: #6B7280; background: #F3F4F6; font-weight: 500; }
.tag-info { color: var(--accent); background: var(--accent-soft); }
.tag-dark { color: #fff; background: var(--warn-2); }
.pill { display: inline-block; font-size: 12px; border-radius: 6px; padding: 3px 8px; min-width: 44px; text-align: center; font-weight: 600; white-space: nowrap; }
.pill-today { color: #fff; background: var(--warn-2); }
.pill-late { color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-line); }
.pill-soon { color: var(--ink-2); background: #EEF0F3; }
.docs { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); background: var(--surface-2);
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
table.t td { padding: 10px 12px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
table.t tbody tr:first-child td { border-top: 0; }
table.t tr.clickable { cursor: pointer; }
table.t tr.clickable:hover td { background: #FAFBFD; }
table.t tr.open td { background: #F7F9FF; }
table.t tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); }
table.t th.num, table.t td.num { text-align: right; }
.cell-main { font-weight: 500; }
.cell-sub { font-size: 12px; color: var(--faint); }
.cell-who { max-width: 340px; }
.cell-who > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-row > td { padding: 0 !important; background: #F7F9FF; border-top: 1px solid var(--accent-line); border-bottom: 1px solid var(--accent-line); }
.detail { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 16px 20px 20px; }
.detail .k { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.file-chip {
  display: flex; align-items: center; gap: 8px; width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; color: var(--ink); cursor: pointer; text-align: left; margin-bottom: 6px;
}
.file-chip:hover { border-color: var(--accent); color: var(--ink); }
.file-chip .ellipsis { flex: 1; min-width: 0; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.loading { padding: 36px 16px; text-align: center; color: var(--faint); }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.field > span b { color: var(--danger); font-weight: 600; }
.field .hint { font-size: 12px; color: var(--faint); }
.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 14px; outline: none;
}
.field textarea { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12); }
.field input[readonly] { background: var(--surface-2); }
.amount-input { font-size: 18px !important; font-weight: 700; height: 46px !important; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; background: var(--surface-2); }
.seg button { height: 34px; padding: 0 16px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg button:disabled { cursor: not-allowed; }
.fieldset { border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; background: #FCFCFD; }
.fieldset > .legend { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.att-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.att-row select { height: 34px !important; font-size: 12px !important; padding: 0 8px !important; }
.inst-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 150px auto; gap: 8px; align-items: center; }
.form-error { color: var(--danger); font-size: 13px; min-height: 0; }
.ai-box { display: flex; gap: 8px; }
.ai-box input { flex: 1; }

/* ---------- 弹窗 ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 200; background: rgba(17, 24, 39, 0.42);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 640px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; max-height: none;
}
.modal.wide { max-width: 880px; }
.modal.viewer { max-width: 1040px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-soft); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.modal-foot .left { margin-right: auto; }
.icon-btn { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 20px; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.viewer-frame { width: 100%; height: 72vh; border: 0; background: #F3F4F6; border-radius: 8px; }
.viewer-img { max-width: 100%; max-height: 74vh; display: block; margin: 0 auto; border-radius: 8px; }

/* ---------- 提示 ---------- */
.toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--danger); }
.notice { border-radius: 10px; padding: 12px 14px; font-size: 13px; background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn); }
.notice.info { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }

/* ---------- 交接页 ---------- */
.step-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.step-no { width: 26px; height: 26px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.dark-card { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 20px; display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.dark-card .muted { color: #C9CED6; }
.dark-card .btn { background: transparent; color: #fff; border-color: #5B6472; }
.dark-card .btn-primary { background: #fff; color: var(--ink); border-color: #fff; }
.bar { height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* ---------- 手机 ---------- */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip > .stat:nth-child(2) { border-right: 0; }
  .strip > .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); }
  .detail { grid-template-columns: 1fr; padding-left: 20px; }
}
@media (max-width: 860px) {
  .sidenav { display: none; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .topbar .brand-text span { display: none; }
  .topbar .btn-add { display: none; }
  .search { order: 5; flex-basis: 100%; }
  .main { padding: 16px 16px 96px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat .v, .stat-big .v { font-size: 17px; }
  .strip > .stat { padding: 12px 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav a, .bottomnav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 48px; gap: 2px;
    font-size: 11px; color: var(--muted); border: 0; background: none; cursor: pointer;
  }
  .bottomnav a.active { color: var(--accent); font-weight: 700; }
  .bottomnav .plus { width: 46px; height: 46px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 26px; display: flex; align-items: center; justify-content: center; }
  .modal-back { padding: 0; align-items: stretch; }
  .modal, .modal.wide { max-width: none; border-radius: 0; min-height: 100%; }
  .modal-foot { border-radius: 0; position: sticky; bottom: 0; }
  .att-row { grid-template-columns: 96px minmax(0, 1fr) auto; }
  .att-row .att-size { display: none; }
  .inst-row { grid-template-columns: 1fr 1fr; }

  /* 流水表在手机上变卡片 */
  table.t.cards thead, table.t.cards tfoot { display: none; }
  table.t.cards, table.t.cards tbody { display: block; }
  table.t.cards tbody tr.clickable {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 12px 14px;
    border-top: 1px solid var(--line-soft); grid-template-areas: "who amt" "meta docs";
  }
  table.t.cards tbody tr.clickable td { display: none; padding: 0; border: 0; background: none !important; }
  table.t.cards td.c-who { display: block !important; grid-area: who; min-width: 0; }
  table.t.cards td.c-amt { display: block !important; grid-area: amt; font-weight: 700; text-align: right; }
  table.t.cards td.c-meta { display: block !important; grid-area: meta; font-size: 12px; color: var(--muted); }
  table.t.cards td.c-docs { display: flex !important; grid-area: docs; justify-content: flex-end; }
  table.t.cards tr.detail-row { display: block; }
  table.t.cards tr.detail-row td { display: block; }
}
@media (min-width: 861px) {
  table.t.cards td.c-amt, table.t.cards td.c-meta { display: none; }
}

/* ---------- 打印 ---------- */
@media print {
  body { background: #fff; }
  .topbar, .sidenav, .bottomnav, .no-print, .toast-host { display: none !important; }
  .main { padding: 0; }
  .card { border-color: #ccc; break-inside: avoid; }
  .dark-card { display: none; }
  table.t th { position: static; }
}

/* 语言切换按钮：显示另一种语言的名字 */
html[lang="vi"] .lang-zh, html:not([lang="vi"]) .lang-vi { display: none; }
