/* Palette matches channelsmartbuildings.com: black header, CSB orange accent. */
:root {
    color-scheme: light dark;
    --bg: #f4f4f5;
    --surface: #ffffff;
    --text: #17181a;
    --muted: #6b7280;
    --border: #e3e4e7;
    --accent: #f08a3d;
    --accent-hover: #d9762f;
    --accent-text: #16130d;
    --brand-black: #0a0a0a;
    --brand-black-border: #262626;
    --error: #b42318;
    --error-bg: #fef2f1;
    --success: #146c2e;
    --success-bg: #edfbf1;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.45;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    flex-wrap: wrap;
    background: var(--brand-black);
    border-bottom: 1px solid var(--brand-black-border);
    padding: 0.65rem 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
}

.brand img { height: 26px; width: auto; display: block; }

.brand .product {
    letter-spacing: 0.08em;
    font-size: 0.95rem;
}

.brand .product em {
    font-style: normal;
    color: var(--accent);
}

.topbar nav {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    flex: 1;
}

.topbar nav a {
    color: #d6d6d8;
    text-decoration: none;
    font-size: 0.95rem;
}

.topbar nav a:hover { color: var(--accent); }

.logout-form {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.whoami { color: #9a9a9d; font-size: 0.9rem; }

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.25rem 1rem 3rem;
}

h1 { font-size: 1.4rem; margin-top: 0; }

.stack {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    max-width: 480px;
}

.combobox { position: relative; }

.combobox-list {
    position: absolute;
    z-index: 20;
    top: 100%;
    left: 0;
    right: 0;
    margin: 2px 0 0;
    padding: 0.25rem 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.combobox-list[hidden] { display: none; }

.combobox-list li {
    padding: 0.55rem 0.7rem;
    cursor: pointer;
}

.combobox-list li:hover,
.combobox-list li.active {
    background: var(--bg);
}

.combobox-list li.combobox-group {
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.5rem 0.7rem 0.2rem;
    cursor: default;
}

.combobox-list li.combobox-group:hover { background: none; }

.field-hint {
    font-size: 0.85rem;
    color: var(--muted);
    margin: -0.4rem 0 0;
}

.inline-filters {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    max-width: none;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.9rem;
    color: var(--muted);
}

label.checkbox {
    flex-direction: row;
    align-items: center;
}

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

input, select, textarea {
    padding: 0.55rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

button, .button {
    display: inline-block;
    padding: 0.6rem 1.1rem;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: 7px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

button:hover, .button:hover { background: var(--accent-hover); }

.link-button {
    background: none;
    border: none;
    color: var(--accent-hover);
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
}

.inline-form { display: inline; margin-left: 0.6rem; }

.error {
    background: var(--error-bg);
    color: var(--error);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
}

.success {
    background: var(--success-bg);
    color: var(--success);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
}

.conflict-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.conflict-card h2 { font-size: 1rem; margin-top: 0; }

.conflict-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.conflict-actions form { margin: 0; }

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

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 0.92rem;
}

th, td {
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th { color: var(--muted); font-weight: 600; }

.quick-ranges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0 0 0.75rem;
}

.quick-ranges a {
    font-size: 0.85rem;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
}

.quick-ranges a:hover { border-color: var(--accent); color: var(--accent-hover); }

/* Below this width, tables render as a stack of labelled cards instead of scrolling
   sideways — a wide table with a long description column is genuinely awkward to use
   on a phone otherwise. */
@media (max-width: 640px) {
    .table-wrap { overflow-x: visible; }

    .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap td {
        display: block;
        width: 100%;
    }

    .table-wrap thead { display: none; }

    .table-wrap tr {
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 0.6rem 0.75rem;
        margin-bottom: 0.75rem;
    }

    .table-wrap td {
        border: none;
        white-space: normal;
        padding: 0.3rem 0;
        display: flex;
        gap: 0.75rem;
        justify-content: space-between;
        align-items: baseline;
    }

    .table-wrap td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--muted);
        flex-shrink: 0;
    }

    .table-wrap td:last-child:empty { display: none; }
}
