:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #687386;
    --line: #dfe5ee;
    --primary: #126b62;
    --primary-dark: #0c4e48;
    --warn: #9b5a00;
    --danger: #a43636;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    display: grid;
    grid-template-columns: 240px 1fr;
}

body.login-page {
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(440px, 100%);
}

.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(20, 32, 50, .12);
    padding: 24px;
}

.login-form {
    display: grid;
    gap: 14px;
    margin-top: 20px;
}

.sidebar {
    background: #16212f;
    color: #fff;
    padding: 22px 16px;
}

.brand {
    align-items: center;
    display: flex;
    justify-content: center;
    font-size: 23px;
    font-weight: 700;
    margin-bottom: 24px;
}

.brand-logo {
    background: #fff;
    border-radius: 7px;
    height: auto;
    max-height: 72px;
    object-fit: contain;
    padding: 6px;
    width: 100%;
}

.company-logo-preview {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    height: 72px;
    object-fit: contain;
    padding: 6px;
    width: 120px;
}

nav {
    display: grid;
    gap: 8px;
}

.nav-group {
    align-items: center;
    background: transparent;
    border: 0;
    color: #8795aa;
    cursor: pointer;
    display: flex;
    font-size: 11px;
    font-weight: 700;
    justify-content: space-between;
    letter-spacing: .08em;
    margin: 0;
    padding: 8px 10px 4px;
    text-align: left;
    text-transform: uppercase;
    width: 100%;
}

.nav-section {
    display: grid;
    gap: 4px;
}

.nav-chevron {
    font-size: 16px;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform .15s ease;
}

.nav-section.open .nav-chevron {
    transform: rotate(90deg);
}

.nav-items {
    display: grid;
    gap: 4px;
}

.nav-items[hidden] {
    display: none !important;
}

nav a {
    color: #d6dde7;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 7px;
}

nav a.active,
nav a:hover {
    background: #243348;
    color: #fff;
}

.main {
    padding: 28px;
    overflow-x: auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 20px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 13px;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 18px;
    margin-bottom: 14px;
}

.panel,
.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(20, 32, 50, .05);
}

.panel {
    padding: 18px;
    margin-bottom: 18px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat {
    padding: 18px;
}

.stat strong {
    display: block;
    font-size: 28px;
}

.stat span,
.muted {
    color: var(--muted);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 12px;
}

.status-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #f8fafc;
}

.status-card strong,
.status-card span {
    display: block;
}

.status-card span {
    color: var(--muted);
    margin-top: 5px;
    font-size: 13px;
}

.status-card.ok {
    background: #e7f7ee;
    border-color: #b9e4cb;
}

.status-card.warn {
    background: #fff3df;
    border-color: #f2d5a7;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
    align-items: end;
}

label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
}

label.wide,
.grid-form .wide {
    grid-column: 1 / -1;
}

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

.checkbox-form {
    margin: 0;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
}

.checkbox-line input {
    width: auto;
    min-height: 0;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 10px 11px;
    min-height: 40px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

.select-search-field {
    align-self: stretch;
}

.select-search {
    min-height: 36px;
}

.select-search-field select[multiple] {
    min-height: 150px;
}

.selected-device-summary {
    display: grid;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--ink);
}

.selected-device-summary strong {
    font-size: 13px;
}

.selected-device-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.selected-device-item {
    border: 1px solid #b8d6c4;
    border-radius: 999px;
    background: #e7f7ee;
    color: #17633a;
    padding: 6px 10px;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.selected-device-item::after {
    content: " x";
}

textarea {
    min-height: 84px;
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 0;
    border-radius: 7px;
    padding: 10px 14px;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
}

.button:hover {
    background: var(--primary-dark);
}

.button.ghost {
    background: #eef5f4;
    color: var(--primary-dark);
}

.button.danger {
    background: var(--danger);
}

.button.small {
    min-height: 32px;
    padding: 7px 10px;
    font-size: 13px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.group-row td {
    background: #eef5f4;
    color: var(--primary-dark);
    font-weight: 700;
}

.group-row .button {
    margin-right: 10px;
}

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

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.report-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: end;
}

.inline-form label {
    min-width: 190px;
}

.inline-action {
    display: inline-flex;
    margin: 0;
}

.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
}

.badge.pending {
    color: var(--warn);
    background: #fff3df;
}

.badge.paid {
    color: #17633a;
    background: #e7f7ee;
}

.badge.partial {
    color: #705600;
    background: #fff7cf;
}

.badge.voided {
    color: var(--danger);
    background: #fdecec;
}

.badge.cancelled {
    color: var(--danger);
    background: #fdecec;
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    background: #e8f7ef;
    color: #145637;
}

.alert.warn {
    background: #fff3df;
    color: var(--warn);
}

@media (max-width: 900px) {
    body {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    nav {
        grid-template-columns: repeat(2, 1fr);
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .stats,
    .status-grid,
    .grid-form {
        grid-template-columns: 1fr;
    }
}
