/* ============================================================
   凭 · 报销凭证管理平台  —  "Ledger" aesthetic
   Warm paper · deep emerald ink · muted gold · tabular figures
   ============================================================ */
:root {
  --paper:        #f7f3ea;
  --paper-2:      #f1ebdd;
  --card:         #fffdf8;
  --ink:          #16221c;
  --ink-soft:     #4a5851;
  --ink-faint:    #8a938c;
  --line:         #e2dccb;
  --line-strong:  #d3ccb6;
  --emerald:      #14503c;
  --emerald-2:    #1c6b4f;
  --emerald-deep: #0e3a2b;
  --gold:         #b8892f;
  --gold-soft:    #d9b968;
  --rust:         #a5432f;
  --rust-soft:    #c96a4f;
  --ok:           #2f7d4f;

  --radius:   14px;
  --radius-s: 10px;
  --shadow:   0 1px 2px rgba(30,40,30,.04), 0 12px 32px -18px rgba(20,60,40,.28);
  --shadow-lg:0 24px 60px -28px rgba(14,58,43,.45);
  --serif: "Fraunces", Georgia, "Songti SC", serif;
  --sans: "Manrope", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(28,107,79,.08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(184,137,47,.09), transparent 55%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv01";
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.ic-svg { display: inline-block; vertical-align: -0.16em; flex: none; }
.btn .ic-svg { vertical-align: -0.18em; }
.nav button .ic { display: inline-grid; place-items: center; width: 22px; }
.icon-btn .ic-svg, .pill-att .ic-svg { vertical-align: middle; }
.dz-ic .ic-svg { color: var(--emerald-2); }
.empty .big .ic-svg { color: var(--line-strong); }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--gold-soft); color: var(--emerald-deep); }

/* ------------------- Auth screen ------------------- */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr;
}
.auth-brand {
  position: relative; overflow: hidden;
  background:
    radial-gradient(700px 400px at 20% 20%, rgba(217,185,104,.18), transparent 55%),
    linear-gradient(155deg, var(--emerald-deep), var(--emerald) 60%, #103524);
  color: #f4efe0; padding: 64px 68px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-brand::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 34px 34px; mask-image: radial-gradient(circle at 70% 40%, black, transparent 80%);
}
.brand-mark { display: flex; align-items: center; gap: 14px; z-index: 1; }
.brand-seal {
  width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--gold-soft); color: var(--gold-soft);
  font-family: var(--serif); font-size: 30px; font-weight: 600;
  box-shadow: inset 0 0 0 4px rgba(217,185,104,.12);
}
.brand-mark h1 { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 0; letter-spacing: .5px; }
.brand-mark p { margin: 2px 0 0; font-size: 12.5px; letter-spacing: 3px; color: var(--gold-soft); text-transform: uppercase; }
.auth-hero { z-index: 1; max-width: 460px; }
.auth-hero h2 { font-family: var(--serif); font-size: clamp(34px, 4vw, 52px); line-height: 1.06; font-weight: 500; margin: 0 0 20px; }
.auth-hero h2 em { font-style: italic; color: var(--gold-soft); }
.auth-hero p { color: #cfd8cc; font-size: 15px; line-height: 1.7; }
.auth-points { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; z-index: 1; }
.auth-points li { display: flex; gap: 12px; align-items: center; font-size: 14px; color: #dfe6da; }
.auth-points li span { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: rgba(217,185,104,.14); color: var(--gold-soft); font-size: 14px; }
.auth-foot { z-index: 1; font-size: 12px; color: #9fb0a4; letter-spacing: .5px; }

.auth-panel { display: grid; place-items: center; padding: 40px; }
.auth-card { width: min(400px, 100%); }
.auth-card h3 { font-family: var(--serif); font-size: 30px; font-weight: 600; margin: 0 0 6px; }
.auth-card .sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 28px; }
.tabs { display: inline-flex; background: var(--paper-2); border-radius: 999px; padding: 4px; margin-bottom: 26px; }
.tabs button { border: 0; background: transparent; padding: 8px 22px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--ink-soft); transition: .2s; }
.tabs button.active { background: var(--card); color: var(--emerald); box-shadow: var(--shadow); }

/* ------------------- Forms ------------------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 7px; letter-spacing: .3px; }
.field .req { color: var(--rust); }
input, select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  background: var(--card); font-size: 14.5px; color: var(--ink); font-family: inherit; transition: .18s;
}
textarea { resize: vertical; min-height: 82px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--emerald-2); box-shadow: 0 0 0 3px rgba(28,107,79,.14); }
input::placeholder, textarea::placeholder { color: var(--ink-faint); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius-s); border: 1px solid transparent;
  font-weight: 700; font-size: 14px; transition: .18s; background: var(--paper-2); color: var(--ink);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(180deg, var(--emerald-2), var(--emerald)); color: #f6f2e6; box-shadow: 0 10px 24px -12px rgba(20,80,60,.7); }
.btn-primary:hover { box-shadow: 0 14px 30px -12px rgba(20,80,60,.8); }
.btn-gold { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #3a2b06; }
.btn-ghost { background: var(--card); border-color: var(--line-strong); color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--emerald-2); color: var(--emerald); }
.btn-danger { background: var(--card); border-color: var(--rust-soft); color: var(--rust); }
.btn-danger:hover { background: var(--rust); color: #fff; border-color: var(--rust); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ------------------- App shell ------------------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(185deg, var(--emerald-deep), #103826);
  color: #dce6dd; padding: 26px 18px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand-mark { margin-bottom: 34px; padding: 0 8px; }
.sidebar .brand-seal { width: 44px; height: 44px; font-size: 22px; }
.sidebar .brand-mark h1 { font-size: 19px; color: #f4efe0; }
.sidebar .brand-mark p { font-size: 10px; letter-spacing: 2px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 14px; border: 0; border-radius: 10px; background: transparent; color: #c2d0c5;
  font-size: 14.5px; font-weight: 600; transition: .16s;
}
.nav button .ic { width: 20px; text-align: center; opacity: .85; }
.nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav button.active { background: rgba(217,185,104,.16); color: #f4efe0; box-shadow: inset 3px 0 0 var(--gold-soft); }
.side-foot { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.08); }
.side-user { display: flex; align-items: center; gap: 12px; padding: 6px 8px 14px; }
.avatar { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--gold); color: #3a2b06; font-weight: 800; font-family: var(--serif); }
.side-user .meta b { display: block; font-size: 14px; color: #f4efe0; }
.side-user .meta small { color: #9fb0a4; font-size: 11.5px; letter-spacing: .5px; }

.main { padding: 30px 40px 60px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h2 { font-family: var(--serif); font-size: 32px; font-weight: 600; margin: 0; letter-spacing: .3px; }
.page-head .kicker { color: var(--gold); font-size: 12px; font-weight: 700; letter-spacing: 3px; text-transform: uppercase; margin-bottom: 6px; }
.page-head p { color: var(--ink-soft); margin: 6px 0 0; font-size: 14px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------- Cards / stats ------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.stat { padding: 22px 22px 20px; position: relative; overflow: hidden; }
.stat .lbl { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; letter-spacing: .4px; display: flex; align-items: center; gap: 8px; }
.stat .val { font-family: var(--serif); font-size: 34px; font-weight: 600; margin-top: 12px; letter-spacing: .5px; line-height: 1; }
.stat .val small { font-size: 16px; color: var(--ink-faint); font-family: var(--sans); font-weight: 700; margin-right: 3px; }
.stat .sub { font-size: 12px; color: var(--ink-faint); margin-top: 8px; }
.stat .chip { position: absolute; top: 18px; right: 18px; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; }
.stat.feature { background: linear-gradient(160deg, var(--emerald), var(--emerald-deep)); color: #f2ede0; border-color: transparent; }
.stat.feature .lbl, .stat.feature .sub { color: #bcd0c2; }
.stat.feature .val small { color: var(--gold-soft); }
.stat.feature .chip { background: rgba(217,185,104,.18); color: var(--gold-soft); }
.c-emerald { background: rgba(28,107,79,.1); color: var(--emerald-2); }
.c-gold { background: rgba(184,137,47,.14); color: var(--gold); }
.c-rust { background: rgba(165,67,47,.12); color: var(--rust); }

.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; margin-bottom: 18px; }
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel { padding: 22px 24px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.panel-head h3 { font-family: var(--serif); font-size: 19px; font-weight: 600; margin: 0; }
.panel-head .hint { font-size: 12px; color: var(--ink-faint); }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 190px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 100%; max-width: 42px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, var(--emerald-2), var(--emerald)); transition: height .5s cubic-bezier(.2,.8,.2,1); position: relative; }
.bars .bar:hover { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); }
.bars .bar .tip { position: absolute; top: -26px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 11px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; opacity: 0; transition: .15s; pointer-events: none; }
.bars .bar:hover .tip { opacity: 1; }
.bars .xl { font-size: 11px; color: var(--ink-faint); }

.breakdown { display: flex; flex-direction: column; gap: 14px; }
.bd-row .bd-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.bd-row .bd-top b { font-weight: 600; }
.bd-row .bd-top span { color: var(--ink-soft); }
.bd-track { height: 9px; background: var(--paper-2); border-radius: 6px; overflow: hidden; }
.bd-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--gold-soft), var(--gold)); }
.bd-row:nth-child(3n+1) .bd-fill { background: linear-gradient(90deg, var(--emerald-2), var(--emerald)); }
.bd-row:nth-child(3n+2) .bd-fill { background: linear-gradient(90deg, var(--gold-soft), var(--gold)); }
.bd-row:nth-child(3n) .bd-fill { background: linear-gradient(90deg, var(--rust-soft), var(--rust)); }

/* ------------------- Filters ------------------- */
.filters { padding: 18px 20px; margin-bottom: 18px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; align-items: end; }
.filters .field { margin: 0; }
.filters .field label { font-size: 11.5px; }
.filters input, .filters select { padding: 9px 11px; font-size: 13.5px; }
.filters .actions { display: flex; gap: 8px; grid-column: span 2; }

/* ------------------- Table ------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { text-align: left; padding: 13px 16px; font-size: 12px; letter-spacing: .5px; text-transform: uppercase; color: var(--ink-soft); border-bottom: 2px solid var(--line-strong); background: var(--paper-2); white-space: nowrap; }
thead th.r, td.r { text-align: right; }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(184,137,47,.05); }
td .desc { font-weight: 600; }
td .muted { color: var(--ink-faint); font-size: 12.5px; }
.amount { font-family: var(--serif); font-weight: 600; font-size: 15.5px; }
tfoot td { padding: 15px 16px; border-top: 2px solid var(--line-strong); font-weight: 700; background: var(--paper-2); }
tfoot .amount { color: var(--emerald); font-size: 18px; }

.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(28,107,79,.1); color: var(--emerald-2); }
.pill-att { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-soft); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; color: var(--ink-soft); font-size: 14px; transition: .15s; }
.icon-btn:hover { border-color: var(--emerald-2); color: var(--emerald); background: var(--paper); }
.icon-btn.danger:hover { border-color: var(--rust); color: var(--rust); }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 4px 0; }
.pagination .pinfo { font-size: 13px; color: var(--ink-soft); }
.pager { display: flex; gap: 6px; }

/* ------------------- Upload / dropzone ------------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.dropzone {
  border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 34px 24px; text-align: center;
  background: var(--paper); transition: .2s; cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--emerald-2); background: rgba(28,107,79,.05); }
.dropzone.drag { transform: scale(1.005); box-shadow: inset 0 0 0 4px rgba(28,107,79,.08); }
.dropzone .dz-ic { font-size: 34px; }
.dropzone h4 { margin: 12px 0 4px; font-size: 16px; font-family: var(--serif); }
.dropzone p { margin: 0; color: var(--ink-soft); font-size: 13px; }
.dropzone .types { margin-top: 10px; font-size: 11.5px; color: var(--ink-faint); }
.filelist { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.fileitem { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--card); }
.fileitem .fic { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font-size: 16px; background: var(--paper-2); }
.fileitem .fmeta { flex: 1; min-width: 0; }
.fileitem .fmeta b { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fileitem .fmeta small { color: var(--ink-faint); font-size: 12px; }
.fileitem .rm { border: 0; background: transparent; color: var(--ink-faint); font-size: 18px; padding: 4px 8px; border-radius: 6px; }
.fileitem .rm:hover { color: var(--rust); background: rgba(165,67,47,.08); }

/* ------------------- Modal ------------------- */
.overlay { position: fixed; inset: 0; background: rgba(18,30,24,.5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 60; padding: 24px; animation: fade .2s; }
.modal { width: min(640px, 100%); max-height: 88vh; overflow: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: pop .24s cubic-bezier(.2,.9,.3,1); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.modal-head h3 { font-family: var(--serif); font-size: 22px; margin: 0; font-weight: 600; }
.modal-body { padding: 24px 26px; }
.modal-foot { padding: 18px 26px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--card); }
.close-x { border: 0; background: var(--paper-2); width: 34px; height: 34px; border-radius: 9px; font-size: 18px; color: var(--ink-soft); }
.close-x:hover { background: var(--rust); color: #fff; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.att-tile { border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--paper); text-decoration: none; display: block; transition: .15s; }
.att-tile:hover { border-color: var(--emerald-2); box-shadow: var(--shadow); }
.att-tile .thumb { height: 100px; display: grid; place-items: center; font-size: 34px; background: var(--paper-2); color: var(--emerald-2); }
.att-tile img { width: 100%; height: 100px; object-fit: cover; display: block; }
.att-tile .cap { padding: 8px 10px; font-size: 12px; }
.att-tile .cap b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.att-tile .cap small { color: var(--ink-faint); }

/* ------------------- misc ------------------- */
.empty { text-align: center; padding: 56px 20px; color: var(--ink-faint); }
.empty .big { font-size: 46px; opacity: .5; }
.empty h4 { font-family: var(--serif); font-size: 20px; color: var(--ink-soft); margin: 14px 0 4px; font-weight: 500; }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 13px 22px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: .3s; z-index: 80; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--rust); }
.toast.ok { background: var(--emerald); }
.err-inline { color: var(--rust); font-size: 13px; margin-top: 6px; min-height: 18px; }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.loading-full { display: grid; place-items: center; min-height: 100vh; }
.loading-full .spinner { width: 34px; height: 34px; border-color: rgba(20,80,60,.2); border-top-color: var(--emerald); }
.reveal { animation: rise .5s cubic-bezier(.2,.8,.2,1) both; }
.stat-grid .stat:nth-child(2) { animation-delay: .05s; }
.stat-grid .stat:nth-child(3) { animation-delay: .1s; }
.stat-grid .stat:nth-child(4) { animation-delay: .15s; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* ------------------- responsive ------------------- */
@media (max-width: 1040px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2b { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(2, 1fr); }
  .filters .actions { grid-column: span 2; }
}
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 14px; overflow-x: auto; }
  .sidebar .brand-mark { margin: 0 18px 0 6px; }
  .nav { flex-direction: row; }
  .side-foot { display: none; }
  .main { padding: 22px 18px 50px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ---- Admin user management ---- */
.btn:disabled { opacity: .42; cursor: not-allowed; pointer-events: none; }
.u-actions { white-space: nowrap; display: flex; gap: 6px; }
.u-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.u-badge.on { background: rgba(28,107,79,.12); color: var(--emerald-2); }
.u-badge.off { background: rgba(165,67,47,.12); color: var(--rust); }
.tag.muted-tag { background: rgba(138,147,140,.16); color: var(--ink-faint); }
.auth-note { margin-top: 18px; font-size: 13px; color: var(--ink-faint); text-align: center; }
.tag.role-super { background: rgba(176,141,63,.16); color: #8a6d25; }

/* ---- Export scope + row selection ---- */
.exp-scope { margin: -6px 0 14px; font-size: 13px; color: var(--ink-soft); }
.exp-scope b { color: var(--emerald); }
.linkbtn { background: none; border: 0; color: var(--emerald-2); cursor: pointer; text-decoration: underline; font: inherit; padding: 0 2px; }
th.chk, td.chk { width: 34px; text-align: center; padding-left: 6px; padding-right: 6px; }
td.chk input, th.chk input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--emerald); }
