:root {
  color-scheme: light;
  --navy: #0b2447;
  --blue: #2563eb;
  --background: #f5f7fa;
  --paper: #fff;
  --ink: #142e4b;
  --muted: #576d87;
  --border: #e0e8f2;
  --soft: #f1f6fc;
  --sidebar: 242px;
  --bar: 68px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); }
body.is-collapsed { --sidebar: 72px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3, p, dd, td { overflow-wrap: anywhere; }
h1 { font-size: clamp(25px, 3vw, 35px); line-height: 1.24; color: var(--navy); letter-spacing: -.025em; }
h2 { font-size: 18px; line-height: 1.32; color: var(--navy); }
h3 { font-size: 16px; }
p { color: var(--muted); }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, a, summary, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, summary, select { cursor: pointer; }
:focus-visible { outline: 3px solid #74a7ff; outline-offset: 3px; }
[hidden] { display: none !important; }

.sidebar { position: fixed; z-index: 5; inset: 0 auto 0 0; width: var(--sidebar); background: var(--navy); display: flex; flex-direction: column; color: #d9e7f8; transition: width .18s ease; overflow: hidden; }
.sidebar-brand { display: flex; min-height: 83px; gap: 10px; align-items: center; padding: 17px 21px; color: white; white-space: nowrap; }
.sidebar-brand img { flex: 0 0 38px; }
.sidebar-brand strong { display: block; font-size: 16px; letter-spacing: .005em; }
.sidebar-brand small { display: block; color: #a9c4e5; font-size: 9px; font-weight: 700; letter-spacing: .12em; margin-top: 2px; }
.navigation { flex: 1; min-height: 0; overflow: auto; padding: 5px 13px; }
.nav-group + .nav-group { margin-top: 21px; }
.nav-group p { margin: 0 0 5px 11px; color: #a2bbd8; font-size: 11px; letter-spacing: .08em; white-space: nowrap; }
.nav-link { position: relative; display: flex; gap: 12px; align-items: center; border-radius: 8px; padding: 10px 12px; color: #c7d8ef; white-space: nowrap; font-weight: 550; margin-bottom: 3px; min-height: 43px; }
.nav-link svg { flex: none; }
.nav-link:hover { background: #173860; color: #fff; }
.nav-link.is-active { color: #fff; background: #214779; box-shadow: inset 3px 0 #70a9ff; }
.sidebar-footer { margin: 12px 14px 15px; border-top: 1px solid #315072; padding: 14px 8px 1px; display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 11px; }
.sidebar-footer b { color: #9db4d0; font-size: 10px; margin-left: 3px; }
.status-dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: #6eabff; display: inline-block; }
.status-dot.green { background: #149467; }
.status-dot.red { background: #d55458; }
.is-collapsed .sidebar-brand { padding-left: 17px; }
.is-collapsed .sidebar-brand span, .is-collapsed .nav-link span, .is-collapsed .sidebar-footer span + span, .is-collapsed .nav-group p { display: none; }
.is-collapsed .nav-link { justify-content: center; padding-inline: 0; }
.is-collapsed .sidebar-footer { justify-content: center; }
.nav-overlay { display: none; }
.shell { margin-left: var(--sidebar); min-width: 0; transition: margin .18s ease; }
.topbar { display: flex; position: sticky; z-index: 4; top: 0; min-height: var(--bar); padding: 9px clamp(13px, 3vw, 35px); justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); background: var(--paper); }
.topbar-left, .quick-search, .account summary { display: flex; align-items: center; gap: 10px; min-width: 0; }
.icon-button { display: inline-grid; place-items: center; border: 1px solid var(--border); background: var(--paper); border-radius: 8px; padding: 0; color: #425c7e; width: 39px; height: 39px; flex: 0 0 39px; font-size: 24px; }
.icon-button:hover { color: var(--blue); background: var(--soft); }
.quick-search { border: 1px solid var(--border); background: #f8fafd; border-radius: 8px; padding: 0 8px; gap: 3px; max-width: 360px; width: min(36vw,360px); }
.quick-search button { background: transparent; display: grid; place-items: center; border: 0; color: #597698; flex: none; padding: 7px 5px; }
.topbar .quick-search input { border: 0; background: transparent; padding: 8px 3px; min-height: 38px; }
.quick-search input:focus { outline: none; }
.quick-search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px #dbe8fe; }
.account { position: relative; min-width: 0; }
.account summary { list-style: none; }
.account summary::-webkit-details-marker { display: none; }
.avatar { display: grid; place-items: center; border-radius: 10px; width: 37px; height: 37px; flex: 0 0 37px; background: #e6efff; color: #184c9f; font-weight: 750; }
.account-name { max-width: 125px; min-width: 0; }
.account-name strong, .account-name small { display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.account-name small { font-size: 11px; color: var(--muted); }
.account-menu { position: absolute; right: 0; top: 49px; border: 1px solid var(--border); background: var(--paper); border-radius: 10px; padding: 6px; width: 168px; box-shadow: 0 11px 24px #0b24471f; }
.account-menu a, .account-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 9px; border: 0; border-radius: 6px; background: none; color: var(--ink); text-align: left; }
.account-menu a:hover, .account-menu button:hover { background: var(--soft); }
.main { max-width: 1640px; margin: auto; padding: 27px clamp(13px,3vw,35px) 40px; min-width: 0; }
.main > .card, .main > form > .card, .main > .notice { margin-bottom: 18px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 0 0 22px; }
.page-heading > div:first-child { min-width: 0; }
.page-heading p { margin-top: 5px; }
.back-link { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 8px; font-weight: 600; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 7px; border: 1px solid transparent; border-radius: 8px; min-height: 41px; padding: 8px 14px; font-weight: 650; color: white; background: var(--blue); text-align: center; white-space: nowrap; line-height: 1.35; transition: background .15s; }
.button:hover { background: #194fcb; }
.button:disabled { opacity: .6; cursor: progress; }
.button--secondary { background: var(--paper); color: var(--ink); border-color: #d4e0ee; }
.button--secondary:hover { background: var(--soft); color: #1e56aa; }
.button--light { background: #fff; color: #163f78; }
.button--light:hover { background: #eaf3ff; }
.button--danger { background: #a32738; }
.button--danger:hover { background: #801b29; }
.button--ghost { background: transparent; color: #476381; padding-inline: 6px; }
.button--ghost:hover { background: var(--soft); }
.button--small { min-height: 34px; padding-block: 5px; font-size: 13px; }
.text-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 650; overflow-wrap: anywhere; }
.text-link:hover, .back-link:hover { text-decoration: underline; }

.card { min-width: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--paper); box-shadow: 0 2px 7px #10274406; overflow: hidden; }
.card-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 17px 19px; }
.card-heading p { font-size: 13px; margin-top: 4px; }
.card-body { padding: 17px 19px; }
.card > .card-heading + .card-body { padding-top: 5px; }
.card-footer { display: flex; gap: 9px; justify-content: space-between; align-items: center; flex-wrap: wrap; padding: 12px 19px; border-top: 1px solid var(--border); }
.pagination { justify-content: flex-end; }
.section-icon { display: inline-grid; place-items: center; border-radius: 9px; width: 38px; height: 38px; background: #eaf1fc; color: #39649d; flex: none; }
.quiet-state { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 9px; min-height: 91px; padding: 15px 14px; border-top: 1px solid var(--border); text-align: center; color: var(--muted); }
.quiet-state svg { color: #6a8ab3; }
.notice { border: 1px solid #ccdcf7; background: #edf4ff; color: #194681; padding: 10px 13px; border-radius: 8px; overflow-wrap: anywhere; }
.notice--error { color: #972638; border-color: #f0c9cf; background: #fff0f2; }
.notice--success { color: #086749; border-color: #bce0d3; background: #e9faf4; }

.dashboard-hero { min-height: 164px; border-radius: 13px; margin-bottom: 18px; padding: 23px 26px; display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; color: white; background: linear-gradient(90deg, #0b2447 0%, #0b2447ee 28%, #10396b88 73%, #0b244733 100%), url("brand-wing.jpg") center 51% / cover; }
.hero-copy { min-width: 0; }
.hero-copy h1 { color: white; margin-top: 8px; }
.hero-copy p { color: #e0eeff; margin-top: 5px; }
.hero-date { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 650; color: #e0eeff; }
.kpi-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 12px; margin: 0 0 18px; }
.kpi { display: grid; grid-template-columns: 1fr auto; gap: 7px 4px; padding: 13px 14px; color: var(--navy); }
.kpi:hover { border-color: #a8c4f0; }
.kpi-icon { width: 32px; height: 32px; grid-column: 1/-1; border-radius: 8px; display: grid; place-items: center; }
.kpi-label { grid-column: 1/-1; color: var(--muted); font-weight: 600; font-size: 13px; }
.kpi strong { font-size: 27px; font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: -.035em; }
.kpi-arrow { align-self: end; color: #6381a8; }
.tone-blue { color: #1e58bc; background: #eaf2ff; }
.tone-indigo { color: #4c51a6; background: #eeeefe; }
.tone-amber { color: #936000; background: #fff4db; }
.tone-green { color: #0e7959; background: #e4f7ef; }
.tone-red { color: #ac3644; background: #fdecef; }
.dashboard-split { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; margin-bottom: 18px; }
.mail-summary { padding: 0 19px 5px; }
.mail-summary > div { padding: 7px 0; border-top: 1px solid var(--border); display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 9px; color: var(--muted); }
.mail-summary strong { color: var(--navy); font-variant-numeric: tabular-nums; font-size: 17px; }
.currency-chip { display: inline-block; border-radius: 5px; padding: 3px 7px; background: #edf3fc; color: #214b86; font-weight: 750; font-size: 12px; }
.badge { display: inline-block; font-size: 11px; font-weight: 675; border-radius: 6px; padding: 3px 7px; color: #426180; background: #ecf2f8; white-space: nowrap; }
.badge--accepted, .badge--paid, .badge--simulated { color: #076246; background: #e2f5ed; }
.badge--overdue, .badge--failed { color: #a52b3d; background: #fcebef; }
.badge--pending, .badge--partial, .badge--unknown { color: #835500; background: #fff2d4; }
.badge--unpaid, .badge--sending { color: #174d9d; background: #e8f0ff; }
.badge--void { color: #5f6470; background: #efeff2; }
.table-scroll { width: 100%; overflow: auto; }
.table { width: 100%; border-collapse: collapse; text-align: left; }
.table th, .table td { border-top: 1px solid var(--border); padding: 10px 13px; vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 19px; }
.table th:last-child, .table td:last-child { padding-right: 19px; }
.table th { background: #f2f6fb; color: #48627f; font-weight: 650; font-size: 12px; white-space: nowrap; }
.table td { min-width: 65px; max-width: 275px; }
.table td:first-child { min-width: 113px; }
.table td .actions { min-width: 91px; }
.table tr:hover td { background: #f8faff; }
.table.compact td, .table.compact th { padding-top: 7px; padding-bottom: 7px; }
.table.tall td { padding-top: 13px; padding-bottom: 13px; }
.right { text-align: right; }
.num, .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount { font-weight: 680; }
.amount > span { font-size: .77em; color: #496683; }
.subline { display: block; color: var(--muted); margin-top: 2px; line-height: 1.35; font-size: 11px; }
.text-red { color: #a32d40; }

label { display: grid; gap: 5px; color: #294461; font-size: 13px; font-weight: 630; min-width: 0; }
input:not([type=checkbox]), select, textarea { min-width: 0; width: 100%; min-height: 40px; padding: 8px 9px; border: 1px solid #cedced; border-radius: 7px; background-color: #fff; color: var(--ink); font-weight: 450; }
input[readonly] { background: var(--soft); }
input::placeholder, textarea::placeholder { color: #677d97; }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--blue); flex: 0 0 17px; margin: 0; }
input[type=file] { font-size: 12px; }
textarea { resize: vertical; }
.checkbox { display: flex; gap: 8px; align-items: center; min-height: 31px; }
.form-grid, .filter-grid, .definition-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px 15px; }
.filter-grid { grid-template-columns: repeat(4,minmax(0,1fr)); align-items: end; }
.form-grid .full, .definition-grid .full { grid-column: 1/-1; }
.stack { display: grid; gap: 11px; }
.check-grid { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.form-end { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.dialog-body .form-end { margin: 13px 0 0; }
.definition-grid dt { color: var(--muted); font-size: 12px; font-weight: 650; }
.definition-grid dd { margin-top: 3px; }
.multiline { white-space: pre-wrap; }
.amount-preview { padding: 6px 12px; background: var(--soft); color: var(--navy); border-radius: 8px; display: grid; align-content: center; }
.amount-preview strong { font-size: 18px; }
.item-card { position: relative; margin: 0 0 10px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 12px; min-width: 0; }
.item-card legend { padding: 0 5px; font-weight: 700; }
.item-grid { grid-template-columns: repeat(5,minmax(0,1fr)); }
.item-actions { display: flex; justify-content: flex-end; margin: -3px 0 5px; }
#items-empty { border: 1px dashed var(--border); border-radius: 8px; }
#item-notice:not([hidden]) { position: fixed; z-index: 8; right: 17px; bottom: 17px; width: min(420px,calc(100% - 34px)); padding: 11px 13px; color: #194681; background: #edf4ff; border-radius: 8px; border: 1px solid #c5d9fa; box-shadow: 0 3px 15px #0b244724; }
dialog { border: 1px solid var(--border); border-radius: 13px; padding: 0; width: min(630px,calc(100% - 24px)); color: var(--ink); }
dialog::backdrop { background: #071c3a9a; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 7px; padding: 16px; border-bottom: 1px solid var(--border); }
.dialog-body { padding: 16px; }
#eterm-message:not(:empty) { padding-top: 8px; color: #9a2737; }
.summary-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.summary-grid strong { display: block; font-size: clamp(15px,2.3vw,26px); margin-top: 4px; }
.summary-grid .card > span { color: var(--muted); }
.summary-grid .summary-primary { background: var(--navy); color: white; }
.summary-primary .amount span, .summary-grid .summary-primary > span { color: #d4e8ff; }
#payment { scroll-margin-top: calc(var(--bar) + 15px); }
.danger-card summary { padding: 13px 19px; color: #a12a3b; font-weight: 680; }
.preview-card iframe { display: block; border: 0; width: 100%; height: min(82vh,950px); min-height: 440px; }
.image-field { display: grid; gap: 8px; align-content: start; min-width: 0; }
.image-field img { display: block; width: 100%; height: 97px; border-radius: 8px; object-fit: contain; background: var(--soft); }
.auth-shell { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(110deg,#0b2447ed,#103f78a6), url("brand-wing.jpg") center / cover; padding: 20px; }
.auth-body { width: min(100%,440px); }
.auth-body > .notice { margin-bottom: 10px; }
.login-card { overflow: hidden; background: var(--paper); border-radius: 15px; border: 1px solid #ffffff55; box-shadow: 0 20px 60px #071b3b61; }
.login-banner { padding: 19px 23px; display: flex; gap: 11px; background: var(--navy); color: white; align-items: center; }
.login-banner strong, .login-banner span { display: block; }
.login-banner strong { font-size: 16px; }
.login-banner span { color: #b8cfe9; font-size: 12px; }
.login-body { padding: 24px; }
.login-body p { margin: 6px 0 19px; }
.login-body .button { margin-top: 5px; }
.narrow { width: min(100%,550px); }
.narrow h1, .narrow p { margin-bottom: 9px; }
@media (max-width: 1150px) {
  :root { --sidebar: 208px; }
  .item-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
}
@media (max-width: 850px) {
  :root { --bar: 59px; }
  .shell { margin-left: 0; }
  .sidebar, .is-collapsed .sidebar { width: min(248px, 84vw); transform: translateX(-100%); transition: transform .18s ease; visibility: hidden; }
  .is-nav-open .sidebar { transform: translateX(0); visibility: visible; }
  .is-collapsed .sidebar-brand span, .is-collapsed .nav-link span, .is-collapsed .sidebar-footer span + span, .is-collapsed .nav-group p { display: block; }
  .is-collapsed .nav-link { justify-content: flex-start; padding-inline: 12px; }
  .is-collapsed .sidebar-footer { justify-content: flex-start; }
  .is-nav-open .nav-overlay { display: block; position: fixed; z-index: 4; inset: 0; border: 0; background: #071c3a82; }
  .quick-search { width: min(51vw,380px); }
  .filter-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 570px) {
  .main { padding-top: 14px; }
  .page-heading { margin-bottom: 15px; }
  .account-name { display: none; }
  .quick-search { width: min(58vw,325px); }
  .topbar, .topbar-left, .account summary { gap: 6px; }
  .dashboard-hero { padding: 15px; min-height: 150px; flex-wrap: wrap; align-content: center; }
  .hero-copy h1 { margin-top: 3px; }
  .dashboard-hero .button { min-height: 35px; }
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .dashboard-split { grid-template-columns: 1fr; }
  .kpi:last-child { grid-column: 1/-1; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px; }
  .kpi:last-child .kpi-icon, .kpi:last-child .kpi-label { grid-column: auto; }
  .recent .table thead { position: absolute; height: 1px; width: 1px; overflow: hidden; clip-path: inset(50%); }
  .recent .table, .recent .table tbody { display: block; }
  .recent .table tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); padding: 9px 12px; border-top: 1px solid var(--border); }
  .recent .table td { border: 0; min-width: 0; max-width: none; text-align: left; padding: 3px 6px 3px 0; }
  .recent .table td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; }
  .recent .table td:first-child { grid-column: 1/-1; }
  .recent .table td:nth-child(2) { grid-column: 1/-1; font-weight: 550; }
  .filter-grid, .form-grid, .definition-grid, .item-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px 10px; }
  .card-heading, .card-body, .card-footer { padding-inline: 12px; }
  .table th:first-child, .table td:first-child { padding-left: 12px; }
  .table th:last-child, .table td:last-child { padding-right: 12px; }
  .summary-grid { grid-template-columns: 1fr; gap: 6px; }
  .summary-grid .card { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding-block: 8px; }
  .summary-grid strong { margin-top: 0; }
  .item-card { padding-inline: 7px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
