:root {
  --navy-950: #061426;
  --navy-900: #071a30;
  --navy-850: #0a213b;
  --navy-800: #0b2b4a;
  --panel: rgba(8, 27, 49, 0.96);
  --panel-strong: #0a1d34;
  --panel-soft: #102e4e;
  --glass: rgba(18, 52, 87, 0.62);
  --glass-strong: rgba(20, 59, 99, 0.76);
  --line: rgba(155, 191, 229, 0.2);
  --line-strong: rgba(159, 197, 238, 0.34);
  --text: #f4f8ff;
  --text-soft: #c1cfe1;
  --text-muted: #8fa5bd;
  --accent: #82aaff;
  --accent-strong: #4d8cff;
  --accent-soft: rgba(130, 170, 255, 0.14);
  --success: #53d6a5;
  --warning: #ff9f43;
  --danger: #ff717d;
  --shadow-sm: 0 8px 24px rgba(0, 7, 18, 0.2);
  --shadow-lg: 0 28px 80px rgba(0, 6, 18, 0.36);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --transition: 180ms cubic-bezier(.2, .8, .2, 1);
  --sidebar-width: 228px;
  --content-max: 1540px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--navy-950);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { max-width: 100%; min-width: 320px; min-height: 100%; overflow-x: hidden; background: var(--navy-950); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 80% 7%, rgba(27, 105, 175, 0.19), transparent 30rem),
    radial-gradient(circle at 18% 95%, rgba(24, 82, 138, 0.18), transparent 27rem),
    linear-gradient(145deg, var(--navy-950) 0%, #071b31 55%, var(--navy-800) 135%);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: .22;
  background-image: radial-gradient(circle, rgba(130, 170, 255, .45) 1px, transparent 1.1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(110deg, transparent 8%, #000 46%, transparent 88%);
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:not(:disabled), select:not(:disabled), input[type="radio"] { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; }

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text);
  background: #091b30;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  font-variant-numeric: tabular-nums;
}

input::placeholder, textarea::placeholder { color: #738ba5; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(130, 170, 255, .14);
  background: #0b2039;
}

input[type="date"] { color-scheme: dark; }
textarea { resize: vertical; }
select { color-scheme: dark; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

[hidden] { display: none !important; }
.mobile-only { display: none !important; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.number, td[data-number], .kpi-value, .result-count { font-variant-numeric: tabular-nums; }

svg {
  width: 1.35em;
  height: 1.35em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.glass-shell {
  border: 1px solid rgba(151, 190, 232, .22);
  background: linear-gradient(135deg, rgba(29, 68, 110, .65), rgba(8, 31, 56, .63));
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(15px) saturate(128%);
  -webkit-backdrop-filter: blur(15px) saturate(128%);
}

.brand-mark {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(130, 170, 255, .56);
  border-radius: 12px;
  color: #d9e7ff;
  background: linear-gradient(145deg, rgba(130, 170, 255, .34), rgba(41, 104, 210, .42));
  box-shadow: 0 8px 26px rgba(45, 111, 229, .23), inset 0 1px rgba(255,255,255,.2);
}

.brand-mark svg { width: 25px; height: 25px; }

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 13px;
  color: var(--text-soft);
  background: var(--navy-950);
  transition: opacity var(--transition);
}

.boot-screen strong { margin-top: 4px; color: var(--text); font-size: 20px; letter-spacing: .02em; }
.boot-screen span:last-child { color: var(--text-muted); font-size: 14px; }
.boot-screen .brand-mark { animation: breathe 1.8s ease-in-out infinite; }

@keyframes breathe { 50% { transform: translateY(-4px); box-shadow: 0 15px 34px rgba(45,111,229,.34); } }

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-card {
  position: relative;
  width: min(100%, 460px);
  padding: 34px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: rgba(7, 26, 47, .94);
  box-shadow: var(--shadow-lg), inset 0 1px rgba(255,255,255,.05);
}

.auth-card::before {
  position: absolute;
  top: -90px;
  right: -100px;
  width: 250px;
  height: 250px;
  content: "";
  border-radius: 50%;
  background: rgba(83, 132, 229, .16);
  filter: blur(5px);
  pointer-events: none;
}

.auth-brand { position: relative; display: flex; align-items: center; gap: 12px; color: var(--text-soft); font-size: 15px; }
.auth-copy { position: relative; margin: 34px 0 25px; }
.auth-copy h1 { margin: 0 0 8px; font-size: clamp(28px, 5vw, 36px); letter-spacing: -.03em; }
.auth-copy p { margin: 0; color: var(--text-muted); }
.auth-form { position: relative; display: grid; gap: 17px; }
.auth-form label, .dialog-fields label { display: grid; gap: 7px; color: var(--text-soft); font-size: 14px; font-weight: 600; }
.form-error { margin: 0; color: #ff9ba4; font-size: 14px; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  transition: transform var(--transition), border-color var(--transition), color var(--transition), background var(--transition), box-shadow var(--transition);
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button svg { width: 18px; height: 18px; }
.button-primary { color: #071326; background: var(--accent); box-shadow: 0 8px 24px rgba(92, 143, 246, .2); }
.button-primary:hover:not(:disabled) { background: #9bbcff; box-shadow: 0 10px 30px rgba(92, 143, 246, .3); }
.button-secondary { color: var(--text); border-color: var(--line-strong); background: #102a47; }
.button-secondary:hover:not(:disabled), .button-tertiary:hover:not(:disabled) { border-color: var(--accent); color: #dce8ff; }
.button-tertiary { min-height: 38px; padding: 7px 12px; color: var(--accent); border-color: rgba(130,170,255,.3); background: var(--accent-soft); }
.button-danger { color: #ffd8dc; border-color: rgba(255,113,125,.36); background: rgba(255,113,125,.12); }
.button-block { width: 100%; margin-top: 5px; }

.app-shell { min-height: 100vh; min-height: 100dvh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 24px 15px 18px;
  border-width: 0 1px 0 0;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(10, 39, 68, .88), rgba(5, 23, 42, .82));
}

.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 7px 28px; }
.sidebar-brand > span:last-child { display: grid; gap: 1px; }
.sidebar-brand strong { font-size: 18px; letter-spacing: .04em; }
.sidebar-brand small { color: var(--text-muted); font-size: 12px; letter-spacing: .08em; }
.sidebar-brand .brand-mark { width: 39px; height: 39px; }

.nav-list { display: grid; gap: 8px; }
.nav-item {
  width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--text-soft);
  background: transparent;
  text-align: left;
  transition: color var(--transition), border-color var(--transition), background var(--transition), transform var(--transition);
}

.nav-item:hover { color: var(--text); background: rgba(130,170,255,.07); }
.nav-item.is-active { color: #fff; border-color: rgba(130,170,255,.55); background: linear-gradient(110deg, rgba(82,137,242,.4), rgba(82,137,242,.16)); box-shadow: inset 0 1px rgba(255,255,255,.08); }
.nav-item svg { width: 23px; height: 23px; color: #b5cdf4; }
.nav-item.is-active svg { color: #e0ebff; }
.nav-item small { margin-left: auto; padding: 2px 7px; border-radius: 99px; color: var(--accent); background: rgba(130,170,255,.11); font-size: 11px; }
.ai-nav { margin-top: 7px; border-color: rgba(130,170,255,.18); background: rgba(37,82,129,.2); }
.sidebar-foot { margin-top: auto; padding-top: 15px; border-top: 1px solid var(--line); }
.nav-muted { color: var(--text-muted); }

.app-main { min-width: 0; min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px clamp(20px, 3vw, 42px);
  border-width: 0 0 1px;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(8,31,55,.91), rgba(9,33,58,.74));
}

.topbar h1 { margin: 0; font-size: 23px; letter-spacing: -.02em; }
.topbar p { margin: 0 0 2px; color: var(--text-muted); font-size: 12px; letter-spacing: .08em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-control {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: rgba(7, 27, 49, .72);
}
.topbar-control:hover { border-color: rgba(130,170,255,.6); color: var(--text); }
.topbar-control svg { width: 19px; height: 19px; }

.content-wrap { width: min(100%, var(--content-max)); margin: 0 auto; padding: 32px clamp(20px, 3vw, 42px) 50px; }
.page { animation: pageIn var(--transition) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(5px); } }
.page-intro { display: flex; min-height: 58px; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-intro h2 { margin: 0 0 4px; font-size: clamp(26px, 2.5vw, 34px); letter-spacing: -.035em; }
.page-intro p { margin: 0; color: var(--text-muted); font-size: 14px; }
.split-intro { align-items: center; }
.intro-actions { display: flex; align-items: center; gap: 10px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(128px, 1fr));
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid rgba(150,190,232,.3);
  border-radius: var(--radius-md);
  background: linear-gradient(110deg, rgba(24,63,103,.7), rgba(11,36,63,.59));
  box-shadow: var(--shadow-sm), inset 0 1px rgba(255,255,255,.06);
  backdrop-filter: blur(15px);
}

.kpi-card { position: relative; min-width: 0; min-height: 151px; display: flex; flex-direction: column; padding: 20px 18px 16px; border-right: 1px solid var(--line); }
.kpi-card:last-child { border-right: 0; }
.kpi-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-icon { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid rgba(130,170,255,.28); border-radius: 9px; color: #b9d2ff; background: rgba(130,170,255,.1); }
.kpi-icon svg { width: 19px; height: 19px; }
.kpi-label { color: var(--text-soft); font-size: 13px; }
.kpi-value { margin-top: 13px; overflow: hidden; color: var(--text); font-size: clamp(18px, 1.55vw, 25px); font-weight: 700; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.kpi-unit { margin-left: 3px; color: var(--text-soft); font-size: .62em; font-weight: 500; }
.kpi-note { margin-top: auto; color: var(--text-muted); font-size: 12px; }
.kpi-card.is-warning .kpi-value, .kpi-card.is-warning .kpi-icon { color: var(--warning); }
.kpi-card.is-success .kpi-icon { color: var(--success); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(260px, .58fr); gap: 16px; align-items: stretch; }
.data-panel, .form-panel, .query-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.panel-heading { min-height: 75px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-heading h3 { margin: 0 0 2px; font-size: 17px; }
.panel-heading p { margin: 0; color: var(--text-muted); font-size: 12px; }
.text-button { display: inline-flex; min-height: 36px; align-items: center; gap: 2px; padding: 6px 4px; border: 0; color: var(--accent); background: transparent; font-size: 13px; white-space: nowrap; }
.text-button svg { width: 16px; height: 16px; }

.table-host { width: 100%; min-width: 0; overflow-x: auto; scrollbar-color: #355476 transparent; }
.data-table { width: 100%; min-width: 570px; border-collapse: collapse; color: var(--text-soft); font-size: 13px; }
.data-table th { height: 42px; padding: 10px 12px; color: #9eb2cb; background: #0e2946; font-weight: 600; text-align: left; white-space: nowrap; }
.data-table td { height: 48px; padding: 10px 12px; border-top: 1px solid rgba(151,190,232,.13); vertical-align: middle; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: rgba(130,170,255,.045); }
.data-table th.align-right, .data-table td.align-right { text-align: right; }
.data-table .primary-cell { color: var(--text); font-weight: 560; }
.data-table .sub-cell { display: block; margin-top: 2px; color: var(--text-muted); font-size: 12px; }
.data-table .warning-text { color: var(--warning); }
.data-table .danger-text { color: var(--danger); }
.data-table .success-text { color: var(--success); }
.status-badge { display: inline-flex; min-height: 26px; align-items: center; padding: 3px 8px; border-radius: 7px; color: var(--text-soft); background: #173553; font-size: 12px; white-space: nowrap; }
.status-badge.is-draft { color: #d7e4f9; background: #1e3c5c; }
.status-badge.is-posted { color: #a7efd3; background: rgba(58,184,135,.14); }
.status-badge.is-overdue { color: #ffc27f; background: rgba(255,159,67,.13); }

.todo-list { display: grid; gap: 9px; padding: 12px; }
.todo-item { display: flex; min-height: 67px; align-items: center; gap: 12px; padding: 12px; border: 1px solid rgba(151,190,232,.14); border-radius: 11px; background: #0a2139; }
.todo-item-icon { display: grid; width: 37px; height: 37px; place-items: center; border-radius: 9px; color: var(--accent); background: var(--accent-soft); }
.todo-item-icon svg { width: 21px; height: 21px; }
.todo-item-copy { min-width: 0; display: grid; gap: 1px; }
.todo-item-copy strong { overflow: hidden; color: var(--text-soft); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.todo-item-copy span { color: var(--text-muted); font-size: 12px; }
.todo-item-value { margin-left: auto; color: var(--accent); font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }

.empty-state { min-height: 245px; display: grid; place-content: center; justify-items: center; padding: 28px; text-align: center; }
.empty-state.compact { min-height: 185px; }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; color: #6683a3; stroke-width: 1.45; }
.empty-state strong { color: var(--text-soft); font-size: 15px; }
.empty-state p { max-width: 320px; margin: 5px 0 0; color: var(--text-muted); font-size: 13px; }

.notice { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 16px; padding: 13px 15px; border: 1px solid rgba(130,170,255,.25); border-radius: var(--radius-sm); background: rgba(130,170,255,.08); }
.notice > svg { width: 22px; height: 22px; color: var(--accent); }
.notice div { display: grid; gap: 2px; }
.notice strong { font-size: 14px; }
.notice span { color: var(--text-muted); font-size: 13px; }

.entry-tabs {
  display: inline-flex;
  gap: 5px;
  margin-bottom: 16px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(7, 25, 45, .72);
  box-shadow: inset 0 1px rgba(255, 255, 255, .04);
}
.entry-tab {
  min-width: 126px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--text-muted);
  background: transparent;
  font-weight: 680;
  transition: color var(--transition), border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.entry-tab:hover { color: var(--text-soft); background: rgba(130, 170, 255, .06); }
.entry-tab.is-active { color: #fff; border-color: rgba(130, 170, 255, .48); background: linear-gradient(110deg, rgba(82, 137, 242, .38), rgba(82, 137, 242, .16)); box-shadow: inset 0 1px rgba(255, 255, 255, .08); }
.entry-tab svg { width: 20px; height: 20px; color: var(--accent); }
.entry-panel[hidden] { display: none !important; }

.form-panel { margin-bottom: 20px; }
.form-section { min-width: 0; margin: 0; padding: 21px; border: 0; border-bottom: 1px solid var(--line); }
.form-section:last-of-type { border-bottom: 0; }
.form-section legend { padding: 0; color: var(--text); font-size: 16px; font-weight: 680; }
.form-grid { display: grid; gap: 14px; margin-top: 15px; }
.form-grid-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-section label, .query-form label { display: grid; gap: 7px; color: var(--text-soft); font-size: 13px; font-weight: 600; }
.field-label { color: var(--text-soft); font-size: 13px; font-weight: 600; }
.field-label b { color: var(--danger); }
.invoice-field { display: flex; align-items: center; gap: 18px; margin-top: 19px; }
.segmented-radio { display: flex; gap: 8px; }
.segmented-radio label { display: block; }
.segmented-radio input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segmented-radio span { min-width: 104px; min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 16px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--text-soft); background: #091b30; transition: all var(--transition); }
.segmented-radio svg { width: 16px; height: 16px; opacity: 0; }
.segmented-radio input:checked + span { border-color: var(--accent); color: var(--text); background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(130,170,255,.14); }
.segmented-radio input:checked + span svg { opacity: 1; color: var(--accent); }
.segmented-radio input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.legend-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.line-table-wrap { width: 100%; max-width: 100%; margin-top: 15px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); contain: inline-size; overscroll-behavior-inline: contain; }
.line-table { width: 100%; min-width: 1020px; border-collapse: collapse; font-size: 13px; }
.line-table th { padding: 10px; color: var(--text-muted); background: #0e2946; font-weight: 600; text-align: left; white-space: nowrap; }
.line-table th:nth-child(1) { width: 23%; }
.line-table th:nth-child(2), .line-table th:nth-child(3), .line-table th:nth-child(4) { width: 13%; }
.line-table th:nth-child(5) { width: 19%; }
.line-table th:nth-child(6) { width: 14%; text-align: right; }
.line-table td { padding: 8px; border-top: 1px solid var(--line); }
.line-table td:nth-child(6) { text-align: right; }
.line-table input, .line-table select { min-height: 40px; padding: 8px 9px; }
.line-amount { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.remove-line { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid transparent; border-radius: 9px; color: var(--text-muted); background: transparent; }
.remove-line:hover { color: var(--danger); border-color: rgba(255,113,125,.25); background: rgba(255,113,125,.08); }
.remove-line svg { width: 18px; height: 18px; }
.line-summary { display: flex; justify-content: flex-end; gap: 24px; padding: 15px 3px 0; color: var(--text-muted); font-size: 13px; }
.line-summary strong { color: var(--text); font-size: 14px; }
.full-field { margin-top: 15px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 17px 21px 21px; border-top: 1px solid var(--line); background: rgba(5,17,31,.42); }
#shipment-error { padding: 0 21px 18px; }
.recent-drafts-panel { margin-top: 20px; }
.receipt-form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.allocation-field { display: grid; gap: 9px; margin-top: 20px; }
.allocation-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.allocation-options > label { display: block; }
.allocation-options input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.allocation-options label > span { min-height: 72px; display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 2px 9px; align-content: center; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--text-soft); background: #091b30; transition: border-color var(--transition), background var(--transition), box-shadow var(--transition); }
.allocation-options label > span > svg { grid-row: 1 / 3; align-self: center; width: 18px; height: 18px; color: var(--accent); opacity: 0; }
.allocation-options strong { color: var(--text); font-size: 13px; }
.allocation-options small { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.allocation-options input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(130, 170, 255, .12); }
.allocation-options input:checked + span > svg { opacity: 1; }
.allocation-options input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
#receipt-error { padding: 0 21px 18px; }
.recent-receipts-panel { margin-top: 20px; }
.unallocated-value { color: var(--warning); font-weight: 680; }
.unallocated-badge { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; padding: 3px 7px; border: 1px solid rgba(255, 159, 67, .3); border-radius: 7px; color: #ffc27f; background: rgba(255, 159, 67, .1); font-size: 11px; font-weight: 600; white-space: nowrap; }
.unallocated-badge svg { width: 13px; height: 13px; }

.panel-toolbar { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.search-field { position: relative; width: min(100%, 420px); }
.search-field svg { position: absolute; top: 50%; left: 12px; z-index: 1; width: 18px; height: 18px; color: var(--text-muted); transform: translateY(-50%); }
.search-field input { padding-left: 39px; }
.result-count { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.reconciliation-panel, .accounting-period-panel { margin-top: 20px; }
.account-tool-form { display: grid; grid-template-columns: minmax(220px, 1.4fr) minmax(155px, .8fr) minmax(155px, .8fr) auto; align-items: end; gap: 14px; padding: 18px; border-bottom: 1px solid var(--line); }
.account-tool-form label, .period-query-row label, .period-write-controls label { display: grid; gap: 7px; color: var(--text-soft); font-size: 13px; font-weight: 600; }
.account-tool-error { margin: 0; padding: 12px 18px 0; }
.reconciliation-summary { display: grid; grid-template-columns: repeat(6, minmax(128px, 1fr)); border-bottom: 1px solid var(--line); background: #0a2139; }
.reconciliation-metric { min-width: 0; display: grid; gap: 5px; padding: 15px 14px; border-right: 1px solid var(--line); }
.reconciliation-metric:last-child { border-right: 0; }
.reconciliation-metric span { color: var(--text-muted); font-size: 12px; }
.reconciliation-metric strong { overflow: hidden; color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.reconciliation-metric.is-unallocated { background: rgba(255, 159, 67, .07); }
.reconciliation-metric.is-unallocated strong { color: #ffc27f; }
.reconciliation-metric small { color: var(--warning); font-size: 10px; font-weight: 500; }
.reconciliation-events:empty::before { min-height: 150px; display: grid; place-items: center; padding: 20px; color: var(--text-muted); content: "请选择客户和日期后查询对账明细"; font-size: 13px; }
.reconciliation-table { min-width: 920px; }
.event-type { display: inline-flex; min-width: 48px; justify-content: center; padding: 3px 7px; border-radius: 6px; color: var(--text-soft); background: #173553; font-size: 11px; }
.event-type.is-receipt { color: #a7efd3; background: rgba(58, 184, 135, .14); }

#accounting-period-form { min-width: 0; }
.period-query-row { display: grid; grid-template-columns: minmax(180px, 260px) auto minmax(180px, 1fr); align-items: end; gap: 14px; padding: 18px; border-bottom: 1px solid var(--line); }
.period-status { align-self: center; justify-self: end; text-align: right; }
.period-status .status-badge { min-height: 30px; }
.period-status .status-badge.is-locked { color: #ffc27f; background: rgba(255, 159, 67, .13); }
.period-status small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 11px; }
.period-warnings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.period-warning { display: flex; min-width: 0; align-items: center; gap: 10px; padding: 15px 18px; border-right: 1px solid var(--line); background: rgba(7, 25, 45, .48); }
.period-warning:last-child { border-right: 0; }
.period-warning svg { width: 20px; height: 20px; color: var(--accent); }
.period-warning.has-warning svg, .period-warning.has-warning strong { color: var(--warning); }
.period-warning span { min-width: 0; display: grid; gap: 2px; color: var(--text-muted); font-size: 12px; }
.period-warning strong { color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; }
.period-write-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 16px; padding: 18px; }
.period-actions { display: flex; gap: 9px; }

.query-panel { overflow: visible; }
.query-tabs { display: flex; gap: 4px; padding: 8px 18px 0; border-bottom: 1px solid var(--line); }
.query-tab { min-height: 48px; padding: 10px 15px; border: 0; border-bottom: 2px solid transparent; color: var(--text-muted); background: transparent; font-weight: 650; }
.query-tab:hover { color: var(--text-soft); }
.query-tab.is-active { border-color: var(--accent); color: var(--accent); }
.query-form { display: grid; grid-template-columns: minmax(210px, 1.35fr) minmax(140px, .8fr) minmax(140px, .8fr) minmax(125px, .65fr) auto; align-items: end; gap: 14px; padding: 20px; border-bottom: 1px solid var(--line); }
.query-summary { display: flex; flex-wrap: wrap; gap: 18px; padding: 14px 20px; color: var(--text-muted); background: #0e2946; font-size: 13px; }
.query-summary strong { margin-left: 4px; color: var(--text); font-variant-numeric: tabular-nums; }
.query-results .empty-state { min-height: 310px; }

.ai-placeholder { position: relative; min-height: 520px; display: grid; place-content: center; justify-items: center; padding: 54px 28px; overflow: hidden; border-radius: var(--radius-lg); text-align: center; }
.ai-placeholder::before { position: absolute; width: 520px; height: 520px; content: ""; border-radius: 50%; background: radial-gradient(circle, rgba(130,170,255,.12), transparent 68%); pointer-events: none; }
.ai-placeholder > * { position: relative; }
.ai-orbit { display: grid; width: 90px; height: 90px; place-items: center; margin-bottom: 22px; border: 1px solid rgba(130,170,255,.26); border-radius: 28px; color: #d7e5ff; background: linear-gradient(145deg, rgba(130,170,255,.25), rgba(34,92,153,.18)); box-shadow: 0 20px 50px rgba(24,80,153,.22), inset 0 1px rgba(255,255,255,.1); }
.ai-orbit svg { width: 47px; height: 47px; }
.ai-placeholder h3 { margin: 0 0 10px; font-size: clamp(24px, 3vw, 32px); }
.ai-placeholder p { max-width: 680px; margin: 0 auto; color: var(--text-soft); }
.ai-safety { display: flex; align-items: center; gap: 8px; margin-top: 19px; padding: 9px 12px; border: 1px solid rgba(130,170,255,.19); border-radius: 9px; color: var(--text-muted); background: rgba(7,25,45,.5); font-size: 13px; }
.ai-safety svg { width: 18px; height: 18px; color: var(--accent); }
.ai-input-preview { width: min(100%, 620px); min-height: 54px; display: flex; align-items: center; margin-top: 28px; padding: 6px 7px 6px 17px; border: 1px solid var(--line-strong); border-radius: 14px; color: #7189a4; background: rgba(6,20,37,.76); text-align: left; }
.ai-input-preview span { flex: 1; }
.ai-input-preview button { display: grid; width: 40px; height: 40px; place-items: center; border: 0; border-radius: 10px; color: #8ba5c3; background: rgba(130,170,255,.12); }

.app-dialog {
  width: min(calc(100% - 32px), 560px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text);
  background: #0a1d34;
  box-shadow: var(--shadow-lg);
}
.app-dialog::backdrop { background: rgba(0,8,19,.72); backdrop-filter: blur(4px); }
.app-dialog[open] { animation: dialogIn var(--transition) both; }
@keyframes dialogIn { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.app-dialog form { margin: 0; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 21px 22px 17px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0 0 3px; font-size: 21px; }
.dialog-heading p { margin: 0; color: var(--text-muted); font-size: 13px; }
.icon-button { display: grid; width: 42px; height: 42px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 10px; color: var(--text-soft); background: rgba(8,29,51,.62); }
.icon-button:hover { border-color: var(--accent); color: var(--text); }
.icon-button svg { width: 20px; height: 20px; }
.dialog-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 21px 22px; }
.dialog-error { padding: 0 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 21px; border-top: 1px solid var(--line); }

.toast-region { position: fixed; right: 24px; bottom: 24px; z-index: 1000; display: grid; gap: 9px; pointer-events: none; }
.toast { min-width: 280px; max-width: min(420px, calc(100vw - 32px)); display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--text-soft); background: #102a47; box-shadow: var(--shadow-lg); animation: toastIn var(--transition) both; pointer-events: auto; }
.toast svg { width: 20px; height: 20px; color: var(--accent); }
.toast.is-error svg { color: var(--danger); }
.toast span { flex: 1; font-size: 14px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.loading-state { min-height: 185px; display: grid; place-items: center; color: var(--text-muted); font-size: 13px; }
.loading-state::before { width: 24px; height: 24px; margin-right: 9px; border: 2px solid rgba(130,170,255,.22); border-top-color: var(--accent); border-radius: 50%; content: ""; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.inline-action { min-height: 34px; padding: 5px 10px; border: 1px solid rgba(130,170,255,.29); border-radius: 8px; color: var(--accent); background: var(--accent-soft); font-size: 12px; white-space: nowrap; }
.inline-action:hover { border-color: var(--accent); }

.mobile-nav { display: none; }

@media (max-width: 1320px) {
  .kpi-grid { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
  .kpi-card { min-height: 132px; border-bottom: 1px solid var(--line); }
  .kpi-card:nth-child(4n) { border-right: 0; }
  .kpi-card:nth-last-child(-n+4) { border-bottom: 0; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .todo-panel { grid-column: 1 / -1; }
  .todo-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1020px) {
  :root { --sidebar-width: 204px; }
  .content-wrap { padding-left: 22px; padding-right: 22px; }
  .topbar { padding-left: 22px; padding-right: 22px; }
  .form-grid-four { grid-template-columns: 1fr 1fr; }
  .receipt-form-grid { grid-template-columns: 1fr 1fr; }
  .account-tool-form { grid-template-columns: 1fr 1fr; }
  .reconciliation-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .reconciliation-metric:nth-child(3) { border-right: 0; }
  .reconciliation-metric:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .query-form { grid-template-columns: 1fr 1fr; }
  .query-form .button { align-self: end; }
}

@media (max-width: 760px) {
  body { background: linear-gradient(155deg, var(--navy-950) 0%, #071d35 67%, var(--navy-800) 150%); }
  body::before { opacity: .18; background-size: 24px 24px; }
  .mobile-only { display: grid !important; }
  .sidebar { display: none; }
  .app-main { margin-left: 0; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .topbar { position: relative; height: 75px; padding: 11px 16px; border-radius: 0; }
  .topbar p, .role-control { display: none; }
  .topbar h1 { font-size: 19px; }
  .topbar-actions { gap: 7px; }
  .topbar-control { min-height: 42px; padding: 8px 10px; }
  .topbar-control span { display: none; }
  .content-wrap { width: 100%; padding: 24px 16px 28px; }
  .page-intro { min-height: auto; margin-bottom: 16px; }
  .page-intro h2 { font-size: 28px; }
  .page-intro p { font-size: 13px; }
  .split-intro { align-items: flex-end; }
  .intro-actions .button { min-width: 44px; padding: 9px 12px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; overflow: visible; border: 0; background: transparent; box-shadow: none; backdrop-filter: none; }
  .kpi-card { min-height: 146px; padding: 16px; border: 1px solid rgba(151,190,232,.27) !important; border-radius: 15px; background: linear-gradient(135deg, rgba(27,67,108,.72), rgba(12,39,68,.68)); box-shadow: var(--shadow-sm), inset 0 1px rgba(255,255,255,.06); backdrop-filter: blur(14px); }
  .kpi-icon { width: 38px; height: 38px; }
  .kpi-icon svg { width: 22px; height: 22px; }
  .kpi-label { font-size: 13px; }
  .kpi-value { margin-top: 10px; font-size: clamp(20px, 5.6vw, 26px); }
  .kpi-note { font-size: 12px; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 14px; }
  .todo-panel { grid-column: auto; }
  .todo-list { grid-template-columns: 1fr; }
  .data-panel, .form-panel, .query-panel { border-radius: 14px; }
  .panel-heading { min-height: 70px; padding: 14px 15px; }
  .table-host { max-width: 100%; }
  .mobile-table { min-width: 0; }
  .mobile-table thead { display: none; }
  .mobile-table tbody { display: grid; }
  .mobile-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; padding: 13px 15px; border-top: 1px solid var(--line); }
  .mobile-table tr:first-child { border-top: 0; }
  .mobile-table td { height: auto; padding: 0; border: 0; text-align: left !important; }
  .mobile-table td:first-child { grid-column: 1 / -1; }
  .receipt-table .receipt-customer { grid-column: 1 / -1; }
  .mobile-table td[data-label]::before { margin-right: 6px; color: var(--text-muted); content: attr(data-label) " "; font-size: 11px; }
  .mobile-table td.mobile-hide { display: none; }
  .mobile-table .inline-action { grid-column: auto; }
  .empty-state { min-height: 210px; }
  .form-section { padding: 18px 15px; }
  .form-grid-four { grid-template-columns: 1fr; }
  .receipt-form-grid { grid-template-columns: 1fr; }
  .entry-tabs { width: 100%; }
  .entry-tab { min-width: 0; flex: 1; }
  .allocation-options { grid-template-columns: 1fr; }
  .account-tool-form { grid-template-columns: 1fr; padding: 15px; }
  .account-tool-form .button { width: 100%; }
  .reconciliation-summary { grid-template-columns: 1fr 1fr; }
  .reconciliation-metric { padding: 13px 12px; border-bottom: 1px solid var(--line); }
  .reconciliation-metric:nth-child(odd) { border-right: 1px solid var(--line); }
  .reconciliation-metric:nth-child(2n) { border-right: 0; }
  .reconciliation-metric:nth-last-child(-n+2) { border-bottom: 0; }
  .period-query-row { grid-template-columns: minmax(0, 1fr) auto; padding: 15px; }
  .period-status { grid-column: 1 / -1; justify-self: start; text-align: left; }
  .period-warnings { grid-template-columns: 1fr; }
  .period-warning { border-right: 0; border-bottom: 1px solid var(--line); }
  .period-warning:last-child { border-bottom: 0; }
  .period-write-controls { grid-template-columns: 1fr; padding: 15px; }
  .period-actions .button { flex: 1; }
  .invoice-field { align-items: flex-start; flex-direction: column; gap: 9px; }
  .segmented-radio { width: 100%; }
  .segmented-radio label { flex: 1; }
  .segmented-radio span { width: 100%; min-width: 0; }
  .legend-row { align-items: flex-start; }
  .line-table-wrap { margin-right: 0; }
  .line-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; justify-content: initial; }
  .form-actions { padding: 15px; }
  .form-actions .button { flex: 1; }
  .panel-toolbar { align-items: stretch; flex-direction: column; gap: 9px; padding: 14px 15px; }
  .search-field { width: 100%; }
  .query-tabs { padding-left: 11px; padding-right: 11px; }
  .query-tab { flex: 1; padding-left: 8px; padding-right: 8px; }
  .query-form { grid-template-columns: 1fr; padding: 16px 15px; }
  .query-form .button { width: 100%; }
  .ai-placeholder { min-height: 470px; padding: 38px 20px; }
  .ai-safety { align-items: flex-start; text-align: left; }
  .dialog-fields { grid-template-columns: 1fr; padding: 18px; }
  .dialog-heading { padding: 18px; }
  .dialog-actions { padding: 15px 18px 18px; }
  .mobile-nav { position: fixed; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); left: 8px; z-index: 30; min-height: 72px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px; border-radius: 18px; }
  .mobile-nav-item { min-width: 0; min-height: 58px; display: grid; place-content: center; justify-items: center; gap: 3px; padding: 5px 2px; border: 0; border-radius: 12px; color: #9fb2ca; background: transparent; transition: color var(--transition), background var(--transition); }
  .mobile-nav-item svg { width: 23px; height: 23px; }
  .mobile-nav-item span { max-width: 100%; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-nav-item.is-active { color: var(--accent); background: rgba(130,170,255,.1); }
  .mobile-nav-item.is-active svg { filter: drop-shadow(0 4px 8px rgba(77,140,255,.5)); }
  .toast-region { right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); left: 16px; }
  .toast { width: 100%; min-width: 0; max-width: none; }
}

@media (max-width: 420px) {
  .auth-shell { padding: 16px; }
  .auth-card { padding: 26px 20px; border-radius: 20px; }
  .content-wrap { padding-left: 12px; padding-right: 12px; }
  .topbar { padding-left: 13px; padding-right: 13px; }
  .page-intro h2 { font-size: 26px; }
  .entry-tab { padding-right: 12px; padding-left: 12px; }
  .kpi-grid { gap: 10px; }
  .kpi-card { min-height: 138px; padding: 14px 12px; }
  .kpi-label { font-size: 12px; }
  .kpi-value { font-size: clamp(18px, 5.7vw, 23px); }
  .kpi-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-nav { right: 6px; left: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  :root { color-scheme: light; }
  body { color: #111; background: #fff; }
  body::before, .sidebar, .topbar, .mobile-nav, .button, .text-button, .intro-actions, .form-actions { display: none !important; }
  .app-main { margin: 0; }
  .content-wrap { width: 100%; max-width: none; padding: 0; }
  .page[hidden] { display: none !important; }
  .page.is-active { display: block !important; }
  .data-panel, .form-panel, .query-panel, .kpi-grid, .kpi-card { color: #111; border-color: #bbb !important; background: #fff !important; box-shadow: none; backdrop-filter: none; }
  .kpi-label, .kpi-note, .page-intro p, .panel-heading p, .result-count { color: #555; }
  .kpi-value, .panel-heading h3, .page-intro h2, .data-table .primary-cell { color: #111; }
  .data-table { color: #222; }
  .data-table th { color: #222; background: #eee; }
  .data-table td { border-color: #ddd; }
}
