:root {
  color-scheme: light;
  --brand: #1764ef;
  --brand-hover: #1054ce;
  --brand-tint: #eaf1ff;
  --blue-tint: var(--brand-tint);
  --ink: #172c4d;
  --muted: #566984;
  --line: #dce4ef;
  --canvas: #f5f7fc;
  --panel: #fff;
  --green: #177052;
  --green-tint: #e8f6ef;
  --rose: #a64268;
  --rose-tint: #fceef3;
  --danger: #a92d4c;
  --pale: var(--brand-tint);
  --shadow: 0 3px 12px #243b6b05;
  --gutter: clamp(18px, 2.4vw, 36px);
  font-family: Inter, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--canvas);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
h1,h2,h3,p { margin: 0; }
h1 { font-size: clamp(1.55rem, 2.3vw, 1.875rem); line-height: 1.42; letter-spacing: -.025em; }
h2 { font-size: 1.25rem; line-height: 1.45; }
h3,.subhead { font-size: 1.04rem; font-weight: 650; }
p { line-height: 1.6; }
button,input,select,textarea { font: inherit; }
button,select { cursor: pointer; }
button { color: inherit; }
button:disabled { cursor: not-allowed; opacity: .56; }
a { color: var(--brand); }
:where(a,button,input,select,textarea,[tabindex]):focus-visible { outline: 3px solid #5593fb; outline-offset: 2px; }
:where(input:not([type="checkbox"]):not([type="radio"]),select,textarea) {
  min-width: 0; max-width: 100%; min-height: 42px; padding: 9px 12px;
  color: var(--ink); background-color: white; border: 1px solid #cdd8e8; border-radius: 8px;
}
input[type="checkbox"],input[type="radio"] { accent-color: var(--brand); }
input::placeholder,textarea::placeholder { color: #718099; }
select {
  appearance: none; padding-right: 33px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='m3 5 4 4 4-4' fill='none' stroke='%23566984' stroke-linecap='round' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
textarea { resize: vertical; }
svg.icon { width: 20px; height: 20px; flex: none; stroke-width: 1.65; vertical-align: middle; }
.muted { color: var(--muted); }
.loading,.empty { text-align: center; padding: 40px 18px; color: var(--muted); font-size: .9375rem; }
.error { font-size: .9rem; color: var(--danger); }
.error:empty { display: none; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 40px; height: 40px; }
.brand b,.brand small { display:block; }
.brand b { font-size: 1.31rem; line-height: 1.35; }
.brand small { margin-top: 2px; font: 650 .65rem/1.4 Inter,Arial,sans-serif; letter-spacing: .075em; color: #5e7191; }
.layout { display: grid; grid-template-columns: 222px minmax(0,1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; align-self: start; display: flex; flex-direction: column;
  height: 100dvh; overflow-y: auto; padding: 22px 12px 18px;
  border-right: 1px solid var(--line); background: #f4f7fd;
}
.sidebar .brand { margin: 0 9px; padding: 0 0 22px; border-bottom: 1px solid var(--line); }
.sidebar nav { margin-top: 5px; }
.nav-group { margin: 19px 16px 9px; color: #607490; font-size: .8rem; font-weight: 550; }
.side-link {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 41px;
  padding: 8px 16px; margin: 3px 0; background: transparent;
  border: 0; border-radius: 8px; text-align: left; font-size: 1rem; font-weight: 525;
}
.side-link .icon { width: 19px; height: 19px; color: #456389; }
.side-link:hover { background: #eaf0fa; }
.side-link.active { color: #124fae; background: #ddebff; font-weight: 650; }
.side-link.active .icon { color: #175dca; }
.sidebar-bottom { margin-top: auto; padding: 26px 9px 5px; }
.identity,.member-name,.account-meta { display: flex; align-items: center; gap: 11px; }
.identity { border-top: 1px solid var(--line); padding-top: 18px; }
.avatar {
  flex-shrink: 0; display: inline-grid; place-items: center; border-radius: 11px;
  width: 38px; height: 38px; background: #dce8fe; color: #234e9c; font-weight: 650;
}
.identity-info { min-width: 0; }
.identity b,.identity small { display: block; }
.identity b { font-size: .94rem; overflow-wrap: anywhere; }
.identity small { margin-top: 2px; font-size: .8rem; color: var(--muted); }
.icon-btn {
  flex-shrink: 0; display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--line); background: white; color: var(--muted); border-radius: 8px;
}
.icon-btn:hover { color: var(--brand); background: var(--brand-tint); }
.identity .logout { margin-left: auto; background: transparent; border-color: transparent; }
.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 62px; padding: 0 var(--gutter); border-bottom: 1px solid var(--line);
  background: #fff; color: var(--muted); font-size: .9rem;
}
.crumb { display: flex; align-items: center; gap: 12px; }
.crumb>.icon { width: 18px; height: 18px; color: var(--brand); }
.crumb strong { font-weight: 500; }
.crumb i { color: #8796ad; font-style: normal; }
.account-meta { border-left: 1px solid var(--line); padding-left: 20px; }
.account-meta .avatar { margin-left: 12px; width: 28px; height: 28px; font-size: .81rem; border-radius: 8px; }
.account-meta b { font-weight: 550; color: var(--ink); }
.mobile-menu,.backdrop { display: none; }
.workspace { max-width: 1770px; margin: auto; padding: 21px var(--gutter) 38px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 69px; margin-bottom: 20px; }
.page-head p { margin-top: 5px; font-size: .94rem; color: var(--muted); }
.page-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.page-tools:empty { display: none; }
.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: 7px; min-height: 40px;
  padding: 8px 16px; font-size: .9375rem; font-weight: 550; line-height: 1.4; text-decoration: none;
  background: white; border: 1px solid #d2ddec; border-radius: 9px;
}
.btn:hover { border-color: #a9c1e8; background: #f3f7ff; }
.btn.primary { color: white; background: var(--brand); border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.small { min-height: 32px; padding: 5px 11px; font-size: .86rem; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.link-btn { color: var(--brand); border: 0; background: transparent; padding: 5px 2px; font-size: .89rem; font-weight: 550; }
.link-btn:hover { text-decoration: underline; }
.actions,.toolbar,.panel-head,.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.toolbar { margin-bottom: 16px; }
.panel-head { justify-content: space-between; margin-bottom: 18px; }
.panel { min-width: 0; padding: 22px; background: white; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.stack { display: grid; gap: 16px; }
.split,.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.split { align-items: start; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; font-size: .9rem; font-weight: 550; }
.field input:not([type="radio"]):not([type="checkbox"]),.field select,.field textarea { width: 100%; font-weight: 400; }
.full { grid-column: 1 / -1; }
.form-actions { justify-content: flex-end; margin-top: 20px; }
.table-wrap { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; text-align: left; }
th,td { padding: 13px 12px; border-bottom: 1px solid #e5eaf3; }
th { background: #f5f7fb; font-size: .83rem; color: var(--muted); font-weight: 550; }
tbody tr:last-child td { border-bottom: 0; }
.pill { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 6px; color: #2458ad; background: var(--brand-tint); font-size: .81rem; font-weight: 550; }
.pill.neutral { color: var(--muted); background: #eff2f7; }
dialog {
  padding: 0; border: 1px solid var(--line); border-radius: 16px; width: min(700px,94vw);
  max-width: 95vw; max-height: 90dvh; box-shadow: 0 22px 80px #13284938; color: var(--ink);
}
dialog::backdrop { background: #15284469; }
.modal-head { position: sticky; top: 0; z-index: 1; background: white; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; }
#notice { position: fixed; z-index: 1000; bottom: 28px; left: 50%; transform: translateX(-50%); max-width: min(92vw,600px); padding: 11px 18px; background: #203351; color: white; border-radius: 9px; box-shadow: 0 4px 16px #162c4a25; text-align: center; pointer-events: none; }
#notice:empty { display: none; }
.ledger-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 9px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; font-size: .94rem; }
.ledger-row strong { font-variant-numeric: tabular-nums; }
.ledger-row.total { border-bottom: 0; color: #174da9; font-weight: 650; }

/* The first-run and sign-in forms share the same business receipt. */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: clamp(20px,4vw,60px); }
.auth-card { display: grid; grid-template-columns: 44.7% 1fr; width: min(1130px,100%); min-height: min(674px,86dvh); overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); }
.auth-preview { display: flex; flex-direction: column; justify-content: center; padding: 36px clamp(26px,3vw,42px) 56px; background: linear-gradient(105deg,#1648b5,#256bec); color: white; }
.auth-preview .brand { margin-bottom: clamp(35px,7vh,84px); }
.auth-preview .brand small { color: #d7e7ff; }
.auth-preview h2 { font-size: clamp(1.45rem,2.2vw,1.875rem); }
.auth-preview .example-caption { margin: 12px 0 34px; color: #d7e7ff; }
.sample-paper { background: white; color: var(--ink); border-radius: 14px; padding: 20px 24px; }
.sample-paper h3 { margin: 0 0 18px; font-size: 1.19rem; }
.sample-paper .ledger-row { color: var(--muted); min-height: 39px; border: 0; }
.sample-paper strong { color: var(--ink); font-weight: 550; }
.sample-paper .total { padding-top: 14px; margin-top: 12px; border-top: 1px solid var(--line); color: var(--brand); }
.sample-paper .total strong { font-size: 1.75rem; font-weight: 700; color: var(--brand); }
.auth-form { align-self: center; padding: 48px clamp(32px,5.2vw,80px); }
.auth-form h1 { font-size: clamp(1.6rem,2.3vw,2rem); }
.auth-form>p { color: var(--muted); margin: 13px 0 35px; }
.auth-form form,.account-create form { display: grid; gap: 22px; }
.auth-form .btn { margin-top: 12px; min-height: 44px; }

/* Account management */
.account-grid { display: grid; grid-template-columns: minmax(0,2fr) minmax(285px,1fr); gap: 18px; align-items: start; }
.account-card { padding: 0; overflow: hidden; }
.account-card>header { padding: 21px 22px 17px; }
.account-card .panel-head { margin: 0 0 7px; }
.title-count { display: inline-flex; align-items: center; gap: 12px; }
.member-name { font-weight: 550; }
.member-name .avatar { width: 40px; height: 40px; }
.member-name .avatar.lilac { color: #65529c; background: #f0ecfb; }
.member-name .avatar.peach { color: #995523; background: #fff0e5; }
.account-card th,.account-card td { padding: 14px 22px; }
.account-card td { overflow-wrap: anywhere; }
.account-create h2 { display: flex; align-items: center; gap: 12px; }
.account-shield { display: grid; place-items: center; width: 42px; height: 42px; color: var(--brand); background: var(--brand-tint); border-radius: 11px; }
.account-create p.muted { margin: 20px 0; font-size: .9rem; }
.account-create .btn { width: 100%; }
.account-create footer { padding-top: 22px; border-top: 1px solid var(--line); }
.role-check { color: var(--green); }
.role-check .icon { width: 18px; }
@media (max-width:1100px) {
  .layout { grid-template-columns: 188px minmax(0,1fr); }
  .sidebar { padding-inline: 9px; }
  .sidebar .brand { gap: 9px; }
  .account-card th,.account-card td { padding-inline: 12px; }
}
@media (max-width:900px) {
  .account-grid { grid-template-columns: minmax(0,1fr); }
  .auth-form { padding-inline: 29px; }
}
@media (max-width:800px) {
  .layout { display: block; }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 238px; transform: translateX(-100%); visibility: hidden; transition: transform .18s ease,visibility .18s; }
  .menu-open .sidebar { transform: none; visibility: visible; }
  .menu-open .backdrop { display:block; position:fixed; inset:0; z-index:35; background:#14274669; border:0; }
  .mobile-menu { display: inline-grid; }
  .topbar { min-height: 56px; padding-inline: 15px; }
  .workspace { padding-top: 16px; }
}
@media (max-width:650px) {
  :root { --gutter: 14px; }
  .page-head { align-items: flex-start; flex-wrap: wrap; gap: 10px; }
  .page-tools { justify-content: flex-start; }
  .crumb { gap: 8px; }
  .crumb>.icon,.crumb>i,.crumb>span { display: none; }
  .account-meta { border: 0; padding-left: 0; gap: 7px; }
  .account-meta .avatar { margin: 0; }
  .account-meta .top-date { display: none; }
  .account-meta b { font-size: .86rem; }
  .panel { padding: 16px; }
  .split,.form-grid { grid-template-columns: minmax(0,1fr); }
  .auth-wrap { padding: 14px; }
  .auth-card { max-width: 445px; min-height: auto; grid-template-columns: minmax(0,1fr); }
  .auth-preview { padding: 21px 24px; }
  .auth-preview .brand { margin: 0; }
  .auth-preview h2,.auth-preview .example-caption,.sample-paper { display: none; }
  .auth-form { padding: 30px 23px; }
  .auth-form>p { margin-bottom: 24px; }
  .account-card { padding: 0; }
  .account-card>header { padding-inline: 15px; }
  .account-card th,.account-card td { padding: 12px 9px; }
  .member-name { gap: 6px; }
  .member-name .avatar { width: 28px; height: 28px; border-radius: 8px; }
  dialog { width: min(96vw,600px); max-height: 93dvh; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior: auto !important; transition-duration: 0s !important; } }
@media (min-width:1000px) {
  .page-tools #new-sale { min-width:146px; }
}
