/* DLC's shared interface layer. Financial logic and brand colors live in index.html. */
:root {
  --font-display: 'Manrope', sans-serif;
  --font-mono: 'Inter', sans-serif;
  --radius: 12px;
  --radius2: 16px;
  --shadow: 0 8px 32px rgba(26,30,46,.06);
}
body { background: var(--bg2); font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, [tabindex] { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent2); outline-offset: 3px; }
#sidebar { width: 232px; min-width: 232px; padding: 10px 12px; }
.sidebar-logo { padding: 22px 12px 28px; display: flex; align-items: center; gap: 12px; border: 0; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; flex-shrink: 0; border-radius: 13px; background: var(--accent); color: var(--on-accent); font: 800 13px var(--font-display); letter-spacing: -1px; }
.sidebar-logo .company { font-size: 16px; font-weight: 800; line-height: 1.4; }
.sidebar-logo .tagline { font-size: 12px; letter-spacing: 0; text-transform: none; margin-top: 2px; }
.sidebar-section { padding: 8px 0 12px; }
.sidebar-section-label { font-size: 12px; font-weight: 500; text-transform: none; letter-spacing: .1px; padding: 0 14px; margin-bottom: 9px; }
.nav-item { min-height: 46px; padding: 12px 16px; margin: 4px 0; gap: 14px; border: 0; font-size: 15px; font-weight: 600; }
.nav-item svg { width: 21px; height: 21px; stroke-width: 1.8; opacity: .8; }
.nav-item.active { background: var(--accent-dim2); color: var(--text); border-radius: 30px; font-weight: 650; }
.nav-item.active svg { color: var(--accent2); opacity: 1; }
.sidebar-footer { padding: 18px 6px 10px; }
.month-badge { padding: 12px; font-size: 13px; background: var(--bg); border: 0; }
.month-badge strong { display: block; font-size: 15px; color: var(--text); margin-top: 3px; }
#main { min-width: 0; }
#topbar { min-height: 76px; padding: 16px 36px; background: var(--topbar-bg); gap: 16px; }
.topbar-title { font-family: var(--font-display); font-size: 19px; font-weight: 700; }
.topbar-title::before { display: none; content: 'Workspace /'; color: var(--text3); margin-right: 10px; font-weight: 400; }
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
.account-role { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text3); text-transform: capitalize; padding-right: 10px; }
.account-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--bg3); color: var(--text2); font-weight: 600; }
#content { width: 100%; max-width: 1680px; margin: 0 auto; padding: 38px 40px 56px; }
.section-header { margin-bottom: 26px; gap: 22px; flex-wrap: wrap; }
.section-title { font-size: 28px; font-weight: 750; letter-spacing: -1px; line-height: 1.25; }
.section-sub { margin-top: 8px; font-size: 14px; color: var(--text3); }
.dashboard-heading .section-title { font-size: 32px; }
.dashboard-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.month-control { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.month-control .btn { border: 0; padding: 5px 9px; min-height: 32px; }
.month-control input { width: 152px; border: 0; background: transparent; padding: 4px; min-height: 32px; font-size: 13px; }
.btn { border-radius: 999px; min-height: 40px; padding: 10px 16px; font-size: 14px; line-height: 1.2; gap: 8px; font-weight: 550; justify-content: center; align-items: center; vertical-align: middle; flex-shrink: 0; }
.btn-sm { min-height: 36px; padding: 8px 14px; font-size: 13px; }
.btn-primary { color: var(--on-accent); box-shadow: none; }
.btn-secondary { background: var(--surface); border-color: var(--border); }
.btn-ghost { border-color: transparent; }
.card { padding: 24px; box-shadow: none; min-width: 0; }
.card-title { font-size: 16px; font-weight: 750; letter-spacing: -.3px; }
.card-header { gap: 12px; }
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 16px; }
.kpi-card { padding: 22px; box-shadow: none; }
.kpi-card::before { display: none; }
.kpi-card.kpi-clickable:hover { background: var(--accent-dim); }
.kpi-card { transition: border-color .18s, box-shadow .18s, transform .18s; }
.kpi-label { font-size: 14px; font-weight: 500; text-transform: none; letter-spacing: 0; margin-bottom: 13px; }
.kpi-value { font-size: 29px; letter-spacing: -1px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.kpi-sub { font-size: 12px; line-height: 1.6; margin-top: 9px; }
.dashboard-kpis { grid-template-columns: repeat(5,minmax(0,1fr)); gap: 0; border: 1px solid var(--border); border-radius: 16px; padding: 26px 0; margin-bottom: 28px; }
.dashboard-kpis .kpi-card { border: 0; border-right: 1px solid var(--border); border-radius: 0; padding: 4px 22px; background: transparent; }
.dashboard-kpis .kpi-card:last-child { border-right: 0; }
.dashboard-kpis .kpi-value { font-size: clamp(23px,2.1vw,34px); color: var(--text); font-weight: 650; letter-spacing: -1.2px; }
.dashboard-kpis .kpi-card:first-child .kpi-value { color: var(--accent2); }
.dashboard-kpis .kpi-value.red { color: var(--red); }
.dashboard-kpis .kpi-label { margin-bottom: 12px; }
.dashboard-charts { grid-template-columns: minmax(0,1.7fr) minmax(0,1fr); gap: 20px; }
.chart-subtitle { font-size: 12px; color: var(--text3); margin-top: 5px; }
.metric-details { margin: 24px 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.metric-details-heading { padding: 18px 22px; font-size: 14px; font-weight: 600; }
.metric-details-heading span { font-weight: 400; color: var(--text3); margin-left: 12px; font-size: 12px; }
.metric-details .kpi-grid { grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 0; padding: 0 6px 12px; margin-bottom: 0; }
.metric-details .kpi-card { background: transparent; border: 0; border-radius: 12px; padding: 18px; }
.metric-details .kpi-value { font-size: 24px; }
.grid-2, .grid-3 { gap: 20px; }
.table-wrap { background: var(--surface); }
table { font-size: 14px; font-variant-numeric: tabular-nums; }
thead th { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; padding: 14px 18px; background: var(--surface); }
tbody td { padding: 16px 18px; }
tbody tr { border-color: var(--bg4); }
tbody tr:hover { background: var(--accent-dim); }
.badge { font-size: 12px; border-radius: 6px; text-transform: none; letter-spacing: 0; padding: 4px 9px; font-weight: 550; }
.badge-green { color: var(--badge-green-text); }.badge-accent { color: var(--badge-accent-text); }.badge-yellow { color: var(--badge-yellow-text); }.badge-red { color: var(--badge-red-text); }
label { font-size: 14px; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text2); }
input, select, textarea { background: var(--surface); font-size: 14px; border-color: var(--border); min-height: 42px; }
input:focus, select:focus, textarea:focus { background: var(--surface); box-shadow: 0 0 0 3px var(--accent-dim2); }
input[type=checkbox], input[type=radio] { min-height: auto; }
.form-hint { font-size: 12px; line-height: 1.6; }
.modal { border-radius: 20px; box-shadow: 0 24px 80px rgba(26,30,46,.2); }
.modal-title { font-size: 22px; letter-spacing: -.5px; }
.tabs { gap: 5px; }
.tab { font-size: 14px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.alert { border-radius: 12px; font-size: 14px; padding: 14px 18px; }
.empty-state { padding: 48px 24px; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-brand { background: var(--brand-panel); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-brand-name { display: flex; gap: 12px; align-items: center; font-weight: 600; }
.login-brand h1 { font: 600 clamp(36px,4vw,62px)/1.15 var(--font-display); letter-spacing: -2px; max-width: 580px; margin: 60px 0 24px; }
.login-brand h1 span { color: var(--accent); }
.login-brand p { color: #cdd2db; max-width: 370px; font-size: 16px; line-height: 1.8; }
.login-brand-footer { font-size: 13px; color: #cdd2db; margin-top: 56px; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--surface); }
.login-form { max-width: 380px; width: 100%; }
.login-form h2 { font: 750 30px var(--font-display); letter-spacing: -.8px; }
.login-form > p { color: var(--text3); font-size: 14px; margin: 10px 0 32px; }
.login-form .form-grid { gap: 20px; }.login-form .btn { margin-top: 6px; min-height: 46px; }
body.login-mode #content { padding: 0; max-width: none; }
.preview-notice { font-size: 12px; color: var(--text3); }
@media (min-width: 769px) and (max-width: 1200px) {
  #sidebar { width: 216px; min-width: 216px; padding-inline: 8px; }
  #content { padding: 28px 24px; } #topbar { padding-inline: 24px; }
  .dashboard-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 24px 0; }
  .dashboard-kpis .kpi-card:nth-child(2) { border-right: 0; }
}
@media (max-width: 1000px) { .dashboard-charts { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  #sidebar { width: 248px; min-width: 248px; }
  #content { padding: 24px 16px; } #topbar { padding: 12px 16px; min-height: 64px; }
  .topbar-title::before { display: none; }.account-role { display: none; }
  .dashboard-heading .section-title { font-size: 28px; }
  .dashboard-tools { width: 100%; }.dashboard-tools > .btn { flex: 1; }
  .dashboard-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 24px 0; padding: 20px 0; }
  .dashboard-kpis .kpi-card { padding: 2px 16px; }
  .dashboard-kpis .kpi-card:nth-child(2) { border-right: 0; }
  .kpi-card { padding: 17px; }.dashboard-kpis .kpi-value { font-size: 26px; }
  .card { padding: 20px; }.section-title { font-size: 25px; }
  .login-layout { grid-template-columns: 1fr; }.login-brand { padding: 28px; }
  .login-brand h1 { font-size: 32px; margin: 30px 0 0; }.login-brand p, .login-brand-footer { display: none; }
  .login-panel { padding: 36px 24px; }.metric-details-heading span { display: none; }
}
@media (max-width: 420px) {
  .dashboard-kpis { grid-template-columns: 1fr; }
  .dashboard-kpis .kpi-card { border-right: 0; }
  .month-control { width: 100%; justify-content: space-between; }
  .topbar-actions { gap: 5px; }.kpi-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

/* Ledger filtering lives with the entries, outside the financial summary. */
.ledger-summary-card { background: var(--surface); }
.ledger-summary .kpi-label { margin-bottom: 8px; }
.ledger-list-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 24px 0 20px; }
.ledger-search { display: flex; gap: 12px; flex: 1 1 340px; }
.ledger-search input { flex: 1; width: 180px; min-width: 0; }
.ledger-search select { flex: 0 1 190px; width: 190px; min-width: 0; }
.ledger-list-toolbar input, .ledger-list-toolbar select, .ledger-list-toolbar > .ledger-filter-actions > .btn, .ledger-date-picker > summary { height: 44px; min-height: 44px; }
.ledger-date-picker { position: relative; flex: 0 1 auto; }
.ledger-date-picker > summary { list-style: none; font-size: 13px; font-weight: 500; cursor: pointer; padding: 10px 14px; border-radius: 12px; white-space: normal; }
.ledger-date-picker > summary::-webkit-details-marker { display: none; }
.ledger-date-picker[open] > summary { border-color: var(--accent2); background: var(--accent-dim); }
.date-picker-chevron { margin-left: 8px; }
.ledger-date-popover { position: absolute; top: calc(100% + 8px); right: 0; z-index: 80; width: 390px; max-width: calc(100vw - 40px); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 12px 40px rgba(26,30,46,.14); padding: 20px; }
.ledger-date-popover-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; }
.ledger-date-range { display: grid; grid-template-columns: 28px minmax(0,1fr) minmax(0,1fr) 28px; align-items: end; gap: 8px; }
.ledger-date-label { display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--text3); }
.ledger-date-range input { width: 100%; min-width: 0; font-size: 13px; padding: 8px; border-radius: 8px; }
.ledger-date-range .ledger-month-step { padding: 0; width: 28px; height: 44px; min-height: 44px; border: 0; background: transparent; display: grid; place-items: center; }
.ledger-month-step span { font: 26px/1 Arial, sans-serif; }
.ledger-date-popover-footer { display: flex; justify-content: flex-end; margin-top: 18px; }
.ledger-filter-actions { display: flex; gap: 8px; align-items: center; }
.ledger-filter-actions .btn { margin: 0; }
@media (max-width: 768px) {
  .ledger-search { flex-basis: 100%; }
  .ledger-date-picker { flex: 1 1 auto; }
  .ledger-date-popover { right: auto; left: 0; }
  .ledger-date-picker > summary { justify-content: center; }
}
@media (max-width: 420px) {
  .ledger-search { flex-direction: column; }
  .ledger-search input, .ledger-search select { width: 100%; flex: auto; }
  .ledger-filter-actions { width: 100%; }
  .ledger-filter-actions .btn { flex: 1; }
  .ledger-date-range { gap: 4px; grid-template-columns: 20px minmax(0,1fr) minmax(0,1fr) 20px; }
  .ledger-date-range .ledger-month-step { width: 20px; }
}

/* Shared button rhythm across page actions, cards, tables and dialogs. */
.btn svg { width: 16px; height: 16px; flex: 0 0 16px; display: block; margin: 0; }
.btn-icon { width: 40px; height: 40px; padding: 0; }
.btn-icon.btn-sm { width: 36px; height: 36px; padding: 0; }
.topbar-actions { gap: 20px; min-width: 0; }
.topbar-page-actions, .topbar-account-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar-page-actions:empty { display: none; }
.topbar-actions .btn { min-height: 40px; padding: 10px 16px; }
.topbar-account-actions { max-width: 100%; }
.topbar-account-actions .preview-notice { line-height: 1.5; }
.card-header { align-items: center; gap: 16px; }
.card-header > .btn, .section-header .btn { min-height: 40px; }
.modal-footer { align-items: center; flex-wrap: wrap; gap: 12px; padding: 20px 24px; }
.modal-footer .btn { min-height: 44px; padding-inline: 20px; }
/* Legacy inline flex groups keep their layout while sharing alignment and gaps. */
#content div[style*="display:flex"]:has(> .btn),
.modal div[style*="display:flex"]:has(> .btn) { align-items: center !important; gap: 10px !important; flex-wrap: wrap; }
#content .card-header > div:first-child { min-width: 0; }
.modal-close { align-items: center; justify-content: center; width: 36px; height: 36px; flex-shrink: 0; }
@media (max-width: 1100px) {
  #topbar { flex-wrap: wrap; }
  .topbar-actions { flex: 1 1 auto; row-gap: 10px; }
  .topbar-account-actions { margin-left: auto; }
}
@media (max-width: 768px) {
  .topbar-actions { width: 100%; justify-content: flex-start; gap: 12px; }
  .topbar-page-actions { gap: 8px; }
  .topbar-account-actions { margin-left: 0; }
  .modal-footer { gap: 10px; padding: 16px 20px; }
  .card-header { flex-wrap: wrap; }
}

/* Keep these three dashboard summaries compact regardless of record count. */
.dashboard-detail-cards > .card { height: 320px; display: flex; flex-direction: column; overflow: hidden; }
.dashboard-detail-cards > .card > .card-title { flex: 0 0 auto; }
.dashboard-card-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; scrollbar-gutter: stable; padding-right: 6px; }
.dashboard-card-scroll:focus-visible { outline-offset: -2px; border-radius: 6px; }
.dashboard-card-scroll .table-wrap { overflow: visible; }
.dashboard-card-scroll thead th { position: sticky; top: 0; background: var(--bg2); z-index: 1; }
.dashboard-card-scroll tbody td { padding: 12px 14px; }
@media (max-width: 768px) {
  .dashboard-detail-cards > .card { height: 300px; }
}
