:root {
    --sidebar-width: 250px;
    --yellow: #ffe600;
    --yellow-hover: #ffd400;
    --navy: #0b1324;
    --navy-hover: #1c2541;
    --page-bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #111827;
    --muted: #667085;
    --border: #e4e7ec;
    --green: #16a34a;
    --blue: #2563eb;
    --orange: #f59e0b;
    --red: #dc2626;
    --shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--page-bg);
    color: var(--text);
    font-family: Arial, sans-serif;
}

button,
input,
select {
    font: inherit;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--navy);
    color: white;
}

.logo {
    min-height: 86px;
    display: flex;
    align-items: center;
    justify-content: center;

    padding: 14px 18px;

    background:
        #ffe600
        url("https://s3-eu-west-1.amazonaws.com/tpd/logos/601d54fbe8edca00013d02e8/0x0.png")
        center / contain
        no-repeat;

    color: transparent;
    font-size: 0;

    border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}

.menu {
    padding: 12px;
}

.menu a {
    display: block;
    margin-bottom: 5px;
    padding: 14px 16px;
    border-radius: 9px;
    color: #dbe2ea;
    text-decoration: none;
    font-weight: 700;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.menu a:hover {
    background: var(--navy-hover);
    color: white;
    transform: translateX(2px);
}

.menu a.active {
    background: var(--navy-hover);
    color: white;
    box-shadow: inset 4px 0 0 var(--yellow);
}

.bottom {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.bottom button {
    width: 100%;
}

.main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    padding: 32px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.15px;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0;
    font-size: 36px;
    line-height: 1.15;
    letter-spacing: -1px;
}

.subtitle {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.topbar-link,
.secondary-button,
button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 0;
    border-radius: 9px;
    background: var(--yellow);
    color: #111827;
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
}

.topbar-link:hover,
button:hover {
    background: var(--yellow-hover);
}

.secondary-button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.secondary-button:hover {
    background: var(--surface-soft);
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 22px;
}

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

.card {
    min-height: 150px;
    padding: 22px;
    border-top: 5px solid var(--blue);
}

.card-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.card h2 {
    margin: 15px 0 7px;
    font-size: 42px;
    line-height: 1;
}

.card small {
    color: var(--muted);
}

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

.card-vacant h2 {
    color: var(--green);
}

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

.card-reserved h2 {
    color: var(--blue);
}

.card-low {
    border-top-color: var(--orange);
}

.card-low h2 {
    color: var(--orange);
}

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

.card-dead h2 {
    color: var(--red);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.85fr);
    gap: 20px;
}

.panel {
    padding: 22px;
}

.panel-header,
.table-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2,
.table-heading h2 {
    margin-bottom: 0;
    font-size: 20px;
}

.count-pill,
.result-summary {
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
}

.result-summary {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.result-summary strong {
    color: var(--text);
    font-size: 20px;
}

.priority-row {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--border);
}

.priority-row:last-child {
    border-bottom: 0;
}

.priority-row strong,
.priority-row span {
    display: block;
}

.priority-row div span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.activity-list p {
    margin: 0;
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
}

.activity-list p:last-child {
    border-bottom: 0;
}

.filter-panel {
    margin-bottom: 20px;
}

.filters {
    display: grid;
    grid-template-columns: minmax(210px, 1.4fr) repeat(5, minmax(145px, 1fr));
    gap: 14px;
    padding-top: 18px;
}

.field {
    display: grid;
    gap: 7px;
}

.field > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.field input,
.field select {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.table-panel {
    padding: 0;
    overflow: hidden;
}

.table-heading {
    padding: 22px;
}

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

.units-table {
    width: 100%;
    min-width: 820px;
    border-collapse: collapse;
}

.units-table th,
.units-table td {
    padding: 15px 18px;
    text-align: left;
}

.units-table th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}

.units-table td {
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.units-table tbody tr {
    transition: background-color 0.18s ease;
}

.units-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.05);
    cursor: pointer;
}

.units-table tbody tr:last-child td {
    border-bottom: 0;
}

.status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 58px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.45px;
    text-transform: uppercase;
}

.status-vacant,
.status-okay {
    background: #ecfdf3;
    color: #15803d;
}

.status-low {
    background: #fffbeb;
    color: #b45309;
}

.status-dead {
    background: #fef2f2;
    color: #b91c1c;
}

.status-neutral {
    background: #f2f4f7;
    color: #475467;
}

.empty-state {
    padding: 50px 24px;
    text-align: center;
}

.empty-state h3 {
    margin-bottom: 6px;
}

.empty-state p {
    margin-bottom: 0;
    color: var(--muted);
}

body.dark {
    --page-bg: #10141c;
    --surface: #1a202b;
    --surface-soft: #242d3b;
    --text: #f3f4f6;
    --muted: #aeb7c5;
    --border: #303a49;
    --shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
}

body.dark .sidebar {
    background: #060b16;
}

body.dark .field input,
body.dark .field select {
    border-color: #445064;
}

body.dark .status-vacant,
body.dark .status-okay {
    background: rgba(22, 163, 74, 0.18);
    color: #4ade80;
}

body.dark .status-low {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
}

body.dark .status-dead {
    background: rgba(220, 38, 38, 0.18);
    color: #f87171;
}

body.dark .status-neutral {
    background: #2c3645;
    color: #dbe2ea;
}

@media (max-width: 1250px) {
    .filters {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .search-field {
        grid-column: span 2;
    }
}

@media (max-width: 1050px) {
    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 760px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
    }

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

    .bottom {
        margin-top: 0;
    }

    .main {
        margin-left: 0;
        padding: 20px;
    }

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

    .cards,
    .filters {
        grid-template-columns: 1fr;
    }

    .search-field {
        grid-column: auto;
    }

    h1 {
        font-size: 30px;
    }

    .panel-header {
        align-items: stretch;
        flex-direction: column;
    }
}


/* Battery replacement quality-of-life controls */
.manual-replacement-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: end;
    gap: 14px;
    padding-top: 18px;
}

.replacement-message {
    margin: 16px 0 0;
    padding: 12px 14px;
    border-radius: 9px;
    background: #ecfdf3;
    color: #15803d;
    font-size: 13px;
    font-weight: 700;
}

.replacement-message.is-error {
    background: #fef2f2;
    color: #b91c1c;
}

.replacement-history-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.replacement-history-item:last-child {
    border-bottom: 0;
}

.replacement-history-item strong {
    display: block;
    margin-bottom: 5px;
}

.replacement-history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: var(--muted);
    font-size: 12px;
}

.undo-button {
    min-height: 36px;
    padding: 8px 13px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.undo-button:hover {
    background: var(--surface-soft);
}

.battery-row-changed {
    display: none;
}

body.dark .replacement-message {
    background: rgba(22, 163, 74, 0.18);
    color: #4ade80;
}

body.dark .replacement-message.is-error {
    background: rgba(220, 38, 38, 0.18);
    color: #f87171;
}

@media (max-width: 760px) {
    .manual-replacement-form,
    .replacement-history-item {
        grid-template-columns: 1fr;
    }

    .undo-button {
        width: 100%;
    }
}