:root {
  color-scheme: light;
  --ink: #20204f;
  --muted: #6b6b82;
  --green: #252566;
  --green-dark: #1b1b4d;
  --mint: #eeeefe;
  --cream: #f6f7fb;
  --yellow: #fff21c;
  --paper: #fff;
  --line: #e1e2ec;
  --danger: #a33a30;
  --shadow: 0 18px 50px rgba(37, 37, 102, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--cream);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: linear-gradient(180deg, #f0f1f8 0, var(--cream) 440px); }
button, input, select { font: inherit; }
button, .drop-zone { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.site-header { height: 78px; padding: 0 clamp(20px, 5vw, 72px); display: flex; align-items: center; justify-content: space-between; background: #252566; border-bottom: 3px solid var(--yellow); }
.brand { color: white; display: flex; align-items: center; gap: 14px; font-weight: 750; text-decoration: none; letter-spacing: -.02em; }
.brand-logo { display: block; width: 168px; height: auto; }
.brand-divider { width: 1px; height: 30px; background: rgba(255,255,255,.28); }
.brand-product { font-size: 15px; letter-spacing: .01em; }
.header-note { color: #d8d8ec; font-size: 13px; }
main { width: min(1180px, calc(100% - 40px)); margin: auto; }
.hero { text-align: center; max-width: 800px; margin: 72px auto 34px; }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 850; letter-spacing: .17em; }
h1 { max-width: 760px; margin: 12px auto 16px; font-size: clamp(38px, 6vw, 62px); line-height: 1.02; font-weight: 800; letter-spacing: -.045em; }
.hero p { max-width: 610px; margin: auto; color: var(--muted); line-height: 1.65; font-size: 17px; }
.workspace { max-width: 820px; margin: 0 auto 72px; }
.drop-zone { display: flex; flex-direction: column; align-items: center; padding: 36px 24px; border: 2px dashed #9a9abd; border-radius: 8px; background: rgba(255,255,255,.88); transition: .18s ease; outline: none; }
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.dragover { border-color: var(--green); background: white; box-shadow: var(--shadow); transform: translateY(-2px); }
.upload-icon { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 15px; border-radius: 8px; background: var(--yellow); color: var(--green); }
.upload-icon svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.drop-zone strong { font-size: 18px; }
.drop-zone > span { color: var(--muted); margin-top: 5px; }
.link-text { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.drop-zone small { color: #899591; margin-top: 12px; }
.privacy-message { display: flex; align-items: center; justify-content: center; gap: 9px; margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.privacy-message svg { width: 19px; fill: none; stroke: var(--green); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.results { margin-bottom: 72px; }
.error-panel { margin: 15px 0; padding: 14px 17px; border: 1px solid #e7b9b4; border-radius: 10px; background: #fff6f4; color: #742a24; font-size: 14px; }
.error-panel > div { display: flex; justify-content: space-between; align-items: center; }
.error-panel button { border: 0; background: transparent; color: inherit; font-size: 22px; }
.error-panel ul { margin: 8px 0 0; padding-left: 20px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 0 14px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.filter-group, .action-group { display: flex; align-items: center; gap: 9px; }
.filter-group { flex: 1; min-width: 0; }
.filter-group label { width: 170px; }
.action-group { flex: 0 0 auto; }
.search-field { position: relative; flex: 1; }
.search-field svg { position: absolute; width: 18px; left: 13px; top: 50%; transform: translateY(-50%); fill: none; stroke: #71807d; stroke-width: 1.8; }
input, select { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); padding: 0 12px; outline: none; }
.search-field input { padding-left: 40px; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,92,.11); }
.secondary-button { height: 42px; display: inline-flex; align-items: center; gap: 7px; padding: 0 14px; border: 1px solid #babad0; border-radius: 6px; background: white; color: var(--green-dark); font-weight: 700; white-space: nowrap; }
.secondary-button:hover { background: var(--mint); }
.secondary-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.text-button { border: 0; background: transparent; color: var(--danger); padding: 0 7px; }
.export-menu { position: relative; }
.export-menu summary { height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border: 1px solid var(--yellow); border-radius: 6px; background: var(--yellow); color: #20204f; font-weight: 800; cursor: pointer; list-style: none; white-space: nowrap; }
.export-menu summary::-webkit-details-marker { display: none; }
.export-menu summary::after { content: '▾'; margin-left: 2px; font-size: 10px; }
.export-menu[open] summary::after { transform: rotate(180deg); }
.export-menu summary svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.export-options { position: absolute; z-index: 10; top: calc(100% + 8px); right: 0; width: 240px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: white; box-shadow: 0 16px 45px rgba(37,37,102,.18); }
.export-options button { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 11px 12px; border: 0; border-radius: 5px; background: transparent; color: var(--ink); text-align: left; }
.export-options button:hover { background: var(--mint); }
.export-options button:disabled { opacity: .45; cursor: not-allowed; }
.export-options span { color: var(--muted); font-size: 11px; }
.expense-dashboard { margin: 0 0 24px; padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: #fafaff; }
.dashboard-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 18px; }
.dashboard-heading h2 { margin: 5px 0 0; font-size: 30px; font-weight: 800; letter-spacing: -.035em; }
.dashboard-heading p { max-width: 420px; margin: 0; color: var(--muted); font-size: 13px; text-align: right; }
.buyer-warning { margin: -4px 0 18px; padding: 10px 12px; border: 1px solid #e7cf9f; border-radius: 8px; background: #fff9e9; color: #725718; font-size: 13px; }
.dashboard-primary { display: grid; grid-template-columns: 1.05fr 1fr 1.15fr; gap: 12px; }
.dashboard-primary article { min-height: 150px; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.dashboard-primary article > span { display: block; color: var(--muted); font-size: 12px; }
.dashboard-primary article > strong { display: block; margin-top: 10px; font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dashboard-primary article > small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.dashboard-primary .net-card { border-color: var(--green); background: var(--green); color: white; box-shadow: inset 0 3px 0 var(--yellow); }
.dashboard-primary .net-card > span, .dashboard-primary .net-card > small { color: #d7d7eb; }
.metric-breakdown { display: flex; gap: 20px; margin-top: 17px; padding-top: 13px; border-top: 1px solid var(--line); }
.metric-breakdown span { color: var(--muted); font-size: 11px; }
.metric-breakdown b { display: block; margin-top: 3px; color: var(--ink); font-size: 14px; }
.adjustment-card { background: #f4f4fa !important; }
.adjustment-row { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; margin-top: 13px; }
.adjustment-row span { color: var(--muted); font-size: 12px; }
.adjustment-row strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.dashboard-meta { display: flex; align-items: center; gap: 12px 24px; margin: 14px 2px 0; color: var(--muted); font-size: 11px; flex-wrap: wrap; }
.dashboard-meta span + span { position: relative; }
.dashboard-meta span + span::before { content: ''; position: absolute; left: -13px; top: 50%; width: 3px; height: 3px; border-radius: 50%; background: #aaaabd; }
.dashboard-meta strong { color: var(--ink); }
.analytics-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; margin-top: 12px; }
.chart-card { min-height: 270px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: white; overflow: hidden; }
.category-card { grid-column: 1 / -1; min-height: auto; }
.chart-title { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; }
.chart-title h3 { margin: 0; font-size: 14px; }
.chart-title span { color: var(--muted); font-size: 11px; }
.bar-chart { height: 202px; display: flex; align-items: stretch; gap: 9px; margin-top: 17px; overflow-x: auto; }
.month-bar { min-width: 52px; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; }
.month-bar strong { font-size: 10px; white-space: nowrap; }
.month-bar-track { width: min(34px, 65%); height: 145px; display: flex; align-items: flex-end; border-radius: 5px 5px 2px 2px; background: #eef3f1; overflow: hidden; }
.month-bar-fill { width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, #4f4f9a, var(--green)); }
.month-bar span { color: var(--muted); font-size: 10px; white-space: nowrap; }
.provider-chart { display: grid; gap: 15px; margin-top: 22px; }
.category-chart { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 28px; margin-top: 20px; }
.category-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; }
.category-label { display: flex; min-width: 0; align-items: center; gap: 7px; font-size: 12px; font-weight: 650; }
.category-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--category-color); flex: 0 0 auto; }
.category-value { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.category-track { grid-column: 1 / -1; height: 7px; border-radius: 99px; background: #eaf0ed; overflow: hidden; }
.category-fill { height: 100%; border-radius: inherit; background: var(--category-color); }
.classification-note { margin: 16px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.provider-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; }
.provider-name { overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.provider-value { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.provider-track { grid-column: 1 / -1; height: 7px; border-radius: 99px; background: #eaf0ed; overflow: hidden; }
.provider-fill { height: 100%; border-radius: inherit; background: var(--green); }
.chart-empty { height: 185px; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; }
.table-card { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: var(--shadow); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 13px 15px; background: #f4f7f5; color: #62716e; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .045em; white-space: nowrap; }
td { padding: 15px; border-top: 1px solid #edf0ef; vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover, tbody tr:focus { background: #f1f8f5; outline: none; }
tbody tr:focus-visible { box-shadow: inset 3px 0 0 var(--yellow); }
.amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.action-column { text-align: right; }
.detail-button { padding: 7px 10px; border: 1px solid #c8c8da; border-radius: 5px; background: white; color: var(--green); font-size: 11px; font-weight: 750; white-space: nowrap; }
.detail-button:hover, .detail-button:focus-visible { border-color: var(--green); background: var(--mint); outline: none; }
tbody tr:hover .detail-button { border-color: var(--green); }
.badge { display: inline-block; padding: 4px 8px; border-radius: 99px; background: var(--mint); color: var(--green-dark); font-size: 11px; font-weight: 750; }
.main-cell { display: block; font-weight: 680; color: var(--ink); white-space: nowrap; }
.sub-cell { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.table-card footer { display: flex; justify-content: space-between; padding: 12px 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.table-footer { align-items: center; }
.pagination { display: flex; align-items: center; gap: 10px; }
.pagination button { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--ink); }
.pagination button:hover:not(:disabled) { border-color: var(--green); background: var(--mint); }
.pagination button:disabled { opacity: .35; cursor: not-allowed; }
.pagination span { min-width: 82px; text-align: center; font-variant-numeric: tabular-nums; }
.empty-filter { padding: 38px; text-align: center; color: var(--muted); }
.intro { padding: 58px 8%; margin: 0 0 80px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; }
.intro p { max-width: 760px; margin: 0 auto; color: var(--muted); line-height: 1.75; }
.site-footer { display: flex; justify-content: space-between; gap: 20px; padding: 24px clamp(20px,5vw,72px); border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.detail-dialog { width: min(780px, calc(100% - 28px)); max-height: 88vh; padding: 0; border: 0; border-radius: 15px; color: var(--ink); box-shadow: 0 30px 90px rgba(10,30,27,.28); }
.detail-dialog::backdrop { background: rgba(10,30,27,.55); backdrop-filter: blur(3px); }
.dialog-header { position: sticky; top: 0; display: flex; align-items: flex-start; justify-content: space-between; padding: 23px 26px 19px; border-bottom: 1px solid var(--line); background: white; z-index: 1; }
.dialog-header h2 { margin: 7px 0 0; font-weight: 800; font-size: 27px; }
.dialog-header button { border: 0; background: transparent; color: var(--muted); font-size: 30px; line-height: 1; }
#detail-content { padding: 25px 26px 30px; }
.detail-section + .detail-section { margin-top: 28px; }
.detail-section h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--green); }
.data-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 30px; }
.data-item span { display: block; color: var(--muted); font-size: 12px; }
.data-item strong { display: block; margin-top: 3px; font-size: 14px; font-weight: 620; overflow-wrap: anywhere; }
.items-table { border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.items-table table { min-width: 560px; }
.items-table td { padding: 11px; }
.totals { width: min(330px, 100%); margin: 16px 0 0 auto; }
.total-line { display: flex; justify-content: space-between; padding: 6px 0; color: var(--muted); }
.total-line.final { margin-top: 5px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--ink); font-size: 18px; font-weight: 750; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 880px) {
  .toolbar { align-items: stretch; flex-direction: column; }
  .filter-group, .action-group { width: 100%; }
  .action-group { justify-content: flex-end; }
  .dashboard-primary { grid-template-columns: 1fr 1fr; }
  .adjustment-card { grid-column: 1 / -1; }
  .analytics-grid { grid-template-columns: 1fr; }
  .category-chart { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .site-header { height: 68px; padding: 0 17px; }
  .brand-logo { width: 138px; }
  .brand-divider, .brand-product { display: none; }
  .header-note { display: none; }
  main { width: min(100% - 28px, 1180px); }
  .hero { margin-top: 48px; }
  .hero p { font-size: 15px; }
  .workspace { margin-bottom: 50px; }
  .drop-zone { padding: 28px 16px; text-align: center; }
  .privacy-message { align-items: flex-start; text-align: left; }
  .toolbar { padding: 10px; }
  .filter-group { flex-wrap: wrap; }
  .filter-group .search-field { flex-basis: 100%; }
  .filter-group label:not(.search-field) { flex: 1; width: calc(50% - 5px); }
  .action-group { align-items: stretch; display: grid; grid-template-columns: 1fr 1fr; }
  .secondary-button { justify-content: center; }
  .text-button { grid-column: 1 / -1; height: 34px; }
  .export-menu summary { justify-content: center; }
  .export-options { left: 0; right: auto; width: min(260px, calc(100vw - 48px)); }
  .expense-dashboard { padding: 18px 14px; }
  .dashboard-heading { align-items: start; flex-direction: column; gap: 8px; }
  .dashboard-heading p { text-align: left; }
  .dashboard-primary { grid-template-columns: 1fr; }
  .adjustment-card { grid-column: auto; }
  .dashboard-primary article { min-height: auto; }
  .dashboard-meta { align-items: flex-start; flex-direction: column; gap: 5px; }
  .dashboard-meta span + span::before { display: none; }
  .table-hint { display: none; }
  .intro { padding: 48px 5%; }
  .site-footer { flex-direction: column; }
  .data-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
