:root {
    --bg: #f4f7f6;
    --panel: #ffffff;
    --ink: #1b2a33;
    --ink-soft: #4f5f67;
    --muted: #7a8991;
    --line: #d9e2e1;
    --teal: #0f8b8d;
    --teal-dark: #08676c;
    --green: #2f8f61;
    --blue: #3c6f91;
    --gold: #b77a24;
    --red: #bf4b3f;
    --shadow: 0 12px 30px rgba(28, 43, 51, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.45;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 268px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: #18242c;
    color: #ecf4f3;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #e7f4ef;
    color: var(--teal-dark);
    font-weight: 800;
}

.brand-name {
    font-weight: 800;
    font-size: 17px;
}

.brand-subtitle,
.eyebrow {
    color: #9fb2b8;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.nav-list {
    display: grid;
    gap: 5px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #cbd8db;
    transition: background 0.16s ease, color 0.16s ease;
}

.nav-link span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #6a7b83;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.nav-link.active span {
    background: var(--teal);
}

.sidebar-actions {
    display: grid;
    gap: 8px;
    margin-top: auto;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 14px;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #31424b;
    font-weight: 800;
}

.user-name {
    font-weight: 700;
}

.sidebar-footer a {
    color: #b9c9ce;
    font-size: 13px;
}

.main {
    min-width: 0;
}

.topbar {
    min-height: 86px;
    padding: 22px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    background: rgba(244, 247, 246, 0.92);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 5;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: 28px;
    line-height: 1.1;
}

h2 {
    font-size: 17px;
}

h3 {
    font-size: 14px;
    margin: 18px 0 8px;
    color: var(--ink-soft);
}

.topbar-meta {
    color: var(--muted);
    white-space: nowrap;
}

.content {
    padding: 28px 32px 44px;
    display: grid;
    gap: 22px;
}

.flash-stack {
    padding: 18px 32px 0;
    display: grid;
    gap: 8px;
}

.alert {
    padding: 11px 14px;
    border-radius: 8px;
    background: #e8f2f5;
    color: var(--ink);
    border: 1px solid #c8dce2;
}

.alert.error {
    background: #fae9e7;
    border-color: #edc3bd;
}

.alert.success {
    background: #e9f5ef;
    border-color: #c7e2d4;
}

.alert.info {
    background: #e9f0f5;
    border-color: #c7d5df;
}

.panel,
.metric,
.property-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel {
    padding: 20px;
    min-width: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.panel-header p {
    color: var(--muted);
    margin-top: 3px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.metric {
    min-width: 0;
    min-height: 110px;
    padding: 14px 15px;
    border-top: 4px solid var(--line);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
}

.metric span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    line-height: 1.25;
}

.metric strong {
    display: block;
    max-width: 100%;
    font-size: 22px;
    line-height: 1.05;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.accent-green {
    border-top-color: var(--green);
}

.accent-teal {
    border-top-color: var(--teal);
}

.accent-blue {
    border-top-color: var(--blue);
}

.accent-gold {
    border-top-color: var(--gold);
}

.accent-red {
    border-top-color: var(--red);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
    gap: 22px;
}

.split-grid,
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.chart-box {
    height: 320px;
    min-height: 260px;
}

.chart-box.compact {
    height: 320px;
}

.two-col-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.event-row,
.warning-row,
.linked-row,
.audit-line {
    display: grid;
    gap: 3px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fbfdfc;
}

.event-row span,
.event-row em,
.warning-row span,
.audit-line span,
small {
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}

.warning-row {
    border-left: 4px solid var(--gold);
}

.warning-panel {
    background: #fff6e8;
    border: 1px solid #ead2ab;
    border-radius: 8px;
    padding: 14px;
    color: #684a1a;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: #f7faf9;
}

td small {
    display: block;
    margin-top: 2px;
}

tr.click-row {
    cursor: pointer;
}

tr.click-row:hover {
    background: #f6fbfa;
}

.empty-cell,
.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 18px;
}

.positive {
    color: var(--green);
}

.negative,
.danger {
    color: var(--red);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #edf2f3;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 700;
}

.badge.managed,
.badge.credit {
    background: #e7f4ef;
    color: var(--teal-dark);
}

.badge.owned {
    background: #edf1f6;
    color: var(--blue);
}

.badge.status {
    background: #f5efe5;
    color: #7c5318;
}

.btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    color: var(--ink);
    background: #edf3f2;
    font-weight: 750;
    white-space: nowrap;
}

.btn-primary {
    background: var(--teal);
    color: #ffffff;
}

.btn-secondary {
    background: #eef2f4;
    border-color: #d3dde1;
}

.btn-muted {
    background: rgba(255, 255, 255, 0.08);
    color: #f3f8f8;
    border-color: rgba(255, 255, 255, 0.12);
}

.btn-block {
    width: 100%;
}

.text-button {
    border: 0;
    background: transparent;
    padding: 0;
    font-weight: 700;
}

.filter-strip,
.inline-form,
.settings-grid,
.stack-form {
    display: grid;
    gap: 14px;
}

.filter-strip {
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    align-items: end;
}

.settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-form {
    grid-template-columns: repeat(7, minmax(120px, 1fr));
    align-items: end;
    padding: 14px;
    background: #f7faf9;
    border-radius: 8px;
    margin-bottom: 18px;
}

.collapsed {
    display: none;
}

label {
    display: grid;
    gap: 6px;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd7d8;
    border-radius: 8px;
    padding: 9px 10px;
    background: #ffffff;
    color: var(--ink);
    min-height: 40px;
}

select[multiple] {
    min-height: 120px;
}

textarea {
    resize: vertical;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
}

.check-label input {
    width: auto;
    min-height: auto;
}

.full-span {
    grid-column: 1 / -1;
}

.property-list {
    display: grid;
    gap: 12px;
}

.property-card {
    overflow: hidden;
}

.property-card summary {
    list-style: none;
    cursor: pointer;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
}

.property-card summary::-webkit-details-marker {
    display: none;
}

.property-card summary span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
}

.property-card form {
    padding: 0 16px 16px;
}

.summary-metrics {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mini-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    grid-column: 1 / -1;
}

.mini-metrics span {
    background: #f6faf9;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    color: var(--muted);
}

.mini-metrics strong {
    display: block;
    color: var(--ink);
    margin-top: 4px;
}

.mini-metrics.tall {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.fact-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.fact-list div {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 12px;
}

.fact-list dt {
    color: var(--muted);
}

.fact-list dd {
    margin: 0;
    font-weight: 700;
}

.detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.audit-ledger {
    display: grid;
    gap: 8px;
}

.audit-line {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.audit-line em,
.linked-row em {
    font-style: normal;
    font-weight: 800;
}

.linked-row {
    grid-template-columns: 95px minmax(0, 1fr) auto;
    align-items: center;
}

.pagination {
    margin-top: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.icon-button {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffff;
    display: grid;
    place-items: center;
}

.icon-button span {
    width: 18px;
    height: 2px;
    background: var(--ink);
    display: block;
    margin: 2px 0;
}

.mobile-only {
    display: none;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(180deg, #f4f7f6 0%, #e8eff0 100%);
}

.login-panel {
    width: min(420px, 100%);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 22px;
}

.login-brand .brand-subtitle {
    color: var(--muted);
}

@media (max-width: 1180px) {
    .kpi-grid {
        grid-template-columns: repeat(3, minmax(180px, 1fr));
    }

    .dashboard-grid,
    .split-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .filter-strip,
    .inline-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(300px, 86vw);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-only {
        display: grid;
    }

    .topbar {
        padding: 18px;
    }

    .content,
    .flash-stack {
        padding-left: 18px;
        padding-right: 18px;
    }

    .kpi-grid,
    .two-col-list,
    .settings-grid,
    .mini-metrics,
    .mini-metrics.tall,
    .filter-strip,
    .inline-form {
        grid-template-columns: 1fr;
    }

    .panel-header,
    .property-card summary {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-meta {
        display: none;
    }

    h1 {
        font-size: 23px;
    }
}
