:root {
    color-scheme: dark;
    --page: #202537;
    --panel: #282e42;
    --panel-raised: #2e354b;
    --border: #3a4259;
    --text: #edf1fa;
    --muted: #9da8c0;
    --accent: #31d4c2;
    --danger: #ff4268;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page);
    color: var(--text);
    font: 14px/1.5 "Segoe UI", Arial, sans-serif;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at 50% 10%, #35415f, var(--page) 55%);
}

.login-card {
    width: min(100%, 430px);
    padding: 38px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: 0 22px 60px #10142180;
}

.brand-mark {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #30d5c2, #4384ef);
    color: #152034;
    font-size: 24px;
    font-weight: 800;
}

.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; font-size: 17px; }
.eyebrow { margin: 18px 0 5px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.login-card h1, .topbar h1 { margin: 0; font-size: 25px; }
.muted, .login-footer, .privacy-note { color: var(--muted); }
.login-card .muted { margin: 8px 0 24px; }
.skip-password-form { margin: 0 0 18px; }
.skip-password-button {
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 10px 14px;
    border: 2px solid var(--accent);
    border-radius: 6px;
    background: transparent;
    color: var(--accent);
    font-weight: 700;
}
.skip-password-button:hover { background: #31d4c21a; }
.login-card label { display: block; margin: 16px 0 6px; color: #dce3f2; font-size: 12px; }
.login-card input {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    background: #202638;
    color: var(--text);
}
.login-card input:focus, .table-toolbar input:focus, .table-toolbar select:focus { border-color: var(--accent); }
.primary-button {
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #10232d;
    font-weight: 700;
}
.primary-button:hover { filter: brightness(1.08); }
.full-width { width: 100%; height: 44px; margin-top: 24px; }
.login-footer { margin: 24px 0 0; font-size: 12px; text-align: center; }
.alert { padding: 11px 13px; border: 1px solid #a93c55; border-radius: 6px; background: #602e43; color: #ffe3e9; }
.success-alert { padding: 11px 13px; border: 1px solid #1f8d76; border-radius: 6px; background: #183f3b; color: #b6f5e4; }

.portal-page { display: flex; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    width: 218px;
    flex-direction: column;
    padding: 20px 14px;
    border-right: 1px solid var(--border);
    background: #252b3e;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 26px; color: var(--text); font-weight: 700; text-decoration: none; }
.sidebar nav { display: grid; gap: 5px; }
.nav-link { padding: 11px 12px; border-radius: 6px; color: #b6bfd1; text-decoration: none; }
.nav-link:hover, .nav-link.active { background: #333b53; color: white; }
.nav-link.active { box-shadow: inset 3px 0 var(--accent); }
.sidebar-footer { margin-top: auto; padding: 12px; color: var(--muted); font-size: 12px; }

.main-content { width: calc(100% - 218px); margin-left: 218px; padding: 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.topbar .eyebrow { margin-top: 0; }
.user-menu { display: flex; align-items: center; gap: 16px; }
.user-menu form { margin: 0; }
.text-button { padding: 6px 10px; border: 1px solid var(--border); border-radius: 5px; background: transparent; color: var(--accent); }
.text-button:hover { border-color: var(--accent); }

.summary-card, .table-card { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); box-shadow: 0 8px 22px #1115223b; }
.summary-card { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px; margin-bottom: 18px; }
.summary-card h2 { margin: 0 0 5px; font-size: 16px; }
.summary-card p { margin: 0; color: var(--muted); }
.record-count { display: grid; justify-items: end; color: var(--muted); }
.record-count strong { color: var(--accent); font-size: 24px; line-height: 1.1; }
.page-alert { margin-bottom: 18px; }
.table-card { overflow: hidden; }
.table-toolbar { display: flex; align-items: end; gap: 16px; padding: 20px 18px; }
.table-toolbar label { display: grid; gap: 6px; color: #cbd4e5; font-size: 12px; }
.table-toolbar .search-control { flex: 1; }
.table-toolbar input, .table-toolbar select {
    min-height: 37px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    outline: 0;
    background: #22283a;
    color: var(--text);
}
.entries-control { display: flex !important; align-items: center; flex-direction: row; }
.entries-control select { min-width: 64px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 1120px; border-collapse: collapse; }
th, td { padding: 13px 12px; border-top: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: #292f43; color: #dce4f2; font-size: 11px; font-weight: 700; }
.sort-button { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; font-weight: inherit; text-align: left; white-space: nowrap; }
.sort-button:hover { color: var(--accent); }
.sort-button span { display: inline-block; min-width: 10px; color: var(--accent); }
td { color: #d9e0ed; font-size: 12px; }
tbody tr:hover { background: #30374c; }
tbody tr[hidden] { display: none; }
.account-cell { color: #a9c5ff; white-space: nowrap; }
.address-cell { min-width: 190px; max-width: 260px; }
.status-badge { display: inline-block; padding: 4px 8px; border: 1px solid; border-radius: 4px; white-space: nowrap; }
.status-badge.installed { border-color: #1fae99; color: #5ae1c9; }
.status-badge.pending { border-color: #c48727; color: #ffd16b; }
.status-badge.other { border-color: #7484a7; color: #c4d2ec; }
.action-link { color: var(--accent); text-decoration: none; white-space: nowrap; }
.action-link:hover { text-decoration: underline; }
.inline-action-form { display: inline-block; margin: 0 0 0 6px; }
.empty-state { padding: 28px 16px; color: var(--muted); text-align: center; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.pagination { display: flex; align-items: center; gap: 9px; }
.pagination button { padding: 6px 10px; border: 1px solid var(--border); border-radius: 4px; background: transparent; color: var(--text); }
.pagination button:disabled { cursor: default; opacity: .4; }
.privacy-note { margin: 16px 0; font-size: 12px; }
.customer-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.compact-card { margin-bottom: 18px; padding: 18px; }
.customer-section { margin: 18px 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px; border-bottom: 1px solid var(--border); }
.section-heading h2 { margin: 0; font-size: 16px; }
.section-heading > span { color: var(--muted); font-size: 12px; }
.customer-table { min-width: 720px; }
.status-badge.paid { border-color: #1fae99; color: #5ae1c9; }
.status-badge.unpaid { border-color: #c44761; color: #ff9aab; }
.status-badge.partially-paid { border-color: #c48727; color: #ffd16b; }
.admin-form-card { margin-bottom: 18px; }
.admin-form { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 14px; padding: 18px; }
.admin-form label { display: grid; gap: 6px; color: #cbd4e5; font-size: 12px; }
.admin-form input, .admin-form select, .payment-form input {
    min-width: 0;
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    outline: 0;
    background: #22283a;
    color: var(--text);
}
.admin-form input:focus, .admin-form select:focus, .payment-form input:focus { border-color: var(--accent); }
.admin-form .wide-field { grid-column: span 2; }
.admin-form > button { align-self: end; min-height: 40px; }
.payment-form { display: grid; min-width: 210px; gap: 7px; }
.payment-form .primary-button { min-height: 36px; }
.admin-table { min-width: 980px; }
.admin-table small { color: var(--muted); }
.page-alert { margin: 0 0 16px; }
.customer-section .empty-state { padding: 22px; }

@media (max-width: 900px) {
    .sidebar { width: 70px; padding: 16px 8px; }
    .brand { justify-content: center; padding: 4px 0 22px; }
    .brand > span:last-child, .nav-link:not(.active), .sidebar-footer { display: none; }
    .nav-link { overflow: hidden; padding: 12px 4px; font-size: 0; text-align: center; }
    .nav-link.active { font-size: 10px; }
    .main-content { width: calc(100% - 70px); margin-left: 70px; padding: 22px 16px; }
}
@media (max-width: 620px) {
    .main-content { padding: 18px 10px; }
    .topbar { align-items: flex-start; }
    .topbar h1 { font-size: 20px; }
    .user-menu { flex-direction: column; align-items: flex-end; gap: 6px; }
    .summary-card { align-items: flex-start; gap: 12px; padding: 18px; }
    .table-toolbar { align-items: stretch; flex-direction: column; gap: 12px; }
    .entries-control { justify-content: flex-start; }
    .table-footer { align-items: flex-start; flex-direction: column; }
    .login-card { padding: 28px 22px; }
    .customer-overview { grid-template-columns: 1fr; gap: 0; }
    .admin-form { grid-template-columns: 1fr; }
    .admin-form .wide-field { grid-column: auto; }
}
