:root {
  color-scheme: light;
  --paper: #f5f6fa;
  --white: #fff;
  --ink: #172037;
  --muted: #505d74;
  --line: #dce2ee;
  --accent: #4939b4;
  --accent-dark: #352485;
  --accent-light: #edeafd;
  --green: #146049;
  --red: #932c42;
  --amber: #815309;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 3px solid #7969dc; outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
#sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--white); border-right: 1px solid var(--line); padding: 24px 14px 16px; overflow: auto; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; color: var(--ink); text-decoration: none; }
.brand b { display: block; font-size: 1.23rem; font-weight: 790; letter-spacing: -.03em; }
.brand small { color: var(--muted); font-size: .75rem; }
.logo { background: var(--accent); color: var(--white); border-radius: 10px; width: 38px; height: 38px; display: grid; place-items: center; font-size: 1.4rem; }
.nav-group { font-size: .68rem; color: var(--muted); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; padding: 15px 10px 7px; }
nav a, .backup button { min-height: 42px; padding: 9px 10px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 8px; text-align: left; color: var(--muted); text-decoration: none; font-size: .89rem; background: transparent; }
nav a span { width: 19px; text-align: center; font-size: 1.06rem; }
nav a:hover, .backup button:hover { background: var(--paper); color: var(--ink); }
nav a[aria-current] { color: var(--accent-dark); background: var(--accent-light); font-weight: 700; }
.backup { margin-top: auto; padding-top: 24px; }
.mobile-bar { display: none; }
main { padding: 31px clamp(16px, 3vw, 44px) 50px; max-width: 1610px; width: 100%; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 24px; }
h1 { font-size: clamp(1.62rem, 3vw, 2.25rem); letter-spacing: -.05em; line-height: 1.16; }
h2 { font-size: 1.1rem; letter-spacing: -.02em; }
h3 { font-size: 1rem; }
.page-head p, .hint, .muted, .detail { color: var(--muted); }
.page-head p { margin-top: 6px; font-size: .91rem; }
.controls, .actions, .toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.controls { align-items: end; }
label { display: grid; gap: 5px; font-weight: 650; font-size: .8rem; color: var(--muted); }
input, select, textarea { min-width: 0; width: 100%; min-height: 39px; border: 1px solid #cbd2e2; background: white; color: var(--ink); border-radius: 7px; padding: 7px 9px; font-size: .91rem; font-weight: 450; }
textarea { min-height: 82px; resize: vertical; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 39px; padding: 7px 12px; background: var(--white); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; font-size: .84rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.button:hover { border-color: var(--accent); color: var(--accent-dark); }
.button.primary { color: var(--white); background: var(--accent); border-color: var(--accent); }
.button.primary:hover { background: var(--accent-dark); }
.button.danger { color: var(--red); }
.button.mini { min-height: 31px; padding: 5px 8px; font-size: .77rem; }
.notice, .inline-error { background: #e5f4eb; color: var(--green); border-radius: 7px; padding: 11px 14px; margin-bottom: 15px; font-size: .89rem; }
.notice.error, .inline-error { background: #fcebf0; color: var(--red); }
.notice .button { margin-left: 9px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 15px; }
.kpi, .panel, .owner-card { border: 1px solid var(--line); background: var(--white); border-radius: 12px; }
.kpi { padding: 16px; min-width: 0; }
.kpi strong { display: block; margin: 7px 0; font-size: clamp(1.15rem, 2.2vw, 1.85rem); letter-spacing: -.055em; overflow-wrap: anywhere; }
.kpi .hint { font-size: .77rem; }
.kpi-label { color: var(--muted); font-size: .81rem; font-weight: 650; }
.panel { min-width: 0; margin-bottom: 15px; overflow: hidden; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 9px; padding: 14px 16px; }
.panel-head p { margin-top: 4px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 15px; }
.bars { padding: 4px 16px 17px; display: grid; gap: 12px; }
.bar-label { display: flex; justify-content: space-between; gap: 6px; font-size: .83rem; }
.bar-label strong { overflow-wrap: anywhere; }
progress { appearance: none; display: block; width: 100%; height: 6px; margin-top: 6px; border: 0; border-radius: 6px; background: #e9e7f3; }
progress::-webkit-progress-bar { background: #e9e7f3; border-radius: 6px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 6px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 6px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .84rem; }
th, td { padding: 10px 13px; vertical-align: middle; border-top: 1px solid #e9edf4; }
th { background: #f9faff; color: var(--muted); font-size: .74rem; white-space: nowrap; }
td { overflow-wrap: anywhere; }
.detail { display: block; margin-top: 3px; font-size: .76rem; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.badge { display: inline-block; border-radius: 20px; padding: 4px 8px; background: #edf0f9; color: #3d4b66; white-space: nowrap; font-size: .72rem; font-weight: 750; }
.badge.good { color: var(--green); background: #e3f4ed; }
.badge.attention { color: var(--amber); background: #fbf0d7; }
.badge.alert { color: var(--red); background: #fbe7ed; }
.empty { padding: 20px 16px; color: var(--muted); font-size: .88rem; }
.toolbar { margin-bottom: 13px; }
.toolbar input, .toolbar select { width: auto; max-width: 100%; min-width: 148px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 13px; }
.owner-card { padding: 16px; display: grid; gap: 10px; }
.owner-card p { overflow-wrap: anywhere; }
.owner-card .hint { font-size: .82rem; }
.owner-card .actions { margin-top: auto; }
dialog { width: min(600px, calc(100% - 24px)); max-height: calc(100% - 24px); color: var(--ink); border: 1px solid var(--line); border-radius: 13px; padding: 0; }
dialog::backdrop { background: #151b37aa; }
.dialog-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 14px 17px; border-bottom: 1px solid var(--line); }
#dialog-body { padding: 16px 17px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.full { grid-column: 1 / -1; }
.form-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; flex-wrap: wrap; }
.inline-error { margin: 0 0 10px; }
@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 720px) {
  body { display: block; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 9px 16px; background: white; border-bottom: 1px solid var(--line); }
  #sidebar { display: none; position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  #sidebar.open { display: flex; }
  #sidebar .brand { display: none; }
  .backup { padding: 10px 0 0; }
  main { padding-top: 21px; }
  .page-head { align-items: start; flex-direction: column; gap: 13px; }
}
@media (max-width: 420px) {
  .form-grid { grid-template-columns: 1fr; }
  .kpi { padding: 12px; }
}
.padded { padding: 20px; }
.form-panel { max-width: 720px; }
.form-panel form p { margin: 16px 0; }
.form-panel label { margin-bottom: 6px; }
.form-panel .helptext { display: block; color: var(--muted); font-size: .8rem; margin-top: 5px; }
.form-panel input[type=checkbox] { width: 20px; min-height: 20px; }
.errorlist { color: var(--red); padding-left: 22px; }
.portal-footer { color: var(--muted); font-size: .78rem; margin-top: 35px; }
.eyebrow { letter-spacing: .12em; font-size: .68rem; margin-bottom: 10px; }
.setup-key { display: block; overflow-wrap: anywhere; background: var(--paper); padding: 15px; margin: 16px 0; }
.auth-qr { display: block; width: min(100%, 280px); height: auto; margin: 18px 0; }
.setup-restart { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
.preserve-lines { white-space: pre-wrap; margin: 16px 0; }
article + article { margin-top: 15px; }
.sms-filters a { display: inline-flex; border: 1px solid var(--line); background: var(--white); padding: 10px 14px; min-height: 44px; }
.sms-filters a[aria-current="page"] { border-color: var(--accent); }
.sms-filters .badge { width: auto; min-width: 24px; }
.sms-filters + .panel article { margin-top: 18px; }
@media(max-width:720px) { #sidebar.portal-sidebar { display: flex; height: auto; } #sidebar.portal-sidebar .brand { display: flex; } #sidebar.portal-sidebar nav { display: flex; flex-wrap: wrap; } #sidebar.portal-sidebar .backup { padding-top: 5px; } }

@media print { #sidebar, .portal-footer, .page-head { display: none !important; } body { display: block; background: white; } main { padding: 0; } .printable-receipt { border: 0; } }
