* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--df-ink); background: var(--df-white); font: 15px/1.55 var(--df-font-body); }
a { color: var(--df-brand-hover); text-underline-offset: .2em; }
button, input, select { font: inherit; }
button { cursor: pointer; color: var(--df-brand-hover); border: 1px solid var(--df-input-border); background: white; border-radius: 4px; min-height: 44px; padding: 8px 14px; }
button[type=submit] { color: white; background: var(--df-brand-hover); border-color: var(--df-brand-hover); font-weight: 650; }
button[disabled] { cursor: wait; opacity: .65; }
input, select { color: inherit; border: 1px solid var(--df-input-border); border-radius: 4px; background: white; min-height: 44px; padding: 7px 10px; max-width: 100%; }
label { display: grid; gap: 4px; font-weight: 600; min-width: 0; }
:focus-visible { outline: 3px solid var(--df-brand); outline-offset: 3px; }
.skip { position: absolute; top: -80px; padding: 10px; background: white; }
.skip:focus { top: 0; z-index: 2; }
.site-header { padding: 14px max(18px, calc((100% - 1320px)/2)); display: flex; gap: 16px; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--df-rule); }
.site-header > a:last-child { font-weight: 550; font-size: 14px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-size: 17px; color: var(--df-ink); font-weight: 750; text-decoration: none; }
main { max-width: 1360px; margin: auto; padding: 28px 20px 48px; display: grid; grid-template-columns: 204px minmax(0,1fr); column-gap: 32px; align-items: start; }
.page-head { grid-column: 1; grid-row: 1; margin-bottom: 18px; padding: 0 4px; }
.page-head h1 { font-size: 23px; letter-spacing: -.025em; }
h1,h2,h3 { line-height: 1.2; margin: 0; }
h2 { font-size: clamp(27px,4vw,38px); font-weight: 760; letter-spacing: -.03em; }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 6px 0 12px; }
.page-head p, .description, .empty, #status { color: var(--df-muted); }
.page-head p { font-size: 13px; margin-bottom: 0; }
nav { grid-column: 1; grid-row: 2 / span 3; align-self: start; display: grid; gap: 4px; border-top: 1px solid var(--df-rule); padding-top: 10px; }
nav a { min-height: 44px; display: flex; align-items: center; padding: 8px 10px; color: var(--df-muted); text-decoration: none; border-left: 3px solid transparent; border-radius: 4px; line-height: 1.3; }
nav a[aria-current=page] { color: var(--df-brand-hover); border-color: var(--df-brand); background: #eef4ff; font-weight: 700; }
nav a:hover { background: var(--df-surface); }
form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 0 0 16px; }
#range { grid-column: 2; grid-row: 1; padding: 0 0 15px; margin: 0; border-bottom: 1px solid var(--df-rule); }
#range label { font-size: 13px; }
#status { grid-column: 2; grid-row: 2; font-size: 13px; margin: 10px 0; }
#report { grid-column: 2; grid-row: 3; width: 100%; }
.report-heading { display: flex; gap: 8px 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 8px 0 18px; }
.report-heading .meta { margin: 0; font-size: 13px; }
#report > section { margin: 26px 0; }
#report > section > h3 { margin-bottom: 8px; }
#report > section > h3 + .table-scroll { margin-top: 12px; }
.cards { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.tile { border: 1px solid var(--df-rule); border-radius: 5px; padding: 16px; background: var(--df-surface); }
.tile > span, .tile > a { font-weight: 640; }
.tile strong { display: block; font-size: 25px; line-height: 1.25; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile p { margin: 4px 0 0; color: var(--df-muted); font-size: 13px; }
.finance-summary { display: grid; grid-template-columns: minmax(220px, .84fr) minmax(0, 1.6fr); gap: 12px; }
#report > .finance-summary { margin: 0; }
.finance-totals .cards { grid-template-columns: repeat(2,minmax(0, 1fr)); height: 100%; }
.profit { border-radius: 5px; padding: clamp(16px, 3vw, 28px); background: var(--df-ink); color: white; display: flex; flex-direction: column; justify-content: center; }
.profit h3 { font-size: 16px; font-weight: 650; }
.profit strong { margin-top: 4px; font-size: clamp(34px,4vw,55px); font-weight: 750; line-height: 1.13; font-variant-numeric: tabular-nums; }
.profit p { color: #dbe7ff; margin: 7px 0 0; }
.finance-method { border: 1px solid var(--df-rule); border-radius: 5px; padding: 12px 16px; margin-top: 12px; }
.finance-method p { margin: 2px 0; color: var(--df-muted); font-size: 13px; }
.finance-chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(28px,1fr); gap: min(2.2vw,20px); padding: 16px 16px 8px; border: 1px solid var(--df-rule); border-radius: 5px; overflow-x: auto; }
.month-col { display: flex; flex-direction: column; gap: 4px; text-align: center; color: var(--df-muted); font-size: 12px; }
.month-bars { position: relative; display: flex; align-items: end; justify-content: center; gap: 3px; height: 118px; }
.month-bars::after { content: ""; position: absolute; inset-inline: 0; bottom: var(--zero,0%); height: 1px; background: var(--df-rule); }
.month-bars > span { position: relative; flex: 1; max-width: 32px; border-radius: 3px 3px 0 0; }
.chart-legend { display: flex; padding: 0; list-style: none; gap: 16px; margin: 3px 0 8px; color: var(--df-muted); font-size: 13px; }
.chart-legend li::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
.month-bars .is-revenue, .chart-legend .is-revenue::before { background: var(--df-brand-hover); }
.month-bars .is-expense, .chart-legend .is-expense::before { background: #667b9a; }
.table-scroll { overflow-x: auto; border: 1px solid var(--df-rule); border-radius: 5px; }
.table-scroll + .table-scroll { margin-top: 18px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; text-align: left; }
caption { text-align: left; padding: 12px; font-weight: 700; }
th,td { padding: 10px 12px; border-bottom: 1px solid var(--df-rule); vertical-align: top; overflow-wrap: anywhere; }
th { background: var(--df-surface); font-weight: 650; overflow-wrap: normal; }
tbody tr:last-child td { border-bottom: 0; }
td.num,th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }
.error { color: var(--df-error) !important; }
details { border: 1px solid var(--df-rule); border-radius: 5px; margin: 10px 0; padding: 6px 14px; }
summary { cursor: pointer; min-height: 44px; padding: 10px 0; font-weight: 650; }
.meta { margin: 8px 0 14px; color: var(--df-muted); }
.funnel { margin: 0 0 16px; padding: 0; list-style: none; max-width: 600px; }
.funnel li { display: grid; grid-template-columns: minmax(120px,2fr) minmax(70px,3fr) 32px; gap: 10px; align-items: center; padding: 4px 0; }
.funnel meter { width: 100%; height: 18px; }
.funnel meter::-webkit-meter-bar { background: var(--df-surface); border-color: var(--df-rule); }
.funnel meter::-webkit-meter-optimum-value { background: var(--df-brand); }
.funnel strong { text-align: right; font-variant-numeric: tabular-nums; }
.funnel-exit { display: block; color: var(--df-muted); }
.template-toolbar,.template-views { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.template-toolbar { justify-content: space-between; border-bottom: 1px solid var(--df-rule); }
.template-toolbar a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 650; }
.template-views a { padding: 0 12px; color: var(--df-muted); text-decoration: none; border-bottom: 3px solid transparent; }
.template-views a[aria-current=page] { border-color: var(--df-brand); color: var(--df-brand-hover); }
.template-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 18px 0 12px; }
.template-controls > label { grid-template-columns: minmax(0,1fr); }
.template-controls :is(input,select) { min-width: 0; width: 100%; }
.template-controls > label:first-child { flex: 1 1 230px; }
.template-controls > label:not(:first-child) { flex: 0 1 250px; }
.template-count:empty { margin: 0; }
.template-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--df-rule); }
.template-list:empty { border: 0; }
.template-list li { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: start; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--df-rule); }
.template-list strong { overflow-wrap: anywhere; }
.template-detail,.template-description { color: var(--df-muted); font-size: 14px; }
.template-detail { display: block; margin-top: 2px; }
.template-description { margin: 5px 0 0; }
.template-list a { display: inline-flex; align-items: center; min-height: 44px; }
.template-total { font-size: 28px; font-weight: 750; line-height: 1.3; }
dialog { max-width: min(480px,calc(100% - 24px)); color: var(--df-ink); border: 1px solid var(--df-input-border); border-radius: 5px; padding: 20px; }
dialog::backdrop { background: #0f172a88; }
@media(max-width: 820px) {
  main { display: block; padding: 18px 16px 40px; }
  .page-head { padding: 0; }
  nav { display: flex; flex-wrap: wrap; padding: 8px 0; gap: 4px; border-bottom: 1px solid var(--df-rule); margin: 0 0 14px; }
  nav a { padding: 6px 10px; }
  .site-header { padding: 10px 16px; }
}
@media(max-width: 520px) {
  .site-header > a:last-child { font-size: 13px; }
  nav a { font-size: 13px; }
  .cards { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .finance-summary { grid-template-columns: 1fr; }
  .tile { padding: 10px; }
  .tile strong { font-size: 22px; }
  th,td { padding: 8px; }
  th { font-size: 13px; }
  form label { flex: 1 1 124px; }
  #range label:first-child { flex-basis: 100%; }
  .finance-chart { grid-auto-columns: 32px; }
  .template-controls > label:first-child,.template-controls > label:last-child { flex-basis: 100%; }
  .template-list li { grid-template-columns: minmax(0,1fr); gap: 0; }
}
