/* Layout and components. Colours come from tokens.css only. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--fw-regular) var(--fs-md)/var(--lh) var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: var(--fw-semibold); }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--sp-3); }
small, .small { font-size: var(--fs-sm); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.i-lg { width: 20px; height: 20px; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }

/* ---- shell ---------------------------------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.shell.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.sidebar {
  background: var(--sidebar-bg); color: var(--sidebar-text); position: sticky; top: 0; height: 100vh;
  overflow-y: auto; display: flex; flex-direction: column; z-index: 30;
}
.brand {
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-4);
  color: #fff; font-weight: var(--fw-semibold); font-size: var(--fs-lg); border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none; white-space: nowrap; overflow: hidden;
}
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: var(--r-md); background: var(--sidebar-accent); color: var(--sidebar-bg);
  display: grid; place-items: center; font-weight: var(--fw-bold); flex: none;
}
.nav { list-style: none; margin: 0; padding: var(--sp-2) 0; }
.nav-section { padding: var(--sp-3) var(--sp-4) var(--sp-1); font-size: var(--fs-xs); text-transform: uppercase;
  letter-spacing: .06em; color: var(--sidebar-text-muted); }
.nav a, .nav summary {
  display: flex; align-items: center; gap: var(--sp-3); padding: 9px var(--sp-4); color: var(--sidebar-text);
  cursor: pointer; text-decoration: none; list-style: none; border-left: 3px solid transparent; white-space: nowrap;
}
.nav summary::-webkit-details-marker { display: none; }
.nav a:hover, .nav summary:hover { background: var(--sidebar-bg-active); color: #fff; text-decoration: none; }
.nav a[aria-current="page"], .nav .is-active > summary { background: var(--sidebar-bg-active); color: #fff;
  border-left-color: var(--sidebar-accent); }
.nav .chev { margin-left: auto; transition: transform var(--motion-fast); }
.nav details[open] > summary .chev { transform: rotate(90deg); }
.nav .sub { list-style: none; margin: 0; padding: 0 0 var(--sp-2); }
.nav .sub a { padding: 7px var(--sp-4) 7px 44px; font-size: var(--fs-sm); color: var(--sidebar-text-muted); }
.nav .sub a[aria-current="page"] { color: #fff; background: transparent; border-left-color: var(--sidebar-accent); }
.is-collapsed .nav-label, .is-collapsed .nav .chev, .is-collapsed .nav .sub, .is-collapsed .brand-name,
.is-collapsed .nav-section { display: none; }
.is-collapsed .nav a, .is-collapsed .nav summary { justify-content: center; padding: 11px 0; }
.sidebar-foot { margin-top: auto; padding: var(--sp-3) var(--sp-4); font-size: var(--fs-xs); color: var(--sidebar-text-muted); }
.is-collapsed .sidebar-foot { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--gutter); position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent; color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.content { padding: var(--gutter); flex: 1; min-width: 0; }
@media (min-width: 1280px) { .content { padding: var(--gutter-lg); } }
.page-head { display: flex; align-items: flex-end; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.page-head h1 small { font-size: var(--fs-md); font-weight: var(--fw-regular); color: var(--text-muted); margin-left: var(--sp-2); }
.page-head .actions { margin-left: auto; display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.crumbs { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: var(--sp-1); }
.crumbs a { color: var(--text-muted); }
.footer { padding: var(--sp-3) var(--gutter); color: var(--text-faint); font-size: var(--fs-xs); }

/* scope switchers */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 7px 10px; border-radius: var(--r-md); color: var(--text); font-weight: var(--fw-medium); white-space: nowrap; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--surface-3); }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 220px; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-popover);
  padding: var(--sp-1) 0; z-index: 50;
}
.menu-list.left { left: 0; right: auto; }
.menu-list a, .menu-list button, .menu-list label.menu-item {
  display: flex; gap: var(--sp-2); align-items: center; width: 100%; padding: 8px var(--sp-3); color: var(--text);
  background: none; border: 0; font: inherit; text-align: left; cursor: pointer; text-decoration: none;
}
.menu-list a:hover, .menu-list button:hover, .menu-list label.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-list .is-current { font-weight: var(--fw-semibold); color: var(--accent); }
.menu-list .sep { border-top: 1px solid var(--border); margin: var(--sp-1) 0; }
.menu-list .menu-title { padding: 6px var(--sp-3); font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

/* ---- buttons ------------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); height: 36px; padding: 0 14px;
  border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: var(--fw-medium) var(--fs-md)/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}
.btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn-xs { height: 24px; padding: 0 8px; font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-icon { width: 30px; padding: 0; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }

/* ---- panels -------------------------------------------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-panel);
  margin-bottom: var(--sp-4); min-width: 0; }
.panel-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.panel-head h2, .panel-head h3 { font-size: var(--fs-lg); }
.panel-head .actions { margin-left: auto; display: flex; gap: var(--sp-2); align-items: center; }
.panel-body { padding: var(--sp-4); }
.panel-body.flush { padding: 0; }
.panel.is-collapsed .panel-body, .panel.is-collapsed .panel-foot { display: none; }
.panel-foot { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--r-md) var(--r-md); }
.collapse-btn { transition: transform var(--motion-fast); }
.panel.is-collapsed .collapse-btn { transform: rotate(-90deg); }

.cols { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) {
  .cols-2 { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  .cols-2-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.stack > * + * { margin-top: var(--sp-3); }

/* ---- forms --------------------------------------------------------------------------------------- */
.form-grid { display: grid; gap: var(--sp-3) var(--sp-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.form-grid .wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field-label { font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.field .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field .error, .errorlist { color: var(--danger); font-size: var(--fs-sm); margin: 0; padding: 0; list-style: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
input[type=text], input[type=number], input[type=email], input[type=tel], input[type=password], input[type=date],
input[type=datetime-local], input[type=time], input[type=search], input[type=url], select, textarea {
  width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--border-input); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font: inherit; line-height: 1.3;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
input[readonly], input:disabled, select:disabled, textarea[readonly] { background: var(--surface-3); color: var(--text-muted); }
.check { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: var(--fw-regular); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.radio-list { display: flex; flex-direction: column; gap: 6px; }
.radio-list.inline { flex-direction: row; flex-wrap: wrap; gap: var(--sp-4); }
.form-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-top: var(--sp-4); }
.form-section { font-size: var(--fs-lg); font-weight: var(--fw-semibold); margin: var(--sp-4) 0 var(--sp-1); grid-column: 1 / -1; }
.quick-dates { display: flex; flex-wrap: wrap; gap: 4px; }
.inline-form { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; }
.color-input { display: flex; gap: var(--sp-2); align-items: center; }
.color-input input[type=color] { width: 40px; height: 36px; padding: 2px; border: 1px solid var(--border-input); border-radius: var(--r-sm); background: var(--surface); }

/* ---- tables -------------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.t th, .t td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.t thead th { background: var(--surface-2); font-weight: var(--fw-semibold); color: var(--text); position: sticky; top: 0; z-index: 1; }
.t thead tr.filters th { padding: 6px 6px; font-weight: var(--fw-regular); top: 37px; }
.t thead tr.filters input, .t thead tr.filters select { min-height: 30px; padding: 4px 6px; font-size: var(--fs-sm); min-width: 70px; }
.t tbody tr:hover { background: var(--surface-2); }
.t tfoot td { background: var(--warning-soft); font-weight: var(--fw-semibold); }
.t th a.sort { color: var(--accent); white-space: nowrap; }
.t th a.sort.is-active::after { content: " ▲"; font-size: 10px; }
.t th a.sort.is-desc::after { content: " ▼"; }
.t td.actions { white-space: nowrap; width: 1%; }
.t .row-muted td { color: var(--text-muted); }
.t .row-group td { background: var(--surface-3); color: var(--text-muted); }
.t.compact th, .t.compact td { padding: 5px 8px; }
.empty { padding: var(--sp-6); text-align: center; color: var(--text-muted); }
.grid-toolbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.grid-toolbar .right { margin-left: auto; display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.grid-summary { padding: 6px var(--sp-4); font-size: var(--fs-sm); color: var(--text-muted); display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.pager { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); }
.pager a, .pager span { min-width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0 8px; border-radius: var(--r-sm);
  border: 1px solid var(--border); color: var(--text); background: var(--surface); font-size: var(--fs-sm); }
.pager a:hover { background: var(--surface-3); text-decoration: none; }
.pager .is-current { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pager .gap { border: 0; background: none; }
.cols-chooser { padding: var(--sp-2) var(--sp-3); min-width: 280px; }
.cols-chooser .grid2 { display: grid; grid-template-columns: 1fr auto auto; gap: 4px var(--sp-3); align-items: center; font-size: var(--fs-sm); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 var(--sp-4); flex-wrap: wrap; }
.tabs a { padding: 10px 12px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: var(--fw-semibold); }

/* ---- chips & badges ------------------------------------------------------------------------------ */
.chip {
  position: relative; display: inline-flex; align-items: baseline; gap: 2px; padding: 2px 7px 2px 6px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: var(--fs-sm);
  line-height: 1.35; white-space: nowrap; text-decoration: none; margin: 1px 0;
}
a.chip:hover { text-decoration: none; filter: brightness(.96); color: var(--text); }
.chip sup { font-size: 10px; color: var(--text-muted); top: -.35em; }
.chip small { font-size: 11px; color: var(--text-muted); }
.chip-corner { position: absolute; right: -1px; bottom: -1px; width: 0; height: 0; border-style: solid; border-width: 0 0 9px 9px; }
.chip-corner--overdue { border-color: transparent transparent var(--danger) transparent; }
.chip-corner--ending { border-color: transparent transparent var(--warning) transparent; }
.chip-mark { font-size: 10px; color: var(--success); margin-left: 2px; }
.chip-unit.is-excluded { border-style: dashed; border-color: var(--text-muted); }
.stat-scope { margin: var(--sp-2) 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.problem-mark { color: var(--danger); font-weight: var(--fw-bold); margin-left: 3px; }
.st-unit-free { background: var(--st-unit-free-bg); border-color: var(--st-unit-free-bd); }
.st-unit-occupied { background: var(--st-unit-occupied-bg); border-color: var(--st-unit-occupied-bd); }
.st-unit-occupied-next { background: var(--st-unit-occupied-next-bg); border-color: var(--st-unit-occupied-next-bd); }
.st-unit-leaving { background: var(--st-unit-leaving-bg); border-color: var(--st-unit-leaving-bd); }
.st-unit-booked-paid { background: var(--st-unit-booked-paid-bg); border-color: var(--st-unit-booked-paid-bd); }
.st-unit-booked-unpaid { background: var(--st-unit-booked-unpaid-bg); border-color: var(--st-unit-booked-unpaid-bd); }
.st-unit-inactive { background: var(--st-unit-inactive-bg); border-color: var(--st-unit-inactive-bd); color: var(--text-muted); }
.st-unit-awaiting { background: var(--st-unit-awaiting-bg); border-color: var(--st-unit-awaiting-bd); }
.st-contract-ok { background: var(--st-contract-ok-bg); border-color: var(--st-contract-ok-bd); }
.st-contract-booking { background: var(--st-contract-booking-bg); border-color: var(--st-contract-booking-bd); }
.st-contract-ending { background: var(--st-contract-ending-bg); border-color: var(--st-contract-ending-bd); }
.st-contract-overdue-1 { background: var(--st-contract-overdue-1-bg); border-color: var(--st-contract-overdue-1-bd); }
.st-contract-overdue-2 { background: var(--st-contract-overdue-2-bg); border-color: var(--st-contract-overdue-2-bd); }
.st-contract-overdue-3 { background: var(--st-contract-overdue-3-bg); border-color: var(--st-contract-overdue-3-bd); }
.st-contract-overdue-4 { background: var(--st-contract-overdue-4-bg); border-color: var(--st-contract-overdue-4-bd); }
.st-contract-closed { background: var(--st-contract-closed-bg); border-color: var(--st-contract-closed-bd); color: var(--text-muted); }
.badge { display: inline-block; padding: 1px 8px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  background: var(--surface-3); color: var(--text-muted); white-space: nowrap; }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.swatch { display: inline-block; padding: 1px 8px; border-radius: var(--r-sm); font-size: var(--fs-xs); border: 1px solid var(--border); font-family: var(--font-mono); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: 0; margin-right: 4px; border: 1px solid rgba(0,0,0,.12); }

/* ---- messages ------------------------------------------------------------------------------------ */
.messages { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.msg { padding: 10px 14px; border-radius: var(--r-md); border: 1px solid; display: flex; gap: var(--sp-2); align-items: flex-start; }
.msg-success { background: var(--success-soft); border-color: #B7E1C6; color: var(--success); }
.msg-error { background: var(--danger-soft); border-color: #F3C0BA; color: var(--danger); }
.msg-warning { background: var(--warning-soft); border-color: #F2DC9C; color: var(--warning); }
.msg-info { background: var(--info-soft); border-color: #BCD3EF; color: var(--info); }
.msg .close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; font-size: 18px; line-height: 1; }
.callout { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--info-soft); color: var(--info); margin-bottom: var(--sp-4); }
.callout.warn { background: var(--warning-soft); color: var(--warning); }

/* ---- dashboard ----------------------------------------------------------------------------------- */
.board-building { margin-bottom: var(--sp-5); }
.board-building h2 { font-size: var(--fs-xl); margin-bottom: var(--sp-2); }
.board-floor { margin-bottom: var(--sp-3); }
.board-floor h3 { font-size: var(--fs-md); font-weight: var(--fw-semibold); display: flex; align-items: center; gap: var(--sp-2); margin-bottom: 6px; }
.board-chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.board-chips .chip { font-size: var(--fs-sm); padding: 3px 8px 3px 7px; }
.stat-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: var(--sp-4); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-4); box-shadow: var(--shadow-panel); }
.stat h3 { font-size: var(--fs-md); color: var(--text-muted); font-weight: var(--fw-semibold); margin-bottom: var(--sp-2); }
.stat .big { font-size: var(--fs-3xl); font-weight: var(--fw-bold); line-height: 1.1; }
.stat .pair { display: flex; gap: var(--sp-4); margin-top: var(--sp-3); flex-wrap: wrap; }
.stat .pair div { min-width: 90px; }
.stat .pair b { display: block; font-size: var(--fs-xl); }
.stat .pair span { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.meter { height: 8px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; margin-top: var(--sp-2); }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); }
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--fs-xs); color: var(--text-muted); }
.legend .chip { font-size: var(--fs-xs); }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 340px; }

/* contract progress */
.progress { position: relative; height: 18px; min-width: 160px; background: var(--surface-3); border-radius: var(--r-sm); overflow: hidden; }
.progress .seg { position: absolute; top: 0; bottom: 0; }
.progress .seg.paid { background: #8FD3A2; }
.progress .seg.unpaid { background: #F2C46B; }
.progress .seg.overdue { background: #E99A9A; }
.progress .tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(22,32,42,.12); }
.progress .now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); }
.progress .dep { position: absolute; top: 1px; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 8px solid #C79100; }
.progress-sum { font-size: 11px; color: var(--text-muted); }
.months-strip { display: flex; flex-wrap: wrap; gap: 3px; }
.months-strip span { width: 22px; height: 18px; border-radius: 3px; font-size: 10px; display: grid; place-items: center; color: var(--text); border: 1px solid rgba(0,0,0,.06); }
.months-strip .m-paid { background: #8FD3A2; }
.months-strip .m-unpaid { background: #F2C46B; }
.months-strip .m-debt { background: #E99A9A; }
.months-strip .m-future { background: var(--surface-3); color: var(--text-faint); }

/* year payments table */
.ytable { font-size: 11px; }
.ytable .yrow { display: grid; grid-template-columns: 230px 1fr; align-items: center; border-bottom: 1px solid var(--border); min-height: 26px; }
.ytable .ylabel { display: flex; gap: 4px; align-items: center; padding: 2px 6px; overflow: hidden; white-space: nowrap; }
.ytable .ytrack { position: relative; height: 24px; background-image: linear-gradient(to right, var(--border) 1px, transparent 1px); background-size: calc(100% / 12) 100%; }
.ytable .ybar { position: absolute; top: 4px; height: 16px; border-radius: 3px; font-size: 10px; line-height: 16px; padding: 0 3px; overflow: hidden; white-space: nowrap; color: var(--text); text-decoration: none; }
.ytable .ybar.paid { background: #BFE8C9; border: 1px solid #8FD3A2; }
.ytable .ybar.unpaid { background: #FBE3A6; border: 1px solid #EBC35A; }
.ytable .ybar.overdue { background: #F6C3C3; border: 1px solid #E38C8C; }
.ytable .yterm { position: absolute; bottom: 1px; height: 2px; background: #E0A35A; }
.ytable .yhead { display: grid; grid-template-columns: 230px 1fr; position: sticky; top: var(--topbar-h); background: var(--surface); z-index: 2; border-bottom: 1px solid var(--border-strong); }
.ytable .ymonths { display: grid; grid-template-columns: repeat(12, 1fr); }
.ytable .ymonths div { padding: 4px; border-left: 1px solid var(--border); font-size: 11px; }
.ytable .ymonths b { display: block; font-size: 12px; }
.ytable .ygroup { padding: 8px 6px 4px; font-weight: var(--fw-semibold); font-size: var(--fs-sm); }

/* floor plan */
.plan-wrap { position: relative; display: inline-block; max-width: 100%; user-select: none; }
.plan-wrap img { display: block; max-width: 100%; height: auto; }
.plan-wrap svg.plan-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.plan-shape { stroke-width: 0.15; cursor: pointer; }
.plan-label { font-size: 1.4px; fill: var(--text); pointer-events: none; }
.plan-mode-solid .plan-shape { fill-opacity: 1; }
.plan-mode-semi .plan-shape { fill-opacity: .6; }
.plan-mode-outline .plan-shape { fill-opacity: 0; stroke-width: .35; }
.plan-mode-image .plan-shape, .plan-mode-image .plan-label { display: none; }
.plan-palette { display: flex; flex-wrap: wrap; gap: 4px; padding: var(--sp-2); border: 1px dashed var(--border-strong); border-radius: var(--r-md); min-height: 44px; }
.plan-editing .plan-shape { cursor: move; }
.plan-handle { fill: var(--surface); stroke: var(--focus); stroke-width: .2; cursor: nwse-resize; }
.plan-empty { padding: var(--sp-8); text-align: center; color: var(--text-muted); border: 1px dashed var(--border-strong); border-radius: var(--r-md); }

/* lead stats tiles */
.tiles { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.tile { border-radius: var(--r-md); padding: var(--sp-3); color: var(--text); text-decoration: none; display: block; border: 1px solid rgba(0,0,0,.06); }
.tile:hover { text-decoration: none; filter: brightness(.97); color: var(--text); }
.tile b { font-size: var(--fs-3xl); display: block; line-height: 1.1; }
.tile span { font-size: var(--fs-sm); }

/* key/value lists */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--sp-4); font-size: var(--fs-sm); margin: 0; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }
.summary-bar { display: flex; flex-wrap: wrap; gap: var(--sp-4); padding: var(--sp-2) var(--sp-4); background: var(--warning-soft); font-size: var(--fs-sm); }
.summary-bar b { font-weight: var(--fw-semibold); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--text-muted); font-size: var(--fs-xs); }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-4); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-panel); padding: var(--sp-6); }
.login-card h1 { font-size: var(--fs-xl); margin-bottom: var(--sp-1); }

dialog { border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-popover); padding: 0; max-width: min(560px, 92vw); color: var(--text); }
dialog::backdrop { background: rgba(16,24,40,.35); }
dialog .panel-head { border-bottom: 1px solid var(--border); }

/* tom-select alignment with our inputs */
.ts-wrapper .ts-control { min-height: 36px; border-color: var(--border-input); border-radius: var(--r-sm); padding: 6px 8px; font-size: var(--fs-md); }
.ts-wrapper.focus .ts-control { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); box-shadow: none; }
.ts-dropdown { font-size: var(--fs-md); }
.ts-wrapper.multi .ts-control > div { background: var(--accent-soft); color: var(--accent); border-radius: var(--r-sm); }

/* ---- responsive ---------------------------------------------------------------------------------- */
@media (max-width: 959px) {
  .shell, .shell.is-collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform var(--motion-base); }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-popover); }
  .is-collapsed .nav-label, .is-collapsed .nav .chev, .is-collapsed .brand-name, .is-collapsed .nav-section { display: initial; }
  .is-collapsed .nav a, .is-collapsed .nav summary { justify-content: flex-start; padding: 9px var(--sp-4); }
  .is-collapsed .nav .sub { display: block; }
  .topbar .scope-label { display: none; }
  .ytable .yrow, .ytable .yhead { grid-template-columns: 140px 1fr; }
}
@media (max-width: 640px) {
  .page-head h1 { font-size: var(--fs-xl); }
  .stat .big { font-size: var(--fs-2xl); }
  .kv { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .grid-toolbar, .pager, .page-head .actions, .no-print, tr.filters { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .panel { box-shadow: none; border: 0; }
  body { background: #fff; }
}
.t tr.row-overdue td { background: var(--danger-soft); }
.t tr.row-today td { background: var(--warning-soft); }
/* plan fills by status */
.plan-shape.st-unit-free { fill: var(--st-unit-free-bg); stroke: var(--st-unit-free-bd); }
.plan-shape.st-unit-occupied { fill: var(--st-unit-occupied-bg); stroke: var(--st-unit-occupied-bd); }
.plan-shape.st-unit-occupied-next { fill: var(--st-unit-occupied-next-bg); stroke: var(--st-unit-occupied-next-bd); }
.plan-shape.st-unit-leaving { fill: var(--st-unit-leaving-bg); stroke: var(--st-unit-leaving-bd); }
.plan-shape.st-unit-booked-paid { fill: var(--st-unit-booked-paid-bg); stroke: var(--st-unit-booked-paid-bd); }
.plan-shape.st-unit-booked-unpaid { fill: var(--st-unit-booked-unpaid-bg); stroke: var(--st-unit-booked-unpaid-bd); }
.plan-shape.st-unit-inactive { fill: var(--st-unit-inactive-bg); stroke: var(--st-unit-inactive-bd); }
.plan-shape.st-unit-awaiting { fill: var(--st-unit-awaiting-bg); stroke: var(--st-unit-awaiting-bd); }
.plan-shape { stroke-width: 2; vector-effect: non-scaling-stroke; }
.plan-mode-outline .plan-shape { stroke-width: 3; }
.plan-shape.is-selected { stroke: var(--focus); stroke-width: 3; }
.plan-label { font-size: 14px; fill: var(--text); pointer-events: none; font-family: var(--font); }
.plan-label tspan.area { font-size: 11px; fill: var(--text-muted); }
.plan-handle { fill: var(--surface); stroke: var(--focus); stroke-width: 2; cursor: nwse-resize; vector-effect: non-scaling-stroke; }
.plan-point { fill: var(--focus); }
.plan-palette .chip { cursor: grab; }
.inline-form.period-row select { flex: 1; width: 100%; min-width: 0; }
@media (max-width: 959px) {
  .ytable-wrap { overflow-x: auto; }
  .ytable { min-width: 900px; }
  .ytable .yhead { position: static; }
}
