:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #17212f;
  --muted: #6b7686;
  --line: #e3e7ee;
  --navy: #1f3a5f;
  --accent: #e35f1c;
  --good: #1a7f4b;
  --bad: #c0392b;
  --warn-bg: #fff4e5;
  --row-hover: #f2f5fa;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 "IBM Plex Sans", system-ui, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
h2 { font-size: 15px; margin: 0; font-weight: 600; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; background: var(--navy); color: #fff; }
.topbar .muted { color: #c8d3e3; }
.topbar-right { display: flex; gap: 16px; align-items: center; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand small { display: block; font-size: 12px; opacity: .75; font-weight: 400; }
.brand b { font-size: 16px; letter-spacing: .2px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.powered { font-size: 12px; opacity: .85; }
.powered b { color: var(--accent); }
.banner { background: var(--warn-bg); color: #8a4b00; padding: 8px 24px; font-size: 13px; border-bottom: 1px solid #f3d9b1; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 16px 24px 4px; }
.presets { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.presets button { border: 0; background: none; padding: 7px 12px; cursor: pointer; font: inherit; color: var(--ink); border-right: 1px solid var(--line); }
.presets button:last-child { border-right: 0; }
.presets button.active { background: var(--navy); color: #fff; }
.dates { display: flex; gap: 6px; align-items: center; }
.dates input { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
#excel { margin-left: auto; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 7px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #c4ccd8; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.btn:disabled { opacity: .6; cursor: wait; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; padding: 12px 24px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .sub .pos { color: var(--good); } .kpi .sub .neg { color: var(--bad); }

.tabs { display: flex; gap: 4px; padding: 8px 24px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--navy); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--line); color: var(--ink); font-size: 11px; margin-left: 4px; }
.badge.warn { background: var(--accent); color: #fff; }
.badge:empty { display: none; }

main { padding: 16px 24px 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.grid2 .card { margin-bottom: 0; } .grid2 { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: right; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child { text-align: left; }
td { padding: 6px 10px; border-bottom: 1px solid #f0f2f6; text-align: right; white-space: nowrap; }
td:first-child { text-align: left; white-space: normal; }
table.list th, table.list td { text-align: left; }
table.list td.num, table.list th.num { text-align: right; }
tr.group td { font-weight: 600; background: #fafbfd; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
tr.cat td:first-child { padding-left: 26px; }
tr.item td { font-size: 12.5px; color: #3b4656; background: #fcfcfe; }
tr.item td:first-child { padding-left: 44px; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--row-hover); }
tr.warn td:first-child { color: var(--accent); font-weight: 600; }
.caret { display: inline-block; width: 14px; color: var(--muted); transition: transform .15s; }
tr.open .caret { transform: rotate(90deg); }
.pos { color: var(--good); } .neg { color: var(--bad); }
td.sep, th.sep { border-left: 1px solid var(--line); }

.aging { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 16px; }
.aging div { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.aging div small { color: var(--muted); display: block; font-size: 12px; }
.aging div b { font-size: 17px; font-variant-numeric: tabular-nums; }
.aging div.late b { color: var(--bad); }
.pill { font-size: 11px; padding: 2px 7px; border-radius: 9px; background: var(--line); }
.pill.late { background: #fde8e6; color: var(--bad); }
select, input[type=text] { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; max-width: 220px; }

.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy), #0e1c30); padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); }
.brand.big { margin-bottom: 8px; }
.login .powered { text-align: center; color: var(--muted); margin: 0; }
.error { color: var(--bad); margin: 0; min-height: 1em; font-size: 13px; }

dialog { border: 0; border-radius: var(--radius); padding: 22px; width: min(760px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 25, 40, .45); }
dialog h3 { margin: 0 0 4px; }
dialog form { text-align: right; margin-top: 16px; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; margin: 14px 0; font-size: 13px; }
.meta small { display: block; color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 10; max-width: 90vw; }

@media (max-width: 700px) {
  .topbar, .toolbar, .kpis, main, .tabs { padding-left: 16px; padding-right: 16px; }
  .powered, #userName { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .aging { grid-template-columns: repeat(2, 1fr); }
  #excel { margin-left: 0; }
}
.dates { flex-wrap: wrap; }
@media (max-width: 700px) {
  .dates input { flex: 1; min-width: 0; }
  .presets button { padding: 7px 8px; }
}
.grid2 > * { min-width: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.acc-line { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid #f0f2f6; }
.acc-line:last-child { border-bottom: 0; margin-bottom: 10px; }
.notice { background: var(--warn-bg); color: #8a4b00; border-radius: 6px; padding: 6px 10px; font-size: 12.5px; margin: 6px 0 10px; }
.week-label { font-size: 12px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; white-space: nowrap; }
.est { color: var(--muted); font-size: 11px; margin-left: 4px; }
tr.part td { font-size: 12.5px; color: var(--muted); }
tr.part td:first-child { padding-left: 44px; }
tr.planline td { font-size: 12.5px; color: var(--muted); font-style: italic; background: #fcfcfe; }
tr.planline td:first-child { padding-left: 44px; }
.ic-share { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.ic-share > div { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.ic-share small { display: block; color: var(--muted); font-size: 12px; }
.ic-share b { font-size: 20px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 8px; position: relative; overflow: hidden; }
.bar span { position: absolute; inset: 0 auto 0 0; background: var(--navy); }
.bar i { position: absolute; top: -2px; bottom: -2px; left: 50%; width: 2px; background: var(--accent); }
.form-grid { text-align: left; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; margin: 12px 0; }
.form-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.form-grid input, .form-grid select { font: inherit; color: var(--ink); padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; max-width: none; }
.pdf-frame { width: 100%; height: 360px; border: 1px solid var(--line); border-radius: 8px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.btn.danger { color: var(--bad); border-color: #f0c9c4; }
/* source of the figures: own calculation (default) or the books */
.source-label { font-size: 12px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted); white-space: nowrap; }
.source-label.ledger { color: var(--navy); border-color: var(--navy); font-weight: 500; }
.source-label.warn { background: var(--warn-bg); color: #8a4b00; border-color: #f3d9b1; }
#sourceToggle { display: inline-flex; margin-top: 4px; }
#sourceToggle button:disabled { cursor: not-allowed; opacity: .6; }
