:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --ink: #111827;
    --muted: #64748b;
    --line: #dbe3ee;
    --primary: #0e7490;
    --primary-strong: #155e75;
    --navy: #111827;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --violet: #7c3aed;
    --shadow: 0 18px 42px rgba(15, 23, 42, 0.09);
    --radius: 8px;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #172033;
    --surface-2: #111827;
    --ink: #e5eefb;
    --muted: #9fb0c8;
    --line: #2c3950;
    --primary: #22a6b8;
    --primary-strong: #5bd5e5;
    --navy: #08111f;
    --shadow: 0 18px 42px rgba(0, 0, 0, 0.26);
}

* {
    box-sizing: border-box;
}

[hidden],
.drawer-panel[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        linear-gradient(180deg, rgba(14, 116, 144, 0.07), rgba(124, 58, 237, 0.03) 320px),
        var(--bg);
    color: var(--ink);
}

body.drawer-open {
    overflow: hidden;
}

.sidebar {
    min-height: 100vh;
    background:
        linear-gradient(180deg, #111827 0%, #182235 55%, #0f172a 100%);
    color: #f8fafc;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    align-self: start;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #0e7490, #7c3aed);
    color: #ffffff;
    font-weight: 900;
    letter-spacing: 0;
}

.brand-logo {
    overflow: hidden;
    background: #ffffff;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: #b8c4d6;
    margin-top: 3px;
}

.menu-toggle {
    display: none;
    margin-left: auto;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    padding: 10px;
}

.menu-toggle span {
    display: block;
    height: 2px;
    margin: 5px 0;
    background: #ffffff;
    border-radius: 99px;
}

.mobile-menu {
    display: block;
}

.nav {
    display: grid;
    gap: 7px;
    margin-top: 20px;
}

.nav a {
    color: #d4deec;
    text-decoration: none;
    padding: 12px 13px;
    border-radius: var(--radius);
    font-weight: 720;
}

.nav a:hover,
.nav a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.user-panel {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    display: grid;
    gap: 10px;
}

.user-panel strong,
.user-panel small {
    display: block;
}

.text-button,
.text-danger {
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius);
    background: transparent;
    color: #ffffff;
    min-height: 42px;
    width: 100%;
    font: inherit;
    font-weight: 760;
    cursor: pointer;
}

.logout-button {
    min-height: 30px;
    width: auto;
    padding: 5px 10px;
    justify-self: start;
    font-size: 12px;
}

.text-danger {
    border-color: #fecaca;
    color: var(--danger);
    background: #fff7f7;
}

.main {
    min-width: 0;
    padding: 30px;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .panel,
[data-theme="dark"] .metrics article,
[data-theme="dark"] .site-card,
[data-theme="dark"] .sub-panel,
[data-theme="dark"] .progress-card {
    background-color: var(--surface);
    color: var(--ink);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    margin-bottom: 22px;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 28px;
    line-height: 1.15;
    letter-spacing: 0;
}

h2 {
    font-size: 16px;
}

.page-header p {
    color: var(--muted);
    margin-top: 8px;
    max-width: 920px;
}

.auth-page {
    display: block;
    min-height: 100vh;
    background:
        linear-gradient(120deg, rgba(15, 23, 42, 0.94), rgba(14, 116, 144, 0.82)),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.06) 0 1px, transparent 1px 90px),
        repeating-linear-gradient(0deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 90px);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(280px, 520px) minmax(320px, 430px);
    gap: 36px;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.login-copy {
    color: #ffffff;
    display: grid;
    gap: 16px;
}

.login-kicker {
    display: inline-flex;
    width: max-content;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

.login-copy h1 {
    font-size: 44px;
}

.login-copy p {
    color: #dbeafe;
    font-size: 17px;
    line-height: 1.6;
}

.login-panel {
    width: min(100%, 430px);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: var(--radius);
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.28);
    padding: 26px;
    display: grid;
    gap: 18px;
}

[data-theme="dark"] .login-panel {
    background: rgba(23, 32, 51, 0.96);
    color: var(--ink);
    border-color: var(--line);
}

[data-theme="dark"] .login-brand {
    color: var(--ink);
}

.login-brand {
    color: var(--ink);
    border-bottom: 1px solid var(--line);
}

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

.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid #99f6e4;
    background: #ecfeff;
    color: #155e75;
    margin-bottom: 18px;
    font-weight: 750;
}

.alert.error {
    border-color: #fecaca;
    background: #fff1f2;
    color: #b42318;
    margin-bottom: 0;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(170px, 1fr));
    gap: 15px;
    margin-bottom: 18px;
}

.metrics article,
.panel,
.site-card,
.sub-panel,
.progress-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.metrics article {
    padding: 17px;
    display: grid;
    gap: 6px;
    min-height: 122px;
}

.metrics span,
small,
.activity-row em {
    color: var(--muted);
}

.metrics strong {
    display: block;
    font-size: 22px;
}

.hero-progress {
    padding: 18px;
    display: grid;
    grid-template-columns: minmax(220px, 340px) 1fr;
    gap: 18px;
    align-items: center;
}

.hero-progress span {
    color: var(--muted);
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
}

.hero-progress strong {
    display: block;
    font-size: 34px;
    margin: 4px 0;
}

.hero-progress p {
    color: var(--muted);
}

.hero-meter {
    height: 18px;
    border-radius: 999px;
    background: #e7edf5;
    overflow: hidden;
}

.hero-meter i {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--success));
}

.metrics em {
    color: var(--muted);
    font-style: normal;
    font-size: 13px;
}

.grid {
    display: grid;
    gap: 18px;
}

.grid.two {
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.dashboard-grid {
    grid-template-columns: 0.8fr 1fr 1fr;
    margin-bottom: 18px;
}

.panel {
    margin-bottom: 20px;
    overflow: hidden;
}

.panel-title {
    padding: 17px 19px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, #ffffff, #fbfdff);
}

.panel-title.tight {
    padding: 14px 16px;
}

.chart-panel {
    margin-bottom: 0;
}

.donut-wrap {
    padding: 18px;
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 18px;
    align-items: center;
}

.donut {
    width: 150px;
    aspect-ratio: 1;
    border-radius: 50%;
    display: grid;
    place-items: center;
    position: relative;
}

.donut::after {
    content: "";
    position: absolute;
    inset: 24px;
    border-radius: 50%;
    background: var(--surface);
}

.donut span,
.donut small {
    position: relative;
    z-index: 1;
}

.donut span {
    font-size: 28px;
    font-weight: 900;
}

.donut small {
    margin-top: 30px;
    position: absolute;
}

.legend {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 700;
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

.dot.done { background: #14b8a6; }
.dot.progress { background: #3b82f6; }
.dot.blocked { background: #ef4444; }
.dot.pending { background: #d8dee8; }

.chart-bars,
.cash-bars,
.site-board {
    padding: 18px;
    display: grid;
    gap: 13px;
}

.chart-bar-row {
    display: grid;
    grid-template-columns: 120px 1fr 46px;
    gap: 10px;
    align-items: center;
}

.chart-track {
    height: 10px;
    border-radius: 999px;
    background: #e8eef6;
    overflow: hidden;
}

.chart-track i {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--violet));
}

.cash-bars div {
    display: grid;
    gap: 6px;
}

.cash-bars span {
    color: var(--muted);
    font-weight: 720;
}

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

.site-mini-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 13px;
    display: grid;
    gap: 10px;
    background: var(--surface-2);
}

.site-mini-card footer {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-weight: 760;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

.data-table tbody tr:nth-child(4n + 1) {
    background: #ffffff;
}

.data-table tbody tr:nth-child(4n + 3) {
    background: #f8fbff;
}

.data-table tbody tr:hover {
    background: #eef9ff;
}

[data-theme="dark"] .data-table tbody tr:nth-child(4n + 1),
[data-theme="dark"] .data-table tbody tr:nth-child(4n + 3),
[data-theme="dark"] tr,
[data-theme="dark"] .drawer-panel,
[data-theme="dark"] .list-toolbar,
[data-theme="dark"] .filter-strip,
[data-theme="dark"] .panel-title {
    background: var(--surface);
}

[data-theme="dark"] th {
    background: var(--surface-2);
    color: var(--muted);
}

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

th {
    color: #475467;
    background: #f8fafc;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0;
}

td {
    font-size: 13px;
}

tr:last-child td {
    border-bottom: 0;
}

.bar {
    height: 10px;
    width: 150px;
    background: #e8edf3;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 7px;
}

.bar span,
.bar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 999px;
}

.bar.mini {
    width: 100%;
    height: 7px;
    margin-bottom: 4px;
}

.bar.delivered i {
    background: linear-gradient(90deg, #2563eb, #14b8a6);
}

.bar.installed i {
    background: linear-gradient(90deg, #16a34a, #84cc16);
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #e0f2fe;
    color: var(--primary-strong);
    font-size: 12px;
    font-weight: 780;
    margin: 0 5px 5px 0;
    white-space: nowrap;
}

.pill.soft {
    background: #fff7ed;
    color: var(--warning);
}

.quote-rank {
    background: #eef2ff;
    color: #3730a3;
}

.rank-mode tr[data-quote-rank="L1"] {
    outline: 2px solid rgba(22, 163, 74, 0.24);
    outline-offset: -2px;
}

.activity {
    display: grid;
    gap: 12px;
    padding: 18px 20px;
}

.activity-row {
    display: grid;
    gap: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

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

.activity-row span {
    color: var(--violet);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

.activity-row em {
    font-style: normal;
}

.site-stack {
    display: grid;
    gap: 16px;
}

.site-card {
    overflow: hidden;
}

.site-card summary {
    cursor: pointer;
    list-style: none;
    display: grid;
    grid-template-columns: 1fr minmax(150px, 260px);
    gap: 18px;
    align-items: center;
    padding: 18px;
    background: linear-gradient(90deg, #ffffff, #f8fbff);
}

.site-card summary::-webkit-details-marker {
    display: none;
}

.site-card summary strong,
.site-card summary small {
    display: block;
}

.summary-progress {
    display: grid;
    gap: 6px;
    justify-items: end;
    color: var(--primary-strong);
    font-weight: 850;
}

.summary-progress .bar {
    width: 100%;
}

.site-card-body {
    padding: 16px;
    display: grid;
    gap: 16px;
    background: #fbfdff;
}

.sub-panel {
    overflow: hidden;
    box-shadow: none;
}

.activity-cards {
    display: grid;
    gap: 12px;
}

.progress-card {
    padding: 14px;
    box-shadow: none;
}

.activity-edit-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    align-items: end;
}

.activity-actions {
    display: grid;
    gap: 8px;
}

.activity-actions .bar {
    width: 100%;
}

.danger-form {
    padding: 0 16px 16px;
    display: flex;
    justify-content: flex-end;
}

.setup-body {
    padding: 20px;
    display: grid;
    gap: 14px;
}

.setup-body pre {
    margin: 0;
    padding: 14px;
    border-radius: var(--radius);
    overflow-x: auto;
    background: var(--navy);
    color: #f8fafc;
}

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

.inline-link {
    color: var(--primary-strong);
    font-weight: 800;
    text-decoration: none;
}

.inline-link:hover {
    text-decoration: underline;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 14px;
    padding: 18px 20px 20px;
    align-items: end;
}

.compact-form {
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    padding: 14px;
}

.billing-form {
    grid-template-columns: repeat(6, minmax(112px, 1fr));
    gap: 12px;
}

.billing-form .span-2 {
    grid-column: span 2;
}

.span-full,
.billing-form .span-full {
    grid-column: 1 / -1;
}

.list-panel {
    overflow: visible;
}

.list-toolbar {
    padding: 13px 15px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.management-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: -8px 0 18px;
}

.management-tabs a {
    display: inline-grid;
    place-items: center;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    text-decoration: none;
    font-weight: 820;
    font-size: 13px;
}

.management-tabs a.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #ffffff;
    border-color: transparent;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 10px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--line);
    background: #fbfdff;
}

.search-input {
    width: min(46vw, 300px);
    min-height: 40px;
}

.icon-button {
    display: inline-grid;
    place-items: center;
    min-width: 38px;
    min-height: 38px;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--ink);
    text-decoration: none;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

[data-theme="dark"] .icon-button {
    background: var(--surface-2);
    color: var(--ink);
    border-color: var(--line);
}

.icon-button.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #ffffff;
    border-color: transparent;
}

.danger-icon {
    color: var(--danger);
    border-color: #fecaca;
    background: #fff7f7;
}

[data-theme="dark"] .danger-icon {
    color: #fca5a5;
    border-color: rgba(252, 165, 165, 0.36);
    background: rgba(220, 38, 38, 0.12);
}

.action-cell {
    display: flex;
    gap: 6px;
    align-items: center;
    white-space: nowrap;
}

.action-cell form {
    display: inline;
}

.bill-icon {
    min-width: 42px;
    font-size: 10px;
    color: var(--primary-strong);
    border-color: #a8d7e2;
}

.bill-line-link {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 11px;
    white-space: nowrap;
}

.muted-text {
    color: var(--muted);
    font-size: 12px;
}

.status-table {
    min-width: 980px;
}

.status-progress {
    display: grid;
    gap: 3px;
    min-width: 160px;
}

.status-progress span {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 820;
}

.drawer-delete-form {
    display: flex;
    justify-content: flex-end;
    padding: 0 14px 14px;
    background: #fbfdff;
}

.drawer-panel {
    background: #fbfdff;
    border-bottom: 1px solid var(--line);
}

.drawer-close {
    display: none;
}

.table-drawer td {
    background: #fbfdff;
    padding: 0;
}

.invoice-items {
    display: grid;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.invoice-items-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.invoice-item-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(140px, 1fr) minmax(180px, 1.35fr) 74px 100px 74px 116px;
    gap: 8px;
    padding: 9px;
    border: 1px solid #e6edf5;
    border-radius: var(--radius);
    background: #fbfdff;
}

.invoice-item-row label {
    gap: 4px;
    font-size: 11px;
}

.amount-words {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #f8fbff;
    display: grid;
    gap: 5px;
}

.amount-words span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
}

.totals-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 14px;
    border-top: 1px solid var(--line);
    background: #fbfdff;
}

.totals-grid div {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    padding: 12px;
}

.totals-grid p {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
}

.totals-grid p:last-child {
    border-bottom: 0;
}

.totals-grid strong {
    color: var(--ink);
}

label {
    display: grid;
    gap: 6px;
    color: #334155;
    font-weight: 760;
    font-size: 12px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    padding: 10px 11px;
    font: inherit;
    color: var(--ink);
    background: #ffffff;
    font-size: 14px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.14);
}

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

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

.check {
    display: flex;
    align-items: center;
    gap: 9px;
}

.check input {
    width: auto;
}

.button {
    border: 0;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #ffffff;
    min-height: 43px;
    padding: 10px 15px;
    font-weight: 850;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(14, 116, 144, 0.16);
}

.button:hover {
    filter: brightness(0.96);
}

.button.small {
    min-height: 36px;
    padding: 8px 10px;
}

.button.danger {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    box-shadow: 0 10px 20px rgba(220, 38, 38, 0.16);
}

.button.ghost {
    display: inline-grid;
    place-items: center;
    text-decoration: none;
    background: #ffffff;
    color: var(--primary-strong);
    border: 1px solid #a8d7e2;
    box-shadow: none;
}

.inline-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(105px, 1fr));
    gap: 8px;
    min-width: 560px;
}

.inline-form input,
.inline-form select {
    padding: 8px;
    font-size: 12px;
}

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

    .sidebar {
        min-height: auto;
        position: sticky;
        z-index: 10;
    }

    .metrics,
    .dashboard-grid,
    .grid.two,
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .invoice-item-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .invoice-item-row label:nth-child(3) {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    body {
        display: block;
        background: var(--bg);
    }

    .sidebar {
        padding: 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    }

    .brand {
        padding-bottom: 0;
        border-bottom: 0;
    }

    .brand-mark {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }

    .menu-toggle {
        display: block;
    }

    .mobile-menu {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.22s ease;
    }

    .menu-open .mobile-menu {
        max-height: 80vh;
        overflow-y: auto;
    }

    .nav {
        margin-top: 14px;
        grid-template-columns: 1fr 1fr;
    }

    .nav a {
        text-align: center;
        min-height: 44px;
        display: grid;
        place-items: center;
        padding: 10px 8px;
    }

    .user-panel {
        margin-top: 12px;
        padding-top: 12px;
    }

    .main {
        padding: 16px 12px 28px;
    }

    .page-header {
        margin-bottom: 16px;
    }

    h1 {
        font-size: 24px;
    }

    .page-header p {
        font-size: 14px;
    }

    .metrics,
    .dashboard-grid,
    .grid.two,
    .form-grid,
    .site-board,
    .filter-strip,
    .activity-edit-form,
    .compact-form,
    .totals-grid {
        grid-template-columns: 1fr;
    }

    .metrics {
        gap: 10px;
    }

    .metrics article {
        min-height: auto;
        padding: 14px;
    }

    .metrics strong {
        font-size: 20px;
    }

    .panel,
    .site-card {
        margin-bottom: 14px;
    }

    .panel-title {
        padding: 14px;
    }

    .form-grid,
    .chart-bars,
    .cash-bars,
    .site-board {
        padding: 12px;
        gap: 9px;
    }

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

    .toolbar-actions {
        width: 100%;
    }

    .toolbar-actions .icon-button {
        flex: 0 0 auto;
    }

    .search-input {
        width: 100%;
        flex: 1;
    }

    .action-cell {
        padding-bottom: 8px;
        justify-content: flex-end;
    }

    .invoice-item-row {
        grid-template-columns: 1fr;
    }

    .status-progress {
        min-width: 0;
    }

    .drawer-delete-form {
        justify-content: stretch;
    }

    .drawer-delete-form .button {
        width: 100%;
    }

    .hero-progress {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .hero-progress strong {
        font-size: 28px;
    }

    .span-2 {
        grid-column: span 1;
    }

    input,
    select,
    textarea,
    .button,
    .text-button {
        min-height: 40px;
        font-size: 13px;
        padding: 8px 10px;
    }

    label {
        gap: 4px;
        font-size: 11px;
    }

    textarea {
        min-height: 70px;
    }

    .donut-wrap {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .legend {
        width: 100%;
    }

    .chart-bar-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .site-card summary {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .summary-progress {
        justify-items: stretch;
    }

    .site-card-body {
        padding: 12px;
    }

    .danger-form {
        padding: 0 14px 14px;
    }

    .table-wrap {
        overflow: visible;
    }

    table {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .status-table {
        min-width: 0;
    }

    thead,
    th {
        display: none;
    }

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

    .data-table tbody tr:not(.table-drawer) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 3px 8px;
        align-items: center;
        min-height: 66px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        padding: 9px 10px;
        background: var(--surface);
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
    }

    .data-table tbody tr:not(.table-drawer) td {
        display: none;
        border-bottom: 0;
        padding: 0;
        min-width: 0;
    }

    .data-table tbody tr:not(.table-drawer) td.mobile-primary,
    .data-table tbody tr:not(.table-drawer) td.mobile-secondary,
    .data-table tbody tr:not(.table-drawer) td.mobile-tertiary,
    .data-table tbody tr:not(.table-drawer) td.action-cell {
        display: flex;
    }

    .data-table tbody tr:not(.table-drawer) td.mobile-primary {
        grid-column: 1;
        grid-row: 1;
        font-size: 13px;
        font-weight: 800;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        line-height: 1.2;
    }

    .data-table tbody tr:not(.table-drawer) td.mobile-primary small {
        display: block;
        font-size: 11px;
        font-weight: 650;
    }

    .data-table tbody tr:not(.table-drawer) td.mobile-secondary,
    .data-table tbody tr:not(.table-drawer) td.mobile-tertiary {
        grid-column: 1;
        font-size: 11px;
        color: var(--muted);
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
    }

    .data-table tbody tr:not(.table-drawer) td.mobile-tertiary {
        display: none;
    }

    .data-table tbody tr:not(.table-drawer) td.action-cell {
        grid-column: 2;
        grid-row: 1 / span 2;
        justify-self: end;
        padding: 0;
    }

    td::before {
        content: none;
    }

    .list-panel > .drawer-panel:not([hidden]),
    .table-drawer:not([hidden]) {
        position: fixed;
        inset: 0;
        z-index: 40;
        display: block;
        overflow-y: auto;
        padding: 14px;
        background: rgba(15, 23, 42, 0.50);
        border: 0;
    }

    .list-panel > .drawer-panel:not([hidden]) > form,
    .table-drawer:not([hidden]) > td {
        display: block;
        width: min(100%, 620px);
        margin: 52px auto 18px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface);
        box-shadow: 0 22px 60px rgba(0, 0, 0, 0.22);
    }

    .table-drawer:not([hidden]) > td > form,
    .table-drawer:not([hidden]) > td > .form-grid {
        box-shadow: none;
    }

    .drawer-close {
        display: grid;
        place-items: center;
        width: max-content;
        min-height: 32px;
        margin: 10px 10px -42px auto;
        padding: 6px 10px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface-2);
        color: var(--ink);
        font: inherit;
        font-size: 12px;
        font-weight: 850;
    }

    .bar {
        width: 100%;
    }

    .inline-form {
        min-width: 0;
        grid-template-columns: 1fr;
    }

    .login-shell {
        min-height: 100vh;
        grid-template-columns: 1fr;
        align-items: start;
        padding: 22px 12px;
        gap: 20px;
    }

    .login-copy {
        padding: 10px 4px 0;
    }

    .login-copy h1 {
        font-size: 30px;
    }

    .login-copy p {
        font-size: 15px;
    }

    .login-panel {
        width: 100%;
        padding: 18px;
    }
}

/* Professional app refresh */
body {
    grid-template-columns: 258px minmax(0, 1fr);
    font-family: Aptos, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
}

[data-theme="light"] {
    --input-bg: #ffffff;
    --panel-grad: linear-gradient(180deg, #ffffff, #f8fbff);
}

[data-theme="dark"] {
    --input-bg: #141e31;
    --panel-grad: linear-gradient(180deg, #172033, #141e31);
}

h1 {
    font-size: 24px;
}

h2 {
    font-size: 15px;
}

td {
    font-size: 12px;
}

small,
.metrics em,
.page-header p {
    font-size: 12px;
}

.sidebar {
    padding: 18px 13px;
    transition: width 0.18s ease, padding 0.18s ease;
}

.brand {
    gap: 10px;
}

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

.brand small {
    font-size: 11px;
}

.sidebar-toggle {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-left: auto;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.07);
    cursor: pointer;
}

.sidebar-toggle span {
    display: block;
    width: 15px;
    height: 2px;
    margin: 2px 0;
    border-radius: 99px;
    background: #ffffff;
}

[data-sidebar-mode="show"] .sidebar-toggle {
    opacity: 0.35;
    cursor: default;
}

.nav-groups {
    gap: 12px;
}

.nav-group {
    display: grid;
    gap: 5px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.nav-group:last-child {
    border-bottom: 0;
}

.nav-group-title {
    padding: 0 6px 2px;
    color: #8fa4c2;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.nav-link,
.nav a.nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #d7e1ef;
    text-decoration: none;
    padding: 9px 10px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 700;
}

.nav-code {
    display: inline-grid;
    place-items: center;
    width: 27px;
    height: 24px;
    flex: 0 0 27px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #bfefff;
    font-size: 10px;
    font-weight: 850;
}

.nav-link:hover,
.nav-link.active,
.nav a.nav-link:hover,
.nav a.nav-link.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.nav-link.active .nav-code {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #ffffff;
}

body.sidebar-collapsed,
body[data-sidebar-mode="hide"]:not(.sidebar-peek) {
    grid-template-columns: 76px minmax(0, 1fr);
}

body.sidebar-collapsed .sidebar,
body[data-sidebar-mode="hide"]:not(.sidebar-peek) .sidebar {
    padding: 16px 9px;
}

body.sidebar-collapsed .brand,
body[data-sidebar-mode="hide"]:not(.sidebar-peek) .brand {
    justify-content: center;
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-group-title,
body.sidebar-collapsed .user-panel > div,
body[data-sidebar-mode="hide"]:not(.sidebar-peek) .brand-copy,
body[data-sidebar-mode="hide"]:not(.sidebar-peek) .nav-label,
body[data-sidebar-mode="hide"]:not(.sidebar-peek) .nav-group-title,
body[data-sidebar-mode="hide"]:not(.sidebar-peek) .user-panel > div {
    display: none;
}

body.sidebar-collapsed .sidebar-toggle,
body[data-sidebar-mode="hide"]:not(.sidebar-peek) .sidebar-toggle {
    margin-left: 0;
}

body.sidebar-collapsed .nav-link,
body[data-sidebar-mode="hide"]:not(.sidebar-peek) .nav-link {
    justify-content: center;
    padding: 9px 0;
}

body[data-sidebar-mode="hide"] .sidebar:hover,
body.sidebar-peek[data-sidebar-mode="hide"] .sidebar {
    position: fixed;
    z-index: 30;
    top: 0;
    bottom: 0;
    left: 0;
    width: 258px;
    overflow-y: auto;
    padding: 18px 13px;
    box-shadow: 18px 0 36px rgba(0, 0, 0, 0.22);
}

body[data-sidebar-mode="hide"] .sidebar:hover .brand-copy,
body[data-sidebar-mode="hide"] .sidebar:hover .nav-label,
body[data-sidebar-mode="hide"] .sidebar:hover .nav-group-title,
body[data-sidebar-mode="hide"] .sidebar:hover .user-panel > div,
body.sidebar-peek[data-sidebar-mode="hide"] .brand-copy,
body.sidebar-peek[data-sidebar-mode="hide"] .nav-label,
body.sidebar-peek[data-sidebar-mode="hide"] .nav-group-title,
body.sidebar-peek[data-sidebar-mode="hide"] .user-panel > div {
    display: block;
}

body[data-sidebar-mode="hide"] .sidebar:hover .brand,
body.sidebar-peek[data-sidebar-mode="hide"] .brand {
    justify-content: flex-start;
}

body[data-sidebar-mode="hide"] .sidebar:hover .sidebar-toggle,
body.sidebar-peek[data-sidebar-mode="hide"] .sidebar-toggle {
    margin-left: auto;
}

.main {
    padding: 24px;
}

.panel-title,
.list-toolbar,
.filter-strip {
    background: var(--panel-grad);
}

input,
select,
textarea {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 13px;
    background: var(--input-bg);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--ink);
    box-shadow: 0 0 0 1000px var(--input-bg) inset;
    transition: background-color 9999s ease-out;
}

.auth-page[data-theme="light"] {
    background:
        linear-gradient(135deg, rgba(240, 249, 255, 0.96), rgba(224, 242, 254, 0.88)),
        repeating-linear-gradient(90deg, rgba(14, 116, 144, 0.08) 0 1px, transparent 1px 96px);
}

.auth-page[data-theme="light"] .login-copy {
    color: #0f172a;
}

.auth-page[data-theme="light"] .login-copy p {
    color: #31506b;
}

.auth-page[data-theme="light"] .login-kicker {
    color: #0f3f57;
    border-color: rgba(14, 116, 144, 0.32);
    background: rgba(255, 255, 255, 0.36);
}

.auth-page[data-theme="dark"] {
    background:
        linear-gradient(125deg, #0d1628 0%, #123047 48%, #0e7490 100%),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.05) 0 1px, transparent 1px 96px);
}

.login-shell {
    grid-template-columns: minmax(280px, 500px) minmax(320px, 410px);
}

.login-copy h1 {
    font-size: 38px;
    line-height: 1.16;
}

.login-panel {
    border-radius: 10px;
}

[data-theme="dark"] .login-panel,
[data-theme="dark"] .drawer-panel,
[data-theme="dark"] .table-drawer td,
[data-theme="dark"] .invoice-section,
[data-theme="dark"] .invoice-items,
[data-theme="dark"] .invoice-item-row,
[data-theme="dark"] .amount-words,
[data-theme="dark"] .totals-grid,
[data-theme="dark"] .totals-grid div,
[data-theme="dark"] .drawer-delete-form,
[data-theme="dark"] .site-mini-card,
[data-theme="dark"] .table-drawer:not([hidden]) > td {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line);
}

[data-theme="dark"] label {
    color: #c6d3e6;
}

[data-theme="dark"] .invoice-item-row,
[data-theme="dark"] .amount-words,
[data-theme="dark"] .totals-grid div {
    background: var(--surface-2);
}

[data-theme="dark"] .button.ghost {
    background: var(--surface-2);
    color: var(--primary-strong);
}

[data-theme="dark"] .table-drawer:not([hidden]),
[data-theme="dark"] .list-panel > .drawer-panel:not([hidden]) {
    background: rgba(2, 6, 23, 0.64);
}

.list-panel > .drawer-panel:not([hidden]),
.table-drawer:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    overflow-y: auto;
    padding: 18px;
    background: rgba(15, 23, 42, 0.42);
    border: 0;
}

.list-panel > .drawer-panel:not([hidden]) > form,
.table-drawer:not([hidden]) > td {
    display: block;
    width: min(100%, 1120px);
    max-height: calc(100vh - 78px);
    overflow-y: auto;
    margin: 44px auto 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.drawer-close {
    display: grid;
    position: sticky;
    top: 8px;
    z-index: 3;
    place-items: center;
    width: max-content;
    min-height: 30px;
    margin: 8px 8px 8px auto;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-size: 12px;
    font-weight: 800;
}

.invoice-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px;
}

.invoice-section {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 12px;
}

.invoice-section h3 {
    margin: 0;
    font-size: 14px;
}

.invoice-section summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    list-style: none;
    font-weight: 850;
}

.invoice-section summary::-webkit-details-marker {
    display: none;
}

.invoice-section summary::after {
    content: "+";
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--primary-strong);
    font-weight: 900;
}

.invoice-section[open] summary::after {
    content: "-";
}

.invoice-section summary small {
    margin-left: auto;
    color: var(--muted);
    font-weight: 700;
}

.invoice-basic-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.invoice-items {
    gap: 9px;
    padding: 12px;
}

.invoice-items-head h3 {
    margin: 0 0 2px;
}

.invoice-item-row {
    grid-template-columns: minmax(130px, 1.1fr) minmax(130px, 1.05fr) minmax(180px, 1.45fr) 70px 102px 70px 140px 38px;
    align-items: end;
    padding: 8px;
}

.invoice-row-remove {
    min-width: 34px;
    min-height: 34px;
    align-self: end;
}

.billing-form .span-2 {
    grid-column: span 1;
}

@media (max-width: 1180px) {
    body.sidebar-collapsed,
    body[data-sidebar-mode="hide"]:not(.sidebar-peek),
    body {
        grid-template-columns: 1fr;
    }

    .sidebar-toggle {
        display: none;
    }
}

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

    .invoice-item-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .main {
        padding: 14px 10px 24px;
    }

    .nav-groups {
        gap: 10px;
    }

    .nav-group {
        grid-template-columns: 1fr 1fr;
    }

    .nav-group-title {
        grid-column: 1 / -1;
        padding-top: 5px;
    }

    .nav-link,
    .nav a.nav-link {
        min-height: 40px;
        justify-content: flex-start;
        padding: 8px;
    }

    .login-copy h1 {
        font-size: 27px;
    }

    .login-panel {
        padding: 16px;
    }

    .list-panel > .drawer-panel:not([hidden]) > form,
    .table-drawer:not([hidden]) > td {
        width: min(100%, 640px);
        max-height: calc(100vh - 46px);
        margin: 28px auto 12px;
    }

    .invoice-form {
        padding: 10px;
    }

    .invoice-basic-grid,
    .invoice-item-row {
        grid-template-columns: 1fr;
    }

.invoice-row-remove {
    width: 100%;
}
}

/* Mobile fit fixes */
@media (max-width: 980px) {
    html,
    body {
        overflow-x: hidden;
    }

    .auth-page {
        min-height: 100vh;
    }

    .login-shell {
        width: 100%;
        min-height: 100vh;
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        align-items: start;
        gap: 16px;
        padding: 18px 12px;
    }

    .login-copy,
    .login-panel {
        width: min(100%, 430px);
    }

    .login-copy {
        text-align: center;
        padding: 4px 0 0;
    }

    .login-kicker {
        margin: 0 auto;
    }

    .login-copy h1 {
        font-size: 28px;
        line-height: 1.18;
    }

    .login-copy p {
        font-size: 14px;
        line-height: 1.45;
    }
}

@media (max-width: 760px) {
    .menu-open .mobile-menu {
        max-height: calc(100vh - 76px);
    }

    .nav,
    .nav-groups {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .nav-group {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .nav-group-title {
        grid-column: 1;
        padding: 8px 6px 2px;
    }

    .nav-link,
    .nav a.nav-link,
    .nav a {
        width: 100%;
        min-height: 38px;
        justify-content: flex-start;
        text-align: left;
        white-space: normal;
        padding: 8px 10px;
    }

    .nav-label {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .user-panel {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .user-panel form {
        flex: 0 0 auto;
    }

    .logout-button {
        min-height: 34px;
    }

    .status-table tbody tr:not(.table-drawer) {
        min-height: 94px;
    }

    .status-table tbody tr:not(.table-drawer) td.mobile-primary,
    .status-table tbody tr:not(.table-drawer) td.mobile-secondary,
    .status-table tbody tr:not(.table-drawer) td.mobile-tertiary {
        display: flex;
    }

    .status-table tbody tr:not(.table-drawer) td.mobile-tertiary {
        grid-column: 1;
        display: block;
        margin-top: 3px;
        -webkit-line-clamp: unset;
    }

    .status-table .status-progress {
        width: min(100%, 230px);
        gap: 2px;
    }

    .status-table .status-progress span {
        font-size: 10px;
    }

    .status-table .bar.mini {
        height: 5px;
    }

    .invoice-section summary {
        align-items: flex-start;
    }

    .invoice-section summary small {
        display: none;
    }
}

/* Final phone refinements */
@media (max-width: 980px) {
    .auth-page {
        overflow-x: hidden;
    }

    .login-shell {
        width: 100%;
        max-width: 100vw;
        min-height: 100vh;
        min-height: 100svh;
        grid-template-columns: 1fr !important;
        justify-content: stretch;
        justify-items: center;
        align-content: start;
        gap: 16px;
        padding: 18px 12px 30px;
    }

    .login-copy,
    .login-panel {
        width: min(calc(100vw - 24px), 430px);
        max-width: calc(100vw - 24px);
    }

    .login-copy {
        text-align: center;
    }

    .login-copy h1 {
        font-size: clamp(24px, 7vw, 30px);
        line-height: 1.18;
        overflow-wrap: break-word;
    }

    .login-copy p {
        font-size: 14px;
        line-height: 1.45;
        overflow-wrap: break-word;
    }

    .login-panel {
        padding: 18px;
    }

    .login-brand,
    .login-brand > div {
        min-width: 0;
    }

    .login-brand strong,
    .login-brand small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 900px) {
    body:not(.auth-page) {
        display: block;
    }

    .sidebar,
    body.sidebar-collapsed .sidebar,
    body[data-sidebar-mode="hide"]:not(.sidebar-peek) .sidebar {
        position: sticky;
        top: 0;
        z-index: 30;
        width: 100%;
        min-height: auto;
        padding: 10px 12px;
    }

    body[data-sidebar-mode="hide"] .sidebar:hover,
    body.sidebar-peek[data-sidebar-mode="hide"] .sidebar {
        position: sticky;
        top: 0;
        bottom: auto;
        left: auto;
        width: 100%;
        overflow: visible;
        padding: 10px 12px;
        box-shadow: none;
    }

    .brand,
    body.sidebar-collapsed .brand,
    body[data-sidebar-mode="hide"]:not(.sidebar-peek) .brand,
    body[data-sidebar-mode="hide"] .sidebar:hover .brand,
    body.sidebar-peek[data-sidebar-mode="hide"] .brand {
        justify-content: flex-start;
        min-width: 0;
        padding-bottom: 0;
        border-bottom: 0;
    }

    .brand-copy,
    body.sidebar-collapsed .brand-copy,
    body.sidebar-collapsed .user-panel > div,
    body[data-sidebar-mode="hide"]:not(.sidebar-peek) .brand-copy,
    body[data-sidebar-mode="hide"]:not(.sidebar-peek) .user-panel > div {
        display: block;
    }

    .brand-copy {
        flex: 1 1 auto;
        min-width: 0;
    }

    .brand-copy strong,
    .brand-copy small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sidebar-toggle,
    body.sidebar-collapsed .sidebar-toggle,
    body[data-sidebar-mode="hide"]:not(.sidebar-peek) .sidebar-toggle {
        display: none;
    }

    .menu-toggle {
        display: block;
        flex: 0 0 44px;
    }

    .mobile-menu {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.22s ease;
    }

    .menu-open .mobile-menu {
        max-height: calc(100vh - 66px);
        max-height: calc(100svh - 66px);
        overflow-y: auto;
        padding-top: 10px;
    }

    .nav,
    .nav-groups {
        display: grid;
        grid-template-columns: 1fr !important;
        gap: 7px;
    }

    .nav-group {
        display: grid;
        grid-template-columns: 1fr !important;
        gap: 4px;
        padding-bottom: 8px;
    }

    .nav-group-title,
    body.sidebar-collapsed .nav-group-title,
    body[data-sidebar-mode="hide"]:not(.sidebar-peek) .nav-group-title {
        display: block;
        grid-column: 1 !important;
        padding: 8px 6px 2px;
    }

    .nav-link,
    .nav a.nav-link,
    .nav a,
    body.sidebar-collapsed .nav-link,
    body[data-sidebar-mode="hide"]:not(.sidebar-peek) .nav-link {
        display: flex !important;
        width: 100%;
        min-height: 38px;
        justify-content: flex-start !important;
        place-items: unset;
        text-align: left;
        white-space: normal;
        padding: 8px 10px !important;
    }

    .nav-label,
    body.sidebar-collapsed .nav-label,
    body[data-sidebar-mode="hide"]:not(.sidebar-peek) .nav-label {
        display: block;
        min-width: 0;
        overflow-wrap: anywhere;
        line-height: 1.25;
    }

    .user-panel {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-top: 10px;
        padding-top: 10px;
    }

    .user-panel form {
        flex: 0 0 auto;
    }

    .logout-button {
        min-height: 32px;
        padding: 5px 10px;
        font-size: 12px;
    }
}

@media (max-width: 760px) {
    .status-table tbody tr:not(.table-drawer) {
        grid-template-columns: minmax(0, 1fr) 42px;
        min-height: auto;
        padding: 10px;
    }

    .status-table tbody tr:not(.table-drawer) td.mobile-primary {
        order: 1;
        grid-column: 1;
        grid-row: 1;
        font-size: 14px;
    }

    .status-table tbody tr:not(.table-drawer) td.mobile-secondary {
        order: 2;
        grid-column: 1;
        grid-row: 2;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        -webkit-line-clamp: unset;
    }

    .status-table tbody tr:not(.table-drawer) td.mobile-tertiary {
        order: 3;
        grid-column: 1 / -1;
        grid-row: 3;
        display: block;
        margin-top: 4px;
    }

    .status-table tbody tr:not(.table-drawer) td.action-cell {
        order: 4;
        grid-column: 2;
        grid-row: 1 / span 2;
        align-self: center;
    }
}

@media (max-width: 420px) {
    .login-shell {
        padding: 14px 10px 24px;
    }

    .login-panel {
        padding: 16px 14px;
    }

    .brand-copy strong {
        font-size: 15px;
    }
}

@media (max-width: 520px) {
    .login-shell {
        display: flex;
        flex-direction: column;
        width: 100vw;
        max-width: 100vw;
        justify-items: stretch;
        align-items: stretch;
        justify-content: flex-start;
        gap: 14px;
        padding: 18px 16px 28px;
        overflow-x: hidden;
    }

    .login-copy,
    .login-panel {
        justify-self: stretch;
        width: auto;
        max-width: 360px;
        margin-left: 0;
        margin-right: 0;
    }

    .login-copy {
        text-align: center;
        gap: 12px;
    }

    .login-copy h1 {
        max-width: 100%;
        font-size: clamp(24px, 7vw, 29px);
        overflow-wrap: anywhere;
    }

    .login-copy p {
        max-width: 100%;
        margin: 0 auto;
    }

    .login-kicker {
        margin: 0 auto;
    }
}

/* Light login contrast guard */
.auth-page[data-theme="light"] .login-copy,
.auth-page[data-theme="light"] .login-copy h1 {
    color: #071526 !important;
    text-shadow: none !important;
}

.auth-page[data-theme="light"] .login-copy p {
    color: #24465f !important;
    text-shadow: none !important;
}

.auth-page[data-theme="light"] .login-kicker {
    color: #063b52 !important;
    border-color: rgba(14, 116, 144, 0.36) !important;
    background: rgba(255, 255, 255, 0.52) !important;
}

.auth-page[data-theme="light"] .login-brand {
    color: #071526 !important;
}

.auth-page[data-theme="light"] .login-brand small {
    color: #52657d !important;
}
