:root {
  --ink: #17211d;
  --muted: #68716d;
  --soft: #f3f5f3;
  --line: #dfe4e1;
  --paper: #ffffff;
  --sidebar: #17211d;
  --sidebar-soft: #25312c;
  --green: #2f6b4f;
  --green-dark: #22543d;
  --green-soft: #e9f3ed;
  --gold: #b78a43;
  --gold-soft: #f7f0e3;
  --red: #b84d4d;
  --red-soft: #faeceb;
  --blue: #426d8f;
  --blue-soft: #eaf1f6;
  --shadow: 0 14px 36px rgba(23, 33, 29, .12);
  --sidebar-width: 244px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--soft); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: Inter, "SF Pro Text", "PingFang HK", "PingFang SC", "Microsoft JhengHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.auth-screen {
  min-height: 100vh;
  padding: 32px 20px;
  display: grid;
  place-items: center;
  background: #eef1ef;
}

.auth-panel {
  width: min(430px, 100%);
  padding: 32px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 4px solid var(--green);
  border-radius: 6px;
  box-shadow: 0 18px 45px rgba(23, 33, 29, .13);
}

.auth-header { margin-bottom: 28px; display: flex; align-items: center; gap: 16px; }
.auth-header img { width: 112px; height: 42px; object-fit: contain; object-position: left center; }
.auth-header > div { min-width: 0; padding-left: 16px; border-left: 1px solid var(--line); }
.auth-header h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 20px; font-weight: 600; }
.auth-header p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }

.auth-form { display: grid; gap: 17px; }
.auth-form label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.auth-form input {
  width: 100%;
  height: 43px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfd6d2;
  border-radius: 4px;
  outline: none;
}
.auth-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 107, 79, .12); }
.auth-submit { width: 100%; min-height: 43px; justify-content: center; margin-top: 2px; }
.auth-submit:disabled, .auth-download:disabled { cursor: not-allowed; opacity: .55; }
.auth-status { padding: 10px 12px; color: #8c3030; background: var(--red-soft); border-left: 3px solid var(--red); font-size: 12px; line-height: 1.45; }
.auth-status.info { color: #315b78; background: var(--blue-soft); border-color: var(--blue); }

.mfa-layout { display: grid; gap: 22px; }
.mfa-qr { display: grid; place-items: center; padding: 14px; background: #fff; border: 1px solid var(--line); }
.mfa-qr img { width: 188px; height: 188px; image-rendering: crisp-edges; }
.secret-field { min-width: 0; display: grid; gap: 7px; }
.secret-field span { color: var(--muted); font-size: 11px; font-weight: 700; }
.secret-field code { padding: 10px; overflow-wrap: anywhere; color: var(--ink); background: var(--soft); border: 1px solid var(--line); font-size: 12px; }
.recovery-codes { margin-bottom: 14px; display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); }
.recovery-codes code { padding: 10px; text-align: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.recovery-codes code:nth-child(2n) { border-right: 0; }
.recovery-codes code:nth-last-child(-n+2) { border-bottom: 0; }
.auth-download { width: 100%; justify-content: center; }
.auth-confirm { margin: 18px 0; display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 12px; }
.auth-confirm input { width: 16px; height: 16px; accent-color: var(--green); }
.auth-loading { height: 42px; display: flex; align-items: center; justify-content: center; gap: 7px; }
.auth-loading span { width: 7px; height: 7px; background: var(--green); border-radius: 50%; animation: auth-pulse 1s ease-in-out infinite; }
.auth-loading span:nth-child(2) { animation-delay: .14s; }
.auth-loading span:nth-child(3) { animation-delay: .28s; }
@keyframes auth-pulse { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }

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

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #f5f7f5;
  border-right: 1px solid rgba(255,255,255,.07);
}

.brand {
  height: 82px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid rgba(255,255,255,.09);
}

.brand-mark {
  width: 35px;
  height: 35px;
  flex: 0 0 35px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  border: 1px solid rgba(255,255,255,.24);
  transform: rotate(45deg);
}

.brand-mark span { font-size: 18px; font-weight: 800; transform: rotate(-45deg); }
.brand-copy { min-width: 0; display: flex; flex-direction: column; }
.brand-copy strong { font-family: Georgia, serif; font-size: 17px; letter-spacing: 1px; white-space: nowrap; }
.brand-copy strong span { color: #9dc3aa; font-family: Inter, sans-serif; font-size: 9px; letter-spacing: 1.2px; }
.brand-copy small { margin-top: 2px; color: #aeb8b3; font-size: 10px; }

.sidebar-close { display: none !important; margin-left: auto; color: #fff !important; }

.nav { flex: 1; padding: 18px 10px; overflow-y: auto; }
.nav-label { padding: 20px 12px 7px; color: #7f8c86; font-size: 10px; font-weight: 700; text-transform: uppercase; }

.nav-item {
  width: 100%;
  min-height: 42px;
  margin: 2px 0;
  padding: 0 11px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: #bdc6c1;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: var(--green); }
.nav-item svg { width: 17px; height: 17px; }
.nav-item span { flex: 1; }
.nav-item b {
  min-width: 21px;
  height: 20px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  color: #dce4e0;
  background: rgba(255,255,255,.09);
  border-radius: 10px;
  font-size: 10px;
}
.nav-item.active b { background: rgba(255,255,255,.16); }
.nav-item b:empty, .nav-item b[data-count="0"] { display: none; }
.nav-item .danger-count:not([data-count="0"]) { color: #ffd5d2; background: rgba(184,77,77,.3); }

.sidebar-foot {
  min-height: 72px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(255,255,255,.09);
}
.user-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #d6c197;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
}
.sidebar-foot > div:nth-child(2) { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sidebar-foot strong { font-size: 11px; }
.sidebar-foot small { margin-top: 3px; color: #87938d; font-size: 10px; }

.workspace { width: calc(100% - var(--sidebar-width)); margin-left: var(--sidebar-width); min-height: 100vh; }

.topbar {
  height: 82px;
  padding: 0 30px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.breadcrumb { margin-bottom: 3px; color: #9aa29e; font-size: 10px; font-weight: 600; text-transform: uppercase; }
.breadcrumb span { color: var(--green); }
.topbar h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 22px; font-weight: 600; }
.mobile-menu { display: none !important; }

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}
.icon-button:hover { color: var(--ink); background: var(--soft); }
.icon-button:disabled { opacity: .35; cursor: not-allowed; }

.global-search {
  width: 270px;
  height: 39px;
  padding: 0 9px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #8b9490;
  background: var(--soft);
  border: 1px solid transparent;
  border-radius: 5px;
}
.global-search:focus-within { background: #fff; border-color: #9bb9a7; box-shadow: 0 0 0 3px rgba(47,107,79,.08); }
.global-search input { width: 100%; min-width: 0; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 12px; }
.global-search input::placeholder { color: #959e99; }
kbd { padding: 2px 5px; color: #8b9490; background: #fff; border: 1px solid #dce1de; border-radius: 3px; font-size: 9px; white-space: nowrap; }

.notification-button { position: relative; }
.notification-button span { width: 6px; height: 6px; position: absolute; top: 8px; right: 8px; background: var(--red); border: 1px solid white; border-radius: 50%; }

.primary-button, .secondary-button, .danger-button, .text-button {
  min-height: 38px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 650;
  white-space: nowrap;
}
.primary-button { color: #fff; background: var(--green); border-color: var(--green); }
.primary-button:hover { background: var(--green-dark); }
.secondary-button { color: var(--ink); background: #fff; border-color: #d3dad6; }
.secondary-button:hover { background: var(--soft); }
.danger-button { color: #fff; background: var(--red); border-color: var(--red); }
.text-button { min-height: 30px; padding: 0 5px; color: var(--green); background: transparent; }
.primary-button svg, .secondary-button svg, .danger-button svg { width: 15px; height: 15px; }
.small-button { min-height: 32px; padding: 0 10px; font-size: 11px; }
.wide-button { width: 100%; }

#app-content { max-width: 1600px; margin: 0 auto; padding: 26px 30px 50px; outline: 0; }
.page-stack { display: flex; flex-direction: column; gap: 18px; }

.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.page-heading h2 { margin: 0 0 5px; font-family: Georgia, "Songti SC", serif; font-size: 20px; font-weight: 600; }
.page-heading p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.page-actions { display: flex; align-items: center; gap: 8px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--paper); }
.metric-card { min-width: 0; min-height: 127px; padding: 20px 21px; position: relative; border-right: 1px solid var(--line); }
.metric-card:last-child { border-right: 0; }
.metric-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.metric-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 4px; }
.metric-icon svg { width: 15px; height: 15px; }
.metric-icon.green { color: var(--green); background: var(--green-soft); }
.metric-icon.gold { color: #8e672e; background: var(--gold-soft); }
.metric-icon.red { color: var(--red); background: var(--red-soft); }
.metric-icon.blue { color: var(--blue); background: var(--blue-soft); }
.metric-value { margin-top: 14px; font-family: Georgia, serif; font-size: 27px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-foot { margin-top: 10px; color: #87908b; font-size: 10px; }
.metric-foot strong { color: var(--green); font-weight: 700; }
.metric-foot strong.danger-text { color: var(--red); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr); gap: 18px; }
.panel { min-width: 0; background: var(--paper); border: 1px solid var(--line); }
.panel-header { min-height: 58px; padding: 13px 17px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.panel-title { min-width: 0; }
.panel-title h3 { margin: 0; font-size: 13px; font-weight: 700; }
.panel-title p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.panel-body { padding: 18px; }

.aging-chart { min-height: 183px; display: flex; align-items: end; justify-content: space-between; gap: 13px; }
.aging-column { flex: 1; min-width: 0; text-align: center; }
.aging-track { height: 128px; display: flex; align-items: end; justify-content: center; border-bottom: 1px solid #d9dedb; }
.aging-bar { width: min(42px, 58%); min-height: 4px; position: relative; background: var(--green); border-radius: 3px 3px 0 0; transition: height .35s ease; }
.aging-column:nth-child(2) .aging-bar { background: #769379; }
.aging-column:nth-child(3) .aging-bar { background: var(--gold); }
.aging-column:nth-child(4) .aging-bar { background: #c77956; }
.aging-column:nth-child(5) .aging-bar { background: var(--red); }
.aging-bar span { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 9px; white-space: nowrap; }
.aging-column > span { margin-top: 8px; display: block; color: var(--muted); font-size: 9px; white-space: nowrap; }

.quick-list { margin: 0; padding: 0; list-style: none; }
.quick-item { min-height: 57px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid #edf0ee; }
.quick-item:last-child { border-bottom: 0; }
.quick-dot { width: 7px; height: 7px; flex: 0 0 7px; background: var(--green); border-radius: 50%; }
.quick-dot.gold { background: var(--gold); }
.quick-dot.red { background: var(--red); }
.quick-item-main { flex: 1; min-width: 0; }
.quick-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.quick-item small { margin-top: 4px; display: block; color: var(--muted); font-size: 9px; }
.quick-item time { color: #8c9590; font-size: 9px; }

.table-toolbar { min-height: 58px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.toolbar-group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.search-field, .select-field, .date-field {
  height: 36px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #7b8580;
  background: #fff;
  border: 1px solid #d9dfdc;
  border-radius: 4px;
}
.search-field { width: 245px; padding: 0 10px; }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); }
.select-field select, .date-field input { height: 100%; padding: 0 28px 0 10px; color: var(--ink); background: transparent; border: 0; outline: 0; cursor: pointer; font-size: 11px; }
.date-range-group { flex-wrap: wrap; }
.date-range-group .field-label { white-space: nowrap; }
.select-field { position: relative; }
.select-field svg { width: 14px; position: absolute; right: 8px; pointer-events: none; }
.select-field select { appearance: none; }

.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table th { height: 42px; padding: 0 14px; color: #737d78; background: #f8f9f8; border-bottom: 1px solid var(--line); font-size: 9px; font-weight: 700; text-align: left; text-transform: uppercase; }
.data-table td { height: 62px; padding: 10px 14px; border-bottom: 1px solid #e8ece9; vertical-align: middle; font-size: 11px; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcfb; }
.data-table .cell-main { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 650; }
.data-table .cell-sub { margin-top: 4px; display: block; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.money { font-family: Georgia, serif; font-size: 12px !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 1px; }
.row-actions .icon-button { width: 31px; height: 31px; }
.row-actions svg { width: 15px; height: 15px; }

.status-pill, .tag {
  min-height: 23px;
  width: fit-content;
  padding: 3px 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill::before { content: ""; width: 5px; height: 5px; background: currentColor; border-radius: 50%; }
.status-paid, .status-accepted, .status-active { color: #276244; background: var(--green-soft); }
.status-pending, .status-partial, .status-sent { color: #856024; background: var(--gold-soft); }
.status-overdue, .status-rejected { color: #a44343; background: var(--red-soft); }
.status-draft { color: #68716d; background: #edf0ee; }
.tag { color: #55625c; background: #eef1ef; font-weight: 600; }
.tag.channel { color: #895e20; background: var(--gold-soft); }
.tag.direct { color: var(--green); background: var(--green-soft); }

.table-empty { min-height: 230px; padding: 38px; display: grid; place-items: center; text-align: center; }
.empty-icon { width: 48px; height: 48px; margin: 0 auto 12px; display: grid; place-items: center; color: #87938d; background: var(--soft); border-radius: 50%; }
.table-empty h3 { margin: 0 0 6px; font-size: 13px; }
.table-empty p { margin: 0 0 14px; color: var(--muted); font-size: 10px; }

.client-avatar { width: 33px; height: 33px; flex: 0 0 33px; display: grid; place-items: center; color: var(--green-dark); background: var(--green-soft); border-radius: 4px; font-family: Georgia, serif; font-weight: 700; }
.client-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.client-cell > div:last-child { min-width: 0; }

.service-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px; }
.category-panel { padding: 8px; align-self: start; }
.category-button { width: 100%; min-height: 39px; padding: 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); background: transparent; border: 0; border-radius: 4px; cursor: pointer; text-align: left; font-size: 11px; }
.category-button:hover, .category-button.active { color: var(--green-dark); background: var(--green-soft); font-weight: 700; }
.category-button b { color: #8c9691; font-size: 9px; }
.category-add { width: 100%; min-height: 35px; margin-top: 8px; padding: 0 10px; display: flex; align-items: center; gap: 6px; color: var(--green); background: #f7faf7; border: 1px dashed #a8b9ae; border-radius: 4px; cursor: pointer; font-size: 10px; font-weight: 700; }
.category-add:hover { background: var(--green-soft); border-color: var(--green); }
.category-add svg { width: 13px; height: 13px; }

.segmented { padding: 3px; display: inline-flex; align-items: center; gap: 2px; background: #edf0ee; border-radius: 5px; }
.segmented button { min-height: 29px; padding: 0 10px; color: var(--muted); background: transparent; border: 0; border-radius: 3px; cursor: pointer; font-size: 10px; font-weight: 650; }
.segmented button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(23,33,29,.1); }

.service-name { max-width: 100%; }
.service-description { max-width: 390px; }
.price-compare { display: flex; align-items: baseline; gap: 7px; }
.price-compare strong { font-family: Georgia, serif; font-size: 13px; white-space: nowrap; }
.price-compare del { color: #a0a8a4; font-size: 9px; }

.summary-band { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: #fff; border: 1px solid var(--line); }
.summary-cell { min-height: 84px; padding: 16px; border-right: 1px solid var(--line); }
.summary-cell:last-child { border-right: 0; }
.summary-cell span { color: var(--muted); font-size: 9px; }
.summary-cell strong { margin-top: 8px; display: block; font-family: Georgia, serif; font-size: 18px; }
.summary-cell small { margin-top: 5px; display: block; color: var(--muted); font-size: 9px; }
.summary-cell .date-range-value { font-family: Inter, sans-serif; font-size: 11px; line-height: 1.45; }

.aging-buckets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.aging-bucket { min-height: 94px; padding: 15px; background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--green); }
.aging-bucket:nth-child(2) { border-top-color: #779478; }
.aging-bucket:nth-child(3) { border-top-color: var(--gold); }
.aging-bucket:nth-child(4) { border-top-color: #c77956; }
.aging-bucket:nth-child(5) { border-top-color: var(--red); }
.aging-bucket span { color: var(--muted); font-size: 9px; }
.aging-bucket strong { margin-top: 11px; display: block; font-family: Georgia, serif; font-size: 17px; }
.aging-bucket small { margin-top: 4px; display: block; color: #8b9490; font-size: 9px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-card { padding: 20px; background: #fff; border: 1px solid var(--line); }
.settings-card.wide { grid-column: 1 / -1; }
.settings-card h3 { margin: 0 0 5px; font-size: 13px; }
.settings-card > p { margin: 0 0 20px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.source-files { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.source-file { min-height: 65px; padding: 11px; display: flex; align-items: center; gap: 11px; color: inherit; background: #f8f9f8; border: 1px solid #e4e8e5; text-decoration: none; }
.source-file svg { color: var(--green); }
.source-file div { min-width: 0; }
.source-file strong, .source-file small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-file strong { font-size: 10px; }
.source-file small { margin-top: 4px; color: var(--muted); font-size: 9px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label, .field-label { color: #59635e; font-size: 9px; font-weight: 700; }
.field label .required { color: var(--red); }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 39px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d7ddda;
  border-radius: 4px;
  outline: 0;
  font-size: 11px;
}
.field textarea { min-height: 78px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #7ba08a; box-shadow: 0 0 0 3px rgba(47,107,79,.08); }
.field-help { color: #8b9490; font-size: 9px; line-height: 1.5; }
.input-with-prefix { position: relative; }
.input-with-prefix span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 10px; }
.input-with-prefix input { padding-left: 42px; }

.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 35px; height: 20px; padding: 2px; background: #c9d0cc; border-radius: 10px; transition: background .2s; }
.toggle-track::after { content: ""; width: 16px; height: 16px; display: block; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked + .toggle-track { background: var(--green); }
.toggle input:checked + .toggle-track::after { transform: translateX(15px); }

.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(16,25,21,.58); backdrop-filter: blur(2px); animation: fade-in .15s ease; }
.modal {
  width: min(620px, 100%);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(255,255,255,.3);
  box-shadow: var(--shadow);
  animation: modal-in .18s ease;
}
.modal.modal-wide { width: min(1050px, 100%); }
.modal.modal-document { width: min(1900px, calc(100% - 32px)); }
.modal-header { min-height: 66px; padding: 13px 18px; position: relative; z-index: 2; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 15px; background: #fff; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 17px; }
.modal-header p { margin: 4px 0 0; color: var(--muted); font-size: 9px; }
.modal-body { min-height: 0; padding: 20px; flex: 1 1 auto; overflow: auto; }
.modal-footer { min-height: 63px; padding: 12px 18px; position: relative; z-index: 3; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(20, 35, 27, .05); }
.modal-footer-actions { min-width: 0; display: flex; align-items: center; gap: 8px; margin-left: auto; }

.upload-zone { min-height: 150px; position: relative; display: grid; place-items: center; text-align: center; background: #f8faf8; border: 1px dashed #aebbb4; cursor: pointer; overflow: hidden; }
.upload-zone:hover { border-color: var(--green); background: var(--green-soft); }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-zone svg { width: 27px; height: 27px; margin-bottom: 8px; color: var(--green); }
.upload-zone strong { display: block; font-size: 11px; }
.upload-zone small { margin-top: 5px; display: block; color: var(--muted); font-size: 9px; }
.upload-preview { width: 100%; height: 150px; object-fit: contain; background: #edf0ee; }
.ocr-progress { margin-top: 10px; padding: 10px; display: none; background: var(--green-soft); }
.ocr-progress.active { display: block; }
.ocr-progress-row { display: flex; justify-content: space-between; color: var(--green-dark); font-size: 9px; }
.progress-track { height: 4px; margin-top: 7px; background: #cee0d4; }
.progress-bar { height: 100%; width: 0; background: var(--green); transition: width .2s; }

.document-builder { min-height: 560px; display: grid; grid-template-columns: 280px minmax(480px, 1fr) minmax(390px, 480px); }
.builder-column { min-width: 0; padding: 17px; overflow-y: auto; border-right: 1px solid var(--line); }
.builder-column:last-child { border-right: 0; background: #fafbfa; }
.builder-section { margin-bottom: 19px; }
.builder-section:last-child { margin-bottom: 0; }
.builder-title { margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; font-size: 10px; font-weight: 750; }
.builder-title span { width: 20px; height: 20px; display: inline-grid; place-items: center; color: #fff; background: var(--green); border-radius: 50%; font-size: 8px; }
.builder-client-card { margin-top: 10px; padding: 11px; display: flex; gap: 9px; align-items: center; background: var(--green-soft); border: 1px solid #d4e6da; }
.builder-client-card > div:last-child { min-width: 0; }
.builder-client-card strong, .builder-client-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.builder-client-card strong { font-size: 10px; }
.builder-client-card small { margin-top: 4px; color: var(--muted); font-size: 8px; }

.service-picker-list { max-height: 430px; margin-top: 10px; overflow-y: auto; border: 1px solid var(--line); }
.service-picker-item { width: 100%; min-height: 64px; padding: 10px; display: flex; align-items: center; gap: 10px; background: #fff; border: 0; border-bottom: 1px solid #e8ece9; cursor: pointer; text-align: left; }
.service-picker-item:last-child { border-bottom: 0; }
.service-picker-item:hover { background: var(--green-soft); }
.service-picker-item > div { min-width: 0; flex: 1; }
.service-picker-item strong, .service-picker-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-picker-item strong { font-size: 10px; }
.service-picker-item small { margin-top: 4px; color: var(--muted); font-size: 8px; }
.service-picker-item b { font-family: Georgia, serif; font-size: 10px; white-space: nowrap; }
.service-picker-item svg { width: 16px; height: 16px; color: var(--green); }

.line-items { border: 1px solid var(--line); background: #fff; }
.line-item { padding: 10px; display: grid; grid-template-columns: minmax(0, 1fr) 42px 72px 72px 28px; gap: 6px; align-items: center; border-bottom: 1px solid var(--line); }
.line-item:last-child { border-bottom: 0; }
.line-item-name { min-width: 0; }
.line-item-name strong, .line-item-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-item-name strong { font-size: 10px; }
.line-item-name small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.line-item-name .line-item-en { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.3; }
.line-fee-mode { margin-top: 4px; display: inline-block; color: var(--muted); font-size: 8px; }
.line-item input { width: 100%; height: 30px; padding: 4px 6px; border: 1px solid #d8deda; outline: 0; font-size: 9px; text-align: right; }
.line-description-label { margin-top: 8px; display: flex; align-items: center; gap: 4px; color: var(--green); font-size: 9px; font-weight: 700; cursor: text; }
.line-description-label svg { width: 12px; height: 12px; }
.line-item .line-description { width: 100%; min-height: 62px; margin-top: 5px; padding: 8px 9px; color: var(--ink); background: #fff; border: 1px solid #9eb4a7; border-radius: 3px; outline: 0; resize: vertical; font-size: 10px; line-height: 1.45; text-align: left; }
.line-item .line-description:focus { background: #fff; border-color: #7ba08a; box-shadow: 0 0 0 2px rgba(47,107,79,.08); }
.line-item .icon-button { width: 28px; height: 28px; color: var(--red); }
.line-item-head { min-height: 31px; color: var(--muted); background: #f5f7f5; font-size: 8px; }

.document-total { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.total-row { min-height: 27px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 9px; }
.total-row.grand { margin-top: 5px; padding-top: 10px; color: var(--ink); border-top: 1px solid var(--line); font-size: 12px; font-weight: 700; }
.total-row.grand strong { font-family: Georgia, serif; font-size: 20px; }

.detail-hero { padding: 18px; display: flex; align-items: center; gap: 13px; background: var(--green-soft); border: 1px solid #d5e4da; }
.detail-hero .client-avatar { width: 47px; height: 47px; flex-basis: 47px; font-size: 17px; }
.detail-hero-main { flex: 1; min-width: 0; }
.detail-hero h3 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 17px; }
.detail-hero p { margin: 5px 0 0; color: var(--muted); font-size: 9px; }
.detail-list { margin-top: 15px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); }
.detail-item { min-height: 64px; padding: 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-item:nth-child(even) { border-right: 0; }
.detail-item:nth-last-child(-n+2) { border-bottom: 0; }
.detail-item span { color: var(--muted); font-size: 8px; }
.detail-item strong { margin-top: 6px; display: block; font-size: 10px; line-height: 1.45; }

.document-preview { width: min(780px, 100%); margin: 0 auto; padding: 42px; color: #1d2622; background: #fff; border: 1px solid #dce1de; box-shadow: 0 5px 18px rgba(23,33,29,.07); }
.document-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 23px; border-bottom: 2px solid var(--ink); }
.document-brand strong { display: block; font-family: Georgia, serif; font-size: 22px; }
.document-brand span { margin-top: 4px; display: block; color: var(--green); font-size: 11px; }
.document-company { max-width: 300px; color: #5d6762; font-size: 9px; line-height: 1.7; text-align: right; }
.document-title { margin: 28px 0 22px; display: flex; align-items: end; justify-content: space-between; }
.document-title h2 { margin: 0; font-size: 25px; text-transform: uppercase; }
.document-title strong { font-family: Georgia, serif; font-size: 13px; }
.document-meta { display: grid; grid-template-columns: 1.1fr .9fr; gap: 30px; }
.document-meta-block span { color: #7a847f; font-size: 8px; font-weight: 700; text-transform: uppercase; }
.document-meta-block strong { margin-top: 6px; display: block; font-size: 11px; }
.document-meta-block p { margin: 4px 0 0; color: #5f6964; font-size: 9px; line-height: 1.5; }
.document-meta-right { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
.document-lines { width: 100%; margin-top: 28px; border-collapse: collapse; }
.document-lines th { padding: 9px; color: #fff; background: var(--ink); font-size: 8px; text-align: left; }
.document-lines td { padding: 12px 9px; border-bottom: 1px solid #e2e6e3; font-size: 9px; vertical-align: top; }
.document-lines th:nth-child(n+2), .document-lines td:nth-child(n+2) { text-align: right; }
.document-lines td strong { display: block; }
.document-lines td small { margin-top: 4px; display: block; color: #6f7974; line-height: 1.45; }
.document-summary { width: 270px; margin: 14px 0 0 auto; }
.document-summary .total-row { font-size: 9px; }
.document-notes { margin-top: 32px; padding-top: 15px; border-top: 1px solid #dfe4e1; color: #646e69; font-size: 8px; line-height: 1.6; }

.epton-document {
  width: min(794px, 100%);
  min-height: 1123px;
  padding: 58px 66px;
  color: #111;
  font-family: "Times New Roman", "Songti SC", serif;
  font-size: 12px;
}
.reference-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.reference-head h1 { margin: 0; font-size: 21px; line-height: 1.15; }
.reference-company-zh { margin-top: 4px; display: block; font-size: 10px; font-weight: 700; }
.reference-logo { width: 142px; height: 52px; flex: 0 0 142px; }
.reference-logo img { width: 100%; height: 100%; display: block; object-fit: contain; }
.reference-rule { margin-top: 18px; border-top: 1px dashed #111; }
.reference-company { margin-top: 17px; max-width: 380px; font-size: 10px; line-height: 1.55; text-transform: uppercase; }
.reference-company p { margin: 0; }
.reference-title-row { min-height: 126px; display: grid; grid-template-columns: 1fr 270px; align-items: start; }
.reference-title-row h2 { margin: 0 0 13px; color: #86a4dc; font-size: 31px; line-height: 1; text-align: right; white-space: nowrap; }
.reference-title-row dl { margin: 0 0 0 auto; width: 220px; display: grid; grid-template-columns: 105px 1fr; font-family: "Times New Roman", serif; font-size: 10px; }
.reference-title-row dt { padding: 2px 4px; font-weight: 700; }
.reference-title-row dd { min-height: 18px; margin: 0; padding: 2px 7px; border-bottom: 1px solid #bbb; border-left: 1px solid #bbb; text-align: center; }
.reference-section-bar { height: 24px; padding: 4px 8px; color: #fff; background: #4875c4; font-size: 12px; font-weight: 700; }
.reference-bill { margin-top: 4px; }
.reference-bill h3 { margin: 30px 3px 4px; font-size: 12px; text-transform: uppercase; }
.reference-bill p { margin: 0 3px 14px; font-size: 10px; }
.document-preview-modal { background: #f2f4f2; }
.document-preview-toolbar { width: min(780px, 100%); margin: 0 auto 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.document-preview-toolbar > span { color: var(--muted); font-size: 9px; font-weight: 700; }
.reference-lines { width: 100%; margin-top: 17px; border-collapse: collapse; table-layout: fixed; }
.reference-lines th { height: 32px; padding: 4px 8px; color: #fff; background: #4875c4; font-size: 12px; line-height: 1.15; text-align: center; }
.reference-lines th:first-child { width: 80%; text-align: left; }
.reference-lines th:last-child { width: 20%; border-left: 1px solid #6f6f6f; text-align: right; }
.reference-lines tbody { height: 178px; border-right: 1px solid #111; border-bottom: 1px solid #111; border-left: 1px solid #111; }
.reference-lines td { padding: 8px 3px; border: 0; font-size: 11px; vertical-align: top; }
.reference-lines td:last-child { width: 20%; padding-right: 8px; border-left: 1px solid #111; text-align: right; vertical-align: middle; }
.reference-lines td strong, .reference-lines td small { display: block; }
.reference-lines td small { margin-top: 5px; color: #222; line-height: 1.45; }
.reference-lines .service-heading td { padding-top: 28px; font-weight: 700; vertical-align: top; }
.reference-lines .service-heading td:first-child { text-align: left; }
.reference-lines .service-intro td { padding-top: 6px; padding-bottom: 1px; }
.reference-lines .fee-row td { padding-top: 2px; padding-bottom: 2px; vertical-align: middle; }
.reference-fee-label { display: block; font-size: 10px; }
.reference-lines .direct-government td { color: #555; }
.reference-government-note { margin: 6px 2px 0; color: #444; font-size: 8px; line-height: 1.35; }
.reference-payment-row { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(190px, .85fr); gap: 20px; align-items: start; }
.reference-payment { margin-top: 17px; border: 1px solid #888; }
.reference-payment h4 { height: 22px; margin: 0; padding: 3px 5px; background: #d4d4d4; border-bottom: 1px solid #888; font-size: 11px; }
.reference-payment p { margin: 0; padding: 3px 4px 0; font-size: 9px; line-height: 1.25; }
.reference-payment p:last-child { padding-bottom: 4px; }
.reference-totals > div { min-height: 22px; padding: 3px 5px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #111; font-size: 10px; }
.reference-totals .reference-subtotal { background: #f4f4f4; }
.reference-totals .reference-other { background: #fff; }
.reference-totals span small { display: block; margin-top: 1px; font-size: 8px; font-weight: 400; line-height: 1; }
.reference-totals b { white-space: nowrap; }
.reference-totals .reference-grand { background: #dfe7f6; border-top: 2px solid #111; border-bottom: 0; font-size: 12px; font-weight: 800; }
.reference-totals .reference-balance { background: #f1f3f2; font-weight: 700; }
.reference-totals .reference-stamp { width: 94px; height: 94px; min-height: 0; margin: 38px 10px 0 auto; padding: 0; display: block; background: #fff; border: 0; }
.reference-stamp img { width: 100%; height: 100%; display: block; object-fit: contain; }
.reference-contact { margin-top: 58px; font-size: 10px; line-height: 1.4; }
.reference-contact p { margin: 0; }
.reference-notes { margin-top: 20px; font-size: 9px; line-height: 1.45; }
.reference-thanks { margin-top: 48px; font-size: 15px; font-style: italic; font-weight: 700; }
.pdf-export-host { width: 794px; position: fixed; left: -10000px; top: 0; z-index: -1; background: #fff; pointer-events: none; }
.pdf-export-host .document-preview { width: 794px !important; height: auto !important; min-height: 1123px !important; margin: 0 !important; padding: 58px 66px !important; overflow: visible !important; border: 0 !important; box-shadow: none !important; }

.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { min-width: 270px; max-width: 380px; min-height: 48px; padding: 11px 14px; display: flex; align-items: center; gap: 10px; color: #fff; background: var(--ink); box-shadow: var(--shadow); animation: toast-in .25s ease; font-size: 10px; }
.toast.success svg { color: #9fd1ad; }
.toast.error svg { color: #ffaaa3; }

.mobile-scrim { display: none; }
.desktop-only { display: initial; }
.mobile-only { display: none; }
.muted { color: var(--muted); }
.danger-text { color: var(--red) !important; }
.positive-text { color: var(--green) !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(15px); } }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card:nth-child(2) { border-right: 0; }
  .metric-card:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .document-builder { grid-template-columns: 230px minmax(330px, 1fr); }
  .document-builder .builder-column:last-child { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .document-builder .builder-column:nth-child(2) { border-right: 0; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: none; }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow); }
  .sidebar-close, .mobile-menu { display: inline-grid !important; }
  .mobile-scrim { position: fixed; inset: 0; z-index: 25; background: rgba(17,25,21,.45); }
  body.sidebar-open .mobile-scrim { display: block; }
  .workspace { width: 100%; margin-left: 0; }
  .topbar { padding: 0 18px; }
  .global-search { width: 210px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .service-layout { grid-template-columns: 1fr; }
  .category-panel { display: flex; overflow-x: auto; }
  .category-button { width: auto; flex: 0 0 auto; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-card.wide { grid-column: auto; }
}

@media (max-width: 640px) {
  .topbar { height: 68px; padding: 0 12px; }
  .topbar h1 { font-size: 18px; }
  .breadcrumb { display: none; }
  .topbar-actions { gap: 4px; }
  .global-search, .notification-button { display: none; }
  .topbar-actions .primary-button { width: 37px; min-height: 37px; padding: 0; }
  .topbar-actions .primary-button span { display: none; }
  #app-content { padding: 17px 12px 36px; }
  .page-stack { gap: 12px; }
  .page-heading { align-items: flex-start; }
  .page-heading h2 { font-size: 17px; }
  .page-heading p { max-width: 240px; font-size: 10px; }
  .page-actions { flex-wrap: wrap; justify-content: flex-end; }
  .page-actions .secondary-button span { display: none; }

  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 112px; padding: 14px; }
  .metric-value { font-size: 20px; }
  .metric-label { font-size: 9px; }
  .metric-icon { width: 25px; height: 25px; }
  .metric-foot { font-size: 8px; }

  .panel-header { min-height: 52px; padding: 11px 12px; }
  .panel-body { padding: 12px; }
  .aging-chart { gap: 5px; }
  .aging-column > span { font-size: 7px; }
  .aging-bar span { font-size: 7px; }

  .table-toolbar { align-items: stretch; flex-direction: column; padding: 9px; }
  .toolbar-group { width: 100%; }
  .search-field { width: 100%; }
  .select-field { flex: 1; }
  .select-field select { width: 100%; }
  .date-range-group .field-label { width: 100%; }
  .date-range-group .date-field { flex: 1; min-width: 125px; }
  .date-range-group .select-field { min-width: 100%; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tbody { padding: 0 10px; }
  .data-table tr { padding: 13px 0; position: relative; border-bottom: 1px solid var(--line); }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table td { height: auto; min-height: 0; padding: 4px 0; border: 0; }
  .data-table td[data-label] { padding-left: 92px; }
  .data-table td[data-label]::before { content: attr(data-label); width: 82px; position: absolute; left: 0; color: var(--muted); font-size: 8px; }
  .data-table .row-actions { position: absolute; right: 0; top: 8px; }
  .data-table td.primary-mobile { padding-right: 72px; }
  .data-table td.hide-mobile { display: none; }
  .client-cell { max-width: calc(100vw - 130px); }

  .summary-band { grid-template-columns: 1fr 1fr; }
  .summary-cell { min-height: 69px; padding: 12px; }
  .summary-cell:nth-child(even) { border-right: 0; }
  .summary-cell:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
  .summary-cell:last-child { grid-column: 1 / -1; }
  .summary-cell strong { font-size: 15px; }
  .aging-buckets { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .aging-bucket { min-width: 145px; scroll-snap-align: start; }

  .category-panel { padding: 5px; }
  .service-description { max-width: 260px; }
  .source-files { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }

  .modal-backdrop { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: 94vh; border: 0; }
  .modal.modal-wide, .modal.modal-document { width: 100%; height: 94vh; height: 94dvh; }
  .modal-header { min-height: 59px; padding: 10px 13px; }
  .modal-body { padding: 14px; }
  .modal-footer { min-height: 58px; padding: 10px 13px; }
  .modal-footer > span { display: none; }
  .modal-wide .modal-footer-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; overflow: visible; }
  .modal-wide .modal-footer-actions button { min-width: 38px; padding: 0 10px; font-size: 0; }
  .modal-wide .modal-footer-actions button svg { width: 16px; height: 16px; }
  .modal-wide .modal-footer-actions [data-action="export-preview"],
  .modal-wide .modal-footer-actions [data-action="export-document"] { min-width: 94px; font-size: 10px; }
  .modal-document .document-builder { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .modal-document .modal-footer { flex: 0 0 auto; }
  .document-builder { display: block; min-height: 0; }
  .builder-column { max-height: none; padding: 13px; border-right: 0; border-bottom: 1px solid var(--line); }
  .service-picker-list { max-height: 280px; }
  .line-item { grid-template-columns: minmax(0, 1fr) 42px 64px 64px 26px; align-items: end; }
  .line-item-name { grid-column: 1 / -1; }
  .line-item > input:nth-of-type(1) { grid-column: 2; }
  .line-item > input:nth-of-type(2) { grid-column: 3; }
  .line-item > input:nth-of-type(3) { grid-column: 4; }
  .line-item > .icon-button { grid-column: 5; }
  .line-item-head { display: none; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-item, .detail-item:nth-child(even), .detail-item:nth-last-child(-n+2) { border-right: 0; border-bottom: 1px solid var(--line); }
  .detail-item:last-child { border-bottom: 0; }
  .document-preview { padding: 22px 17px; border: 0; box-shadow: none; }
  .epton-document { min-height: 0; padding: 24px 18px; font-size: 8px; }
  .reference-head h1 { font-size: 13px; }
  .reference-company-zh { font-size: 7px; }
  .reference-logo { width: 90px; min-width: 90px; height: 34px; flex-basis: 90px; }
  .reference-rule { margin-top: 10px; }
  .reference-company { margin-top: 10px; font-size: 7px; }
  .reference-title-row { min-height: 91px; grid-template-columns: 1fr 185px; }
  .reference-title-row h2 { margin-bottom: 8px; font-size: 19px; }
  .reference-title-row dl { width: 180px; grid-template-columns: 82px 1fr; font-size: 7px; }
  .reference-title-row dd { min-height: 14px; }
  .reference-section-bar { height: 19px; padding: 3px 6px; font-size: 8px; }
  .reference-bill h3 { margin-top: 18px; font-size: 8px; }
  .reference-lines { margin-top: 11px; }
  .reference-lines th { height: 27px; font-size: 8px; }
  .reference-lines th:first-child { width: 76%; }
  .reference-lines th:last-child, .reference-lines td:last-child { width: 24%; }
  .reference-lines tbody { height: 120px; }
  .reference-lines td { font-size: 7px; }
  .reference-lines .service-heading td { padding-top: 15px; }
  .reference-payment-row { grid-template-columns: 1fr; gap: 8px; }
  .reference-payment { margin-top: 10px; }
  .reference-payment p, .reference-payment h4, .reference-totals > div { font-size: 7px; }
  .reference-contact { margin-top: 25px; font-size: 7px; }
  .reference-thanks { margin-top: 25px; font-size: 10px; }
  .reference-totals .reference-stamp { width: 62px; height: 62px; margin-top: 25px; margin-right: 8px; }
  .pdf-export-host .epton-document { padding: 58px 66px; font-size: 12px; }
  .pdf-export-host .reference-head h1 { font-size: 21px; }
  .pdf-export-host .reference-logo { width: 142px; min-width: 142px; height: 52px; flex-basis: 142px; }
  .pdf-export-host .reference-rule { margin-top: 18px; }
  .pdf-export-host .reference-company { margin-top: 17px; font-size: 10px; }
  .pdf-export-host .reference-title-row { min-height: 126px; grid-template-columns: 1fr 270px; }
  .pdf-export-host .reference-title-row h2 { margin-bottom: 13px; font-size: 31px; }
  .pdf-export-host .reference-title-row dl { width: 220px; grid-template-columns: 105px 1fr; font-size: 10px; }
  .pdf-export-host .reference-title-row dd { min-height: 18px; }
  .pdf-export-host .reference-section-bar { height: 24px; padding: 4px 8px; font-size: 12px; }
  .pdf-export-host .reference-bill h3 { margin-top: 30px; font-size: 12px; }
  .pdf-export-host .reference-lines { margin-top: 17px; }
  .pdf-export-host .reference-lines th { height: 32px; font-size: 12px; }
  .pdf-export-host .reference-lines th:first-child { width: 80%; }
  .pdf-export-host .reference-lines th:last-child, .pdf-export-host .reference-lines td:last-child { width: 20%; }
  .pdf-export-host .reference-lines tbody { height: 178px; }
  .pdf-export-host .reference-lines td { font-size: 11px; }
  .pdf-export-host .reference-lines .service-heading td { padding-top: 28px; }
  .pdf-export-host .reference-payment-row { grid-template-columns: minmax(0, 1.75fr) minmax(190px, .85fr); gap: 20px; }
  .pdf-export-host .reference-payment { margin-top: 17px; }
  .pdf-export-host .reference-payment p { font-size: 9px; }
  .pdf-export-host .reference-payment h4 { font-size: 11px; }
  .pdf-export-host .reference-totals > div { font-size: 10px; }
  .pdf-export-host .reference-contact { margin-top: 58px; font-size: 10px; }
  .pdf-export-host .reference-thanks { margin-top: 48px; font-size: 15px; }
  .document-head, .document-title { gap: 12px; }
  .document-company { max-width: 165px; font-size: 7px; }
  .document-title h2 { font-size: 18px; }
  .document-meta { grid-template-columns: 1fr; gap: 15px; }
  .document-lines td, .document-lines th { padding: 8px 5px; font-size: 7px; }
  .document-summary { width: 220px; }

  .desktop-only { display: none !important; }
  .mobile-only { display: initial; }
  .toast-root { right: 10px; bottom: 10px; left: 10px; }
  .toast { min-width: 0; width: 100%; }
}

@media print {
  html, body { width: auto; height: auto; background: #fff; }
  body { margin: 0; padding: 0; }
  @page { size: A4 portrait; margin: 15.35mm 17.46mm; }
  .app-shell, #modal-root, .toast-root { display: none !important; }
  .document-preview.epton-document { width: auto !important; height: auto !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; overflow: visible !important; border: 0 !important; box-shadow: none !important; }
  .reference-lines thead { display: table-header-group; }
  .reference-lines tr, .reference-payment-row, .reference-contact, .reference-notes, .reference-thanks { break-inside: avoid; page-break-inside: avoid; }
}

@media (max-width: 480px) {
  .auth-screen { padding: 0; place-items: stretch; background: #fff; }
  .auth-panel { width: 100%; min-height: 100vh; padding: 28px 20px; border: 0; border-top: 4px solid var(--green); border-radius: 0; box-shadow: none; }
  .auth-header { align-items: flex-start; }
  .auth-header img { width: 96px; }
  .auth-header h1 { font-size: 18px; }
}
