:root {
  font-family: Inter, "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1c2d47;
  background: #f3f6fb;
  --muted: #566883;
  --line: #dce4ef;
  --blue: #1e56b5;
  --blue-dark: #154690;
  --light-blue: #ebf2ff;
  --surface: #fff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
body:has(dialog[open]) { overflow: hidden; }
a { text-decoration: none; color: var(--blue); }
button, input, select, textarea { font: inherit; }
button, select, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
button, .button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border: 1px solid #c8d5e8;
  border-radius: 7px;
  background: #fff;
  color: #244569;
  font-weight: 650;
  white-space: nowrap;
}
button:hover:not(:disabled), .button:hover { border-color: #9ab6da; background: #f4f8ff; }
.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.primary:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }
:focus-visible { outline: 2px solid #3776cf; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: 31px; line-height: 1.2; letter-spacing: -.4px; }
h2 { font-size: 17px; line-height: 1.35; }

.shell { width: min(1400px, 100% - 64px); margin-inline: auto; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner { display: flex; min-height: 67px; align-items: center; gap: 45px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #1b3559; font-size: 16px; font-weight: 750; white-space: nowrap; }
.brand-mark { display: flex; width: 32px; height: 32px; align-items: end; justify-content: center; gap: 3px; border-radius: 8px; background: var(--blue); padding: 8px 6px; }
.brand-mark i { width: 4px; background: white; border-radius: 1px; height: 7px; }
.brand-mark i:nth-child(2) { height: 11px; }
.brand-mark i:nth-child(3) { height: 15px; }
nav { display: flex; flex-wrap: wrap; align-self: stretch; gap: 15px; }
nav a { display: flex; align-items: center; padding: 0 10px; border-bottom: 2px solid transparent; color: var(--muted); text-align: center; white-space: nowrap; }
nav a:hover { color: var(--blue); }
nav a[aria-current] { color: var(--blue); border-bottom-color: var(--blue); font-weight: 700; }

.workspace { padding: 32px 0 56px; }
.page-title { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title p { margin-top: 8px; color: var(--muted); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel { margin-bottom: 18px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 19px; border-bottom: 1px solid #e7edf5; }
.detail-header .muted { margin-top: 3px; }
.selection-row { display: grid; grid-template-columns: minmax(145px, .6fr) minmax(145px, 1fr) minmax(145px, 1fr) auto; gap: 12px; align-items: end; padding: 18px 19px 0; }
.panel-note { margin: 12px 19px 17px; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.empty { padding: 46px 18px; text-align: center; }
.empty h2 { color: #314765; }
.empty p { color: var(--muted); margin-top: 9px; }
.bill-export { margin: 0 19px 15px; padding-top: 11px; border-top: 1px solid #e7edf5; }
.bill-export summary { color: var(--blue); font-weight: 650; }
.bill-export .actions { align-items: end; margin-top: 9px; }
.bill-export .panel-note { margin: 7px 0 0; }

label { display: grid; gap: 6px; min-width: 0; color: #334964; font-size: 13px; font-weight: 650; }
input:not([type=hidden]), select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #c8d5e5;
  border-radius: 7px;
  min-height: 40px;
  background-color: #fff;
  color: #182b46;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 400;
}
input::placeholder, textarea::placeholder { color: #697a91; }
input[type=file] { padding: 6px; }
input[type=file]::file-selector-button { background: var(--light-blue); color: var(--blue-dark); padding: 5px 9px; margin-right: 8px; border: 0; border-radius: 4px; cursor: pointer; }
textarea { resize: vertical; }
.spaced { margin-top: 13px; }
.filterbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 19px; }
.filterbar input { flex: 1 1 220px; max-width: 300px; }
.filterbar select { width: auto; max-width: 100%; }
.result-count { margin-left: auto; color: var(--muted); font-size: 13px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; text-align: left; border-collapse: collapse; }
th, td { border-bottom: 1px solid #e9edf4; padding: 10px 12px; }
th:first-child, td:first-child { padding-left: 19px; }
th:last-child, td:last-child { padding-right: 19px; }
th { font-size: 13px; background: #f2f6fc; color: #365173; font-weight: 650; white-space: nowrap; }
td { color: #263a55; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcff; }
.results-panel tbody tr:last-child td { border-bottom: 1px solid #e9edf4; }
.cell-main { display: block; color: #213953; font-weight: 650; }
.cell-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; max-width: 31ch; overflow-wrap: anywhere; white-space: normal; }
.table-empty { padding: 37px 14px; color: var(--muted); text-align: center; white-space: normal; }
.text-button { background: transparent; border: 0; padding: 3px 0; color: var(--blue); min-height: 32px; }
.text-button:hover:not(:disabled) { text-decoration: underline; background: transparent; }
.amount { text-align: right; font-variant-numeric: tabular-nums; }
.positive { color: #176341; }
.negative { color: #a33335; }
.badge { display: inline-block; font-size: 12px; padding: 3px 7px; border-radius: 4px; background: #edf1f6; color: #435a78; }
.badge.changed { background: #eaf2ff; color: #2055a1; }
.badge.added, .badge.missing, .badge.conflict { background: #fff2df; color: #874a05; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { display: grid; align-content: start; gap: 6px; padding: 15px 17px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { color: #1a3c69; font-size: clamp(20px, 2.4vw, 26px); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-items { z-index: 1; position: absolute; right: 0; margin-top: 5px; width: 158px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 8px 20px #2539551c; }
.menu-items a { display: block; padding: 8px 10px; border-radius: 4px; color: #1a477f; }
.menu-items a:hover { background: var(--light-blue); }

dialog { width: min(660px, 100% - 30px); max-height: min(900px, 100% - 42px); padding: 0; border: 1px solid #cfdbea; border-radius: 11px; box-shadow: 0 25px 70px #172b5140; color: #1c2d47; background: #fff; }
dialog::backdrop { background: #152b4b75; }
dialog form { margin: 0; }
.dialog-header, .dialog-footer { position: sticky; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 12px 20px; background: #fff; }
.dialog-header { top: 0; min-height: 57px; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-footer { bottom: 0; justify-content: flex-end; border-top: 1px solid var(--line); }
.dialog-body { padding: 16px 20px; }
.icon-button { min-width: 32px; min-height: 32px; padding: 1px 5px; border: 0; background: transparent; color: #526581; font-size: 22px; }
fieldset { min-width: 0; padding: 0; border: 0; margin: 0 0 16px; }
legend { margin-bottom: 7px; padding: 0; font-weight: 750; color: #234570; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-feedback { margin-top: 9px; white-space: pre-wrap; overflow-wrap: anywhere; color: #a33335; font-size: 13px; }
.form-feedback.success { color: #176341; }
.form-feedback:empty { display: none; }
#import-hint { margin: 6px 0 12px; }
.detail-list { display: grid; grid-template-columns: minmax(130px, max-content) minmax(0, 1fr); gap: 5px 14px; margin: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.detail-reason { margin-top: 12px; padding: 10px 12px; border-radius: 6px; background: #f1f6ff; color: #244b85; }
.raw-details { margin-top: 12px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px; }
.raw-details summary { color: #244b85; font-weight: 650; }
.raw-details ol { padding-left: 22px; margin: 8px 0 0; }
.raw-details li + li { margin-top: 6px; }
.raw-values { display: block; margin-top: 2px; color: var(--muted); overflow-wrap: anywhere; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 9; max-width: min(460px, 100% - 40px); padding: 12px 16px; border: 1px solid #a8caf8; border-radius: 8px; background: #eaf3ff; color: #183f76; box-shadow: 0 8px 22px #1d355626; white-space: pre-wrap; }
.toast.error { background: #fff0f0; color: #933238; border-color: #e8b5b9; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 850px) {
  .shell { width: calc(100% - 38px); }
  .selection-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .selection-row button { justify-self: start; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 500px) {
  .shell { width: calc(100% - 28px); }
  .header-inner { gap: 11px; flex-wrap: wrap; padding: 8px 0 0; }
  .header-inner nav { min-height: 43px; gap: 7px; }
  .workspace { padding-top: 22px; }
  h1 { font-size: 26px; }
  .page-title { align-items: flex-start; flex-wrap: wrap; }
  .panel-head, .filterbar, .selection-row { padding-inline: 12px; }
  .panel-note { margin-inline: 12px; }
  .detail-header { flex-wrap: wrap; }
  .result-count { margin-left: 0; }
  .dialog-header, .dialog-footer, .dialog-body { padding-inline: 13px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}
.login-page{max-width:460px; padding-top:60px}
.login-form{grid-template-columns:minmax(0,1fr)}
.login-form .primary{justify-self:start}
.login-panel h1{font-size:20px}
.cloud-logout{margin-left:auto}
.cloud-logout button{border:1px solid currentColor; background:none; color:inherit; border-radius:6px; padding:6px 10px; cursor:pointer; white-space:nowrap}
