/* ============================================================
   Fair Key Homes — Property Accounting
   Palette shared with the Bradley Place quarterly report.
   ============================================================ */
:root {
    --navy: #12414f;
    --teal: #225b6c;
    --teal-600: #17414e;
    --gold: #c08a2e;
    --maroon: #733832;
    --bg: #f4f6f6;
    --surface: #ffffff;
    --border: #dde4e4;
    --text: #22333a;
    --muted: #6b7a80;
    --ok: #2e7d5b;
    --watch: #b8860b;
    --warn: #c2701c;
    --bad: #b3261e;
    --shadow: 0 1px 2px rgba(18,65,79,.05), 0 6px 18px rgba(18,65,79,.06);
    --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--navy); margin: 0; letter-spacing: -.01em; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 236px;
    flex: 0 0 236px;
    background: var(--navy);
    color: #cfe0e4;
    padding: 1.1rem .75rem 2rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: .6rem; padding: 0 .5rem 1.25rem; }
.brand-mark {
    display: grid; place-items: center;
    width: 34px; height: 34px; border-radius: 8px;
    background: var(--gold); color: #fff; font-weight: 800; font-size: .85rem;
}
.brand-text strong { display: block; color: #fff; font-size: .95rem; }
.brand-text small { color: #9db9c0; font-size: .72rem; }

.nav-groups { display: flex; flex-direction: column; gap: 1px; }
.nav-group-label {
    margin: 1rem .6rem .3rem;
    font-size: .66rem; font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; color: #7fa3ac;
}
.nav-item {
    display: flex; align-items: center; gap: .55rem;
    padding: .45rem .6rem; border-radius: 7px;
    color: #cfe0e4; font-size: .85rem;
}
.nav-item:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav-item.active { background: var(--teal); color: #fff; font-weight: 600; }
.nav-icon { width: 1.1em; text-align: center; opacity: .85; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    height: 52px; padding: 0 1.5rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-weight: 700; color: var(--navy); letter-spacing: .02em; }

.sync-pill {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .28rem .7rem; border-radius: 999px;
    background: #eef5f4; color: var(--teal-600);
    font-size: .76rem; font-weight: 600;
}
.sync-pill-warn { background: #fdf1e7; color: var(--warn); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

.content { padding: 1.5rem; max-width: 1500px; width: 100%; }

/* ---------- Page header ---------- */
.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.25rem;
}
.page-header h1 { font-size: 1.5rem; }
.page-subtitle { margin: .3rem 0 0; color: var(--muted); }
.page-actions { display: flex; gap: .5rem; }

.btn {
    display: inline-flex; align-items: center; padding: .4rem .85rem;
    border: 1px solid var(--border); border-radius: 7px;
    background: var(--surface); color: var(--navy); font-weight: 600; font-size: .82rem;
}
.btn:hover { border-color: var(--teal); text-decoration: none; }

/* ---------- Stats ---------- */
.stat-grid {
    display: grid; gap: .75rem; margin-bottom: 1.25rem;
    grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-left: 3px solid var(--muted);
    border-radius: var(--radius); padding: .8rem .95rem; box-shadow: var(--shadow);
}
.stat-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 1.5rem; font-weight: 750; color: var(--navy); line-height: 1.15; margin-top: .2rem; }
.stat-caption { font-size: .75rem; color: var(--muted); margin-top: .15rem; }

.stat-good  { border-left-color: var(--ok); }
.stat-watch { border-left-color: var(--watch); }
.stat-warn  { border-left-color: var(--warn); }
.stat-bad   { border-left-color: var(--bad); }
.stat-info  { border-left-color: var(--teal); }

/* ---------- Panels ---------- */
.panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1rem 1.1rem; margin-bottom: 1.25rem;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.panel-head h2 { font-size: 1rem; }
.panel-head a { font-size: .8rem; font-weight: 600; }
.panel-note { margin: .7rem 0 0; font-size: .78rem; color: var(--muted); }
.panel-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }

/* ---------- Tables ---------- */
.grid {
    width: 100%; border-collapse: collapse; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.panel .grid { border: 0; box-shadow: none; margin-bottom: 0; }

.grid th, .grid td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--border); }
.grid thead th {
    background: #f2f6f6; color: var(--navy);
    font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    white-space: nowrap;
}
.grid tbody tr:hover { background: #f8fbfb; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tfoot th {
    background: #f2f6f6; color: var(--navy); font-weight: 750;
    border-top: 2px solid var(--border); border-bottom: 0;
}
.grid.compact th, .grid.compact td { padding: .38rem .6rem; font-size: .83rem; }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 700; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.row-vacant { background: #fffdf6; }
.row-heading td { background: #f7f9f9; }

/* ---------- Chips ---------- */
.chip {
    display: inline-block; padding: .1rem .45rem; border-radius: 999px;
    font-size: .7rem; font-weight: 700; white-space: nowrap;
}
.chip-ok    { background: #e4f2ea; color: var(--ok); }
.chip-info  { background: #e6eff2; color: var(--teal-600); }
.chip-watch { background: #fdf4e0; color: var(--watch); }
.chip-warn  { background: #fdeede; color: var(--warn); }
.chip-bad   { background: #fbe6e4; color: var(--bad); }
.chip-worst { background: var(--bad); color: #fff; }
.chip-muted { background: #eef0f0; color: var(--muted); }

/* ---------- Ageing bars ---------- */
.aging { display: flex; flex-direction: column; gap: .4rem; }
.aging-row { display: grid; grid-template-columns: 62px 1fr 92px; align-items: center; gap: .6rem; }
.aging-label { font-size: .76rem; font-weight: 600; color: var(--muted); }
.aging-track { height: 16px; background: #eef1f1; border-radius: 4px; overflow: hidden; }
.aging-fill { height: 100%; border-radius: 4px; min-width: 2px; transition: width .3s ease; }
.aging-amount { text-align: right; font-size: .82rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.aging-ok { background: var(--ok); }
.aging-watch { background: var(--watch); }
.aging-warn { background: var(--warn); }
.aging-bad { background: var(--bad); }
.aging-worst { background: #7d1a15; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: .75rem; margin-bottom: .8rem; flex-wrap: wrap; }
.search {
    flex: 1 1 260px; max-width: 400px; padding: .42rem .7rem;
    border: 1px solid var(--border); border-radius: 7px; font: inherit; background: var(--surface);
}
.search:focus { outline: 0; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(34,91,108,.12); }
.check { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; color: var(--muted); }
.toolbar-count { margin-left: auto; font-size: .78rem; color: var(--muted); }

.loading, .empty { padding: 2rem; text-align: center; color: var(--muted); }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    padding: .7rem 1.25rem; background: #fbe6e4; color: var(--bad); box-shadow: 0 -2px 10px rgba(0,0,0,.1);
}

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: static; }
    .panel-grid { grid-template-columns: 1fr; }
}

/* ---------- Auth ---------- */
.user-chip {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .22rem .6rem .22rem .25rem; border-radius: 999px;
    background: #eef5f4; color: var(--teal-600);
    font-size: .76rem; font-weight: 600; max-width: 260px;
}
.user-avatar {
    display: grid; place-items: center; flex: 0 0 auto;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--teal); color: #fff; font-size: .7rem; font-weight: 700;
}
.user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.signout-link { font-size: .76rem; font-weight: 600; color: var(--muted); }
.signout-link:hover { color: var(--maroon); }

.topbar-meta { display: flex; align-items: center; gap: .75rem; }

.auth-card {
    max-width: 460px; margin: 4rem auto; padding: 2.25rem 2rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); text-align: center;
}
.auth-icon { font-size: 2.25rem; line-height: 1; margin-bottom: .75rem; }
.auth-card h1 { font-size: 1.35rem; margin-bottom: .6rem; }
.auth-card p { color: var(--muted); margin: 0 0 1.35rem; }
.btn-primary {
    background: var(--teal); border-color: var(--teal); color: #fff;
}
.btn-primary:hover { background: var(--teal-600); border-color: var(--teal-600); color: #fff; }

@media (max-width: 900px) {
    .user-email { display: none; }
}

/* ---------- Admin editing grids ---------- */
.admin-note { margin-bottom: 1.25rem; }
.admin-note p { margin: 0; font-size: .88rem; }
.cell-input {
    width: 100%; min-width: 6rem; padding: .28rem .45rem;
    border: 1px solid var(--border); border-radius: 6px; font: inherit; background: var(--surface);
}
.cell-input:focus { outline: 0; border-color: var(--teal); }
.cell-input.num { text-align: right; }
.row-actions { display: flex; gap: .35rem; white-space: nowrap; }

/* ---------- Water sparkline ---------- */
.spark {
    display: flex; align-items: flex-end; gap: 2px;
    height: 140px; padding: .5rem .25rem 0;
    background: linear-gradient(to top, #f6f9f9 0 1px, transparent 1px);
}
.spark-bar { flex: 1 1 0; min-width: 2px; border-radius: 2px 2px 0 0; background: var(--teal); }
.spark-normal { background: var(--teal); }
.spark-med    { background: var(--watch); }
.spark-high   { background: var(--warn); }
.spark-crit   { background: var(--bad); }
.spark-bar:hover { filter: brightness(1.25); }
.spark-axis {
    display: flex; justify-content: space-between;
    margin-top: .3rem; font-size: .74rem; color: var(--muted);
}
.muted-row td { opacity: .55; }
