:root {
  --ink: #17231f;
  --muted: #6e7772;
  --paper: #f5f4ef;
  --card: #fffefb;
  --line: #e5e3dc;
  --line-dark: #d5d3ca;
  --forest: #1e342d;
  --forest-2: #2f4d42;
  --coral: #ef6d4f;
  --coral-soft: #fff0e9;
  --lime: #bbd46b;
  --sky: #8fc3cb;
  --sand: #ece7d9;
  --positive: #24805e;
  --negative: #c24d3b;
  --shadow: 0 12px 35px rgba(31, 42, 37, .07);
  --sidebar: 224px;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 77% -10%, rgba(187, 212, 107, .12), transparent 25%),
    var(--paper);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: 24px 16px 18px;
  color: #f7f5ee;
  background:
    linear-gradient(160deg, rgba(255,255,255,.035), transparent 36%),
    var(--forest);
  box-shadow: 10px 0 35px rgba(25, 38, 32, .08);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 27px; }
.brand-mark {
  display: grid; place-items: center; width: 39px; height: 39px;
  border: 1px solid rgba(255,255,255,.36); border-radius: 12px;
  font-family: Georgia, serif; font-size: 15px; letter-spacing: -.5px;
  background: rgba(255,255,255,.08);
}
.brand strong { display: block; font-size: 14px; letter-spacing: .04em; }
.brand small { display: block; margin-top: 3px; color: rgba(255,255,255,.46); font-size: 8px; letter-spacing: .18em; }
.nav-list { display: grid; gap: 5px; }
.nav-kicker { margin: 22px 12px 7px; color: rgba(255,255,255,.34); font-size: 9px; font-weight: 800; letter-spacing: .2em; }
.nav-link { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 13px; color: rgba(255,255,255,.68); border-radius: 11px; transition: .18s ease; }
.nav-link:hover { color: white; background: rgba(255,255,255,.06); }
.nav-link.active { color: white; background: rgba(255,255,255,.1); box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.nav-link.active::before { content: ""; position: absolute; left: -16px; width: 3px; height: 23px; background: var(--lime); border-radius: 0 3px 3px 0; }
.nav-icon { display: grid; place-items: center; width: 22px; height: 22px; font-size: 18px; color: var(--lime); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 12px; border: 1px solid rgba(255,255,255,.09); border-radius: 12px; background: rgba(0,0,0,.08); }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 11px; }
.sidebar-foot small { margin-top: 3px; color: rgba(255,255,255,.4); font-size: 9px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 5px rgba(187,212,107,.1); }

.shell { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { position: sticky; top: 0; z-index: 30; height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; border-bottom: 1px solid rgba(218,216,208,.78); background: rgba(245,244,239,.87); backdrop-filter: blur(14px); }
.breadcrumb { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.breadcrumb span { color: #8d938f; }
.breadcrumb b { color: #c0c2bd; font-weight: 400; }
.topbar-actions { display: flex; align-items: center; gap: 11px; }
.date-chip { color: var(--muted); font-size: 11px; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; color: white; background: var(--coral); font-size: 10px; font-weight: 800; }
.icon-button { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.6); cursor: pointer; }
.notification-dot { position: absolute; top: 7px; right: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--coral); }
.mobile-only { display: none; }

.main-content { max-width: 1600px; min-height: calc(100vh - 64px); margin: 0 auto; padding: 30px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin: 1px 0 24px; }
.compact-heading { margin-bottom: 20px; }
.eyebrow, .panel-kicker { display: block; margin-bottom: 7px; color: var(--coral); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
.page-heading h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(26px, 3vw, 38px); font-weight: 500; letter-spacing: -.035em; }
.page-heading p { max-width: 650px; margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.heading-actions { display: flex; align-items: center; gap: 9px; }
.data-freshness { display: flex; align-items: center; gap: 7px; margin-right: 4px; color: var(--muted); font-size: 10px; }
.data-freshness i { width: 6px; height: 6px; border-radius: 50%; background: var(--positive); }
.formula-note { padding: 9px 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.48); font-size: 10px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: 10px; font-size: 11px; font-weight: 700; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--coral); box-shadow: 0 8px 18px rgba(239,109,79,.2); }
.button.primary:hover { background: #e56245; }
.button.secondary { border-color: var(--line-dark); background: rgba(255,255,255,.62); }
.button.dark { color: white; background: var(--forest); }
.button.ghost { border-color: var(--line); background: transparent; }
.button.wide { width: 100%; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 15px; }
.metric-card { min-height: 145px; padding: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--card); box-shadow: 0 8px 25px rgba(27,42,34,.035); }
.metric-card.accent-dark { color: white; border-color: transparent; background: var(--forest); }
.metric-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.accent-dark .metric-top, .accent-dark p { color: rgba(255,255,255,.55); }
.metric-glyph { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 9px; color: var(--forest); background: var(--lime); font-style: normal; font-weight: 800; }
.metric-glyph.coral { color: var(--coral); background: var(--coral-soft); }
.metric-glyph.lime { background: #f2f7df; }
.metric-glyph.sky { color: #39747c; background: #e9f5f6; }
.metric-card > strong { display: block; margin-top: 19px; font-family: Georgia, serif; font-size: clamp(27px, 3vw, 36px); font-weight: 500; letter-spacing: -.04em; }
.metric-card > strong small { margin-right: 3px; color: var(--muted); font-family: inherit; font-size: 15px; }
.accent-dark > strong small { color: var(--lime); }
.metric-card p { margin: 7px 0 0; color: #8a908c; font-size: 10px; }

.dashboard-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: 15px; background: var(--card); box-shadow: 0 8px 30px rgba(31,42,37,.035); }
.span-7 { grid-column: span 7; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.dashboard-grid .panel { min-height: 320px; padding: 21px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 21px; }
.panel-head h2, .budget-tabs h2, .upload-card h2, .export-card h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 19px; font-weight: 500; }
.panel-note { color: var(--muted); font-size: 9px; }
.bar-chart { display: grid; gap: 13px; }
.bar-row { display: grid; grid-template-columns: 72px minmax(80px, 1fr) 80px; align-items: center; gap: 11px; }
.bar-label { overflow: hidden; color: #4e5954; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 15px; padding: 3px; border-radius: 20px; background: #f0efe9; }
.bar-track span { display: block; min-width: 3px; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--forest-2), #547164); }
.bar-row:nth-child(2n) .bar-track span { background: linear-gradient(90deg, var(--coral), #f2a080); }
.bar-row strong { text-align: right; font-family: Georgia, serif; font-size: 12px; font-weight: 500; }
.donut-layout { display: flex; align-items: center; justify-content: center; gap: clamp(30px, 5vw, 70px); padding: 2px 0 19px; }
.donut { position: relative; width: 138px; height: 138px; border-radius: 50%; background: conic-gradient(var(--forest) calc(var(--active) * 1%), var(--coral) 0); }
.donut::after { content: ""; position: absolute; inset: 19px; border-radius: 50%; background: var(--card); }
.donut > span { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; text-align: center; }
.donut strong, .donut small { display: block; }
.donut strong { font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.donut small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.legend-stack { min-width: 130px; }
.legend-stack > div { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.legend-stack > div:last-child { border: 0; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.dark { background: var(--forest); }.legend-dot.coral { background: var(--coral); }.legend-dot.pale { background: var(--sand); }
.insight-box { display: flex; gap: 9px; padding: 12px 13px; border-radius: 10px; background: #f4f3ed; }
.insight-box span { height: fit-content; padding: 3px 6px; color: #6d7639; border-radius: 5px; background: #e9efca; font-size: 8px; font-weight: 800; }
.insight-box p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.mini-bars { display: grid; gap: 17px; }
.mini-bars > div:not(.empty-state) { display: grid; grid-template-columns: 55px 1fr 60px; align-items: center; gap: 9px; }
.mini-bars span { color: var(--muted); font-size: 10px; }
.mini-bars b { height: 5px; overflow: hidden; border-radius: 6px; background: #ecebe5; }
.mini-bars b i { display: block; height: 100%; border-radius: inherit; background: var(--forest-2); }
.coral-bars b i { background: var(--coral); }
.mini-bars strong { text-align: right; font-family: Georgia, serif; font-size: 11px; font-weight: 500; }
.source-list { display: grid; }
.source-list > div:not(.empty-state) { display: grid; grid-template-columns: 32px 1fr 35px 35px; align-items: center; min-height: 42px; border-bottom: 1px solid var(--line); }
.source-list > div:last-child { border: 0; }
.source-rank { color: #b5b7b2; font-family: Georgia, serif; font-size: 10px; }
.source-name { font-size: 11px; }
.source-list strong { font-family: Georgia, serif; font-weight: 500; }
.source-list small { color: var(--muted); font-size: 9px; text-align: right; }
.seven-charts .panel { min-height: 310px; }
.dashboard-bars .bar-row { grid-template-columns: minmax(75px, 110px) minmax(80px, 1fr) 82px; }
.count-bars .bar-track span { background: linear-gradient(90deg, var(--coral), #f2a080); }

.filter-panel { margin-bottom: 13px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.55); }
.filters { display: flex; align-items: flex-end; gap: 9px; }
.filters label, .form-grid label, .upload-form-row label, .export-card form label { display: grid; gap: 6px; }
.filters label > span:not(:first-child), .filters label > span:first-child, .form-grid label > span, .upload-form-row label > span, .export-card label > span { color: var(--muted); font-size: 9px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 38px; padding: 0 11px; color: var(--ink); border: 1px solid var(--line-dark); border-radius: 9px; outline: none; background: var(--card); transition: border .15s, box-shadow .15s; }
textarea { padding-top: 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #719286; box-shadow: 0 0 0 3px rgba(64,104,89,.09); }
.search-box { position: relative; flex: 1; min-width: 220px; }
.search-box > span { position: absolute; left: 11px; bottom: 9px; z-index: 1; color: #89918c; font-size: 16px !important; }
.search-box input { padding-left: 34px; }
.filters label:not(.search-box) { min-width: 135px; }
.table-panel { overflow: hidden; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 17px; border-bottom: 1px solid var(--line); }
.table-toolbar > div:first-child { display: flex; align-items: baseline; gap: 7px; }
.table-toolbar strong { font-family: Georgia, serif; font-size: 18px; font-weight: 500; }
.table-toolbar span { color: var(--muted); font-size: 10px; }
.column-legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.column-legend i { width: 8px; height: 8px; margin-left: 8px; border-radius: 2px; }
.column-legend .content { background: var(--forest); }.column-legend .delivery { background: var(--coral); }.column-legend .quality { background: var(--lime); }
.table-scroll { max-width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; }
.data-table th { height: 43px; padding: 0 13px; color: #7e8581; border-bottom: 1px solid var(--line); background: #faf9f5; font-size: 9px; font-weight: 800; letter-spacing: .04em; text-align: left; }
.data-table td { height: 58px; max-width: 250px; padding: 8px 13px; overflow: hidden; border-bottom: 1px solid #eceae4; font-size: 10px; text-overflow: ellipsis; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #faf9f4; }
.data-table .number { font-variant-numeric: tabular-nums; text-align: right; }
.data-table .emphasis { color: var(--forest); font-family: Georgia, serif; font-size: 12px; font-weight: 700; }
.ads-table { min-width: 1750px; }
.sticky-col { position: sticky; left: 0; z-index: 2; width: 330px; min-width: 330px; background: var(--card); box-shadow: 7px 0 13px rgba(30,48,41,.03); }
thead .sticky-col { z-index: 3; background: #faf9f5; }
.clickable-row { cursor: pointer; }
.ad-cell { display: flex; align-items: center; gap: 10px; }
.thumb { display: grid; place-items: center; flex: 0 0 35px; height: 35px; border-radius: 10px; color: white; background: linear-gradient(145deg, var(--forest-2), #788f67); font-family: Georgia, serif; }
.media-thumb { width: 35px; object-fit: cover; }
.ad-cell div { min-width: 0; }
.ad-cell strong, .ad-cell small { display: block; overflow: hidden; text-overflow: ellipsis; }
.ad-cell strong { max-width: 250px; font-size: 10px; }
.ad-cell small { margin-top: 4px; color: #999e9a; font-size: 8px; }
.tag-stack .tag { display: inline-flex; padding: 4px 7px; color: #466051; border-radius: 6px; background: #edf1e8; font-size: 9px; }
.tag-stack small { margin-left: 5px; color: var(--muted); }
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px; border-radius: 20px; background: #f1f1ed; font-size: 9px; text-transform: capitalize; }
.status-badge i { width: 5px; height: 5px; border-radius: 50%; background: #aaa; }
.status-badge.active { color: var(--positive); background: #eaf6f0; }.status-badge.active i { background: var(--positive); }
.status-badge.off { color: #a05c50; background: #f8ece9; }.status-badge.off i { background: var(--coral); }
.decision-badge { display: block; max-width: 230px; overflow: hidden; padding: 5px 8px; border-radius: 6px; color: #4f6b5f; background: #edf2ed; text-overflow: ellipsis; font-size: 8px; }
.decision-badge.low_3, .decision-badge.high_2_1, .decision-badge.high_3_1, .decision-badge.high_4_1 { color: #b24f3c; background: var(--coral-soft); }
.decision-badge.low_1, .decision-badge.high_1 { color: #5d6a29; background: #f1f6dc; }
.decision-badge.none { color: #8a8f8b; background: #f1f1ed; }
.score-pill { display: inline-flex; min-width: 48px; justify-content: center; padding: 5px; border-radius: 7px; color: #4c6125; background: #edf4d5; font-family: Georgia, serif; }
.pagination { display: flex; align-items: center; justify-content: space-between; min-height: 53px; padding: 0 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.pagination div { display: flex; gap: 7px; }.pagination a { padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: white; }

.match-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 14px; }
.match-metric { min-height: 113px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.match-metric.dark { color: white; border-color: var(--forest); background: var(--forest); }
.match-metric > span, .match-metric > strong, .match-metric > small { display: block; }
.match-metric > span { color: var(--muted); font-size: 9px; }
.match-metric.dark > span, .match-metric.dark > small { color: rgba(255,255,255,.55); }
.match-metric > strong { margin-top: 10px; font-family: Georgia, serif; font-size: 27px; font-weight: 500; }
.match-metric > small { margin-top: 5px; color: var(--muted); font-size: 8px; }
.match-filters { flex-wrap: wrap; }
.match-filters .search-box { min-width: 300px; }
.match-filters label:not(.search-box) { min-width: 125px; }
.attribution-rule { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; }
.attribution-rule i { width: 6px; height: 6px; border-radius: 50%; background: var(--lime); }
.match-table { min-width: 1410px; }
.bill-number { color: var(--forest); font-family: Georgia, serif; font-size: 12px; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 9px; }
.mono.faint { color: #929792; }
.invoice-type { display: inline-flex; padding: 4px 8px; border-radius: 6px; color: #41685a; background: #e8f4ee; font-size: 8px; }
.invoice-type.mid { color: #9b5b3d; background: #fff0e9; }
.match-status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 20px; font-size: 8px; }
.match-status i { width: 5px; height: 5px; border-radius: 50%; }
.match-status.matched { color: var(--positive); background: #e9f6ef; }.match-status.matched i { background: var(--positive); }
.match-status.unmatched { color: #956152; background: #f7ece8; }.match-status.unmatched i { background: var(--coral); }
.ad-id-cell { padding: 5px 8px; color: #425f53; border-radius: 6px; background: #edf2ed; font-family: "SFMono-Regular", Consolas, monospace; font-size: 8px; }
.empty-value { color: #b0b3af; }

.import-layout { display: grid; grid-template-columns: 1.55fr .85fr; gap: 14px; margin-bottom: 14px; }
.upload-card, .export-card { position: relative; min-height: 345px; padding: 25px; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--card); }
.step-number { position: absolute; top: 18px; right: 21px; color: var(--coral-soft); font-family: Georgia, serif; font-size: 53px; line-height: 1; }.step-number.pale { color: #eef0e5; }
.upload-copy p, .export-card > p { max-width: 540px; margin: 8px 0 19px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.dropzone { display: grid; place-items: center; min-height: 156px; padding: 20px; border: 1px dashed #b9bbb4; border-radius: 12px; background: #faf9f5; text-align: center; cursor: pointer; transition: .15s; }
.dropzone.dragging { border-color: var(--coral); background: var(--coral-soft); }
.upload-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 9px; border-radius: 12px; color: white; background: var(--forest); font-size: 20px; }
.dropzone strong { font-size: 11px; }.dropzone small { margin-top: 6px; color: var(--muted); font-size: 9px; }
.upload-form-row { display: grid; grid-template-columns: 1fr 190px; align-items: end; gap: 10px; margin-top: 12px; }
.export-card form { display: grid; gap: 12px; margin-top: 35px; }
.export-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.export-stats > div { padding: 12px; border-radius: 9px; background: #f4f3ed; }
.export-stats span, .export-stats strong { display: block; }.export-stats span { color: var(--muted); font-size: 8px; }.export-stats strong { margin-top: 6px; font-family: Georgia, serif; font-size: 14px; font-weight: 500; }
.import-history { margin-bottom: 30px; }
.import-history .panel-head { padding: 18px 20px 0; }
.file-cell { display: flex; align-items: center; gap: 9px; }
.file-cell span { padding: 5px 6px; color: var(--positive); border-radius: 5px; background: #e7f4ed; font-size: 7px; font-weight: 900; }
.file-cell strong { max-width: 270px; overflow: hidden; font-size: 10px; text-overflow: ellipsis; }
.batch-status { padding: 4px 7px; border-radius: 6px; color: var(--muted); background: #efefeb; font-size: 8px; }.batch-status.success { color: var(--positive); background: #e8f5ee; }.batch-status.failed, .batch-status.partial { color: var(--negative); background: var(--coral-soft); }
.positive { color: var(--positive) !important; }.negative { color: var(--negative) !important; }

.budget-config-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; margin-bottom: 14px; }
.budget-config-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.config-head { display: flex; align-items: center; justify-content: space-between; }
.config-head > div { display: flex; align-items: center; gap: 8px; }.config-head strong { font-size: 11px; }
.account-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--forest); }.account-2 { background: var(--coral); }.account-3 { background: var(--lime); }
.config-value { margin: 19px 0 13px; }.config-value span, .config-value strong { display: block; }.config-value span { color: var(--muted); font-size: 9px; }.config-value strong { margin-top: 4px; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }.config-value small { font-size: 12px; color: var(--muted); }
.inline-config-form { display: flex; gap: 5px; }.inline-config-form input { min-height: 31px; }.inline-config-form button { padding: 0 11px; color: white; border: 0; border-radius: 8px; background: var(--forest); font-size: 9px; cursor: pointer; }
.budget-table-panel { overflow: hidden; }
.budget-tabs { display: flex; align-items: flex-end; justify-content: space-between; padding: 18px 19px 13px; border-bottom: 1px solid var(--line); }
.budget-tabs nav { display: flex; gap: 4px; padding: 3px; border-radius: 9px; background: #efeee8; }
.budget-tabs nav a { padding: 7px 10px; color: var(--muted); border-radius: 7px; font-size: 9px; }.budget-tabs nav a.active { color: var(--ink); background: white; box-shadow: 0 2px 7px rgba(30,48,41,.08); }
.budget-table { min-width: 1550px; }
.tier-badge { padding: 4px 7px; border-radius: 6px; color: #5f6a2d; background: #f1f6dc; font-size: 8px; }.tier-badge.high { color: #a9513e; background: var(--coral-soft); }
.group-label { display: flex; align-items: center; max-width: 320px; }.group-label > span { min-width: 55px; color: var(--coral); font-family: Georgia, serif; font-size: 12px; font-weight: 700; }.group-label p { overflow: hidden; margin: 0; text-overflow: ellipsis; }
.target-input { display: inline-flex; align-items: center; width: 108px; height: 30px; border: 1px solid var(--line-dark); border-radius: 7px; background: white; }.target-input span { padding-left: 7px; color: var(--muted); }.target-input input { min-height: 28px; padding: 0 4px; border: 0; box-shadow: none; background: transparent; text-align: right; }.target-input button { width: 25px; align-self: stretch; color: var(--positive); border: 0; border-left: 1px solid var(--line); background: #eff7f2; cursor: pointer; }
.gap-pill { padding: 4px 6px; border-radius: 6px; background: #eff6f1; font-size: 9px; }.gap-pill.negative { background: var(--coral-soft); }
.table-footnote { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }.table-footnote i { width: 6px; height: 6px; border-radius: 50%; background: var(--lime); }.table-footnote p { margin: 0; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 25px; background: rgba(20,32,27,.48); backdrop-filter: blur(3px); }
.modal-backdrop[hidden] { display: none; }
.modal-card { width: min(680px, 100%); max-height: 92vh; overflow: auto; border-radius: 17px; background: var(--card); box-shadow: 0 30px 80px rgba(12,25,19,.25); }
.modal-head, .drawer-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 21px 23px; border-bottom: 1px solid var(--line); }.modal-head h2, .drawer-head h2 { margin: 0; font-family: Georgia, serif; font-size: 22px; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 22px; }.span-2 { grid-column: span 2; }.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 5px; }
.detail-drawer { position: fixed; top: 0; right: 0; z-index: 102; width: min(480px, 95vw); height: 100vh; overflow-y: auto; background: var(--card); box-shadow: -20px 0 50px rgba(20,32,27,.15); transform: translateX(105%); transition: transform .25s ease; }.detail-drawer.open { transform: translateX(0); }.drawer-scrim { position: fixed; inset: 0; z-index: 101; background: rgba(20,32,27,.3); }.drawer-body { padding: 22px; }.drawer-loading { padding: 50px 0; color: var(--muted); text-align: center; }
.drawer-hero { padding: 16px; border-radius: 12px; background: var(--forest); color: white; }.drawer-hero small, .drawer-hero strong { display: block; }.drawer-hero small { color: rgba(255,255,255,.5); font-size: 9px; }.drawer-hero strong { margin-top: 7px; font-family: Georgia, serif; font-size: 17px; font-weight: 500; }.drawer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }.drawer-stat { padding: 13px; border: 1px solid var(--line); border-radius: 10px; }.drawer-stat span, .drawer-stat strong { display: block; }.drawer-stat span { color: var(--muted); font-size: 8px; }.drawer-stat strong { margin-top: 5px; font-family: Georgia, serif; font-size: 16px; font-weight: 500; }.drawer-section { margin-top: 20px; }.drawer-section h3 { margin: 0 0 9px; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }.drawer-section p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; white-space: normal; }
.drawer-media-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.drawer-media-item { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #faf9f5; }
.drawer-media-item img { display: block; width: 100%; height: 110px; object-fit: cover; }
.drawer-media-item span { display: block; overflow: hidden; padding: 8px; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.drawer-media-item.file { display: flex; align-items: center; gap: 8px; min-height: 54px; padding-left: 10px; }
.drawer-media-item.file b { display: grid; place-items: center; flex: 0 0 28px; height: 28px; color: white; border-radius: 8px; background: var(--forest); font-size: 9px; }
.drawer-media-item.file span { padding-left: 0; }
.drawer-muted { color: var(--muted); font-size: 10px; }
.daily-stat-filters { justify-content: flex-start; }
.daily-stats-table { min-width: 1850px; }
.metric-date { font-size: 20px !important; }

.toast-stack { position: fixed; top: 76px; right: 22px; z-index: 200; display: grid; gap: 7px; }
.toast { display: flex; align-items: center; gap: 18px; min-width: 270px; padding: 12px 14px; color: #315547; border: 1px solid #cfe1d7; border-radius: 10px; background: #eff8f3; box-shadow: var(--shadow); font-size: 10px; }.toast.error { color: #914737; border-color: #f0d1c9; background: #fff2ee; }.toast button { margin-left: auto; border: 0; background: transparent; cursor: pointer; }
.empty-state { padding: 40px 15px; color: #929793; text-align: center; font-size: 10px; }.empty-state.compact { padding: 30px 10px; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .span-7, .span-5 { grid-column: span 12; }
  .span-6 { grid-column: span 6; }
  .span-4 { grid-column: span 6; }
  .filters { flex-wrap: wrap; }.search-box { flex-basis: 100%; }.filters label:not(.search-box) { flex: 1; }
  .import-layout { grid-template-columns: 1fr; }
  .match-metric-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  :root { --sidebar: 0px; }
  .sidebar { width: 224px; transform: translateX(-105%); transition: transform .2s ease; }.sidebar.open { transform: translateX(0); }
  .shell { margin-left: 0; }
  .mobile-only { display: grid; }
  .topbar { padding: 0 16px; }.breadcrumb { display: none; }
  .main-content { padding: 20px 15px; }
  .page-heading { align-items: flex-start; flex-direction: column; }.heading-actions { width: 100%; flex-wrap: wrap; }.data-freshness { flex-basis: 100%; }
  .span-4 { grid-column: span 12; }
  .span-6 { grid-column: span 12; }
  .budget-config-grid { grid-template-columns: 1fr; }
  .budget-tabs { align-items: flex-start; flex-direction: column; gap: 14px; }.budget-tabs nav { max-width: 100%; overflow-x: auto; }
  .topbar-actions .date-chip { display: none; }
}
@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 128px; }
  .filters label:not(.search-box) { flex-basis: calc(50% - 5px); min-width: 0; }
  .filters .button { flex: 1; }
  .column-legend { display: none; }
  .donut-layout { gap: 20px; }.donut { width: 115px; height: 115px; }.donut::after { inset: 16px; }
  .upload-form-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }.form-grid .span-2 { grid-column: span 1; }
  .match-metric-grid { grid-template-columns: 1fr 1fr; }
  .match-metric { min-height: 105px; }
}
