/* =============================================================================
   Rental Management System — application stylesheet.
   Self-contained: no CDN, no external fonts. Light/dark via [data-theme-resolved].
   ============================================================================= */

/* ---------- Tokens ---------- */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px; --radius-sm: 6px; --radius-lg: 14px;
  --sidebar-w: 248px; --sidebar-w-collapsed: 68px; --topbar-h: 60px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 4px 16px rgba(15, 23, 42, .08);
  --shadow-lg: 0 16px 48px rgba(15, 23, 42, .16);
  --ease: cubic-bezier(.2, .7, .2, 1);

  --bg: #f5f7fb; --surface: #ffffff; --surface-2: #f8fafc; --surface-3: #eef2f7;
  --border: #e5e9f0; --border-strong: #d2d9e3;
  --text: #0f172a; --text-2: #475569; --text-3: #94a3b8;
  --primary: #2563eb; --primary-hover: #1d4ed8; --primary-soft: #e8efff; --primary-text: #1e40af;
  --success: #16a34a; --success-soft: #e6f6ec; --success-text: #166534;
  --warning: #d97706; --warning-soft: #fdf1dd; --warning-text: #92400e;
  --danger: #dc2626; --danger-soft: #fde8e8; --danger-text: #991b1b;
  --info: #0891b2; --info-soft: #e0f5f9; --info-text: #155e75;
  --neutral-soft: #eef2f7; --neutral-text: #475569;
  --sidebar-bg: #0f172a; --sidebar-text: #cbd5e1; --sidebar-active: rgba(255, 255, 255, .08); --sidebar-border: rgba(255, 255, 255, .06);
  --focus: 0 0 0 3px rgba(37, 99, 235, .3);
  --skeleton: linear-gradient(90deg, #eef2f7 25%, #f6f8fb 37%, #eef2f7 63%);
}
[data-theme-resolved="dark"] {
  --bg: #0b1220; --surface: #111a2c; --surface-2: #0f172a; --surface-3: #1a2438;
  --border: #1f2a40; --border-strong: #2c3a55;
  --text: #e6ecf5; --text-2: #a7b3c7; --text-3: #6b7a93;
  --primary: #3b82f6; --primary-hover: #60a5fa; --primary-soft: #16264a; --primary-text: #93c5fd;
  --success: #22c55e; --success-soft: #0f2d1f; --success-text: #86efac;
  --warning: #f59e0b; --warning-soft: #33230a; --warning-text: #fcd34d;
  --danger: #ef4444; --danger-soft: #3a1414; --danger-text: #fca5a5;
  --info: #22d3ee; --info-soft: #0c2c33; --info-text: #67e8f9;
  --neutral-soft: #1a2438; --neutral-text: #a7b3c7;
  --sidebar-bg: #0a1020; --sidebar-text: #aab6ca; --sidebar-active: rgba(255, 255, 255, .07); --sidebar-border: rgba(255, 255, 255, .06);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 4px 16px rgba(0, 0, 0, .35); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
  --skeleton: linear-gradient(90deg, #1a2438 25%, #22304a 37%, #1a2438 63%);
  color-scheme: dark;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a.strong, .strong { font-weight: 600; color: var(--text); }
code { font-family: var(--mono); font-size: .85em; }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
dl.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
dl.dl dt { color: var(--text-2); font-size: 12.5px; }
dl.dl dd { margin: 0; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.block { display: block; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.p-2 { padding: 1rem; }
.row-gap { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--primary); color: #fff; padding: .5rem 1rem; border-radius: var(--radius-sm); z-index: 1000; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
.icon { flex: none; vertical-align: -.2em; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; z-index: 60; transition: width .18s var(--ease), transform .2s var(--ease); }
.app-main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); transition: margin .18s var(--ease); display: flex; flex-direction: column; min-height: 100vh; }
.app-shell.is-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.app-shell.is-collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); padding: 0 14px 0 16px; border-bottom: 1px solid var(--sidebar-border); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 15px; overflow: hidden; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); display: inline-flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.brand-logo { width: 34px; height: 34px; border-radius: 8px; object-fit: contain; background: #fff; flex: none; }
.brand-name { overflow: hidden; text-overflow: ellipsis; }
.sidebar-close { display: none; color: var(--sidebar-text); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 11px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; white-space: nowrap; position: relative; background: none; border: 0; width: 100%; text-align: left; cursor: pointer; transition: background .12s, color .12s; }
.nav-item:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav-item.is-active { background: var(--primary); color: #fff; }
.nav-icon { flex: none; opacity: .9; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer { padding: 10px; border-top: 1px solid var(--sidebar-border); }
.app-shell.is-collapsed .nav-label, .app-shell.is-collapsed .brand-name { display: none; }
.app-shell.is-collapsed .nav-item { justify-content: center; padding: 10px; }
.app-shell.is-collapsed .sidebar-brand { padding: 0; justify-content: center; }
.app-shell.is-collapsed .collapse-icon { transform: rotate(180deg); }
.app-shell.is-collapsed .nav-item[data-tooltip]:hover::after { content: attr(data-tooltip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); background: var(--text); color: var(--bg); padding: 4px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; box-shadow: var(--shadow); z-index: 100; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 55; }

.topbar { position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 20px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-menu { display: none; }
.topbar-search { position: relative; flex: 1; max-width: 520px; }
.search-field { display: flex; align-items: center; gap: 8px; background: var(--surface-3); border: 1px solid transparent; border-radius: 9px; padding: 0 10px; height: 38px; transition: border-color .12s, background .12s; }
.search-field:focus-within { background: var(--surface); border-color: var(--primary); box-shadow: var(--focus); }
.search-field input { flex: 1; border: 0; background: none; outline: none; font: inherit; color: var(--text); min-width: 0; }
.search-field input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-icon { color: var(--text-3); }
.search-kbd { font: 11px var(--mono); color: var(--text-3); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; }
.search-field-sm { height: 34px; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 70vh; overflow: auto; z-index: 80; }
.search-group-label { padding: 8px 12px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.search-item { display: block; padding: 8px 12px; color: var(--text); }
.search-item:hover, .search-item.is-active { background: var(--surface-2); text-decoration: none; }
.search-item .muted { display: block; }
.search-empty { padding: 16px; color: var(--text-2); text-align: center; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.branch-switch .branch-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.branch-static { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; font-size: 13px; }
.icon-btn { position: relative; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; border-radius: 9px; color: var(--text-2); cursor: pointer; transition: background .12s, color .12s; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.badge-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }
.theme-icon-dark { display: none; }
[data-theme-resolved="dark"] .theme-icon-dark { display: inline-flex; }
[data-theme-resolved="dark"] .theme-icon-light { display: none; }
.user-menu { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border: 0; background: none; border-radius: 9px; cursor: pointer; color: var(--text); }
.user-menu:hover { background: var(--surface-3); }
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; flex: none; }

.page { padding: 24px 28px 48px; flex: 1; max-width: 1480px; width: 100%; margin: 0 auto; }
.page-narrow { max-width: 760px; }
.breadcrumbs { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; flex-wrap: wrap; }
.breadcrumbs a { color: var(--text-2); display: inline-flex; align-items: center; }
.breadcrumbs a:hover { color: var(--primary); }
.crumb-sep { color: var(--text-3); }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 22px; }
.page-subtitle { margin: 4px 0 0; color: var(--text-2); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 22px 0 10px; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 70; display: none; animation: pop .12s var(--ease); }
.dropdown-menu-right { left: auto; right: 0; }
.dropdown-menu-lg { width: 360px; max-width: calc(100vw - 32px); left: auto; right: 0; }
.dropdown.is-open .dropdown-menu { display: block; }
.dropdown-header { padding: 8px 10px; font-size: 12px; color: var(--text-2); display: flex; justify-content: space-between; align-items: center; }
.dropdown-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 7px; color: var(--text); text-align: left; cursor: pointer; justify-content: space-between; }
.dropdown-item:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-item.is-active { background: var(--primary-soft); color: var(--primary-text); }
.dropdown-divider { height: 1px; background: var(--border); margin: 6px 0; }
.dropdown-empty { padding: 20px; text-align: center; }
.notification-list { max-height: 360px; overflow: auto; }
.notification-item { display: block; padding: 10px; border-radius: 7px; color: var(--text); }
.notification-item:hover { background: var(--surface-2); text-decoration: none; }
.notification-item.is-unread { background: var(--primary-soft); }
.notification-item .muted { display: block; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent; font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, color .12s, transform .05s; text-decoration: none !important; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-loading { opacity: .6; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn.is-loading::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { font-weight: 500; }
.link-sm { font-size: 12.5px; font-weight: 500; background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0; }

/* ---------- Cards / grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-title { font-size: 15px; }
.card-body { padding: 18px; }
.card-body.no-pad { padding: 0; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; color: var(--text); box-shadow: var(--shadow-sm); transition: transform .12s var(--ease), box-shadow .12s; }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; }
.kpi-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.kpi-icon { color: var(--text-3); }
.kpi-value { font-size: 24px; font-weight: 650; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-foot { margin-top: 6px; font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.kpi-success .kpi-value { color: var(--success-text); } .kpi-danger .kpi-value { color: var(--danger-text); } .kpi-warning .kpi-value { color: var(--warning-text); } .kpi-primary .kpi-value { color: var(--primary-text); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tile { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; color: var(--text); transition: transform .12s var(--ease), box-shadow .12s, border-color .12s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); text-decoration: none; }
.tile-icon { color: var(--primary); flex: none; margin-top: 2px; }
.tile-title { font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 600; white-space: nowrap; background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr:hover, .table tbody tr.is-link:hover { background: var(--surface-2); }
.table tbody tr.is-link { cursor: pointer; }
.table td.actions, .table th.actions { text-align: right; white-space: nowrap; }
.table .inline-form { display: inline-block; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable .sort-ind { opacity: .35; margin-left: 4px; font-size: 10px; }
th.sortable.is-sorted .sort-ind { opacity: 1; color: var(--primary); }
.datatable-toolbar { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.datatable-toolbar .search-field { min-width: 240px; flex: 1; max-width: 360px; }
.datatable-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.datatable-filters .input { width: auto; min-width: 150px; max-width: 240px; }
.datatable-toolbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.datatable-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination { display: flex; gap: 4px; align-items: center; }
.pagination button { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 7px; cursor: pointer; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; }
.pagination button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.pagination button.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: default; }
.mobile-cards { display: none; }
.mcard { display: block; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.mcard:hover { background: var(--surface-2); text-decoration: none; }
.mcard-title { font-weight: 600; }
.mcard-sub { color: var(--text-2); font-size: 13px; }
.mcard-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; font-size: 12.5px; color: var(--text-2); align-items: center; }
.skeleton-rows { display: flex; flex-direction: column; gap: 10px; padding: 6px 0; }
.skeleton { height: 14px; border-radius: 6px; background: var(--skeleton); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.table-empty { padding: 32px; text-align: center; color: var(--text-2); }
.detail-toggle { cursor: pointer; }
.diff-block { font: 12px var(--mono); background: var(--surface-2); border-radius: 6px; padding: 8px 10px; white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; }
.diff-old { color: var(--danger-text); } .diff-new { color: var(--success-text); }

/* ---------- Badges / alerts / toasts ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-info { background: var(--info-soft); color: var(--info-text); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid transparent; }
.alert-danger { background: var(--danger-soft); color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); }
.alert-success { background: var(--success-soft); color: var(--success-text); }
.alert-info { background: var(--info-soft); color: var(--info-text); }
.toast-region { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-lg); animation: slidein .18s var(--ease); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: .18s; }
.toast-success { border-left-color: var(--success); } .toast-error { border-left-color: var(--danger); } .toast-warning { border-left-color: var(--warning); }
.toast-close { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--text-3); }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 4px; }
.label { font-size: 13px; font-weight: 500; color: var(--text); }
.req { color: var(--danger); }
.input { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; transition: border-color .12s, box-shadow .12s; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input:disabled, .input[readonly] { background: var(--surface-2); color: var(--text-2); }
.input-sm { height: 34px; font-size: 13px; }
textarea.input { height: auto; padding: 9px 11px; resize: vertical; min-height: 80px; }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.has-error .input { border-color: var(--danger); }
.field-error { color: var(--danger-text); font-size: 12.5px; }
.field-help { font-size: 12.5px; }
.input-group { display: flex; }
.input-group .input-addon { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--border-strong); border-right: 0; border-radius: 8px 0 0 8px; background: var(--surface-2); color: var(--text-2); font-size: 13px; white-space: nowrap; }
.input-group .input { border-radius: 0 8px 8px 0; }
.input-money { text-align: right; font-variant-numeric: tabular-nums; }
.checkbox { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; font-size: 13.5px; }
.checkbox input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.check-card { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; transition: border-color .12s, background .12s; }
.check-card:hover { border-color: var(--border-strong); }
.check-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.check-card input { margin-top: 3px; accent-color: var(--primary); }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: .15s; }
.switch-track::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }
.switch input:disabled + .switch-track { opacity: .5; cursor: not-allowed; }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }
.form-row { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.form-row.between { justify-content: space-between; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.form-actions.sticky { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); padding: 12px 0; margin-top: 0; border-top: 1px solid var(--border); }
.inline-form { display: inline; }
.settings-list { display: flex; flex-direction: column; }
.setting-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); align-items: start; }
.setting-row:last-child { border-bottom: 0; }
.setting-control { max-width: 420px; }
.perm-matrix { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.perm-module { padding: 14px 18px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.perm-module-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.perm-items { display: flex; flex-direction: column; gap: 6px; }
.perm-item code { margin-left: 4px; }
.logo-row { display: flex; gap: 12px; align-items: center; }
.logo-preview { width: 56px; height: 56px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.side-col { position: sticky; top: calc(var(--topbar-h) + 16px); }

/* ---------- Lists / timeline / empty / phases ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item.is-unread { background: var(--primary-soft); }
.timeline { list-style: none; margin: 0; padding: 12px 18px; position: relative; }
.timeline-item { position: relative; padding: 0 0 14px 22px; }
.timeline-item::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: -2px; width: 2px; background: var(--border); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { position: absolute; left: 0; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--border); }
.timeline.compact .timeline-item { padding-bottom: 10px; }
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-3); color: var(--text-3); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.empty-title { font-size: 15px; }
.empty-body { max-width: 420px; margin: 4px auto 0; }
.empty-action { margin-top: 14px; }
.phase-list { list-style: none; margin: 0; padding: 0; }
.phase-item { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.phase-item:last-child { border-bottom: 0; }
.phase-num { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: none; }
.phase-item.is-built .phase-num { background: var(--success-soft); color: var(--success-text); }
.phase-item > div { flex: 1; }
.phase-name { font-weight: 600; }

/* ---------- Modal / drawer ---------- */
.modal { position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 23, 42, .55); animation: fade .12s; }
.modal-dialog { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: pop .15s var(--ease); }
.modal-dialog-lg { max-width: 860px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 16px; }
.modal-body { padding: 18px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.confirm-dialog { max-width: 420px; }
.confirm-dialog .modal-body { font-size: 14.5px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer { position: fixed; inset: 0; z-index: 150; background: rgba(15, 23, 42, .55); animation: fade .12s; }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slideleft .18s var(--ease); }
.drawer-panel .modal-body { flex: 1; overflow: auto; }
@keyframes slideleft { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: none; color: var(--text-2); font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel[hidden] { display: none; }

/* ---------- Progress / charts ---------- */
.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 999px; transition: width .4s var(--ease); }
.progress-bar.success { background: var(--success); } .progress-bar.warning { background: var(--warning); } .progress-bar.danger { background: var(--danger); }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); fill: var(--text-2); font-size: 11px; }
.chart .grid-line { stroke: var(--border); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

/* ---------- Auth ---------- */
.auth-body { background: var(--bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow); }
.auth-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.auth-app { font-weight: 650; font-size: 16px; }
.auth-title { font-size: 20px; margin-bottom: 4px; }
.auth-foot { text-align: center; margin-top: 16px; }

/* ---------- Error pages ---------- */
.error-page { text-align: center; padding: 48px 16px; max-width: 560px; margin: 0 auto; }
.error-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.error-code { font-size: 12px; letter-spacing: .1em; color: var(--text-3); font-weight: 600; }
.error-title { font-size: 22px; margin: 4px 0 8px; }
.error-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.debug-trace { text-align: left; font-size: 11.5px; background: var(--surface-2); padding: 12px; border-radius: 8px; overflow: auto; margin-top: 24px; max-height: 50vh; }

/* ---------- Print ---------- */
.print-body { background: #fff; color: #000; }
.print-page { max-width: 800px; margin: 0 auto; padding: 24px; }
@media print { .sidebar, .topbar, .toast-region, .form-actions, .breadcrumbs, .page-actions, .datatable-toolbar, .datatable-footer { display: none !important; } .app-main { margin: 0 !important; } .page { padding: 0; } .card { box-shadow: none; border-color: #ccc; break-inside: avoid; } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-main-side { grid-template-columns: 1fr; }
  .side-col { position: static; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .app-shell.is-mobile-open .sidebar { transform: none; }
  .app-shell.is-mobile-open .sidebar-backdrop { display: block; }
  .app-shell.is-collapsed .nav-label, .app-shell.is-collapsed .brand-name { display: inline; }
  .app-shell.is-collapsed .nav-item { justify-content: flex-start; }
  .app-main { margin-left: 0 !important; }
  .sidebar-close, .topbar-menu { display: inline-flex; }
  .sidebar-footer { display: none; }
  .topbar { padding: 0 12px; }
  .user-name, .branch-switch .branch-name, .branch-static { display: none; }
  .page { padding: 16px 14px 40px; }
  .grid-2, .grid-3, .grid-form { grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
}
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .setting-row { grid-template-columns: 1fr; gap: 8px; }
  .datatable .table-wrap { display: none; }
  .datatable .mobile-cards { display: block; }
  .datatable-toolbar .search-field { max-width: none; width: 100%; }
  .datatable-toolbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .topbar-search { display: none; }
  .topbar-search.is-mobile-visible { display: block; position: absolute; left: 12px; right: 12px; top: 8px; z-index: 45; }
  .kpi-value { font-size: 20px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-dialog { max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .perm-module { border-right: 0; }
  dl.dl { grid-template-columns: 1fr; gap: 2px; }
  dl.dl dd { margin-bottom: 8px; }
}
/* ---------- Money: documents, aging ---------- */
.doc { font-size: 13.5px; color: #111; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; border-bottom: 2px solid #111; padding-bottom: 14px; margin-bottom: 18px; }
.doc-org { font-size: 20px; font-weight: 700; }
.doc-title { text-align: right; }
.doc-title h1 { font-size: 22px; letter-spacing: .08em; margin: 0; }
.doc-num { font-family: var(--mono); font-size: 14px; margin: 4px 0; }
.doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 18px; }
.doc-table th { background: #f1f3f5; color: #111; }
.doc-amount { display: flex; justify-content: space-between; align-items: center; background: #f1f3f5; padding: 12px 16px; border-radius: 8px; margin: 12px 0; font-size: 18px; }
.print-body .badge { border: 1px solid currentColor; }
.aging-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.aging-cell { display: block; padding: 10px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); text-align: center; }
.aging-cell:hover { background: var(--surface-2); text-decoration: none; }
.aging-val { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 14px; }
@media (max-width: 900px) { .aging-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .doc-meta { grid-template-columns: 1fr; } }

/* ---------- Applications pipeline ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px; min-height: 160px; }
.board-col-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 13px; padding: 4px 6px 10px; }
.board-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; color: var(--text); box-shadow: var(--shadow-sm); transition: transform .12s var(--ease), box-shadow .12s; }
.board-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.board-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.board-empty { padding: 20px; text-align: center; }
.pipeline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.pipeline-step { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 13px; font-weight: 500; }
.pipeline-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.pipeline-step.is-done { background: var(--success-soft); color: var(--success-text); } .pipeline-step.is-done .pipeline-dot { background: var(--success); color: #fff; border-color: var(--success); }
.pipeline-step.is-current { background: var(--primary); color: #fff; } .pipeline-step.is-current .pipeline-dot { background: #fff; color: var(--primary); border-color: #fff; }
.pipeline-step.is-closed { opacity: .5; }
@media (max-width: 1100px) { .board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .board { grid-template-columns: 1fr; } }

/* ---------- Property / unit module ---------- */
.stacked-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.stacked-seg { display: block; height: 100%; }
.seg-success { background: var(--success); } .seg-info { background: var(--info); } .seg-warning { background: var(--warning); } .seg-danger { background: var(--danger); } .seg-neutral { background: var(--text-3); }
.occ { display: flex; flex-direction: column; gap: 3px; min-width: 120px; }
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; padding: 14px; }
.unit-tile { display: block; padding: 12px; border: 1px solid var(--border); border-left: 4px solid var(--text-3); border-radius: 10px; color: var(--text); background: var(--surface); transition: transform .12s var(--ease), box-shadow .12s; }
.unit-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.unit-tile.tone-success { border-left-color: var(--success); } .unit-tile.tone-info { border-left-color: var(--info); } .unit-tile.tone-warning { border-left-color: var(--warning); } .unit-tile.tone-danger { border-left-color: var(--danger); }
.unit-tile-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 4px; }
.unit-code { font-weight: 650; font-size: 15px; }
.unit-rent { margin-top: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.unit-hero-body { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-start; }
.unit-hero-status { min-width: 140px; }
.unit-hero-value { font-size: 17px; font-weight: 600; margin-top: 2px; }
.doc-row { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.doc-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.block-item { align-items: flex-start; }
.floor-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.floor-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; background: var(--surface-3); font-size: 12.5px; }
.chip-x { border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 0 2px; font-size: 14px; line-height: 1; }
.chip-x:hover { color: var(--danger); }
.cover-img { width: 100%; border-radius: 8px; margin-bottom: 10px; object-fit: cover; max-height: 180px; }
.owners-table td { vertical-align: middle; }
@media (max-width: 720px) { .unit-hero-body { gap: 14px; } .unit-grid { grid-template-columns: 1fr 1fr; padding: 10px; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---- Phase 6: operations ---- */
.board-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1400px) { .board-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .board-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .board-6 { grid-template-columns: 1fr; } }
.board-card.prio-urgent { border-left: 4px solid var(--danger); }
.board-card.prio-high { border-left: 4px solid var(--warning); }
.board-card.prio-low { border-left: 4px solid var(--border-strong, var(--border)); }
.row-worse td { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.row-worse td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.insp-table td, .insp-table th { vertical-align: top; }
.insp-table .input-sm { min-width: 110px; }
.insp-cat td { background: var(--surface-2); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.cond-pills { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.cond-pill { border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; font-size: 12px; cursor: pointer; background: var(--surface); }
.cond-pill:has(input:checked) { background: var(--primary); color: #fff; border-color: var(--primary); }
.cond-pill input { position: absolute; opacity: 0; pointer-events: none; }
.vendor-rating { color: var(--warning); letter-spacing: 1px; }

/* ---- Phase 7: accounting ---- */
.mono { font-family: var(--mono); font-size: 12.5px; }
.row-cleared td { background: color-mix(in srgb, var(--success) 8%, transparent); }
.table tbody th { background: var(--surface-2); text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
@media print { .sidebar, .topbar, .page-header .actions, .card-header form, .form-actions, .alert { display: none !important; } .card { box-shadow: none; border-color: #ccc; } }

/* ---- Phase 8: charts & reports ---- */
.chart { width: 100%; height: auto; display: block; font-family: inherit; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .bar { transition: opacity .12s; } .chart .bar:hover { opacity: .8; }
.chart .donut-center { fill: var(--text); font-size: 15px; font-weight: 700; }
.chart-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 0 0; margin: 0; font-size: 12px; color: var(--muted); }
.chart-legend li { display: flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-legend-col { flex-direction: column; gap: 6px; padding: 0; }
.chart-legend-col li { justify-content: space-between; gap: 10px; }
.chart-legend-col .legend-label { flex: 1; color: var(--text); }
.chart-legend-col .legend-value { font-variant-numeric: tabular-nums; }
.chart-donut-wrap { display: grid; grid-template-columns: 180px 1fr; gap: 16px; align-items: center; }
.chart-hbars { display: grid; gap: 8px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; transition: width .3s var(--ease); }
.hbar-value { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.sparkline { color: var(--primary); vertical-align: middle; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.report-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); text-decoration: none; transition: transform .12s var(--ease), box-shadow .12s; }
.report-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.report-card .report-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--primary-soft, var(--surface-3)); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.report-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.report-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } .chart-donut-wrap { grid-template-columns: 1fr; justify-items: center; } }
.chart-donut { width: 180px; height: 180px; max-width: 100%; flex-shrink: 0; }
.chart-legend-col { max-width: 420px; }
.chart-legend-col li { font-size: 12.5px; }
.grid-2 .chart-donut-wrap { grid-template-columns: 150px 1fr; }
.grid-2 .chart-donut { width: 150px; height: 150px; }
@media (max-width: 600px) { .chart-donut-wrap, .grid-2 .chart-donut-wrap { grid-template-columns: 1fr; } .chart-donut, .grid-2 .chart-donut { width: 160px; height: 160px; margin: 0 auto; } .chart-legend-col { max-width: none; } }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1000px) { .grid-3 { grid-template-columns: 1fr; } }

/* ---- Phase 10: portals ---- */
.portal-body { background: var(--bg); color: var(--text); }
.portal-shell { min-height: 100vh; display: flex; flex-direction: column; }
.portal-topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.portal-topbar-inner { max-width: 1100px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.portal-topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.portal-nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.portal-nav a { padding: 8px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.portal-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.portal-nav a.is-active { background: var(--primary-soft, var(--surface-3)); color: var(--primary); }
.portal-main { max-width: 1100px; width: 100%; margin: 0 auto; padding: 24px 20px 40px; flex: 1; }
.portal-footer { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; border-top: 1px solid var(--border); }
.portal-hero-grid { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; }
.portal-h1 { font-size: 26px; margin: 4px 0 6px; }
.portal-balance { text-align: right; padding: 14px 18px; border-radius: 14px; background: var(--surface-2); min-width: 240px; }
.portal-balance.is-due { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.portal-balance.is-clear { background: color-mix(in srgb, var(--success) 10%, var(--surface)); }
.portal-balance-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
@media (max-width: 720px) { .portal-hero-grid { grid-template-columns: 1fr; } .portal-balance { text-align: left; } .portal-topbar-inner { padding: 8px 12px; } .portal-main { padding: 16px 12px 32px; } }
