:root {
    --bg: #1f2326;
    --panel: #171a1d;
    --panel-2: #24282c;
    --line: #343b42;
    --line-soft: #2b3035;
    --text: #f0f3f4;
    --muted: #9aa3aa;
    --faint: #687179;
    --accent: #ff4d5b;
    --accent-2: #38c7b5;
    --warn: #f0b65f;
    --time-today-bg: #252a2d;
    --radius: 6px;
    --sidebar-width: 320px;
}

/* Time tracking clarity pass: compact 13 px ledgers, generous input controls. */
.time-pane {
    font-family: Aptos, "Segoe UI", sans-serif;
    font-size: 13px;
}

.time-commandbar h1,
.time-entry-dialog h2 {
    font-family: Bahnschrift, "Aptos Display", "Segoe UI", sans-serif;
    font-weight: 600;
    letter-spacing: -.015em;
}

.time-pane button,
.time-entry-dialog button {
    min-height: 38px;
}

.time-entry-card {
    gap: 6px;
    min-height: 92px;
    padding: 12px 12px 10px;
    border-radius: 7px;
}

.time-entry-card .time-entry-description {
    color: #edf2f4;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.time-entry-card > span:not(.time-entry-description),
.time-entry-card > small {
    font-size: 13px;
    line-height: 1.35;
}

.time-entry-card footer {
    font-size: 13px;
    font-weight: 500;
}

.time-day-column > header,
.time-day-column > header small,
.time-day-add,
.time-week-toolbar,
.time-mobile-day-picker {
    font-size: 13px;
}

.time-report-filters {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(220px, 1.5fr) minmax(145px, .8fr) minmax(145px, .8fr) auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 14px;
    padding: 14px;
    border: 1px solid #3a444c;
    border-radius: 8px;
    background: #22282d;
}

.time-report-filters > label {
    min-width: 0;
    display: grid;
    gap: 6px;
}

.time-report-filters > label > span {
    color: #9ba8b1;
    font-size: 12px;
}

.time-report-filters input {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid #46515a;
    border-radius: 6px;
    outline: none;
    color: #edf2f4;
    background: #14191d;
    font: inherit;
}

.time-report-filters input:focus,
.time-entry-fields input:focus,
.time-entry-fields textarea:focus {
    border-color: #ff5967;
    box-shadow: 0 0 0 3px rgba(255, 89, 103, .13);
}

.time-report-filters > button {
    min-height: 42px;
    white-space: nowrap;
}

.time-filter-result {
    grid-column: 1 / -1;
    min-height: 16px;
    color: #9ba8b1;
    font-size: 12px;
}

.time-report-filters .autocomplete-results,
.time-customer-field .autocomplete-results {
    padding: 5px;
    border-color: #46515a;
    border-radius: 7px;
    background: #14191d;
}

.time-report-filters .autocomplete-results button,
.time-customer-field .autocomplete-results button {
    width: 100%;
    min-height: 38px;
    display: block;
    padding: 8px 10px;
    border: 0;
    color: #dfe6e9;
    background: transparent;
    text-align: left;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.time-customer-suggestion-meta {
    margin-left: 6px;
    color: #81909a;
    font-size: 11px;
    font-weight: 400;
}

.time-report-filters .autocomplete-results button:hover,
.time-report-filters .autocomplete-results button[aria-selected="true"],
.time-customer-field .autocomplete-results button:hover,
.time-customer-field .autocomplete-results button[aria-selected="true"] {
    color: #fff;
    background: #30383f;
}

.time-report-filters .autocomplete-results button:hover .time-customer-suggestion-meta,
.time-report-filters .autocomplete-results button[aria-selected="true"] .time-customer-suggestion-meta,
.time-customer-field .autocomplete-results button:hover .time-customer-suggestion-meta,
.time-customer-field .autocomplete-results button[aria-selected="true"] .time-customer-suggestion-meta {
    color: #aeb9bf;
}

.time-report-totals {
    font-size: 13px;
}

.time-report-totals span {
    font-size: 12px;
}

.time-report-totals strong {
    font-size: 17px;
    font-weight: 600;
}

.time-customer-group {
    overflow: visible;
    font-size: 13px;
}

.time-customer-group > summary {
    --time-color: #2563eb;
    min-height: 68px;
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(380px, auto) 24px;
    align-items: center;
    gap: 18px;
    padding: 10px 14px;
    border-left: 5px solid var(--time-color);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.time-customer-group > summary::-webkit-details-marker {
    display: none;
}

.time-customer-group[open] > summary {
    border-bottom: 1px solid var(--line-soft);
    background: rgba(255, 255, 255, .018);
}

.time-customer-group > summary > div:first-child {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.time-customer-group > summary span,
.time-report-row,
.time-report-row small {
    font-size: 13px;
}

.time-customer-name {
    overflow: hidden;
    color: #edf2f4;
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.time-group-sums {
    gap: 8px 18px;
    color: #b9c3c9;
    font-size: 13px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

.time-group-sums > span {
    white-space: nowrap;
}

.time-group-total,
.time-money {
    color: #edf2f4 !important;
    font-family: "Cascadia Mono", Consolas, monospace;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.time-group-chevron {
    color: #9ba8b1;
    font-size: 20px !important;
    line-height: 1;
    text-align: center;
    transition: transform .16s ease;
}

.time-customer-group[open] .time-group-chevron {
    transform: rotate(180deg);
}

.time-report-table,
.time-billed-list {
    min-width: 0;
    overflow-x: auto;
}

.time-report-head,
.time-report-row {
    min-width: 940px;
    display: grid;
    grid-template-columns: 28px 92px minmax(250px, 1fr) 90px 105px 105px 115px;
    align-items: center;
    gap: 10px;
    padding-right: 15px;
    padding-left: 15px;
}

.time-report-head {
    min-height: 38px;
    color: #9ba8b1;
    border-bottom: 1px solid var(--line-soft);
    background: #181d21;
    font-size: 11px;
    letter-spacing: .035em;
    text-transform: uppercase;
}

.time-report-row {
    min-height: 52px;
    color: #d7dfe3;
    font-weight: 400;
}

.time-report-row > span:nth-child(3),
.time-billed-description {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.time-report-row small,
.time-billed-description small,
.time-billed-row > small {
    color: #87959e;
    font-size: 12px;
    font-weight: 400;
}

.time-customer-group > footer {
    padding: 12px 15px;
    border-top: 1px solid var(--line-soft);
}

.time-billed-list {
    border-color: #3a444c;
    background: #202529;
}

.time-billed-head,
.time-billed-row {
    min-width: 1220px;
    display: grid;
    grid-template-columns: 8px minmax(155px, .85fr) 92px minmax(250px, 1.5fr) 96px 112px minmax(185px, 1fr) 220px;
    align-items: center;
    gap: 13px;
    padding-right: 14px;
    padding-left: 14px;
}

.time-billed-head {
    min-height: 40px;
    color: #9ba8b1;
    border-bottom: 1px solid #3a444c;
    background: #181d21;
    font-size: 11px;
    letter-spacing: .035em;
    text-transform: uppercase;
}

.time-billed-row {
    min-height: 58px;
    color: #d7dfe3;
    background: #202529;
    font-size: 13px;
    font-weight: 400;
}

.time-billed-row > span,
.time-billed-row > small {
    color: inherit;
    font-size: 13px;
}

.time-billed-row button {
    justify-self: start;
    min-height: 34px;
    font-size: 12px;
}

.time-color-dot {
    width: 6px;
    height: 34px;
}

.time-entry-dialog {
    width: min(820px, calc(100vw - 32px));
    max-height: min(880px, calc(100vh - 32px));
    overflow: hidden;
    border-color: #4a555e;
    border-radius: 11px;
    background: #1d2327;
}

.time-entry-dialog form {
    max-height: inherit;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.time-entry-dialog form > header {
    padding: 18px 22px;
    background: #22282d;
}

.time-entry-dialog h2 {
    font-size: 26px;
}

.time-entry-fields {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
    overflow-y: auto;
    padding: 22px;
}

.time-entry-fields > label,
.time-entry-fields > .calculated-field {
    grid-column: span 6;
}

.time-entry-fields > .field-wide,
.time-entry-fields > .time-customer-field {
    grid-column: 1 / -1;
}

.time-entry-fields > .time-date-field {
    grid-column: span 6;
}

.time-entry-fields label {
    gap: 7px;
    font-size: 13px;
}

.time-entry-fields label > span,
.time-entry-fields .calculated-field > span {
    color: #aab6bd;
    font-size: 13px;
}

.time-entry-fields > .time-customer-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.time-entry-fields > .time-customer-field > label {
    display: block;
    color: #aab6bd;
    font-size: 13px;
}

.time-entry-fields input,
.time-entry-fields textarea {
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #46515a;
    border-radius: 6px;
    outline: none;
    color: #edf2f4;
    background: #14191d;
    font: 14px/1.35 Aptos, "Segoe UI", sans-serif;
}

.time-date-control {
    position: relative;
}

.time-date-control input[type="date"] {
    position: relative;
    width: 100%;
    color: transparent;
    cursor: pointer;
}

.time-date-control input[type="date"]::-webkit-datetime-edit {
    color: transparent;
}

.time-date-readable {
    position: absolute;
    inset: 0 42px 0 13px;
    display: flex;
    align-items: center;
    overflow: hidden;
    color: #edf2f4;
    font: 14px/1.35 Aptos, "Segoe UI", sans-serif;
    white-space: nowrap;
    pointer-events: none;
}

.time-date-icon {
    position: absolute;
    top: 50%;
    right: 13px;
    width: 17px;
    height: 17px;
    transform: translateY(-50%);
    fill: none;
    stroke: #aab6bd;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.time-date-control:focus-within .time-date-icon {
    stroke: #edf2f4;
}

.time-entry-fields textarea {
    min-height: 104px;
    resize: vertical;
}

.time-entry-fields .calculated-field strong {
    min-height: 46px;
    padding: 0 2px;
    color: #edf2f4;
    font-size: 15px;
    font-weight: 500;
}

.time-entry-dialog form > footer {
    padding: 14px 22px 18px;
    background: #22282d;
}

.time-entry-dialog form > footer button {
    min-height: 44px;
    padding-right: 16px;
    padding-left: 16px;
}

.time-entry-dialog form > footer .primary-command {
    min-width: 112px;
    background: #ff5967;
}

.time-entry-error {
    padding-right: 22px;
    padding-left: 22px;
    font-size: 13px;
}

@media (max-width: 1000px) {
    .time-report-filters {
        grid-template-columns: 1fr 1fr;
    }

    .time-report-filters > button {
        justify-self: start;
    }

    .time-filter-result {
        grid-column: auto;
        align-self: center;
    }
}

@media (max-width: 760px) {
    .time-report-filters {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .time-filter-result {
        grid-column: 1;
    }

    .time-customer-group > summary {
        grid-template-columns: minmax(0, 1fr) 24px;
        gap: 8px 12px;
        padding: 12px;
    }

    .time-customer-group > summary .time-group-sums {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: flex-start;
    }

    .time-group-chevron {
        grid-column: 2;
        grid-row: 1;
    }

    .time-report-row > span:nth-last-child(-n+3),
    .time-report-row > .time-money:last-child,
    .time-billed-row > span,
    .time-billed-row > small {
        display: initial;
    }

    .time-report-head,
    .time-report-row,
    .time-billed-head,
    .time-billed-row {
        display: grid;
    }

    .time-entry-fields {
        grid-template-columns: 1fr 1fr;
        padding: 16px;
    }

    .time-entry-fields > label,
    .time-entry-fields > .calculated-field,
    .time-entry-fields > .time-date-field {
        grid-column: span 1;
    }

    .time-entry-fields > .field-wide,
    .time-entry-fields > .time-customer-field,
    .time-entry-fields > .time-date-field {
        grid-column: 1 / -1;
    }

    .time-entry-dialog h2 {
        font-size: 22px;
    }

    .time-entry-dialog form > footer {
        padding: 12px 14px 16px;
    }

    .time-entry-dialog form > footer .dialog-spacer {
        display: none;
    }

    .time-entry-dialog form > footer button {
        flex: 1 1 auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .time-group-chevron {
        transition: none;
    }
}

/* Customers and recurring payments reuse the Serverit visual system. */
.view-switch-separator {
    width: 1px;
    height: 22px;
    margin: 0 8px;
    background: var(--line);
}

.business-pane {
    height: 100%;
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: #1b1f22;
}

.business-table tbody td {
    height: 58px;
}

.business-table td a {
    color: #a9d9ff;
    text-decoration: none;
}

.business-table td a:hover {
    color: var(--text);
    text-decoration: underline;
}

.customer-pane .business-table th:nth-child(1),
.customer-pane .business-table td:nth-child(1) { min-width: 210px; }
.customer-pane .business-table th:nth-child(2),
.customer-pane .business-table td:nth-child(2) { min-width: 125px; }
.customer-pane .business-table th:nth-child(3),
.customer-pane .business-table td:nth-child(3) { min-width: 190px; }
.customer-pane .business-table th:nth-child(4),
.customer-pane .business-table td:nth-child(4) { min-width: 235px; }
.customer-pane .business-table th:nth-child(5),
.customer-pane .business-table td:nth-child(5) { min-width: 150px; }

.customer-name-cell {
    --customer-color: #2563eb;
    background-color: color-mix(in srgb, var(--customer-color) 18%, #1b1f22);
    box-shadow: inset 4px 0 0 var(--customer-color);
    transition: background-color .14s ease;
}

.business-table tbody tr:hover .customer-name-cell,
.business-table tbody tr.selected .customer-name-cell {
    background-color: color-mix(in srgb, var(--customer-color) 25%, #242a2e);
}

.customer-name-cell strong {
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .45);
}

.server-drawer-foot > .customer-archive-hint {
    max-width: 260px;
    margin: 0 0 0 auto;
    color: var(--warn);
    line-height: 1.25;
    text-align: right;
}

.server-drawer-foot .danger-command:disabled {
    border-color: var(--line);
    color: var(--faint);
    cursor: not-allowed;
    opacity: .72;
}

.customer-pane .business-table th:nth-child(8),
.customer-pane .business-table td:nth-child(8),
.customer-pane .business-table th:nth-child(9),
.customer-pane .business-table td:nth-child(9),
.customer-pane .business-table th:nth-child(10),
.customer-pane .business-table td:nth-child(10),
.customer-pane .business-table th:nth-child(11),
.customer-pane .business-table td:nth-child(11) { min-width: 130px; }

.recurring-payment-table th,
.recurring-payment-table td {
    min-width: 145px;
}

.recurring-payment-table th:nth-child(3),
.recurring-payment-table td:nth-child(3),
.recurring-payment-table th:nth-child(4),
.recurring-payment-table td:nth-child(4) {
    min-width: 185px;
}

.business-drawer {
    width: min(600px, calc(100vw - 56px));
}

.business-drawer .server-form-grid input,
.business-drawer .server-form-grid select,
.business-drawer .server-form-grid textarea,
.business-drawer > .server-drawer-body > .server-form-section > .notes-field textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    outline: none;
    background: #141719;
    color: var(--text);
    padding: 9px 10px;
}

.business-drawer .server-form-grid select {
    min-height: 38px;
}

.business-drawer .server-form-grid input:focus,
.business-drawer .server-form-grid select:focus,
.business-drawer .server-form-grid textarea:focus {
    border-color: var(--accent-2);
}

.autocomplete-field {
    position: relative;
}

.autocomplete-results {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    z-index: 110;
    max-height: 230px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #111416;
    padding: 5px;
    box-shadow: 0 16px 38px rgba(0, 0, 0, .48);
}

.autocomplete-heading {
    padding: 6px 8px 5px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.autocomplete-option {
    width: 100%;
    min-height: 34px;
    border: 0;
    background: transparent;
    padding: 6px 8px;
    text-align: left;
}

.autocomplete-option:hover,
.autocomplete-option.active {
    background: #2a3035;
    color: #fff;
}

.recurring-margin-positive {
    color: var(--accent-2);
    font-weight: 700;
}

.recurring-margin-negative {
    color: #ff8b95;
    font-weight: 700;
}

body.business-drawer-open {
    overflow: hidden;
}

@media (max-width: 760px) {
    .view-switch {
        width: 100%;
        overflow-x: auto;
    }

    .view-switch-separator {
        flex: 0 0 1px;
    }

    .business-drawer {
        top: 0;
        width: 100vw;
        max-width: none;
    }

    .business-drawer .server-form-grid,
    .business-drawer .server-form-grid.three-columns {
        grid-template-columns: 1fr;
    }

    .business-table tbody td {
        height: 54px;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button,
input,
select,
textarea,
[contenteditable="true"] {
    font: inherit;
}

button {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #262b30;
    color: var(--text);
    cursor: pointer;
}

button:hover,
.file-button:hover {
    border-color: var(--accent);
}

.hidden {
    display: none !important;
}

.login-body {
    display: grid;
    place-items: center;
    min-height: 100%;
    background:
        linear-gradient(145deg, rgba(56, 199, 181, .12), transparent 32%),
        linear-gradient(315deg, rgba(255, 77, 91, .12), transparent 35%),
        var(--bg);
}

.login-panel {
    width: min(380px, calc(100% - 32px));
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(23, 26, 29, .94);
    padding: 28px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .32);
}

.brand-mark,
.brand-icon {
    display: block;
    object-fit: contain;
    background: transparent;
}

.brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 0;
}

.login-panel h1 {
    margin: 18px 0 22px;
    font-size: 32px;
}

.login-panel label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
}

.login-panel input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #111416;
    color: var(--text);
    padding: 12px;
}

.login-panel button {
    width: 100%;
    margin-top: 14px;
    padding: 12px;
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 700;
}

.login-error {
    color: #ff9ca5;
    margin: 10px 0 0;
}

.app-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) 6px minmax(0, 1fr);
    grid-template-rows: 58px 1fr;
    overflow: hidden;
}

.topbar {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto auto minmax(220px, 520px) 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
    background: #22262a;
    border-bottom: 1px solid #151719;
}

.view-switch {
    display: flex;
    align-items: center;
    align-self: stretch;
    gap: 2px;
}

.view-switch a {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    padding: 0 12px;
    font: inherit;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.view-switch a::after {
    content: "";
    position: absolute;
    right: 12px;
    bottom: 0;
    left: 12px;
    height: 2px;
    background: transparent;
}

.view-switch a:hover,
.view-switch a.active {
    color: var(--text);
}

.view-switch a.active::after {
    background: var(--accent);
}

.view-switch a:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: -3px;
}

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

.brand-icon {
    width: 48px;
    height: 32px;
    border-radius: 0;
    background: #fff;
}

.search-wrap {
    position: relative;
}

.search-wrap input {
    width: 100%;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: #171a1d;
    color: var(--text);
    padding: 10px 12px 10px 34px;
    outline: none;
}

.search-wrap input:focus {
    border-color: var(--accent-2);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.save-status {
    color: var(--muted);
    font-size: 13px;
    justify-self: end;
}

.save-status.saving {
    color: var(--warn);
}

.save-status.saved {
    color: var(--accent-2);
}

.save-status.error {
    color: #ff8d97;
}

.ghost-button {
    padding: 8px 12px;
    background: transparent;
}

.topbar > .ghost-button {
    justify-self: end;
}

.sidebar {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    overflow: auto;
    background: var(--panel);
    border-right: 1px solid #151719;
}

.sidebar-resize-handle {
    grid-column: 2;
    grid-row: 2;
    position: relative;
    z-index: 4;
    background: #151719;
    cursor: col-resize;
    touch-action: none;
}

.sidebar-resize-handle::after {
    content: "";
    position: absolute;
    inset: 0 2px;
    border-radius: 999px;
    background: transparent;
}

.sidebar-resize-handle:hover::after,
.sidebar-resize-handle:focus-visible::after,
body.sidebar-resizing .sidebar-resize-handle::after {
    background: var(--accent-2);
}

body.sidebar-resizing {
    cursor: col-resize;
    user-select: none;
}

.sidebar-actions {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
    background: var(--panel);
    border-bottom: 1px solid var(--line-soft);
}

.sidebar-actions button,
.tree-action,
.note-action {
    padding: 8px;
    font-size: 13px;
}

.tree-view,
.search-results {
    padding: 8px;
}

.tree-row,
.note-row,
.result-row {
    display: grid;
    align-items: center;
    min-height: 34px;
    border-radius: var(--radius);
    color: var(--text);
}

.tree-row {
    grid-template-columns: 18px 1fr auto auto;
    gap: 4px;
    padding: 3px 4px;
    font-weight: 600;
}

.note-row {
    grid-template-columns: 1fr auto;
    gap: 4px;
    padding: 7px 8px;
    margin-left: 24px;
    color: #d9dddf;
}

.tree-row[draggable="true"],
.note-row[draggable="true"] {
    cursor: grab;
}

.tree-row.dragging,
.note-row.dragging {
    cursor: grabbing;
    opacity: .45;
}

.tree-row.drop-before,
.note-row.drop-before {
    box-shadow: inset 0 2px 0 var(--accent-2);
}

.tree-row.drop-after,
.note-row.drop-after {
    box-shadow: inset 0 -2px 0 var(--accent-2);
}

.tree-row.drop-inside {
    background: rgba(56, 199, 181, .14);
    box-shadow: inset 0 0 0 1px var(--accent-2);
}

.tree-view.drop-root {
    box-shadow: inset 0 0 0 1px var(--accent-2);
}

.tree-row:hover,
.note-row:hover,
.result-row:hover,
.tree-row.active,
.note-row.active,
.result-row.active {
    background: #24282c;
}

.tree-toggle {
    color: var(--muted);
    text-align: center;
}

.tree-name,
.note-title,
.result-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-action,
.note-action {
    opacity: .72;
    min-width: 26px;
    padding: 4px 6px;
    border-color: transparent;
    background: transparent;
}

.tree-action:hover,
.note-action:hover {
    opacity: 1;
    background: #30363c;
}

.tree-children {
    margin-left: 14px;
}

.tree-item {
    position: relative;
}

.tree-item.menu-open {
    z-index: 20;
}

.category-menu {
    position: absolute;
    top: 32px;
    right: 8px;
    z-index: 24;
    display: grid;
    gap: 2px;
    width: 172px;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #111416;
    padding: 4px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, .32);
}

.category-menu button {
    width: 100%;
    border-color: transparent;
    background: transparent;
    padding: 8px 10px;
    text-align: left;
}

.category-menu button:hover {
    background: #24282c;
}

.category-menu .danger {
    color: #ff8d97;
}

.note-menu {
    right: 0;
}

.result-row {
    gap: 4px;
    width: 100%;
    border: 0;
    background: transparent;
    padding: 10px;
    margin-bottom: 4px;
    text-align: left;
    text-decoration: none;
}

.result-meta {
    color: var(--faint);
    font-size: 12px;
}

.result-excerpt {
    color: var(--muted);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace {
    grid-column: 3;
    grid-row: 2;
    min-width: 0;
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
        var(--bg);
    background-size: 34px 34px;
}

.notes-workspace {
    height: 100%;
}

.app-shell.server-mode {
    grid-template-columns: minmax(0, 1fr);
}

.server-mode .sidebar,
.server-mode .sidebar-resize-handle {
    display: none;
}

.server-mode .workspace {
    grid-column: 1;
}

.server-pane {
    height: 100%;
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: #1b1f22;
}

.server-commandbar {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line-soft);
    background: #1f2326;
}

.server-heading {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.server-heading h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
}

.server-summary {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.server-summary-block {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.server-summary-annual {
    font-size: 12px;
}

.server-commands {
    min-width: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 8px;
}

.compact-field {
    display: grid;
    gap: 3px;
    color: var(--muted);
    font-size: 11px;
}

.compact-field select,
.server-drawer .server-form-grid select,
.server-form-grid input,
.server-form-grid textarea,
.notes-field textarea,
.settings-grid input,
.server-domain-input {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    outline: none;
    background: #141719;
    color: var(--text);
}

.compact-field select {
    min-width: 158px;
    height: 34px;
    padding: 0 28px 0 9px;
}

.server-form-grid input:focus,
.server-drawer .server-form-grid select:focus,
.server-form-grid textarea:focus,
.notes-field textarea:focus,
.settings-grid input:focus,
.server-domain-input:focus,
.compact-field select:focus {
    border-color: var(--accent-2);
}

.icon-command {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
}

.primary-command {
    min-height: 36px;
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    padding: 0 13px;
    font-weight: 600;
}

.column-menu {
    position: relative;
    height: 36px;
}

.column-menu summary {
    height: 36px;
    display: flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #262b30;
    padding: 0 11px;
    cursor: pointer;
    list-style: none;
}

.column-menu summary::-webkit-details-marker {
    display: none;
}

.column-choices {
    position: absolute;
    top: 42px;
    right: 0;
    z-index: 40;
    width: 210px;
    display: grid;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #111416;
    padding: 6px;
    box-shadow: 0 14px 38px rgba(0, 0, 0, .42);
}

.column-choices label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 4px 7px;
    color: #d9dddf;
    font-size: 13px;
}

.column-choices label:hover {
    background: #24282c;
}

.server-table-wrap {
    min-height: 0;
    min-width: 0;
    overflow: auto;
}

.server-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    font-size: 13px;
}

.server-table th,
.server-table td {
    min-width: 0;
    height: 48px;
    border-right: 1px solid rgba(52, 59, 66, .5);
    border-bottom: 1px solid var(--line-soft);
    padding: 7px 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    vertical-align: middle;
}

.server-table th {
    position: sticky;
    top: 0;
    z-index: 5;
    height: 38px;
    background: #171a1d;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.server-table th button {
    width: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    text-align: left;
    text-transform: inherit;
    font-size: inherit;
}

.server-table th.sorted button {
    color: var(--text);
}

.server-table tbody tr {
    cursor: pointer;
    background: #1b1f22;
}

.server-table tbody tr:hover,
.server-table tbody tr.selected {
    background: #242a2e;
}

.server-table tbody tr.archived {
    color: var(--faint);
}

.server-table tbody td {
    height: 82px;
}

.server-bottom-name {
    color: #aab7c0;
}

.server-bottom-marker {
    display: inline-flex;
    margin-left: 6px;
    color: #7f929e;
    font-size: 12px;
    font-weight: 600;
    vertical-align: 1px;
}

.server-table td:first-child,
.server-table th:first-child {
    position: sticky;
    left: 0;
    z-index: 4;
    background: inherit;
}

.server-table th:first-child {
    z-index: 7;
    background: #171a1d;
}

.server-table td:nth-child(2),
.server-table th:nth-child(2) {
    position: sticky;
    left: var(--server-status-width, 76px);
    z-index: 3;
    background: inherit;
    box-shadow: 1px 0 0 var(--line-soft);
}

.server-table td:nth-child(2).customer-name-cell {
    background: inherit;
    box-shadow: inset 4px 0 0 var(--customer-color), 1px 0 0 var(--line-soft);
}

.server-table tbody tr:hover td:nth-child(2).customer-name-cell,
.server-table tbody tr.selected td:nth-child(2).customer-name-cell {
    background-color: color-mix(in srgb, var(--customer-color) 25%, #242a2e);
}

.server-table th:nth-child(2) {
    z-index: 6;
    background: #171a1d;
}

.server-table tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 4;
    height: 42px;
    background: #15181a;
    color: var(--text);
    font-weight: 600;
}

.server-table tfoot td:first-child {
    z-index: 6;
    background: #15181a;
}

.server-table tfoot td:nth-child(2) {
    background: #15181a;
}

.server-table .numeric,
.server-table .money,
.server-table .mono {
    font-family: "Cascadia Mono", "Consolas", monospace;
    font-variant-numeric: tabular-nums;
}

.server-table .money {
    text-align: right;
}

.capacity-part,
.metric-part,
.load-part {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
}

.resource-contract {
    font-weight: 600;
}

.resource-observed {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.resource-observed-label {
    margin-right: 8px;
    color: var(--faint);
}

.inventory-version-cell {
    line-height: 1.25;
}

.inventory-agent-notice {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-family: Inter, Arial, sans-serif;
    font-size: 9px;
    font-weight: 600;
    white-space: nowrap;
}

.inventory-agent-notice::before {
    width: 5px;
    height: 5px;
    flex: 0 0 5px;
    border-radius: 50%;
    background: currentColor;
    content: '';
}

.inventory-agent-notice.missing {
    color: var(--accent);
}

.inventory-agent-notice.stale {
    color: var(--warn);
}

.metric-separator {
    margin: 0 6px;
    color: var(--faint);
}

.metric-label {
    color: var(--muted);
}

.resource-usage-values {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.server-metric-history {
    display: inline;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: inherit;
    text-align: left;
    cursor: pointer;
}

.server-metric-history:hover .metric-label {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.server-metric-history:focus-visible {
    outline: 1px solid var(--focus);
    outline-offset: 3px;
}

.server-domains-cell {
    white-space: normal !important;
}

.server-domain-monitor + .server-domain-monitor {
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px solid var(--line-soft);
}

.server-domain-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    line-height: 1.45;
}

.server-domain-line span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-domain-line strong,
.server-domain-result {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.server-domain-line.domain-warning strong,
.server-domain-result.domain-warning {
    color: var(--warn);
    font-weight: 700;
}

.server-domain-line.domain-critical strong,
.server-domain-result.domain-critical {
    color: var(--accent);
    font-weight: 700;
}

.server-domain-none,
.server-domain-empty {
    color: var(--faint);
}

.server-domain-sparkline {
    display: block;
    width: 100%;
    height: 30px;
    margin: 3px 0 -3px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    cursor: zoom-in;
}

.server-domain-sparkline:hover,
.server-domain-sparkline:focus-visible {
    border: 0;
    background: rgba(56, 199, 181, .06);
    outline: 1px solid rgba(56, 199, 181, .28);
    outline-offset: 1px;
}

.server-domain-sparkline[aria-disabled="true"] {
    cursor: default;
}

.server-domain-sparkline[aria-disabled="true"]:hover {
    background: transparent;
    outline: 0;
}

.server-domain-sparkline svg {
    display: block;
    width: 100%;
    height: 100%;
}

.server-domain-sparkline-line {
    fill: none;
    stroke: #46d3a1;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.server-domain-incident-band {
    fill: rgba(255, 101, 113, .13);
    pointer-events: none;
}

.server-domain-incident-line {
    stroke: #ff6571;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.server-domain-sparkline-baseline,
.server-domain-sparkline-placeholder {
    stroke: rgba(157, 165, 171, .22);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.server-domain-sparkline-placeholder {
    stroke-dasharray: 3 4;
}

.server-load-sparkline {
    display: block;
    width: 100%;
    height: 32px;
    margin: 5px 0 -3px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    cursor: zoom-in;
}

.server-load-sparkline:hover,
.server-load-sparkline:focus-visible {
    border: 0;
    background: rgba(255, 101, 113, .06);
    outline: 1px solid rgba(255, 101, 113, .28);
    outline-offset: 1px;
}

.server-load-sparkline[aria-disabled="true"] {
    cursor: default;
}

.server-load-sparkline[aria-disabled="true"]:hover {
    background: transparent;
    outline: 0;
}

.server-load-sparkline svg {
    display: block;
    width: 100%;
    height: 100%;
}

.server-load-sparkline-line {
    fill: none;
    stroke: #46d3a1;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.server-load-sparkline-gradient {
    color-interpolation: sRGB;
}

.server-load-sparkline-baseline,
.server-load-sparkline-placeholder {
    stroke: rgba(157, 165, 171, .22);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.server-load-sparkline-placeholder {
    stroke-dasharray: 3 4;
}

.capacity-mismatch,
.metric-warning {
    color: var(--warn);
    font-weight: 600;
}

.metric-critical {
    color: var(--accent);
    font-weight: 600;
}

.metric-warning .metric-label,
.metric-critical .metric-label {
    color: inherit;
}

.server-metric-history.metric-warning:hover .metric-label {
    color: var(--warn);
}

.server-metric-history.metric-critical:hover .metric-label {
    color: var(--accent);
}

.column-resizer {
    position: absolute;
    top: 0;
    right: -3px;
    bottom: 0;
    width: 7px;
    z-index: 2;
    cursor: col-resize;
    touch-action: none;
}

.column-resizer:hover,
body.server-column-resizing .column-resizer {
    background: rgba(56, 199, 181, .5);
}

body.server-column-resizing {
    cursor: col-resize;
    user-select: none;
}

.server-status-rail {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    color: var(--muted);
}

.server-status-rail::before {
    content: "";
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--faint);
}

.server-status-rail.online::before {
    background: var(--accent-2);
}

.server-status-rail .status-label {
    color: var(--text);
}

.server-status-rail.warning::before {
    background: var(--warn);
}

.server-status-rail.warning .status-label {
    color: var(--warn);
    font-weight: 700;
}

.server-status-rail.critical::before,
.server-status-rail.offline::before {
    background: var(--accent);
}

.server-status-rail.critical .status-label,
.server-status-rail.offline .status-label {
    color: var(--accent);
    font-weight: 700;
}

.server-status-rail.stale::before,
.server-status-rail.unknown::before {
    background: #a78bfa;
}

.server-status-rail.stale .status-label,
.server-status-rail.unknown .status-label {
    color: #c4b5fd;
    font-weight: 700;
}

.server-status-rail.unmonitored .status-label {
    color: var(--muted);
    font-weight: 600;
}

.server-drawer-backdrop {
    position: fixed;
    inset: 58px 0 0;
    z-index: 70;
    background: rgba(4, 6, 7, .52);
}

.server-drawer {
    position: fixed;
    top: 58px;
    right: 0;
    bottom: 0;
    z-index: 80;
    width: min(560px, calc(100vw - 56px));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border-left: 1px solid var(--line);
    background: #171a1d;
    box-shadow: -18px 0 48px rgba(0, 0, 0, .36);
}

.server-drawer-head,
.server-drawer-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: #1d2124;
}

.server-drawer-head {
    border-bottom: 1px solid var(--line-soft);
}

.server-drawer-head h2 {
    margin: 2px 0 0;
    font-size: 22px;
    overflow-wrap: anywhere;
}

.server-drawer-status {
    color: var(--muted);
    font-size: 12px;
}

.server-drawer-foot {
    border-top: 1px solid var(--line-soft);
}

.server-drawer-foot > span {
    color: var(--muted);
    font-size: 12px;
    margin-right: auto;
}

.server-drawer-body {
    min-height: 0;
    overflow: auto;
}

.server-form-section {
    padding: 19px 18px 21px;
    border-bottom: 1px solid var(--line-soft);
}

.server-form-section h3,
.settings-scroll h3 {
    margin: 0 0 14px;
    color: #d9dddf;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
}

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

.section-heading-row h3 {
    margin: 0;
}

.section-heading-row button,
.agent-section > button,
.server-drawer-foot button {
    min-height: 32px;
    padding: 0 10px;
}

.server-form-grid,
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.server-form-grid.three-columns {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.server-form-grid label,
.settings-grid label,
.notes-field {
    min-width: 0;
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
}

.server-form-grid input,
.server-drawer .server-form-grid select,
.settings-grid input {
    height: 36px;
    padding: 0 9px;
}

.server-form-grid textarea,
.notes-field textarea {
    width: 100%;
    resize: vertical;
    padding: 9px;
}

.server-domain-list {
    display: grid;
    gap: 8px;
}

.server-domain-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    align-items: start;
    gap: 8px;
}

.server-domain-input-wrap {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.server-domain-input {
    width: 100%;
    height: 36px;
    padding: 0 9px;
}

.server-domain-result {
    min-height: 16px;
}

.server-domain-remove {
    width: 34px;
    height: 36px;
    color: var(--muted);
}

.server-domain-empty {
    margin: 0;
    font-size: 12px;
}

.field-wide {
    grid-column: 1 / -1;
}

.notes-field {
    margin-top: 12px;
}

.calculated-field {
    min-width: 0;
    display: grid;
    gap: 5px;
    align-content: center;
}

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

.calculated-field strong {
    min-height: 36px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--line);
    font-family: "Cascadia Mono", "Consolas", monospace;
    font-size: 12px;
    line-height: 1.3;
    font-variant-numeric: tabular-nums;
}

.pricing-suggestion {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin: 0;
    padding: 0 1px 3px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.45;
}

.pricing-suggestion strong {
    color: #d9dddf;
    font-weight: 600;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 14px;
    color: #d9dddf;
    font-size: 13px;
}

.toggle-row input {
    accent-color: var(--accent-2);
}

.metric-definition-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
}

.metric-definition-list > div {
    min-width: 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(52, 59, 66, .55);
}

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

.metric-definition-list dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    text-align: right;
    font-family: "Cascadia Mono", "Consolas", monospace;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.resource-meter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.resource-meter {
    min-width: 0;
    border: 1px solid var(--line-soft);
    border-radius: 4px;
    background: #141719;
    padding: 9px 10px 7px;
}

.resource-meter-heading,
.resource-meter-scale {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.resource-meter-heading {
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
}

.resource-meter-heading strong {
    color: var(--text);
    font-family: "Cascadia Mono", "Consolas", monospace;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.resource-meter-track {
    height: 8px;
    overflow: hidden;
    border: 1px solid #30363c;
    background: linear-gradient(to right, transparent 49.5%, #30363c 49.5%, #30363c 50.5%, transparent 50.5%), #0f1113;
}

.resource-meter-fill {
    display: block;
    height: 100%;
    background: var(--accent-2);
    transition: width .25s ease;
}

.resource-meter.load .resource-meter-fill {
    background: #8ba7d9;
}

.resource-meter.metric-warning .resource-meter-fill {
    background: var(--warn);
}

.resource-meter.metric-critical .resource-meter-fill {
    background: var(--accent);
}

.resource-meter.metric-warning .resource-meter-heading strong,
.resource-meter.metric-critical .resource-meter-heading strong {
    font-weight: 700;
}

.resource-meter.metric-warning .resource-meter-heading strong {
    color: var(--warn);
}

.resource-meter.metric-critical .resource-meter-heading strong {
    color: var(--accent);
}

.resource-meter-scale {
    margin-top: 4px;
    color: var(--faint);
    font-size: 9px;
}

.filesystem-list {
    margin-top: 15px;
}

.filesystem-row {
    display: grid;
    grid-template-columns: minmax(80px, 1fr) minmax(120px, 2fr) auto;
    gap: 10px;
    align-items: center;
    min-height: 34px;
    font-size: 12px;
}

.filesystem-meter {
    height: 6px;
    overflow: hidden;
    background: #0f1113;
}

.filesystem-meter > span {
    display: block;
    height: 100%;
    background: var(--accent-2);
}

.filesystem-row.warning .filesystem-meter > span {
    background: var(--warn);
}

.filesystem-row.critical .filesystem-meter > span {
    background: var(--accent);
}

.range-switch {
    display: flex;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.range-switch button {
    height: 30px;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    padding: 0 9px;
    font-size: 12px;
}

.range-switch button:last-child {
    border-right: 0;
}

.range-switch button.active {
    background: #30363c;
    color: var(--text);
}

.history-message,
.muted-copy {
    color: var(--muted);
    font-size: 12px;
}

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

.history-grid figure {
    min-width: 0;
    margin: 0;
}

.history-grid figcaption {
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 11px;
}

.history-grid svg {
    display: block;
    width: 100%;
    height: 96px;
    border-bottom: 1px solid var(--line-soft);
    background: #141719;
}

.history-grid .chart-grid {
    stroke: #30363c;
    stroke-width: 1;
}

.history-grid .chart-line {
    fill: none;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.history-grid .chart-label {
    fill: #d9dddf;
    font-size: 11px;
}

.agent-token-reveal {
    display: grid;
    gap: 8px;
    margin-top: 12px;
    border-left: 2px solid var(--warn);
    background: #141719;
    padding: 11px;
}

.agent-token-reveal code {
    display: block;
    overflow-wrap: anywhere;
    color: #f5d491;
}

.danger-command {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-color: #8f3440;
    background: transparent;
    color: #ff8d97;
}

.danger-command svg {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
}

.server-load-chart-dialog {
    width: min(840px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #171a1d;
    color: var(--text);
    padding: 0;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .58);
}

.server-load-chart-dialog::backdrop {
    background: rgba(4, 6, 7, .74);
}

.server-load-chart-dialog header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-soft);
}

.server-load-chart-dialog h2 {
    margin: 2px 0 0;
    font-size: 19px;
}

.server-load-chart-body {
    position: relative;
    padding: 16px 18px 14px;
}

.server-load-chart-body svg {
    display: block;
    width: 100%;
    aspect-ratio: 800 / 260;
    background: #141719;
    touch-action: none;
}

.server-load-chart-grid {
    stroke: #30363c;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.server-domain-chart-guide-band {
    fill: rgba(255, 184, 77, .08);
    pointer-events: none;
}

.server-load-chart-line {
    fill: none;
    stroke: #46d3a1;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.server-load-chart-gradient {
    color-interpolation: sRGB;
}

.server-load-chart-hover-line {
    stroke: rgba(238, 242, 244, .72);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.server-load-chart-hover-point {
    fill: #f4f7f8;
    stroke: #171a1d;
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.server-load-chart-hit-area {
    fill: transparent;
    cursor: crosshair;
    pointer-events: all;
}

.server-load-chart-tooltip {
    position: absolute;
    z-index: 2;
    padding: 5px 7px;
    border: 1px solid #4a5258;
    border-radius: 3px;
    background: #0f1214;
    color: #f1f4f5;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .38);
    font-family: "Cascadia Mono", "Consolas", monospace;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
}

.server-load-chart-axis-label {
    fill: #9fa8ad;
}

.server-load-chart-label {
    fill: #d9dddf;
    font-size: 11px;
}

.server-load-chart-summary {
    margin-top: 10px;
    color: #d9dddf;
    font-family: "Cascadia Mono", "Consolas", monospace;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.server-settings-dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #171a1d;
    color: var(--text);
    padding: 0;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}

.server-settings-dialog::backdrop {
    background: rgba(4, 6, 7, .7);
}

.server-settings-dialog form {
    max-height: calc(100vh - 50px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.server-settings-dialog header,
.server-settings-dialog footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
}

.server-settings-dialog header {
    border-bottom: 1px solid var(--line-soft);
}

.server-settings-dialog footer {
    border-top: 1px solid var(--line-soft);
}

.server-settings-dialog footer > span {
    margin-right: auto;
    color: var(--muted);
    font-size: 12px;
}

.server-settings-dialog h2 {
    margin: 2px 0 0;
    font-size: 22px;
}

.dialog-kicker {
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
}

.settings-scroll {
    min-height: 0;
    overflow: auto;
}

.settings-scroll section {
    padding: 18px;
    border-bottom: 1px solid var(--line-soft);
}

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

.pricing-settings {
    margin-top: 4px;
}

.empty-state {
    height: 100%;
    display: grid;
    place-content: center;
    text-align: center;
    color: var(--muted);
}

.empty-state h1 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 44px;
}

.editor-pane {
    height: 100%;
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
}

.editor-head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: end;
    padding: 26px 34px 18px;
    border-bottom: 1px solid var(--line-soft);
    background: rgba(31, 35, 38, .92);
}

.breadcrumb {
    min-height: 18px;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px;
}

.title-input {
    width: 100%;
    border: 0;
    border-bottom: 1px solid transparent;
    background: transparent;
    color: var(--text);
    outline: none;
    font-size: clamp(28px, 4vw, 46px);
    font-weight: 800;
}

.title-input:focus {
    border-bottom-color: var(--line);
}

.editor-tools {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: 560px;
}

.format-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    background: rgba(17, 20, 22, .62);
}

.format-toolbar button {
    min-width: 32px;
    height: 30px;
    border-color: transparent;
    background: transparent;
    padding: 0 8px;
}

.format-toolbar button:hover {
    background: #30363c;
    border-color: var(--line);
}

.file-button {
    display: inline-flex;
    align-items: center;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0 12px;
    background: #262b30;
    cursor: pointer;
}

.editor-scroll {
    min-height: 0;
    overflow: auto;
}

.rich-editor {
    width: 100%;
    max-width: 980px;
    min-height: 100%;
    margin: 0 auto;
    border: 0;
    outline: none;
    background: rgba(18, 21, 23, .38);
    color: var(--text);
    padding: 34px 42px 110px;
    line-height: 1.68;
    font-size: 16px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.rich-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--faint);
}

.rich-editor.drop-ready {
    box-shadow: inset 0 0 0 2px var(--accent-2);
}

.rich-editor h1,
.rich-editor h2,
.rich-editor h3 {
    line-height: 1.2;
    margin: 1em 0 .45em;
}

.rich-editor h1 {
    font-size: 34px;
}

.rich-editor h2 {
    font-size: 24px;
}

.rich-editor p {
    color: #d9dddf;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.rich-editor pre {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #141719;
    padding: 16px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.rich-editor code,
.rich-editor pre {
    color: #f5d491;
    font-family: "Cascadia Mono", "Consolas", monospace;
}

.rich-editor pre code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.rich-editor img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 14px 0;
    border-radius: var(--radius);
    border: 1px solid var(--line);
}

.rich-editor a {
    color: var(--accent-2);
}

@media (max-width: 920px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 220px 1fr;
    }

    .topbar {
        grid-column: 1;
        grid-template-columns: auto 1fr auto;
        padding: 12px;
    }

    .view-switch {
        order: 4;
        grid-column: 1 / -1;
        min-height: 36px;
    }

    .view-switch a {
        height: 36px;
    }

    .search-wrap {
        grid-column: 1 / -1;
        order: 5;
    }

    .save-status {
        display: none;
    }

    .sidebar {
        grid-column: 1;
        grid-row: 2;
        border-right: 0;
        border-bottom: 1px solid #151719;
    }

    .sidebar-resize-handle {
        display: none;
    }

    .workspace {
        grid-column: 1;
        grid-row: 3;
    }

    .app-shell.server-mode {
        grid-template-rows: auto minmax(0, 1fr);
    }

    .server-mode .workspace {
        grid-row: 2;
    }

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

    .server-commands {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .compact-field {
        flex: 1 1 170px;
    }

    .compact-field select {
        width: 100%;
    }

    .editor-head {
        grid-template-columns: 1fr;
    }

    .editor-tools {
        justify-content: flex-start;
    }

    .rich-editor {
        min-height: 280px;
        padding: 24px 18px 80px;
    }
}

@media (max-width: 760px) {
    .app-shell {
        grid-template-rows: auto 190px minmax(0, 1fr);
    }

    .topbar {
        gap: 8px 12px;
    }

    .brand strong {
        font-size: 14px;
    }

    .brand-icon {
        width: 42px;
        height: 28px;
    }

    .server-commandbar {
        padding: 13px 12px;
    }

    .server-heading {
        width: 100%;
        justify-content: space-between;
    }

    .server-heading h1 {
        font-size: 21px;
    }

    .server-summary {
        max-width: 55%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .server-heading > .server-summary-block {
        max-width: 55%;
    }

    .server-summary-block .server-summary {
        max-width: none;
    }

    .server-commands .primary-command {
        flex: 1 1 auto;
    }

    .server-table th,
    .server-table td {
        height: 44px;
        padding-right: 8px;
        padding-left: 8px;
    }

    .server-table tbody td {
        height: 78px;
    }

    .server-load-chart-dialog {
        width: calc(100vw - 20px);
    }

    .server-load-chart-body {
        padding: 12px;
    }

    .server-drawer-backdrop {
        inset: 0;
    }

    .server-drawer {
        top: 0;
        width: 100vw;
        border-left: 0;
    }

    .server-form-grid,
    .server-form-grid.three-columns,
    .settings-grid,
    .history-grid,
    .metric-definition-list {
        grid-template-columns: 1fr;
    }

    .history-grid svg {
        height: 116px;
    }

    .server-settings-dialog {
        width: 100vw;
        max-width: none;
        height: 100vh;
        max-height: none;
        border: 0;
    }

    .server-settings-dialog form {
        height: 100vh;
        max-height: none;
    }
}

.recurring-payment-table tbody td {
    height: 42px;
}

/* Time tracking */
.time-pane {
    height: 100%;
    min-width: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    color: var(--text);
    background: #181c1f;
}

.time-commandbar {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
    align-items: center;
    gap: 20px;
    padding: 17px 20px;
    border-bottom: 1px solid var(--line-soft);
    background: #202529;
}

.time-commandbar h1 {
    margin: 2px 0 0;
    font-size: 24px;
}

.time-commandbar > .primary-command {
    justify-self: end;
}

.time-view-tabs {
    display: flex;
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #171a1d;
}

.time-view-tabs button {
    min-height: 36px;
    padding: 0 16px;
    border: 0;
    border-radius: 5px;
    color: var(--muted);
    background: transparent;
}

.time-view-tabs button.active {
    color: #fff;
    background: #343b42;
}

.time-timer-bar {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(56, 199, 181, .38);
    background: rgba(32, 103, 96, .22);
}

.time-timer-bar > div {
    min-width: 0;
    display: grid;
    flex: 1;
}

.time-timer-bar span,
.time-timer-bar strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.time-timer-bar > div > span {
    color: var(--accent-2);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.time-timer-elapsed {
    color: #fff;
    font: 700 17px/1 "Cascadia Mono", "Consolas", monospace;
}

.time-week-view,
.time-report-view {
    min-height: 0;
    overflow: auto;
}

.time-week-view {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
}

.time-week-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 12px 16px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line-soft);
    scrollbar-width: none;
    white-space: nowrap;
}

.time-week-toolbar::-webkit-scrollbar {
    display: none;
}

.time-week-navigation {
    display: flex;
    flex: none;
    align-items: stretch;
    min-height: 34px;
    overflow: hidden;
    border: 1px solid #3a444b;
    border-radius: 4px;
    background: #252b30;
}

.time-week-navigation button,
.time-week-today {
    border: 0;
    color: #d7dfe3;
    background: #252b30;
}

.time-week-navigation button {
    width: 34px;
    min-width: 34px;
    min-height: 36px;
    padding: 0;
    border-radius: 0;
    font-size: 18px;
}

.time-week-navigation button:hover,
.time-week-today:hover {
    color: #fff;
    background: #30383e;
}

.time-week-navigation button:focus-visible,
.time-week-today:focus-visible {
    position: relative;
    z-index: 1;
    outline: 2px solid var(--accent-2);
    outline-offset: -2px;
}

.time-week-range-control {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 11px 0 7px;
    color: #d7dfe3;
    font-size: 13px;
}

.time-week-range-control svg {
    flex: none;
}

.time-week-today,
.time-week-summary {
    min-height: 38px;
    flex: none;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid #3a444b;
    border-radius: 4px;
    background: #252b30;
}

.time-week-summary {
    font-weight: 700;
}

.time-week-totals {
    color: #d7dfe3;
    font-family: inherit;
}

.time-week-extras,
.time-month-billing {
    flex: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.time-month-billing {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.time-month-billing-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.time-month-billing-item[hidden] {
    display: none;
}

.time-mobile-day-picker {
    display: none;
}

.time-week-grid {
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(7, minmax(176px, 1fr));
    overflow-x: auto;
}

.time-day-column {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border-right: 1px solid var(--line-soft);
    background: linear-gradient(180deg, rgba(255,255,255,.018), transparent 140px);
}

.time-day-column.is-today {
    background-color: var(--time-today-bg);
}

.time-day-column > header {
    min-height: 61px;
    display: grid;
    align-content: center;
    gap: 5px;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line-soft);
}

.time-day-column > header > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    text-transform: capitalize;
}

.time-day-column > header span {
    color: var(--accent-2);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.time-day-column > header small {
    color: var(--muted);
    font-family: "Cascadia Mono", "Consolas", monospace;
}

.time-day-entries {
    min-height: 80px;
    overflow-y: auto;
    padding: 8px;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 29px,
        rgba(255, 255, 255, .045) 29px,
        rgba(255, 255, 255, .045) 30px
    );
    background-position: 0 8px;
}

.time-entry-card {
    --time-color: #2563eb;
    display: grid;
    gap: 5px;
    margin-bottom: 8px;
    padding: 10px 10px 9px;
    border: 1px solid #38414a;
    border-left: 4px solid var(--time-color);
    border-radius: 6px;
    background: #252b30;
    cursor: pointer;
}

.time-entry-card:hover {
    border-color: #59646d;
    border-left-color: var(--time-color);
    background: #2a3136;
}

.time-entry-card.billed {
    opacity: .58;
}

.time-entry-card > strong {
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.time-entry-card > span,
.time-entry-card > small {
    color: var(--muted);
    font-size: 11px;
}

.time-entry-card footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding-top: 4px;
    color: #fff;
    font: 700 12px/1.2 "Cascadia Mono", "Consolas", monospace;
}

.time-pane .time-day-add {
    width: 100%;
    min-height: 46px;
    margin: 0 0 8px;
    border: 1px solid #3a444b;
    border-radius: 4px;
    color: #c7d0d5;
    background: #2a3035;
    font-size: 13px;
    font-weight: 600;
    transition: transform .08s ease;
}

.time-pane .time-day-add:hover {
    color: #fff;
    border-color: #4a565f;
    background: #343c42;
}

.time-pane .time-day-add:active {
    background: #2d3439;
    transform: translateY(1px);
}

.time-pane .time-day-add:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -4px;
}

.time-report-view {
    padding: 18px 20px 60px;
}

.time-report-totals {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 1px;
    margin-bottom: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--line);
}

.time-report-totals > div {
    display: grid;
    gap: 4px;
    padding: 13px 15px;
    background: #22272b;
}

.time-report-totals span {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

.time-report-totals strong {
    font: 700 18px/1.2 "Cascadia Mono", "Consolas", monospace;
}

.time-customer-group {
    margin-bottom: 15px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #202529;
}

.time-customer-group > header {
    --time-color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 13px 15px;
    border-left: 5px solid var(--time-color);
    border-bottom: 1px solid var(--line-soft);
}

.time-customer-group > header > div:first-child {
    display: grid;
    gap: 2px;
}

.time-customer-group > header span,
.time-report-row small {
    color: var(--muted);
    font-size: 11px;
}

.time-group-sums {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px 16px;
    font-family: "Cascadia Mono", "Consolas", monospace;
}

.time-report-row {
    display: grid;
    grid-template-columns: 28px 92px minmax(220px, 1fr) 90px 105px 105px 115px;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 7px 15px;
    border-bottom: 1px solid var(--line-soft);
}

.time-report-row:hover {
    background: rgba(255,255,255,.025);
}

.time-report-row > span:nth-child(3) {
    display: grid;
    gap: 2px;
}

.time-customer-group > footer {
    display: flex;
    justify-content: flex-end;
    padding: 10px 15px;
}

.time-billed-list {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
}

.time-billed-row {
    display: grid;
    grid-template-columns: 12px minmax(150px, .7fr) minmax(240px, 1.5fr) 100px 115px auto;
    align-items: center;
    gap: 13px;
    min-height: 66px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--line-soft);
    background: #202529;
}

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

.time-billed-row > div {
    display: grid;
    gap: 3px;
}

.time-billed-row span,
.time-billed-row small {
    color: var(--muted);
    font-size: 11px;
}

.time-color-dot {
    width: 8px;
    height: 32px;
    border-radius: 4px;
    background: var(--time-color);
}

.time-empty {
    padding: 50px 20px;
    border: 1px dashed var(--line);
    border-radius: 7px;
    color: var(--muted);
    text-align: center;
}

.time-feedback {
    min-height: 29px;
    padding: 6px 20px;
    border-top: 1px solid var(--line-soft);
    color: var(--muted);
    font-size: 12px;
    background: #171a1d;
}

.time-feedback.saved {
    color: var(--accent-2);
}

.time-feedback.error,
.time-entry-error {
    color: #ff919a;
}

.time-entry-dialog {
    width: min(680px, calc(100vw - 30px));
    padding: 0;
    border: 1px solid #4a535b;
    border-radius: 9px;
    color: var(--text);
    background: #202529;
    box-shadow: 0 24px 90px rgba(0,0,0,.6);
}

.time-entry-dialog::backdrop {
    background: rgba(8, 10, 12, .74);
}

.time-entry-dialog form > header,
.time-entry-dialog form > footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
}

.time-entry-dialog form > header {
    justify-content: space-between;
}

.time-entry-dialog h2 {
    margin: 2px 0 0;
}

.time-entry-dialog form > footer {
    border-top: 1px solid var(--line);
    border-bottom: 0;
}

.dialog-spacer {
    flex: 1;
}

.time-entry-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 13px;
    padding: 18px;
}

.time-entry-fields label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
}

.time-entry-fields input,
.time-entry-fields select,
.time-entry-fields textarea {
    width: 100%;
}

.time-entry-error {
    min-height: 20px;
    padding: 0 18px 8px;
    font-size: 12px;
}

.customer-color-field {
    min-width: 0;
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
}

.customer-color-controls {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 9px;
    align-items: end;
}

.customer-color-controls input[type="color"][data-customer-field="time_color"] {
    width: 58px;
    min-height: 36px;
    padding: 3px;
    cursor: pointer;
}

.customer-color-hex-field {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 7px;
    align-items: center;
}

.customer-color-hex-field > span,
.customer-color-field > small {
    color: var(--faint);
    font-size: 11px;
}

.customer-color-hex-field input {
    min-width: 0;
    font-family: "Cascadia Mono", Consolas, monospace;
    letter-spacing: .02em;
}

.customer-color-hex-field input[aria-invalid="true"] {
    border-color: var(--accent);
}

@media (max-width: 760px) {
    .view-switch,
    .time-view-tabs,
    .time-week-toolbar,
    .time-mobile-day-picker {
        scrollbar-width: none;
    }

    .view-switch::-webkit-scrollbar,
    .time-view-tabs::-webkit-scrollbar,
    .time-week-toolbar::-webkit-scrollbar,
    .time-mobile-day-picker::-webkit-scrollbar {
        display: none;
    }

    .time-commandbar {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px;
    }

    .time-commandbar > div:first-child {
        display: none;
    }

    .time-commandbar > .primary-command {
        justify-self: stretch;
    }

    .time-view-tabs {
        min-width: 0;
        overflow-x: auto;
    }

    .time-view-tabs button {
        padding: 0 10px;
        white-space: nowrap;
    }

    .time-timer-bar {
        flex-wrap: wrap;
        padding: 10px 12px;
    }

    .time-timer-bar > div {
        flex-basis: calc(100% - 100px);
    }

    .time-week-toolbar {
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
    }

    .time-mobile-day-picker {
        display: flex;
        overflow-x: auto;
        border-bottom: 1px solid var(--line-soft);
    }

    .time-mobile-day-picker button {
        min-width: 76px;
        display: grid;
        gap: 3px;
        padding: 8px 6px;
        border: 0;
        border-right: 1px solid var(--line-soft);
        border-radius: 0;
        color: var(--muted);
        background: #1c2023;
    }

    .time-mobile-day-picker button.active {
        color: #fff;
        box-shadow: inset 0 -3px var(--accent-2);
        background: #292f34;
    }

    .time-mobile-day-picker strong {
        font-size: 10px;
    }

    .time-week-grid {
        display: block;
        overflow: auto;
    }

    .time-day-column {
        display: none;
        min-height: 100%;
        border-right: 0;
    }

    .time-day-column.mobile-active {
        display: grid;
    }

    .time-report-view {
        padding: 10px 10px 50px;
    }

    .time-report-totals {
        grid-template-columns: 1fr 1fr;
    }

    .time-customer-group > header {
        align-items: flex-start;
        flex-direction: column;
    }

    .time-group-sums {
        justify-content: flex-start;
    }

    .time-report-row {
        grid-template-columns: 28px 74px minmax(140px, 1fr) 84px;
        overflow-x: auto;
    }

    .time-report-row > span:nth-last-child(-n+3),
    .time-report-row > strong:last-child {
        display: none;
    }

    .time-billed-row {
        grid-template-columns: 8px minmax(100px, .7fr) minmax(150px, 1.3fr);
    }

    .time-billed-row > span,
    .time-billed-row > strong {
        display: none;
    }

    .time-billed-row button {
        grid-column: 2 / -1;
    }

    .time-entry-fields {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .time-entry-dialog {
        width: 100vw;
        max-width: none;
        height: 100vh;
        max-height: none;
        border: 0;
        border-radius: 0;
    }

    .time-entry-dialog form > footer {
        position: sticky;
        bottom: 0;
        flex-wrap: wrap;
        background: #202529;
    }
}

/* Keep the clarity pass after legacy time styles in the cascade. */
.time-pane { font-family: Aptos, "Segoe UI", sans-serif; font-size: 13px; }
.time-entry-card {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 5px;
    height: var(--time-card-height, 64px);
    min-height: 64px;
    padding: 8px 10px;
    border: 0;
    border-radius: 7px;
    color: #fff;
    background: var(--time-color);
}
.time-entry-card:hover {
    border: 0;
    background: color-mix(in srgb, var(--time-color) 90%, #fff);
}
.time-entry-card-copy {
    min-width: 0;
    overflow: hidden;
    display: grid;
    align-content: start;
    gap: 2px;
}
.time-entry-card-copy > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.time-entry-card .time-entry-description {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
}
.time-entry-customer {
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
    line-height: 1.15;
}
.time-entry-card .time-entry-card-footer {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
}
.time-entry-amount {
    color: rgba(255, 255, 255, .82);
    font: 400 11px/1.2 "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.time-entry-duration {
    color: #fff;
    font: 600 13px/1.2 "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.time-customer-group { overflow: visible; font-size: 13px; }
.time-report-charts {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
}
.time-report-charts.has-monthly-chart {
    grid-template-columns: minmax(410px, .8fr) minmax(600px, 1.2fr);
}
.time-chart-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border: 1px solid #3a444c;
    border-radius: 7px;
    background: #202529;
}
.time-customer-chart {
    display: flex;
    flex-direction: column;
}
.time-chart-header {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 14px;
    border-bottom: 1px solid #343d44;
    background: #22282d;
}
.time-chart-header > div:first-child {
    min-width: 0;
    display: grid;
    gap: 2px;
}
.time-chart-header h2 {
    margin: 0;
    color: #eef2f4;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}
.time-chart-kicker {
    color: #8e9ca5;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .055em;
    text-transform: uppercase;
}
.time-month-bar-mark:focus-visible {
    outline: 2px solid #7ec2ff;
    outline-offset: 2px;
}
.time-donut-layout {
    min-height: 288px;
    display: grid;
    grid-template-columns: 280px minmax(340px, 500px);
    align-items: center;
    justify-content: center;
    gap: 40px;
    padding: 12px 24px 18px;
}
.time-customer-chart .time-donut-layout {
    height: 0;
    flex: 1 1 auto;
}
.time-donut {
    width: 280px;
    max-width: 100%;
    display: block;
    justify-self: center;
}
.time-donut-track {
    stroke: #343c42;
}
.time-donut-segment {
    transition: opacity .16s ease;
}
.time-donut-segment:hover {
    opacity: .78;
}
.time-donut-total {
    fill: #f2f5f6;
    font: 700 21px/1 "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
}
.time-donut-count {
    fill: #91a0a9;
    font: 400 13px/1 Aptos, "Segoe UI", sans-serif;
}
.time-donut-money {
    fill: #c9d2d7;
    font: 600 12px/1 "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
}
.time-donut-percentage {
    fill: #e8edef;
    stroke: #202529;
    stroke-width: 3px;
    paint-order: stroke;
    font: 500 11px/1 Aptos, "Segoe UI", sans-serif;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}
.time-chart-legend {
    width: 100%;
    min-width: 0;
    max-width: 520px;
    max-height: 244px;
    margin: 0;
    padding: 0 8px 0 0;
    overflow-y: auto;
    list-style: none;
}
.time-customer-chart .time-chart-legend {
    min-height: 0;
    height: 100%;
    align-self: stretch;
    max-height: none;
}
.time-chart-legend li {
    min-height: 40px;
    display: grid;
    grid-template-columns: 8px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    padding: 6px 2px;
    color: #d5dde1;
    font-size: 13px;
}
.time-chart-swatch {
    width: 8px;
    height: 8px;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 50%;
    background: var(--time-color);
}
.time-chart-customer {
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 600;
}
.time-chart-value,
.time-chart-year {
    font-family: "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.time-chart-value {
    display: inline-flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 12px;
    color: #edf2f4;
    font-size: 13px;
    font-weight: 600;
    text-align: right;
}
.time-chart-value-money {
    min-width: 88px;
    color: #9fadb5;
    font-size: 12px;
    font-weight: 500;
}
.time-chart-legend li.time-chart-empty {
    color: #8e9ca5;
}
.time-chart-year {
    padding: 5px 8px;
    border: 1px solid #46515a;
    border-radius: 4px;
    color: #cad3d8;
    background: #1b2024;
    font-size: 12px;
}
.time-monthly-chart-scroll {
    overflow-x: auto;
    padding: 4px 8px 8px;
}
.time-monthly-chart svg {
    width: 100%;
    min-width: 720px;
    display: block;
}
.time-chart-gridline {
    stroke: rgba(210, 222, 229, .14);
    stroke-width: .75;
    shape-rendering: crispEdges;
}
.time-chart-axis-label {
    fill: #8f9ca5;
    font: 400 10.5px/1 "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
}
.time-month-bar-mark {
    fill: #58a8f6;
    cursor: default;
    transition: fill .16s ease, opacity .16s ease;
}
.time-month-bar-mark:hover,
.time-month-bar-mark:focus {
    fill: #80c0ff;
}
.time-month-value {
    fill: #cbd6dc;
    font: 400 10px/1 "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}
.time-chart-no-data {
    fill: #7f8d96;
    font: 400 13px/1 Aptos, "Segoe UI", sans-serif;
}
.time-chart-tooltip {
    position: absolute;
    z-index: 5;
    max-width: 220px;
    padding: 6px 8px;
    transform: translate(-50%, -100%);
    border: 1px solid #53616b;
    border-radius: 4px;
    color: #fff;
    background: #11161a;
    box-shadow: 0 6px 18px rgba(0,0,0,.28);
    font: 400 12px/1.25 "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s ease;
    white-space: nowrap;
}
.time-chart-tooltip.visible {
    opacity: 1;
}
.time-report-head,
.time-report-row {
    min-width: 1090px;
    display: grid;
    grid-template-columns: 28px 92px minmax(260px, 420px) 90px 105px 105px 115px 34px;
    align-items: center;
    justify-content: start;
    gap: 10px;
    padding-right: 15px;
    padding-left: 15px;
}
.time-report-head { min-height: 38px; font-size: 11px; }
.time-report-row { min-height: 52px; font-size: 13px; font-weight: 400; }
.time-billed-list { overflow-x: auto; }
.time-billed-head,
.time-billed-row {
    min-width: 1292px;
    display: grid;
    grid-template-columns: 8px 145px 92px 320px 96px 112px 190px 210px;
    align-items: center;
    justify-content: start;
    gap: 13px;
    padding-right: 14px;
    padding-left: 14px;
}
.time-billed-head { min-height: 40px; font-size: 11px; }
.time-billed-row { min-height: 58px; font-size: 13px; font-weight: 400; }
.time-billed-row > span,
.time-billed-row > small { display: initial; color: inherit; font-size: 13px; font-weight: 400; }

@media (min-width: 1100px) {
    .time-customer-group > summary {
        grid-template-columns: 560px auto 24px;
        justify-content: start;
        gap: 10px;
        padding-left: 10px;
    }
    .time-group-sums {
        display: grid;
        grid-template-columns: 90px 105px 105px 115px;
        justify-content: start;
        gap: 10px;
    }
}
.time-billed-description { display: grid !important; }
.time-report-description,
.time-billed-description {
    min-width: 0;
    gap: 2px;
}
.time-copy-value {
    position: relative;
    min-width: 0;
    min-height: 25px;
    display: inline-flex;
    align-items: center;
    justify-self: start;
    margin: -3px -5px;
    padding: 3px 5px;
    border: 0;
    border-radius: 4px;
    color: inherit;
    background: transparent;
    font: inherit;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
}
.time-copy-value:hover {
    color: #fff;
    background: rgba(255,255,255,.07);
}
.time-copy-value:focus-visible {
    outline: 2px solid #7ec2ff;
    outline-offset: 1px;
}
.time-copy-value.is-copied {
    color: #d9ffe9;
    background: rgba(45, 188, 112, .16);
}
.time-copy-description {
    max-width: 100%;
    overflow-wrap: anywhere;
}
.time-copy-duration {
    font-family: "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.time-report-edit {
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    justify-self: start;
    padding: 0;
    border: 1px solid #46515a;
    border-radius: 4px;
    color: #b8c2c8;
    background: #262c31;
    cursor: pointer;
    transition: color .16s ease, border-color .16s ease, background-color .16s ease;
}
.time-report-edit:hover {
    border-color: #65737d;
    color: #fff;
    background: #30373d;
}
.time-report-edit:active {
    background: #1f2428;
}
.time-report-edit:focus-visible {
    outline: 2px solid #7ec2ff;
    outline-offset: 2px;
}
.time-report-edit svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}
.time-copy-confirm {
    position: absolute;
    left: 4px;
    bottom: calc(100% + 4px);
    z-index: 3;
    padding: 3px 6px;
    border: 1px solid #397b59;
    border-radius: 3px;
    color: #dcffea;
    background: #173d29;
    box-shadow: 0 4px 12px rgba(0,0,0,.24);
    font: 600 10px/1.2 Aptos, "Segoe UI", sans-serif;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transform: translateY(2px);
    transition: opacity .12s ease, transform .12s ease;
}
.time-copy-value.is-copied .time-copy-confirm {
    opacity: 1;
    transform: translateY(0);
}
.time-load-more {
    min-height: 42px;
    display: block;
    margin: 14px auto 0;
    padding: 0 18px;
    color: #dfe6e9;
    border-color: #46515a;
    background: #22282d;
}
.time-entry-dialog {
    width: min(820px, calc(100vw - 32px));
    max-height: min(880px, calc(100vh - 32px));
    overflow: hidden;
    border-radius: 11px;
    background: #1d2327;
}
.time-entry-dialog form {
    max-height: inherit;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
}
.time-entry-dialog form > header { padding: 18px 22px; background: #22282d; }
.time-entry-dialog form > footer { padding: 14px 22px 18px; background: #22282d; }
.time-entry-fields {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
    overflow-y: auto;
    padding: 22px;
}
.time-entry-fields > label,
.time-entry-fields > .calculated-field { grid-column: span 6; }
.time-entry-fields > .field-wide,
.time-entry-fields > .time-customer-field { grid-column: 1 / -1; }
.time-entry-fields > .time-date-field { grid-column: span 4; }
.time-entry-fields > .time-duration-field { grid-column: span 8; }
.time-entry-fields input,
.time-entry-fields textarea {
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #46515a;
    border-radius: 6px;
    color: #edf2f4;
    background: #14191d;
    font: 14px/1.35 Aptos, "Segoe UI", sans-serif;
}
.time-entry-fields textarea { min-height: 104px; resize: none; }
.time-entry-fields .calculated-field strong { min-height: 46px; font-size: 15px; font-weight: 500; }
.time-duration-field {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}
.time-duration-field legend {
    width: 100%;
    margin: 0 0 7px;
    padding: 0;
    color: #aab6bd;
    font-size: 13px;
    text-align: center;
}
.time-duration-row {
    min-height: 46px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.time-duration-input {
    flex: 0 0 58px;
    min-width: 58px;
    height: 42px;
    display: grid;
    grid-template-rows: 30px 12px;
    align-items: center;
    gap: 0;
}
.time-entry-fields .time-duration-input input {
    width: 100%;
    min-width: 0;
    min-height: 30px;
    padding: 4px 1px 3px;
    border: 0;
    border-bottom: 1px solid #52606a;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font: 400 15px/1 "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
    text-align: center;
    appearance: textfield;
}
.time-entry-fields .time-duration-input input::-webkit-inner-spin-button,
.time-entry-fields .time-duration-input input::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
}
.time-duration-input b {
    width: 100%;
    color: #b4c0c6;
    font-size: 12px;
    font-weight: 400;
    line-height: 12px;
    text-align: center;
}
.time-duration-input:focus-within {
    box-shadow: none;
}
.time-entry-fields .time-duration-input input:focus {
    border-bottom-color: #ff5967;
    box-shadow: 0 2px 0 rgba(255, 89, 103, .16);
}
.time-duration-clock {
    width: 18px;
    height: 18px;
    color: #7f8d96;
}
.time-duration-quick {
    min-width: 0;
    min-height: 34px;
    display: flex;
    flex: 0 0 auto;
    justify-content: flex-start;
    gap: 6px;
}
.time-duration-quick-previous {
    width: 126px;
    flex-basis: 126px;
    justify-content: flex-end;
    margin-right: 4px;
}
.time-duration-quick-next {
    width: 192px;
    flex-basis: 192px;
    margin-left: 4px;
}
.time-duration-quick button {
    width: 60px;
    flex: 0 0 60px;
    min-height: 34px;
    padding: 0 4px;
    border: 1px solid #46515a;
    border-radius: 5px;
    color: #dce3e7;
    background: #262d32;
    font-size: 11px;
    white-space: nowrap;
}
.time-duration-quick button:hover {
    border-color: #65737c;
    color: #fff;
    background: #323b41;
}
.time-duration-quick button:focus-visible {
    outline: 2px solid #7ec2ff;
    outline-offset: 2px;
}
.time-duration-quick button:disabled {
    opacity: .45;
    cursor: default;
}
.time-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 760px) {
    .time-report-charts,
    .time-report-charts.has-monthly-chart {
        grid-template-columns: minmax(0, 1fr);
    }
    .time-chart-header {
        padding: 10px 12px;
    }
    .time-donut-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 6px;
        padding: 8px 10px 12px;
    }
    .time-customer-chart .time-donut-layout {
        height: auto;
    }
    .time-donut {
        width: min(280px, 100%);
    }
    .time-chart-legend {
        width: 100%;
        min-width: 0;
        max-width: none;
        max-height: 220px;
    }
    .time-customer-chart .time-chart-legend {
        height: auto;
        max-height: 220px;
    }
    .time-chart-legend li {
        grid-template-columns: 8px minmax(90px, 1fr) auto;
        gap: 9px;
    }
    .time-chart-customer {
        max-width: none;
    }
    .time-report-row > span:nth-last-child(-n+3),
    .time-report-row > .time-money:last-child,
    .time-billed-row > span,
    .time-billed-row > small { display: initial; }
    .time-report-head,
    .time-report-row,
    .time-billed-head,
    .time-billed-row { display: grid; }
    .time-entry-dialog { width: 100vw; max-height: none; border-radius: 0; }
    .time-entry-fields { grid-template-columns: 1fr 1fr; padding: 16px; }
    .time-entry-fields > label,
    .time-entry-fields > .calculated-field,
    .time-entry-fields > .time-date-field { grid-column: span 1; }
    .time-entry-fields > .field-wide,
    .time-entry-fields > .time-customer-field,
    .time-entry-fields > .time-date-field,
    .time-entry-fields > .time-duration-field { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
    .time-duration-quick {
        width: 100%;
        flex-basis: 100%;
        margin-inline: 0;
        justify-content: center;
    }
}

@media (max-width: 1400px) and (min-width: 761px) {
    .time-report-charts.has-monthly-chart {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .time-donut-segment,
    .time-month-bar-mark,
    .time-chart-tooltip,
    .time-copy-confirm {
        transition-duration: .01ms;
    }
}
