:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Microsoft YaHei", sans-serif;
  background: #f7f3e9;
  color: #2d251d;
  --line: #ddcfb8;
  --paper: #fffcf5;
  --accent: #6e4826;
  --muted: #645849;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.top { min-height: 66px; display: flex; align-items: center; justify-content: space-between; padding: 12px clamp(18px, 5vw, 70px); border-bottom: 1px solid var(--line); }
.top-actions, .dialog-heading { display: flex; align-items: center; gap: 10px; }
.dialog-heading { justify-content: space-between; }
.dialog-heading h2 { min-width: 0; margin-block: 0; overflow-wrap: anywhere; }
.dialog-heading button { flex-shrink: 0; }
.brand { color: inherit; text-decoration: none; font-family: Songti SC, SimSun, serif; font-weight: 800; font-size: 1.65rem; }
.brand span { font: 600 .875rem system-ui, sans-serif; color: var(--muted); margin-left: 12px; }
main { padding: 28px clamp(16px, 5vw, 70px) 60px; max-width: 1480px; margin: auto; }
.layout { display: grid; grid-template-columns: minmax(195px, 245px) minmax(0, 1fr); gap: 24px; align-items: start; }
.workspace-body { min-width: 0; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.sidebar h2 { margin-top: 0; }
.sidebar button { text-align: left; width: 100%; margin-bottom: 8px; overflow-wrap: anywhere; }
.sidebar button[aria-current="true"] { background: #efdfc4; border-color: #d5b991; color: #432d18; }
h1 { font-family: Songti SC, SimSun, serif; margin: 0 0 12px; font-size: clamp(1.85rem, 4vw, 2.5rem); line-height: 1.25; overflow-wrap: anywhere; }
h2 { font-size: 1.1rem; margin: 16px 0 12px; }
p { color: var(--muted); line-height: 1.6; }
label { font-weight: 600; display: block; margin: 10px 0 6px; }
input:not([type="checkbox"]) { display: block; border: 1px solid var(--line); border-radius: 8px; padding: 10px; width: 100%; font: inherit; background: white; color: inherit; margin-top: 6px; }
button { border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: inherit; padding: 10px 13px; font: 600 .9rem system-ui, sans-serif; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid #9a601f; outline-offset: 2px; }
button:disabled { opacity: .55; cursor: default; }
.primary { background: #34261a; color: #fff9ec; border-color: transparent; }
.quiet { background: transparent; }
.actions { display: flex; justify-content: flex-end; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
#notification { border-radius: 9px; padding: 10px 14px; background: #ecf0e4; color: #384d2c; margin: 0 0 14px; }
#notification.error { background: #f5e4db; color: #822f1a; }
#registration-error { color: #822f1a; }
section + section { margin-top: 20px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.table { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; text-align: left; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); max-width: 350px; overflow-wrap: anywhere; vertical-align: top; }
th { background: #f1e6d1; font-size: .9rem; white-space: nowrap; }
.amount, .date { white-space: nowrap; }
small { color: var(--muted); font-size: .83rem; display: block; margin-top: 4px; }
a { color: #62401f; text-underline-offset: 3px; }
dialog { border: 1px solid var(--line); border-radius: 14px; width: min(96vw, 480px); padding: 20px; background: var(--paper); color: inherit; }
dialog::backdrop { background: #35291e60; }
#preview { width: min(95vw, 860px); background: #fff; max-height: 90vh; }
#preview h1 { text-align: center; margin: 28px 0 36px; color: #111; font-family: inherit; }
#report { color: #111; }
#report th { background: #e7e9eb; }
#report td, #report th { border: 1px solid #a2abb3; }
@media (max-width: 710px) {
  .layout, .grid { grid-template-columns: 1fr; }
  #libraries { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
  #libraries button { width: auto; margin: 0; }
  .panel { padding: 14px; }
}
@media print {
  body, #preview { background: white; }
  body > :not(#preview), .no-print { display: none !important; }
  #preview { display: block; position: static; width: auto; max-width: none; max-height: none; margin: 0; padding: 0; overflow: visible; border: 0; }
  #preview::backdrop { display: none; }
  #report th { print-color-adjust: exact; }
  tr { break-inside: avoid; }
}
#user-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.inline-check, .grant { display: flex; align-items: center; gap: 10px; }
.grant { justify-content: space-between; flex-wrap: wrap; }
.grant select { border: 1px solid var(--line); padding: 8px; border-radius: 8px; background: white; color: inherit; font: inherit; }
#user-error { color: #822f1a; }

/* The sign-in layout stays separate from the workspace. */
.login-view {
  background: radial-gradient(ellipse at 8% 5%, #e9dcc9 0%, transparent 56%), #f4eee4;
}
.login-view .top { display: none; }
.login-view main {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100vh;
  min-height: 100svh;
  max-width: none;
  padding: clamp(20px, 5vw, 72px);
}
.login-view #notification { width: min(100%, 1120px); margin: 14px 0 0; }
.signin {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr);
  width: min(100%, 1120px);
  min-height: clamp(610px, 75svh, 720px);
  border: 1px solid #d6c6b2;
  border-radius: 24px;
  overflow: hidden;
  background: #fffcf6;
  box-shadow: 0 26px 70px #36231224, 0 4px 16px #3623120d;
}
.signin-cover {
  position: relative;
  isolation: isolate;
  min-height: 100%;
  background: #352318;
  color: #fff8e9;
}
.signin-cover img,
.signin-cover::after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.signin-cover img { object-fit: cover; object-position: center 51%; }
.signin-cover::after {
  content: "";
  z-index: 1;
  background: linear-gradient(153deg, #21130dc9 0%, #28181155 31%, transparent 64%);
}
.signin-brand {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: clamp(30px, 4.5vw, 62px);
}
.signin-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border: 1px solid #d6b784;
  border-radius: 12px;
  background: #fbddb115;
}
.signin-mark::before {
  content: "";
  width: 16px;
  height: 21px;
  border: 1.5px solid #efd5a6;
  border-radius: 3px;
}
.signin-mark::after {
  content: "";
  position: absolute;
  top: 18px;
  width: 8px;
  height: 1px;
  background: #efd5a6;
  box-shadow: 0 5px #efd5a6, 0 10px #efd5a6;
}
.signin-wordmark {
  margin: 0;
  color: inherit;
  font: 700 2.25rem/1 "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  letter-spacing: .13em;
}
.signin-product { margin: 8px 0 0; color: #eddbc0; font-size: .875rem; letter-spacing: .13em; }
.signin-entry {
  display: grid;
  place-items: center;
  padding: 56px clamp(34px, 5.3vw, 88px);
  background: radial-gradient(ellipse at 100% 0, #f7ede1 0%, transparent 57%), #fffcf6;
}
.signin-content { width: min(100%, 350px); }
.signin-content::before {
  content: "";
  display: block;
  width: 38px;
  height: 2px;
  margin-bottom: 25px;
  background: #b78952;
}
.signin h1 {
  color: #32251b;
  font: 700 clamp(2rem, 3.6vw, 2.75rem)/1.18 "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  letter-spacing: .015em;
  margin: 0 0 12px;
}
#signin-help { margin: 0 0 35px; color: #645549; font-size: .955rem; }
.signin-field { margin-top: 20px; }
.signin-field label { margin: 0 0 8px; color: #49382a; font-size: .9rem; }
.signin-field input {
  min-height: 52px;
  margin: 0;
  padding: 12px 15px;
  background: #fffefa;
  border: 1px solid #d7c6b1;
  border-radius: 9px;
}
.signin-field input::placeholder { color: #7b6b5d; }
.signin-password { position: relative; }
.signin-password input { padding-right: 88px; }
#toggle-password {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 36px;
  padding: 4px 8px;
  color: #6c482b;
  background: transparent;
  border: 0;
  font-size: .84rem;
}
#toggle-password:hover { background: #f3e7d6; }
#signin-submit {
  width: 100%;
  min-height: 54px;
  margin-top: 27px;
  border-radius: 9px;
  color: #fff8ee;
  background: #3a281c;
  font-size: 1rem;
  letter-spacing: .18em;
  box-shadow: 0 6px 12px #38281a24;
}
#signin-submit:hover:not(:disabled) { background: #563c28; }
#signin-error {
  margin: 14px 0 0;
  padding: 9px 11px;
  color: #862f20;
  background: #f8e9e0;
  border-left: 2px solid #ad604c;
  border-radius: 3px 7px 7px 3px;
  font-size: .875rem;
}
@media (max-width: 740px) {
  .login-view main { padding: 20px 16px; }
  .signin {
    grid-template-columns: minmax(0, 1fr);
    width: min(100%, 480px);
    min-height: 0;
    border-radius: 18px;
  }
  .signin-cover { min-height: clamp(166px, 27svh, 232px); }
  .signin-cover img { object-position: center 50%; }
  .signin-cover::after { background: linear-gradient(140deg, #21130df5, #2818118c 43%, transparent 86%); }
  .signin-brand { margin: 26px; gap: 12px; }
  .signin-mark { width: 42px; height: 42px; }
  .signin-mark::after { top: 14px; }
  .signin-wordmark { font-size: 1.85rem; }
  .signin-product { margin-top: 5px; }
  .signin-entry { padding: 32px 25px 36px; }
  .signin-content::before { margin-bottom: 14px; }
  #signin-help { margin-bottom: 23px; }
  .signin-field { margin-top: 17px; }
  #signin-submit { margin-top: 23px; }
}

.welcome-view { background: radial-gradient(ellipse at 12% 6%, #ecdfcc, transparent 58%), #f7f1e7; }
.welcome-view main {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: calc(100svh - 66px);
}
.welcome-view #notification { width: min(100%, 610px); }
.welcome {
  width: min(100%, 610px);
  overflow: hidden;
  border: 1px solid #d6c6b2;
  border-radius: 21px;
  background: #fffcf6;
  box-shadow: 0 18px 60px #3623121c;
}
.welcome-cover {
  min-height: clamp(124px, 17vw, 205px);
  background: #3a281c url("/signin-cover.jpg") 50% 62% / cover no-repeat;
}
.welcome-content { padding: clamp(27px, 5vw, 49px); }
.welcome h1 { margin-bottom: 14px; color: #32251b; }
.welcome h1:focus { outline: none; }
#welcome-company { margin: 0 0 24px; overflow-wrap: anywhere; }
#welcome-picker { margin-bottom: 24px; }
#welcome-select {
  display: block;
  width: 100%;
  background: #fffefa;
  border: 1px solid #d7c6b1;
  border-radius: 8px;
  padding: 10px 12px;
  color: inherit;
  font: inherit;
}
#enter-workspace { min-height: 44px; padding-inline: 22px; }
#settings h3 { margin-top: 22px; font-size: 1rem; }
#settings-companies { list-style: none; margin: 0; padding: 0; }
#settings-companies li { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 12px 0;
  border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#settings-companies li > div { min-width: 0; }
#settings-companies li button, #settings-companies .desk-badge { flex-shrink: 0; }

.desk-view {
  --desk-side: #eee5d3;
  --desk-canvas: #f8f4ec;
  --desk-paper: #fdfaf3;
  --desk-gold: #85592e;
  --desk-wash: #f1e2c7;
  --line: #daceb5;
  background: var(--desk-canvas);
}
.desk-view .top {
  position: absolute;
  z-index: 1;
  top: 16px;
  right: clamp(16px, 3vw, 44px);
  min-height: 0;
  padding: 0;
  border: 0;
}
.desk-view .top .brand { display: none; }
.desk-view .top button { padding: 7px 11px; }
.desk-view main { max-width: none; padding: 0; }
.desk-view #notification {
  position: fixed;
  z-index: 2;
  bottom: 58px;
  right: clamp(14px, 3vw, 40px);
  left: auto;
  max-width: min(540px, calc(100vw - 28px));
  margin: 0;
  box-shadow: 0 3px 14px #49342018;
}
.desk-view .layout {
  --sidebar-width: clamp(214px, 19vw, 270px);
  min-height: 100vh;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
}
.desk-sidebar {
  background: var(--desk-side);
  border-right: 1px solid var(--line);
  padding: 22px 14px 24px;
}
.desk-brand { display: flex; align-items: center; gap: 11px; margin: 3px 8px 26px; }
.desk-brand strong { font: 700 1.52rem Songti SC, "Noto Serif CJK SC", SimSun, serif; }
.desk-brand small { margin-top: 1px; }
.desk-mark, .drop-symbol, .expense-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  color: var(--desk-gold);
  background: var(--desk-wash);
}
.desk-mark { background: linear-gradient(135deg, #986638, #3c291c); color: white; font-size: 1.35rem; }
.desk-caption {
  font-size: .75rem;
  letter-spacing: .065em;
  color: var(--muted);
  margin: 18px 8px 8px;
}
.desk-fee-caption { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.desk-sidebar #libraries { display: grid; gap: 4px; margin: 0; }
.desk-sidebar #libraries button, .desk-nav-item {
  position: relative;
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  overflow-wrap: anywhere;
}
.desk-sidebar #libraries button[aria-current="true"], .desk-nav-item[aria-current="page"] {
  border-color: #dfd2b9;
  background: var(--desk-paper);
}
.desk-sidebar #libraries button[aria-current="true"]::before, .desk-nav-item[aria-current="page"]::before {
  position: absolute;
  inset: 9px auto 9px 1px;
  width: 2px;
  background: var(--desk-gold);
  border-radius: 3px;
  content: "";
}
.desk-nav-item { display: grid; grid-template-columns: 20px 1fr auto; gap: 6px; align-items: center; }
.nav-symbol { color: var(--desk-gold); text-align: center; font-size: 1rem; line-height: 1; }
.nav-count { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.desk-sidebar #manage-users { margin-top: 16px; }
.desk-view .workspace-body { display: flex; min-height: 100%; flex-direction: column; }
.desk-view #screen { width: 100%; max-width: 1720px; margin-inline: auto; padding: 30px clamp(16px, 3vw, 44px) 26px; }
.desk-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  padding: 9px clamp(16px, 3vw, 44px);
  border-top: 1px solid var(--line);
  background: var(--desk-canvas);
}
.desk-heading { margin-bottom: 20px; }
.desk-heading h1 { margin: 2px 0 5px; font-size: clamp(2rem, 4vw, 3rem); }
.desk-heading p { margin: 0; }
.desk-heading .desk-context { font-size: .82rem; overflow-wrap: anywhere; padding-right: 145px; }
.desk-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.desk-metrics > div, .desk-invoice, .desk-empty { background: var(--desk-paper); border: 1px solid var(--line); border-radius: 14px; }
.desk-metrics > div { padding: 13px 15px; min-width: 0; }
.desk-metrics span { display: block; color: var(--muted); font-size: .84rem; }
.desk-metrics strong, .invoice-value strong {
  display: block;
  min-width: 0;
  font: 600 clamp(1.25rem, 2.5vw, 1.8rem)/1.2 Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: lining-nums tabular-nums;
  overflow-wrap: anywhere;
}
.desk-metrics strong { margin-top: 4px; }
.desk-upload {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px dashed #b89970;
  border-radius: 11px;
  background: var(--desk-paper);
}
.desk-upload.file-hover { background: var(--desk-wash); border-color: var(--desk-gold); }
.drop-title { margin: 0; font-size: .92rem; }
input.file-input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.desk-upload:focus-within { outline: 2px solid #9a601f; outline-offset: 2px; }
.upload-controls, .desk-filters, .desk-selection { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.desk-view .desk-invoices { margin-top: 20px; }
.desk-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.desk-toolbar h2 { margin: 0; }
.desk-toolbar .desk-filters { flex: 1 1 570px; justify-content: flex-end; }
#visible-count { margin-left: .36em; color: var(--muted); font-size: .84rem; }
.desk-filters select, .desk-filters input[type="search"] {
  width: auto;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  font: inherit;
  font-size: .84rem;
  color: inherit;
  border: 1px solid var(--line);
  padding: 7px 8px;
  border-radius: 8px;
  min-height: 34px;
  background: var(--desk-paper);
}
.desk-filters input[type="search"] { width: min(180px, 100%); }
.desk-filters > button { padding-block: 7px; }
.view-toggle { display: inline-flex; padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--desk-paper); }
.view-toggle button { padding: 3px 8px; border-color: transparent; border-radius: 5px; }
.view-toggle button[aria-pressed="true"] { background: var(--desk-wash); }
.desk-selection { padding: 8px 10px; margin-bottom: 10px; border-radius: 8px; background: var(--desk-wash); }
.desk-selection > span { margin-right: auto; font-weight: 600; font-size: .9rem; }
.invoice-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(235px, 100%), 1fr)); gap: 12px; }
.desk-invoice { min-width: 0; padding: 13px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }
.desk-invoice:has(:checked) { outline: 1px solid var(--desk-gold); border-color: var(--desk-gold); }
.desk-invoice header, .invoice-value, .desk-invoice footer { display: flex; align-items: center; gap: 8px; min-width: 0; }
.desk-invoice input[type="checkbox"] { flex: 0 0 19px; margin: 0 0 0 auto; width: 19px; height: 19px; accent-color: var(--desk-gold); }
.expense-icon { width: 34px; height: 34px; }
.expense-0 { color: #3b5b5f; background: #e3eae5; }
.expense-1 { color: #6f5836; background: #ede6d9; }
.expense-2 { color: #73556a; background: #ede6e9; }
.invoice-category { min-width: 0; font-weight: 600; font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invoice-info { min-width: 0; }
.invoice-title { display: block; width: 100%; min-width: 0; border: 0; background: transparent; padding: 1px 0; text-align: left; font-size: .95rem; color: inherit; }
.invoice-title:hover { text-decoration: underline; text-underline-offset: .15em; }
.invoice-title span, .invoice-info p { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.invoice-info p { margin: 2px 0 0; font-size: .82rem; }
.invoice-value { justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
.invoice-value time { font-size: .78rem; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; color: var(--muted); }
.desk-invoice footer { padding-top: 7px; border-top: 1px solid var(--line); justify-content: space-between; }
.desk-invoice footer a { font-size: .78rem; }
.desk-badge { display: inline-block; border-radius: 18px; padding: 3px 8px; color: #405d4b; background: #e9ebe1; font-weight: 600; font-size: .75rem; }
.desk-badge.marked { background: #eee4d4; color: #76512c; }
.desk-badge.unclassified, .desk-error, #compose-error { color: #8a3c25; }
.desk-badge.unclassified { background: #f3e5d9; }
.invoice-list-view { display: grid; gap: 7px; }
.invoice-list-view .desk-invoice {
  grid-template-columns: minmax(150px, .8fr) minmax(140px, 1.3fr) minmax(105px, .7fr) auto;
  align-items: center;
  border-radius: 10px;
  padding: 9px 11px;
}
.invoice-list-view .desk-invoice footer { border: 0; padding: 0; }
.invoice-list-view .invoice-value strong { font-size: 1.2rem; }
.invoice-list-view .invoice-value { justify-content: start; }
.report-card footer { justify-content: flex-end; }
.report-card footer button { padding: 5px 8px; font-size: .78rem; }
.desk-empty { display: grid; place-items: center; text-align: center; padding: 30px 14px; }
.invoice-facts, #compose-groups, #import-result-list, .upload-review-list { margin-block: 14px; padding: 0; }
.invoice-facts div, #compose-groups li, #import-result-list li, .upload-review-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.invoice-facts div { flex-wrap: wrap; }
.invoice-facts dt { font-weight: 600; }
.invoice-facts dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
#import-result-list { max-height: 50vh; overflow-y: auto; }
#import-result-list li { display: block; overflow-wrap: anywhere; }
#storage-alert { padding: 10px 16px; border-bottom: 1px solid var(--line); background: #f7e7cb; color: #624618; }
#storage-alert.storage-critical { background: #f7dad2; color: #8b2d1b; }
.upload-review-list li { align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
.upload-review-list li > strong { flex-basis: 100%; }
@media (max-width: 850px) {
  .invoice-list-view .desk-invoice { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoice-list-view .desk-invoice footer { justify-content: end; }
}
@media (max-width: 710px) {
  .desk-view .top {
    position: static;
    min-height: 50px;
    padding: 7px 14px;
    border-bottom: 1px solid var(--line);
  }
  .desk-view .top .brand { display: block; font-size: 1.2rem; }
  .desk-view .layout { grid-template-columns: minmax(0, 1fr); min-height: calc(100vh - 54px); }
  .desk-sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px 10px; }
  .desk-brand { display: none; }
  .desk-sidebar #libraries { display: flex; flex-wrap: wrap; }
  .desk-sidebar #libraries button { width: auto; }
  #workspace-nav { display: flex; flex-wrap: wrap; gap: 5px; }
  #workspace-nav h2 { flex-basis: 100%; margin: 6px 0 0; padding-top: 6px; }
  .desk-nav-item { width: auto; grid-template-columns: auto auto auto; padding: 5px 7px; font-size: .8rem; }
  .desk-view #screen { padding-top: 16px; }
  .desk-heading .desk-context { padding-right: 0; }
  .desk-toolbar .desk-filters { justify-content: flex-start; }
  .desk-metrics { gap: 6px; }
  .desk-metrics > div { padding: 8px; }
  .desk-metrics strong { font-size: 1.04rem; }
}
@media (max-width: 430px) {
  .desk-upload { grid-template-columns: 36px minmax(0, 1fr); }
  .upload-controls { grid-column: 1 / -1; justify-content: flex-end; }
  .desk-filters input[type="search"] { width: 100%; }
}

textarea, #workflow select, #invoice-view select, #compose select, #preview select, #screen select {
  border: 1px solid var(--line);
  background: #fffdf8;
  color: inherit;
  font: inherit;
  border-radius: 8px;
  padding: 8px 9px;
  max-width: 100%;
}
textarea { display: block; width: 100%; margin-top: 6px; resize: vertical; }
.settings-tools { padding-block: 13px; border-bottom: 1px solid var(--line); }
.settings-tools button { width: 100%; }

#workflow { width: min(94vw, 810px); max-height: 90dvh; }
#invoice-view, #compose { width: min(96vw, 1220px); max-height: 92dvh; }
#invoice-view #original-picker { width: 100%; }
.compose-layout, .invoice-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
  gap: 18px;
  margin-top: 12px;
}
.compose-layout > section, .invoice-detail-layout > section { min-width: 0; margin-top: 0; }
.invoice-source {
  display: grid;
  min-height: 245px;
  margin-top: 12px;
  place-items: center;
  background: #f0ece3;
  border-radius: 8px;
  overflow: hidden;
}
.invoice-source img { display: block; max-width: 100%; max-height: 62dvh; object-fit: contain; border-radius: 2px;
  box-shadow: 0 1px 6px #31211428; }
.invoice-source p { padding: 14px; }
.invoice-source { padding: 10px; }
.invoice-source nav { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 12px;
  margin-top: 9px; font-size: .86rem; font-variant-numeric: lining-nums tabular-nums; }
.invoice-source nav button { padding: 5px 8px; }
.invoice-reason { margin: 0; color: #8a3c25; overflow-wrap: anywhere; }
.compose-preview {
  background: #edf0f1;
  border: 1px solid var(--line);
  border-radius: 9px;
  min-height: 160px;
  padding: 13px;
  max-height: 64dvh;
  overflow: auto;
}
.compose-preview > h3 { margin-top: 5px; }
.compose-plan > summary { cursor: pointer; font-weight: 700; margin-block: 7px; }
.compose-summary { display: flex; justify-content: space-between; flex-wrap: wrap; padding: 7px 0; border-bottom: 1px solid var(--line); }
.report-paper { background: white; color: #111; padding: 14px; }
.report-paper h1 { text-align: center; font-family: inherit; font-size: 1.8rem; }
.report-paper h2 { font-size: 1rem; }
.report-paper th { background: #e7e9eb; }
.report-paper th, .report-paper td { border: 1px solid #a2abb3; white-space: normal; }
.report-state { font-weight: 600; margin-right: auto; }
.workflow-list { margin: 12px 0; padding: 0; list-style: none; }
.workflow-list > li { padding: 9px 3px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.workflow-list .actions { margin-top: 4px; }
.compose-rows { max-height: 31dvh; overflow: auto; }
.compose-rows .inline-check { align-items: flex-start; margin: 0; }
.month-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.month-metrics button { text-align: left; }
.month-metrics button[aria-pressed="true"] { background: var(--desk-wash); }
dialog button:focus-visible, .tag-choices input:focus-visible { outline-offset: 1px; }
@media (max-width: 750px) {
  .compose-layout, .invoice-detail-layout { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .month-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-paper { padding: 6px; }
  .report-paper th, .report-paper td { padding: 4px; font-size: .78rem; }
}

.impact-summary, .impact-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px 15px; }
.impact-summary { color: var(--ink, #30241b); margin: 0 0 7px; font-variant-numeric: lining-nums tabular-nums; }
.impact-note { margin: 0 0 12px; font-size: .86rem; }
.expense-impact { display: grid; grid-template-columns: minmax(230px, 1fr) minmax(0, 1.35fr); gap: 12px; align-items: start; }
.expense-impact > * { margin: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--desk-paper, #fffcf5); min-width: 0; }
.impact-counts, .impact-movements .workflow-list { max-height: 41vh; overflow: auto; }
.impact-counts thead { position: sticky; top: 0; z-index: 1; }
.impact-counts tbody th { font-weight: 600; background: transparent; white-space: normal; }
.impact-counts th, .impact-counts td { padding: 7px 10px; }
.impact-counts td, .impact-counts thead th:not(:first-child) { text-align: right; font-variant-numeric: lining-nums tabular-nums; }
.impact-counts .impact-unclassified { background: #f3e5d9; }
.expense-impact > :only-child { grid-column: 1 / -1; }
.impact-movements h3 { margin: 10px 12px 0; font-size: .96rem; }
.impact-movements .workflow-list { margin: 0; padding: 0 12px 9px; }
.impact-movements li strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.impact-move { color: var(--desk-gold, #85592e); }
.impact-actions { justify-content: space-between; border-top: 1px solid var(--line); margin-top: 12px; padding-top: 9px; }
.impact-actions [role="status"] { margin-left: auto; font-size: .84rem; }
.impact-actions [role="status"]:empty { display: none; }
@media (max-width: 620px) {
  .expense-impact { grid-template-columns: minmax(0, 1fr); }
  .impact-counts, .impact-movements .workflow-list { max-height: 28vh; }
}

#preview { width: min(96vw, 1140px); }
#report-view-title { overflow-wrap: anywhere; }
.invoice-detail-caption { margin: 6px 0 0; }
.invoice-detail-layout { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); }
#edit-invoice { max-height: 66dvh; overflow: auto; padding: 0 8px 8px; }
.report-reading { background: #eef2f5; border: 1px solid #d5dae0; border-radius: 8px; overflow: hidden; margin: 13px 0; }
.report-reading iframe { display: block; width: 100%; height: clamp(290px, 61vh, 800px); border: 0; }
.report-web-details summary { cursor: pointer; font-weight: 600; color: var(--muted); }
#report-actions { justify-content: flex-start; border-top: 1px solid var(--line); padding-top: 10px; }
.report-spacer { flex: 1 1 auto; }
.reimbursement-cover col:nth-child(1) { width: 16.13%; }
.reimbursement-cover col:nth-child(2) { width: 17.47%; }
.reimbursement-cover col:nth-child(3) { width: 18.82%; }
.reimbursement-cover col:nth-child(4) { width: 20.16%; }
.reimbursement-cover col:nth-child(5) { width: 27.42%; }
@media (max-width: 750px) {
  .invoice-detail-layout { grid-template-columns: minmax(0, 1fr); }
  #edit-invoice { max-height: none; padding: 0; }
}

.desk-item-menu { position: relative; min-width: 0; flex: 0 0 auto; }
.desk-item-menu summary { cursor: pointer; padding: 0 3px; font-weight: 750; list-style: none; line-height: 1.4; }
.desk-item-menu summary::-webkit-details-marker { display: none; }
.desk-item-menu[open] { z-index: 2; }
.desk-item-menu > div { position: absolute; inset: 100% 0 auto auto; min-width: 125px; padding: 5px; background: var(--paper);
  border: 1px solid var(--line); box-shadow: 0 3px 10px #47331b23; border-radius: 8px; }
.desk-item-menu button, .desk-item-menu a { display: block; width: 100%; border: 0; padding: 6px 8px; font-size: .83rem; text-align: left; }
.desk-item-menu a { text-decoration: none; }
.desk-item-menu button:hover, .desk-item-menu a:hover { background: var(--desk-wash); }
.report-card footer { justify-content: flex-start; flex-wrap: wrap; }
.report-card footer small { margin-right: auto; }

.expense-company { margin: 3px 0 12px; font-size: .9rem; }
.expense-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px;
  border: 1px solid var(--line); border-radius: 9px; padding: 4px; margin: 0 0 12px; }
.expense-modes legend { padding-inline: 4px; font-size: .88rem; }
.expense-modes label { position: relative; margin: 0; cursor: pointer; }
.expense-modes input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.expense-modes span { display: block; padding: 7px 12px; border-radius: 6px; text-align: center; }
.expense-modes input:checked + span { background: var(--desk-wash, #f1e2c7); }
.expense-modes input:focus-visible + span { outline: 2px solid var(--accent); }
.expense-defaults { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; padding: 12px; gap: 8px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--desk-paper, #fffcf5); margin-bottom: 12px; }
#expense-tags { display: grid; gap: 8px; margin-bottom: 12px; }
.expense-tag-group { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 10px; }
.expense-tag-group legend { color: var(--muted); font-size: .89rem; font-weight: 650; padding-inline: 4px; }
.tag-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 12px; }
.tag-choices label { margin: 4px 0; min-width: 0; overflow-wrap: anywhere; }
.tag-choices input { margin: 0; accent-color: var(--desk-gold); }
.monthly-tools summary { border: 1px solid var(--line); border-radius: 9px; background: var(--paper); padding: 10px 13px; font-size: .9rem; }
@media (max-width: 620px) {
  .tag-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
