:root {
    --bg: #f5f7f8;
    --panel: #ffffff;
    --ink: #1f2933;
    --muted: #6b7280;
    --line: #d9e0e6;
    --accent: #0f766e;
    --accent-ink: #ffffff;
    --danger: #b42318;
    --success: #237a3b;
    --warn: #9a6700;
    --soft: #eef3f2;
    --shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
    font-family: "Segoe UI", Arial, sans-serif;
}

body.theme-dark {
    --bg: #111820;
    --panel: #18222c;
    --ink: #eef4f8;
    --muted: #9fb0bd;
    --line: #2d3b46;
    --accent-ink: #ffffff;
    --danger: #ff6b5f;
    --success: #5bd47b;
    --warn: #f7c948;
    --soft: #20313a;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}

body.theme-vivid-dark {
    --bg: #000000;
    --panel: #05070d;
    --ink: #f4f7ff;
    --muted: #99a5ff;
    --line: #2732ff;
    --accent-ink: #000000;
    --danger: #ff2079;
    --success: #39ff14;
    --warn: #fff200;
    --soft: #090024;
    --shadow: 0 0 22px color-mix(in srgb, var(--accent) 42%, transparent);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    display: grid;
    grid-template-columns: 238px minmax(0, 1fr);
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.sidebar {
    background: #19232b;
    color: #e9eef2;
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 6px 8px 18px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--accent);
    font-weight: 700;
}

.brand small { display: block; color: #aab6bf; margin-top: 2px; }
.nav { display: grid; gap: 4px; }
.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #cbd5dc;
}
.nav a.active, .nav a:hover { background: #26343e; color: #fff; }
.nav svg, .button svg, .icon-button svg, .server-pill svg { width: 18px; height: 18px; }

.sidebar-user {
    margin-top: 18px;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    display: grid;
    gap: 8px;
    color: #dce6ec;
    font-size: 13px;
}

.sidebar-user-summary {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 46px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    min-width: 0;
}

.sidebar-user-summary:hover,
.sidebar-user-summary[aria-expanded="true"] {
    color: #ffffff;
}

.sidebar-user-summary div {
    flex: 1;
    min-width: 0;
}

.sidebar-user-summary svg {
    width: 16px;
    height: 16px;
    color: #aab6bf;
    transition: transform 140ms ease;
}

.sidebar-user-summary[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.sidebar-user-summary strong,
.sidebar-user-summary small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user small {
    color: #aab6bf;
}

.sidebar-account-menu {
    display: grid;
    gap: 3px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.18);
}

.sidebar-account-menu[hidden] {
    display: none;
}

.sidebar-account-menu a,
.sidebar-account-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    width: 100%;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #dce6ec;
    font-weight: 700;
    text-align: left;
}

.sidebar-account-menu a span:nth-child(2),
.sidebar-account-action span {
    flex: 1 1 auto;
}

.notification-badge,
.notification-count-pill {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ef2b2d;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 0 0 2px rgba(239, 43, 45, 0.26), 0 0 14px rgba(239, 43, 45, 0.45);
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
}

.notification-badge.is-empty,
.notification-count-pill.is-empty {
    display: none;
}

.sidebar-notification-badge {
    position: absolute;
    left: 28px;
    top: -4px;
    z-index: 2;
}

.notification-count-pill {
    margin-left: auto;
}

.sidebar-account-menu a:hover,
.sidebar-account-action:hover {
    background: #26343e;
    color: #ffffff;
}

.sidebar-account-action.is-enabled {
    color: #b7f7cb;
}

.sidebar-avatar-form {
    display: grid;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-avatar-file {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 8px;
    border-radius: 7px;
    color: #dce6ec;
    font-weight: 700;
    overflow: hidden;
}

.sidebar-avatar-file:hover {
    background: #26343e;
    color: #ffffff;
}

.sidebar-avatar-file input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.sidebar-avatar-form .button {
    min-height: 34px;
    color: #dce6ec;
    border-color: rgba(255, 255, 255, 0.12);
}

.sidebar-avatar-form .button:hover {
    background: #26343e;
    color: #ffffff;
}

.sidebar-avatar-cropper {
    grid-template-columns: 58px minmax(0, 1fr);
    padding: 8px;
    background: rgba(0, 0, 0, 0.14);
    border-color: rgba(255, 255, 255, 0.12);
}

.sidebar-avatar-cropper canvas {
    width: 58px;
    height: 58px;
}

.sidebar-avatar-cropper label {
    color: #aab6bf;
}

.sidebar-account-menu svg {
    width: 15px;
    height: 15px;
}

.shell {
    min-width: 0;
    padding: 22px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
    margin-bottom: 18px;
}
.topbar h1 { margin: 0; font-size: 28px; line-height: 1.15; }
.topbar p { margin: 4px 0 0; color: var(--muted); }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.top-logo {
    width: 148px;
    height: auto;
    display: block;
}

.server-pill {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    white-space: nowrap;
}

.count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}

.flash-stack { display: grid; gap: 8px; margin-bottom: 14px; }
.flash {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
}
.flash.success { border-color: #9bd3ad; background: #effaf2; color: #1f6b35; }
.flash.error { border-color: #f0a6a0; background: #fff1f0; color: var(--danger); }

.notification-history-panel {
    max-width: 920px;
}

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

.notification-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--panel) 94%, var(--soft));
}

.notification-item.is-unread {
    border-color: #ef2b2d;
    background: color-mix(in srgb, var(--panel) 84%, #ef2b2d 16%);
    box-shadow: inset 3px 0 0 #ef2b2d;
}

.notification-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--soft);
    color: var(--accent);
}

.notification-item.is-unread .notification-icon {
    background: #ef2b2d;
    color: #ffffff;
}

.notification-content {
    min-width: 0;
    display: grid;
    gap: 7px;
}

.notification-content header {
    display: flex;
    gap: 10px;
    align-items: baseline;
    justify-content: space-between;
    min-width: 0;
}

.notification-content strong,
.notification-content p {
    min-width: 0;
    overflow-wrap: anywhere;
}

.notification-content p {
    margin: 0;
    color: var(--muted);
}

.notification-content time {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
}

.notification-content .button {
    justify-self: start;
}

.login-body {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto auto;
    place-items: center;
    align-content: center;
    gap: 18px;
    padding: 18px;
}

.login-logo {
    display: block;
    max-width: min(260px, 72vw);
    max-height: 96px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.login-card {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 22px;
    display: grid;
    gap: 14px;
}

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

.login-brand h1 {
    margin: 0;
    font-size: 24px;
}

.login-brand p {
    margin: 3px 0 0;
    color: var(--muted);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
.toolbar.wrap { flex-wrap: wrap; }
.toolbar.mini { margin-bottom: 0; }
.toolbar-title { padding: 0 8px; min-width: 180px; text-align: center; }

.button, .icon-button {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    min-height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.ghost { background: transparent; }
.button.save-button,
.icon-button.save-button {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    gap: 0;
    background: color-mix(in srgb, var(--panel) 88%, var(--line) 12%);
    border-color: var(--line);
    color: var(--muted);
    box-shadow: none;
    opacity: 0.62;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}
.button.save-button .save-button-label,
.icon-button.save-button .save-button-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.button.save-button.is-dirty,
.icon-button.save-button.is-dirty {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    opacity: 1;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.button.danger { color: var(--danger); }
.button.danger:not(:disabled) {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
    box-shadow: 0 18px 36px rgba(127, 29, 29, 0.36);
    font-weight: 800;
}

.button.danger[data-delete-selected-visit]:not(:disabled) {
    background: #2a0709;
    border-color: #ef4444;
    border-width: 2px;
    color: #ff6b6b;
    box-shadow: 0 0 22px rgba(239, 68, 68, 0.32);
}
.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.icon-button { width: 36px; padding: 0; }
.icon-button.danger { color: var(--danger); }
.icon-button.success { color: var(--success); }
.secret-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px 36px auto;
    gap: 8px;
    align-items: center;
}
.secret-input-row input { min-width: 0; }
.copy-status {
    color: var(--success);
    font-size: 12px;
    font-weight: 700;
    min-width: 48px;
}

.avatar {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 50%;
    object-fit: cover;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

.avatar-sidebar {
    width: 38px;
    height: 38px;
}

.avatar-large {
    width: 58px;
    height: 58px;
    font-size: 20px;
}

.avatar-note {
    width: 34px;
    height: 34px;
    font-size: 13px;
}

.avatar-initials {
    text-transform: uppercase;
}

.two-factor-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-width: 0;
}

body.theme-dark .sidebar {
    background: #0d1319;
}

body.theme-dark .nav a.active,
body.theme-dark .nav a:hover {
    background: #202d38;
}

body.theme-vivid-dark .sidebar {
    background: #000000;
    border-right: 1px solid var(--accent);
    box-shadow: 0 0 28px color-mix(in srgb, var(--accent) 22%, transparent);
}

body.theme-vivid-dark .brand-mark,
body.theme-vivid-dark .button.primary,
body.theme-vivid-dark .calendar-cell.today .day-number {
    box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 60%, transparent);
}

body.theme-vivid-dark .button.save-button:not(.is-dirty),
body.theme-vivid-dark .icon-button.save-button:not(.is-dirty) {
    box-shadow: none;
    background: color-mix(in srgb, var(--panel) 88%, var(--line) 12%);
    border-color: var(--line);
    color: var(--muted);
}

body.theme-vivid-dark .button.save-button.is-dirty,
body.theme-vivid-dark .icon-button.save-button.is-dirty {
    box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 60%, transparent);
}

body.theme-vivid-dark .nav a.active,
body.theme-vivid-dark .nav a:hover {
    background: color-mix(in srgb, var(--accent) 18%, #000000);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 14px;
    align-items: start;
}
.diary-layout { grid-template-columns: minmax(680px, 1fr) 390px; }
.sites-layout { grid-template-columns: 330px minmax(0, 1fr); }
.customers-layout { grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); }

.panel-head, .section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
}
.panel-head h2, .section-title h2 { margin: 0; font-size: 18px; }
.panel-head span { color: var(--muted); }
.section-title-inline {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.inline-filter {
    display: inline-flex;
    align-items: center;
    margin: 0;
}
.section-title .inline-filter .check {
    color: var(--muted);
    font-size: 13px;
}

.column-picker {
    position: relative;
}

.column-picker summary {
    list-style: none;
}

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

.column-picker-menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    left: 0;
    display: grid;
    gap: 2px;
    width: 190px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.column-picker-menu label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    padding: 4px 6px;
    border-radius: 6px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}

.column-picker-menu label:hover {
    background: var(--soft);
}

.column-picker-menu input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.calendar-head, .calendar-grid {
    --calendar-zoom: 1;
    display: grid;
    grid-template-columns: repeat(7, minmax(92px, 1fr));
}
.calendar-head {
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-weight: 600;
}
.calendar-head span { padding: 10px; text-align: center; }
.calendar-cell {
    min-height: calc(126px * var(--calendar-zoom));
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: calc(8px * var(--calendar-zoom));
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: #fff;
}
.calendar-cell:nth-child(7n) { border-right: 0; }
.calendar-cell.muted { background: #f8fafb; color: #9aa4ad; }
.calendar-cell.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.calendar-cell.is-picked {
    background: #e8f2f1;
    box-shadow: inset 0 0 0 2px var(--accent);
}
.calendar-cell.is-drop-target {
    background: #e8f2f1;
    box-shadow: inset 0 0 0 2px var(--accent);
}
.calendar-cell.today .day-number {
    background: var(--accent);
    color: #fff;
}
.day-number {
    width: calc(28px * var(--calendar-zoom));
    height: calc(28px * var(--calendar-zoom));
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-weight: 600;
}
.chip {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: calc(4px * var(--calendar-zoom)) calc(6px * var(--calendar-zoom));
    border-radius: 6px;
    background: #e8f2f1;
    color: #0f5f59;
    font-size: calc(12px * var(--calendar-zoom));
}
.diary-job-chip { cursor: pointer; }
.diary-job-chip.is-selected {
    box-shadow: inset 0 0 0 2px var(--accent);
    border-color: var(--accent);
}
.chip.done { background: #edf0f2; color: #66727c; }
.chip.oncall { background: #fff4d7; color: var(--warn); }
.more { font-size: calc(12px * var(--calendar-zoom)); color: var(--muted); }

.schedule-range-button {
    min-width: 128px;
    justify-content: center;
}

.engineer-schedule {
    margin-top: 14px;
    overflow: auto;
}

.schedule-grid {
    --schedule-zoom: 1;
    --schedule-row-height: 104px;
    display: grid;
    grid-template-columns: 190px repeat(var(--schedule-days), minmax(145px, 1fr));
    min-width: calc(190px + (var(--schedule-days) * 145px));
}

.schedule-grid-day {
    grid-template-columns: 190px minmax(360px, 1fr);
    min-width: 640px;
}

.schedule-grid-day .schedule-cell {
    align-content: stretch;
    grid-auto-rows: minmax(0, 1fr);
    overflow: hidden;
}

.schedule-grid-day .schedule-cell.has-single-visit {
    grid-template-rows: 1fr;
}

.schedule-grid-day .schedule-visit.is-day-line {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.schedule-grid-day .schedule-visit.is-day-line strong {
    flex: 0 1 150px;
    min-width: 0;
}

.schedule-grid-day .schedule-visit.is-day-line span {
    flex: 0 0 auto;
    min-width: 0;
}

.schedule-grid-day .schedule-visit.is-day-line small {
    flex: 1 1 auto;
    min-width: 0;
}

.schedule-grid-day .schedule-visit.is-day-line .schedule-address {
    flex: 1.4 1 0;
}

.schedule-grid-day .schedule-visit.is-day-line .site-link-action {
    flex: 0 1 130px;
    min-width: 0;
    max-width: 130px;
}

.schedule-grid-day .schedule-cell.has-multiple-visits .schedule-visit.is-day-line {
    min-height: 0;
}

.schedule-grid-month {
    grid-template-columns: 170px repeat(var(--schedule-days), minmax(90px, 1fr));
    min-width: calc(170px + (var(--schedule-days) * 90px));
}

.schedule-grid-month .schedule-date {
    padding: 8px 6px;
}

.schedule-grid-month .schedule-engineer {
    padding: 10px;
}

.schedule-grid-month .schedule-cell {
    padding: 5px;
    gap: 4px;
}

.schedule-grid-month .schedule-cell.has-single-visit {
    grid-template-rows: 1fr;
}

.schedule-grid-month .schedule-visit {
    min-height: 44px;
    padding: 4px;
    gap: 1px;
}

.schedule-grid-month .schedule-cell.has-single-visit .schedule-visit {
    height: 100%;
    align-content: center;
}

.schedule-grid-month .schedule-visit strong {
    font-size: 11px;
    line-height: 1.15;
    white-space: nowrap;
    overflow-wrap: anywhere;
}

.schedule-grid-month .schedule-visit small {
    font-size: 10px;
    line-height: 1.15;
    white-space: nowrap;
    display: block;
}

.schedule-grid-month .schedule-cell.has-single-visit .schedule-visit small {
    font-size: 11px;
    line-height: 1.2;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.schedule-corner,
.schedule-date,
.schedule-engineer,
.schedule-cell {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.schedule-corner,
.schedule-date {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafb;
}

.schedule-corner {
    left: 0;
    z-index: 3;
    padding: 12px;
    font-weight: 700;
}

.schedule-date {
    display: grid;
    gap: 2px;
    padding: 10px 12px;
    text-align: center;
    border-top: 0;
    border-left: 0;
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-radius: 0;
    color: inherit;
    cursor: default;
}

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

.schedule-date.today {
    color: var(--accent);
}

.schedule-date.weekend {
    background: #fff6dc;
}

.schedule-date.selected {
    box-shadow: inset 0 -3px 0 var(--accent);
}

.schedule-date.is-picked {
    background: #f8fafb;
    box-shadow: none;
}

.schedule-engineer {
    position: sticky;
    left: 0;
    z-index: 1;
    display: grid;
    align-content: start;
    gap: 3px;
    padding: 12px;
    height: var(--schedule-row-height);
    min-height: var(--schedule-row-height);
    overflow: hidden;
    background: #fff;
    cursor: grab;
}

.schedule-engineer.is-dragging {
    opacity: 0.55;
}

.schedule-engineer.is-drop-target {
    background: #e8f2f1;
    box-shadow: inset 0 0 0 2px var(--accent);
}

.schedule-engineer span {
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-cell {
    height: var(--schedule-row-height);
    min-height: var(--schedule-row-height);
    padding: 7px;
    display: grid;
    align-content: start;
    gap: 6px;
    background: #fff;
    transition: background 120ms ease, box-shadow 120ms ease;
    cursor: pointer;
}

.schedule-cell.weekend {
    background: #fff9e8;
}

.schedule-cell.is-on-call {
    background: #fff1b8;
    box-shadow: inset 0 0 0 2px #d99a00;
}

.schedule-cell.is-date-picked {
    background: #dff2ef;
    box-shadow: inset 0 0 0 2px var(--accent);
}

.schedule-cell.is-on-call.is-date-picked {
    background: #fff1b8;
    box-shadow: inset 0 0 0 2px var(--accent);
}

.schedule-cell.is-drop-target {
    background: #e8f2f1;
    box-shadow: inset 0 0 0 2px var(--accent);
}

.schedule-cell.is-saving {
    opacity: 0.65;
}

.schedule-grid-week .schedule-cell {
    align-content: stretch;
    grid-auto-rows: minmax(0, 1fr);
    overflow: hidden;
}

.schedule-grid-week .schedule-cell.has-single-visit {
    grid-template-rows: 1fr;
}

.schedule-grid-week .schedule-visit {
    min-height: 0;
    height: 100%;
    align-content: center;
    grid-template-rows: auto auto auto;
    gap: 1px;
    padding: 4px 7px;
    overflow: hidden;
}

.schedule-grid-week .schedule-visit strong {
    line-height: 1.15;
}

.schedule-grid-week .schedule-visit span,
.schedule-grid-week .schedule-visit small {
    line-height: 1.15;
}

.schedule-grid-week .schedule-cell.has-single-visit .schedule-visit,
.schedule-grid-week .schedule-cell.has-multiple-visits .schedule-visit {
    height: 100%;
}

.schedule-grid-week .schedule-cell.has-single-visit .schedule-time {
    display: none;
}

.schedule-grid-week .schedule-cell.has-single-visit .schedule-summary,
.schedule-grid-week .schedule-cell.has-single-visit .schedule-address {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.schedule-grid-week .schedule-cell.has-multiple-visits .schedule-visit {
    grid-template-rows: auto minmax(0, 1fr);
    align-content: stretch;
    padding-top: 3px;
    padding-bottom: 3px;
}

.schedule-grid-week .schedule-cell.has-multiple-visits .schedule-address,
.schedule-grid-week .schedule-cell.has-multiple-visits .site-link-action {
    display: none;
}

.schedule-grid-week .schedule-cell.has-multiple-visits .schedule-summary {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.schedule-grid-week .schedule-cell.is-dense-visits {
    gap: 3px;
}

.schedule-grid-week .schedule-cell.is-dense-visits .schedule-visit {
    grid-template-rows: 1fr;
    align-content: center;
    padding: 2px 5px;
    gap: 0;
}

.schedule-grid-week .schedule-cell.is-dense-visits .schedule-visit strong {
    display: block;
    min-height: 14px;
    font-size: 10px;
    line-height: 1.1;
    letter-spacing: 0;
}

.schedule-grid-week .schedule-cell.is-dense-visits .schedule-summary,
.schedule-grid-week .schedule-cell.is-dense-visits .schedule-address,
.schedule-grid-week .schedule-cell.is-dense-visits .schedule-subcategory,
.schedule-grid-week .schedule-cell.is-dense-visits .schedule-time,
.schedule-grid-week .schedule-cell.is-dense-visits .site-link-action {
    display: none;
}

.schedule-visit {
    display: grid;
    gap: 2px;
    padding: 8px 7px;
    border-radius: 7px;
    background: #e8f2f1;
    color: #0f5f59;
    border: 1px solid #c8dfdc;
    cursor: grab;
    touch-action: manipulation;
    user-select: none;
}

.schedule-visit .site-link-action,
.job-tile .site-link-action {
    display: none;
}

.schedule-visit.is-selected .site-link-action,
.job-tile.is-selected .site-link-action {
    display: inline-flex;
}

.site-link-action {
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 24px;
    padding: 0 7px;
    border-radius: 6px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.site-link-action svg {
    width: 13px;
    height: 13px;
}

.schedule-visit.done {
    background: #edf0f2;
    color: #66727c;
    border-color: #d8dee3;
}

.schedule-visit.is-selected {
    border-color: var(--danger) !important;
    outline: 0;
    box-shadow: inset 0 0 0 2px var(--danger) !important;
}

.schedule-grid-week .schedule-cell.is-dense-visits .schedule-visit.is-selected {
    box-shadow: inset 0 0 0 2px var(--danger) !important;
}

.schedule-visit[style*="--tile-bg"],
.job-tile[style*="--tile-bg"] {
    background: var(--tile-bg);
    color: var(--tile-fg);
    border-color: transparent;
    border-width: 3px;
    box-shadow: none;
}

.schedule-visit strong,
.schedule-visit span,
.schedule-visit small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-visit span,
.schedule-visit small {
    font-size: 12px;
    line-height: 1.25;
}

.schedule-visit .schedule-address {
    color: inherit;
    opacity: 0.82;
}

.schedule-visit .schedule-subcategory {
    font-weight: 900;
}

.visit-warning {
    padding: 8px 10px;
    border-radius: 7px;
    background: #fff9e8;
    color: #765100;
    border: 1px solid #efd58d;
    font-size: 12px;
    font-weight: 700;
}

body.is-visit-dragging {
    overscroll-behavior: none;
}

.schedule-empty {
    grid-column: 1 / -1;
}

select.needs-site {
    background: #fff4d7;
    border-color: #d99a00;
    color: #765100;
    font-weight: 700;
}

.job-tray {
    margin-top: 14px;
}

.job-tile-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 0;
}

.job-tile-filters label {
    position: relative;
    flex: 1;
}

.job-tile-filters label svg {
    position: absolute;
    left: 10px;
    top: 50%;
    width: 16px;
    height: 16px;
    color: var(--muted);
    transform: translateY(-50%);
}

.job-tile-filters input {
    width: 100%;
    padding-left: 34px;
}

.job-tile-filters select {
    flex: 1;
    min-width: 150px;
}

.job-tile-sort {
    flex: 0 0 auto;
}

.job-tile-filters span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.job-tile-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
    max-height: 260px;
    overflow: auto;
    padding: 14px;
}

.job-tile {
    display: grid;
    gap: 4px;
    min-height: 86px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: grab;
}

.job-tile:hover {
    border-color: #aac9c5;
    background: #fbfdfd;
}

.job-tile.is-selected {
    border-color: var(--danger) !important;
    background: #e8f2f1;
    outline: 0;
    box-shadow: inset 0 0 0 2px var(--danger) !important;
}

.job-tile strong,
.job-tile span,
.job-tile small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.job-tile span,
.job-tile small {
    color: var(--muted);
    font-size: 12px;
}

.schedule-visit[style*="--tile-bg"] span,
.schedule-visit[style*="--tile-bg"] small,
.job-tile[style*="--tile-bg"] span,
.job-tile[style*="--tile-bg"] small {
    color: var(--tile-muted);
}

.job-tile[style*="--tile-bg"]:hover {
    background: var(--tile-bg);
    border-color: transparent;
    filter: saturate(1.08);
}

.job-tile[style*="--tile-bg"].is-selected {
    background: var(--tile-bg);
    border-color: var(--danger) !important;
    box-shadow: inset 0 0 0 2px var(--danger) !important;
}

.is-dragging {
    opacity: 0.55;
}

.stack { display: grid; gap: 10px; padding: 14px; }
.record {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    display: grid;
    gap: 8px;
}
.diary-job-record { cursor: pointer; }
.diary-job-record.is-selected {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--accent);
}
.record strong, .record span { display: block; }
.record span, .record p { color: var(--muted); }
.record p { margin: 0; }
dl { display: grid; grid-template-columns: 90px 1fr; gap: 4px 8px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

.table-panel { overflow: auto; }
.table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}
.table-scroll .data-table {
    margin: 0;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}
.data-table.compact { min-width: 680px; }
.data-table th {
    text-align: left;
    color: #4b5563;
    font-size: 13px;
    background: #f8fafb;
    border-bottom: 1px solid var(--line);
    padding: 10px;
    position: sticky;
    top: 0;
}
.data-table .select-col {
    width: 42px;
    text-align: center;
}
.data-table .select-col input {
    width: auto;
}
a[x-apple-data-detectors],
.chip a[x-apple-data-detectors],
.schedule-visit a[x-apple-data-detectors],
.job-tile a[x-apple-data-detectors] {
    color: inherit !important;
    text-decoration: none !important;
    pointer-events: none;
}
.data-table td {
    border-bottom: 1px solid var(--line);
    padding: 8px 10px;
    vertical-align: middle;
}
.data-table tr:hover td { background: #fbfcfd; }
.data-table tr.is-selected td {
    background: #dff2ef;
    box-shadow: inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent);
}
.jobs-table tr.is-selected td,
.jobs-table tr.is-selected:hover td {
    background: #3a0c12;
    color: #fff4f4;
    box-shadow: inset 0 2px 0 #ff2a2a, inset 0 -2px 0 #ff2a2a;
}
.jobs-table tr.is-selected td:first-child {
    box-shadow: inset 2px 0 0 #ff2a2a, inset 0 2px 0 #ff2a2a, inset 0 -2px 0 #ff2a2a;
}
.jobs-table tr.is-selected td:last-child {
    box-shadow: inset -2px 0 0 #ff2a2a, inset 0 2px 0 #ff2a2a, inset 0 -2px 0 #ff2a2a;
}
.jobs-table tr.is-selected select {
    border-color: #ff4d4d;
    background: #17080a;
    color: #fff4f4;
}
.jobs-table tr.is-selected .icon-button {
    border-color: rgba(255, 77, 77, 0.7);
}
.data-table .is-muted td { color: #87919a; background: #fafafa; }
.jobs-table tr.is-muted.is-selected td,
.jobs-table tr.is-muted.is-selected:hover td {
    background: #3a0c12;
    color: #fff4f4;
}
.actions, .inline-form {
    display: flex;
    gap: 6px;
    align-items: center;
}
.actions form, .inline-form { margin: 0; }

.data-table td.actions {
    display: table-cell;
    min-width: 154px;
    white-space: nowrap;
}

.data-table td.actions > form,
.data-table td.actions > a,
.data-table td.actions > button {
    display: inline-flex;
    margin: 0 4px 0 0;
    vertical-align: middle;
}

.data-table td.actions > :last-child {
    margin-right: 0;
}

.job-site-cell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    gap: 6px;
    align-items: center;
}

.job-site-cell span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.needs-site-label {
    color: var(--danger);
    font-weight: 700;
}

.ip-actions {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    min-width: max-content;
    max-width: none;
    white-space: nowrap;
    vertical-align: middle;
}

.ip-actions .ip-link {
    display: inline-block;
    width: 108px;
    min-width: 108px;
    max-width: 108px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ip-actions .ip-link,
.ip-actions .ping-button,
.ip-actions .ping-status {
    flex: 0 0 auto;
}

.controllers-table {
    min-width: 1120px;
}

.controllers-table-standard {
    min-width: 880px;
}

.controllers-table-iq {
    min-width: 1240px;
}

.controllers-table.has-hidden-columns {
    min-width: max-content;
}

.controller-group-stack {
    display: grid;
    gap: 14px;
}

.controller-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--panel);
}

.controller-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--soft);
}

.controller-group-head h3 {
    margin: 0;
    font-size: 15px;
}

.controller-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.controller-group-title span {
    color: var(--muted);
    font-weight: 800;
}

.controller-group-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.controller-group-actions .button {
    min-height: 32px;
    padding: 0 10px;
}

.auto-ping-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.auto-ping-toggle input {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
}

.auto-ping-toggle.is-checked {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 36%, transparent);
}

.controller-group-actions .controller-cancel-button:not([hidden]) {
    border-color: var(--danger);
    color: var(--danger);
}

.controller-group-actions .lookup-status {
    min-width: 118px;
    text-align: right;
    white-space: nowrap;
}

.controller-security-form {
    display: grid;
    grid-template-columns: 68px 74px 96px 34px;
    gap: 6px;
    align-items: end;
    min-width: 286px;
}

.controller-security-form label {
    display: grid;
    gap: 2px;
}

.controller-security-form span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.1;
}

.controller-security-form input,
.controller-security-form select {
    min-height: 34px;
    padding: 5px 7px;
    font-size: 12px;
}

.controller-security-form label.is-disabled {
    opacity: .5;
}

.controller-security-form input:disabled,
.controller-security-form select:disabled {
    cursor: not-allowed;
    background: color-mix(in srgb, var(--panel) 74%, #8b96a5);
    color: var(--muted);
    border-color: color-mix(in srgb, var(--line) 78%, #8b96a5);
}

.controller-security-form .icon-button {
    width: 34px;
    height: 34px;
    min-height: 34px;
}

.controller-more-settings-form {
    display: block;
    min-width: 0;
}

.controller-more-settings-form .controller-info-grid {
    max-width: 520px;
    grid-template-columns: minmax(0, 1fr) 36px;
    align-items: end;
}

@keyframes controller-cell-red-flash {
    0% {
        background: color-mix(in srgb, var(--danger) 50%, transparent);
        box-shadow: inset 0 0 0 2px var(--danger);
    }
    100% {
        background: transparent;
        box-shadow: inset 0 0 0 0 transparent;
    }
}

.controller-field-flash {
    animation: controller-cell-red-flash 900ms ease;
}

.controller-more-settings-form label {
    min-width: 0;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.controller-more-settings-form label input {
    width: 100%;
    min-height: 32px;
}

.controller-more-settings-form .controller-info-grid > div,
.controller-more-settings-form .controller-info-grid > label {
    grid-column: 1;
}

.controller-more-settings-form .controller-info-grid > .controller-more-send-supervisor {
    grid-column: 2;
    grid-row: 2;
}

.controller-more-settings-form .controller-info-grid > .controller-more-send-access {
    grid-column: 2;
    grid-row: 3;
}

.sip-summary-row {
    background: color-mix(in srgb, var(--panel) 92%, var(--soft) 8%);
}

.sip-group-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    color: var(--ink);
    font-size: 12px;
    font-weight: 800;
}

.sip-group-toggle svg {
    width: 15px;
    height: 15px;
    transition: transform 140ms ease;
}

.sip-group-toggle.is-open svg {
    transform: rotate(90deg);
}

.sip-detail-row > td {
    padding: 0;
    background: color-mix(in srgb, var(--panel) 86%, var(--soft) 14%);
}

.sip-detail-panel {
    display: grid;
    gap: 0;
    padding: 10px 14px 12px;
    border-top: 1px solid var(--line);
}

.sip-detail-grid {
    display: grid;
    grid-template-columns: 72px 72px minmax(220px, 1fr) 44px;
    gap: 10px;
    align-items: center;
    min-width: 0;
    padding: 7px 8px;
}

.sip-detail-head {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}

.sip-detail-item {
    border-top: 1px solid var(--line);
}

.sip-detail-item strong,
.sip-detail-item span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.controller-more-row > td {
    padding: 0;
    background: color-mix(in srgb, var(--panel) 88%, var(--soft) 12%);
}

.controller-credentials-row > td {
    padding: 0;
    background: color-mix(in srgb, var(--panel) 90%, var(--soft) 10%);
}

.controller-credential-form {
    display: grid;
    grid-template-columns: minmax(160px, 0.8fr) minmax(150px, 1fr) minmax(170px, 1fr) 36px;
    gap: 10px;
    align-items: end;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
}

.controller-credential-form label {
    display: grid;
    gap: 5px;
    min-width: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.controller-credential-form .check {
    align-self: center;
    display: flex;
    align-items: center;
    text-transform: none;
    font-size: 12px;
}

.controller-credential-form input:not([type="checkbox"]) {
    min-height: 34px;
    font-size: 12px;
}

.customer-device-credentials {
    display: grid;
    gap: 8px;
    padding: 12px;
}

.credential-settings-row {
    display: grid;
    grid-template-columns: minmax(160px, 0.9fr) minmax(150px, 1fr) minmax(170px, 1fr) 36px;
    gap: 10px;
    align-items: end;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.credential-settings-row strong {
    align-self: center;
    min-width: 0;
}

.credential-settings-row label {
    display: grid;
    gap: 5px;
    min-width: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.controller-more-panel {
    display: grid;
    gap: 14px;
    padding: 14px;
    border-top: 1px solid var(--line);
}

.controller-more-section {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.controller-more-section h4 {
    margin: 0;
    font-size: 14px;
}

.controller-info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(130px, 1fr));
    gap: 8px;
}

.controller-info-grid div {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.controller-info-grid span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.controller-info-grid strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.icon-button[aria-expanded="true"][data-controller-more-toggle] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.controller-vcnc-panel {
    display: grid;
    gap: 8px;
    min-width: 520px;
}

.controller-vcnc-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.controller-vcnc-toolbar .button {
    min-height: 30px;
    padding: 0 9px;
}

.controller-vcnc-list {
    display: grid;
    gap: 4px;
}

.controller-vcnc-grid-head,
.controller-vcnc-form {
    display: grid;
    grid-template-columns: 42px minmax(120px, 1.35fr) 72px 82px minmax(88px, 1fr) minmax(92px, 1fr) 34px;
    gap: 5px;
    align-items: center;
}

.controller-vcnc-grid-head {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.controller-vcnc-form {
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--soft);
}

.controller-vcnc-form strong,
.controller-vcnc-form span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.controller-vcnc-form input {
    min-height: 32px;
    padding: 5px 7px;
    font-size: 12px;
}

.controller-vcnc-form .icon-button {
    width: 32px;
    height: 32px;
    min-height: 32px;
}

.empty.mini {
    padding: 8px;
    font-size: 12px;
}
.ip-link {
    color: var(--accent);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ping-button.is-online {
    color: var(--success);
    border-color: #9bd3ad;
    background: #effaf2;
}
.ping-button.is-offline {
    color: var(--danger);
    border-color: #f0a6a0;
    background: #fff1f0;
}
.ping-status {
    display: inline-flex;
    align-items: center;
    min-width: 58px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}
.ping-status.is-online { color: var(--success); }
.ping-status.is-offline { color: var(--danger); }
.ping-status.is-pending { color: var(--warn); }

.status-pill {
    width: fit-content;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.status-pill.success {
    border-color: #9bd3ad;
    background: #effaf2;
    color: #1f6b35;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 9px;
    background: #fff;
    color: var(--ink);
}
textarea { resize: vertical; }
label { display: grid; gap: 5px; color: #3d4650; font-size: 13px; font-weight: 600; }
.check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    white-space: nowrap;
}
.check input { width: auto; }

.toolbar-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.toolbar-check {
    min-height: 40px;
    padding: 0 4px;
}

.search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 8px;
    min-height: 40px;
}
.search input {
    border: 0;
    min-width: 240px;
    padding-left: 0;
}
.upload {
    display: flex;
    gap: 8px;
    align-items: center;
}

.empty {
    color: var(--muted);
    text-align: center;
    padding: 22px;
}

.list-panel {
    overflow: hidden;
}
.list-row {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
}
.list-row.active, .list-row:hover { background: var(--soft); }
.list-row span, .list-row small { color: var(--muted); }

.detail-form {
    padding: 14px;
    display: grid;
    gap: 12px;
}
.detail-form .panel-head { padding: 0 0 12px; }
.fields-2, .fields-3 {
    display: grid;
    gap: 10px;
}
.fields-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section-title { margin-top: 12px; }

.site-server-action {
    display: flex;
    align-items: flex-end;
    min-width: 0;
}

.site-server-action .button {
    width: 100%;
    justify-content: center;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 14px;
}

.info-grid div,
.info-grid .info-link {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    min-width: 0;
    background: #fff;
}

.info-grid .info-link {
    color: inherit;
}

.info-grid .info-link:hover {
    border-color: var(--accent);
    background: #e8f2f1;
}

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

.info-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.info-grid strong {
    display: block;
    font-weight: 600;
    overflow-wrap: anywhere;
}

dialog {
    border: 0;
    border-radius: 8px;
    padding: 0;
    width: min(640px, calc(100vw - 32px));
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

#visit-dialog,
#bulk-job-dialog {
    width: min(720px, calc(100vw - 20px));
}

dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.dialog-form {
    display: grid;
    gap: 12px;
    padding: 16px;
    min-width: 0;
}
.dialog-form header, .dialog-form footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.dialog-form h2 { margin: 0; }
.dialog-form footer { justify-content: flex-end; }
.dialog-form label,
.dialog-form input,
.dialog-form select,
.dialog-form textarea {
    width: 100%;
    min-width: 0;
}

#visit-dialog .dialog-form input,
#visit-dialog .dialog-form select,
#visit-dialog .dialog-form textarea,
#bulk-job-dialog .dialog-form input,
#bulk-job-dialog .dialog-form select,
#bulk-job-dialog .dialog-form textarea {
    border-radius: 8px;
}

.job-picker {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.job-picker small {
    color: var(--danger);
    font-size: 12px;
    font-weight: 800;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.form-grid .full {
    grid-column: 1 / -1;
}

.job-notes-panel form {
    display: grid;
    gap: 12px;
}

.job-notes-panel {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}

.job-notes-list {
    display: grid;
    gap: 12px;
    padding: 0 14px 14px;
}

.job-note {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
}

.job-note-body {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.job-note-body header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.job-note-body time {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.job-note-body p {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.job-note-replies {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.job-note-reply .job-note-body {
    background: var(--soft);
}

.job-note-reply-box {
    margin-top: 10px;
}

.job-note-reply-box summary {
    width: fit-content;
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
}

.job-note-reply-box form {
    margin-top: 10px;
}

.segmented {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
}
.segmented label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 700;
    cursor: pointer;
}
.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.segmented label:has(input:checked) {
    background: var(--accent);
    color: #fff;
}

.lookup-action {
    display: grid;
    align-content: end;
    gap: 6px;
}
.lookup-status {
    min-height: 18px;
    color: var(--muted);
    font-size: 12px;
}
.lookup-status.is-online { color: var(--success); }
.lookup-status.is-offline { color: var(--danger); }
.lookup-status.is-pending { color: var(--warn); }

.customer-detail {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.customer-detail .panel {
    min-width: 0;
    overflow: hidden;
}

.customer-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 10px;
    padding: 14px;
}

.customer-stats div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfcfd;
}

.customer-stats span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.customer-stats strong {
    display: block;
    font-size: 21px;
    overflow-wrap: anywhere;
}

.customer-table-scroll {
    max-width: 100%;
}

.customer-table {
    table-layout: fixed;
    min-width: 0;
}

.customer-table th,
.customer-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.customer-table th:nth-child(1),
.customer-table td:nth-child(1) {
    width: 118px;
}

.customer-table th:nth-child(3),
.customer-table td:nth-child(3) {
    width: 22%;
}

.customer-table th:last-child,
.customer-table td:last-child {
    width: 118px;
}

.customer-jobs-table th:nth-child(1),
.customer-jobs-table td:nth-child(1) {
    width: 112px;
}

.customer-jobs-table th:nth-child(2),
.customer-jobs-table td:nth-child(2) {
    width: auto;
}

.customer-jobs-table th:nth-child(3),
.customer-jobs-table td:nth-child(3) {
    width: 76px;
}

.customer-jobs-table th:nth-child(4),
.customer-jobs-table td:nth-child(4),
.customer-jobs-table th:nth-child(5),
.customer-jobs-table td:nth-child(5),
.customer-jobs-table th:nth-child(6),
.customer-jobs-table td:nth-child(6) {
    width: 92px;
}

.customer-jobs-table .job-number-col { width: 112px; }
.customer-jobs-table .job-name-col { width: auto; }
.customer-jobs-table .job-status-col { width: 76px; }
.customer-jobs-table .money-col { width: 92px; }

.customer-settings {
    display: grid;
}

.customer-colour-panel {
    overflow: hidden;
}

.collapsible-panel summary {
    cursor: pointer;
    list-style: none;
}

.collapsible-panel summary::-webkit-details-marker {
    display: none;
}

.collapsible-panel summary::after {
    content: "Show";
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.collapsible-panel[open] summary::after {
    content: "Hide";
}

.region-sub-settings {
    border-top: 1px solid var(--line);
}

.region-sub-settings .section-title {
    border-bottom: 0;
}

.region-sub-settings[open] .section-title {
    border-bottom: 1px solid var(--line);
}

.colour-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 14px;
}

.colour-presets.compact {
    padding: 0;
    gap: 6px;
}

.colour-preset,
.custom-colour {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.colour-preset input,
.custom-colour input[type="radio"] {
    margin: 0;
}

.colour-swatch {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 2px solid color-mix(in srgb, var(--swatch, var(--line)) 70%, #000000 30%);
    background: var(--swatch);
}

.colour-swatch.is-default {
    background: linear-gradient(135deg, #ffffff 0 46%, #d9e0e6 46% 54%, #ffffff 54% 100%);
}

.custom-colour input[type="color"] {
    width: 34px;
    min-height: 28px;
    padding: 2px;
}

.region-colour-list {
    display: grid;
    gap: 0;
}

.region-colour-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) 80px minmax(260px, 2fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
}

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

.region-colour-row > span {
    color: var(--muted);
    font-size: 12px;
}

.invoice-scheduled-panel {
    margin-bottom: 14px;
}

.rate-settings {
    display: grid;
    min-width: 0;
}

.job-rates-panel {
    margin-bottom: 14px;
    overflow: hidden;
}

.job-rates-panel > summary.section-title {
    margin-top: 0;
    cursor: pointer;
}

.job-rates-panel[open] > summary.section-title {
    border-bottom: 1px solid var(--line);
}

.rate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 10px;
    padding: 14px;
    min-width: 0;
}

.rate-grid label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    min-width: 0;
}

.rate-grid small {
    color: var(--muted);
    font-weight: 600;
}

.rate-grid input:disabled {
    background: #edf0f2;
    color: #7b8790;
    cursor: not-allowed;
}

.rate-mode {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 14px 14px 0;
    min-width: 0;
}

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

.rate-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0 14px 14px;
}

.reports-panel {
    margin: 0 0 14px;
}

.job-subsettings-panel {
    margin: 0 0 14px;
}

.job-subsetting-add,
.job-visit-category-list form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
    padding: 14px;
}

.job-subsetting-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 14px 14px;
}

.job-subsetting-list form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 4px 5px 4px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
    font-weight: 800;
}

.job-visit-category-list {
    display: grid;
    gap: 8px;
    border-top: 1px solid var(--line);
}

.job-visit-category-list form {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 260px) 34px;
    padding-block: 10px;
}

.job-visit-category-list strong,
.job-visit-category-list span {
    display: block;
    overflow-wrap: anywhere;
}

.job-visit-category-list span {
    color: var(--muted);
    font-size: 12px;
}

.report-template-panel {
    margin: 0 0 14px;
}

.report-template-summary,
.report-upload-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 260px) auto;
    gap: 12px;
    align-items: end;
    padding: 14px;
}

.report-template-summary div {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.report-template-summary span {
    color: var(--muted);
    font-size: 12px;
}

.report-template-summary strong {
    overflow-wrap: anywhere;
}

.visit-subcategory-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    gap: 8px;
    align-items: end;
}

.report-upload-form {
    grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) auto;
    border-bottom: 1px solid var(--line);
}

.mobile-report-list {
    display: none;
}

.invoice-rate-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 10px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
}

.invoice-rate-summary div {
    display: grid;
    gap: 5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.invoice-rate-summary span,
.invoice-rate-summary small {
    color: var(--muted);
    font-size: 12px;
}

.invoice-rate-summary strong {
    font-weight: 700;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea,
body.theme-vivid-dark input,
body.theme-vivid-dark select,
body.theme-vivid-dark textarea {
    background: #0f1720;
    color: var(--ink);
    border-color: var(--line);
}

body.theme-vivid-dark input,
body.theme-vivid-dark select,
body.theme-vivid-dark textarea {
    background: #02030a;
}

body.theme-dark .calendar-cell,
body.theme-dark .schedule-engineer,
body.theme-dark .schedule-cell,
body.theme-dark .job-tile,
body.theme-dark .info-grid div,
body.theme-dark .info-grid .info-link,
body.theme-dark .job-note-body,
body.theme-dark .customer-stats div,
body.theme-vivid-dark .calendar-cell,
body.theme-vivid-dark .schedule-engineer,
body.theme-vivid-dark .schedule-cell,
body.theme-vivid-dark .job-tile,
body.theme-vivid-dark .info-grid div,
body.theme-vivid-dark .info-grid .info-link,
body.theme-vivid-dark .job-note-body,
body.theme-vivid-dark .customer-stats div {
    background: var(--panel);
}

body.theme-dark .calendar-head,
body.theme-dark .schedule-corner,
body.theme-dark .schedule-date,
body.theme-dark .data-table th,
body.theme-vivid-dark .calendar-head,
body.theme-vivid-dark .schedule-corner,
body.theme-vivid-dark .schedule-date,
body.theme-vivid-dark .data-table th {
    background: color-mix(in srgb, var(--panel) 88%, var(--accent) 12%);
}

body.theme-dark .data-table tr:hover td,
body.theme-vivid-dark .data-table tr:hover td {
    background: color-mix(in srgb, var(--panel) 84%, var(--accent) 16%);
}

@media (max-width: 1320px) {
    .customers-layout {
        grid-template-columns: minmax(180px, 250px) minmax(0, 1fr);
        gap: 10px;
    }

    .customers-layout .list-row {
        padding: 10px 12px;
        gap: 3px;
    }

    .customers-layout .list-row strong {
        font-size: 13px;
    }

    .customers-layout .list-row span,
    .customers-layout .list-row small {
        font-size: 12.5px;
    }

    .customer-detail {
        gap: 10px;
    }

    .customer-detail .panel-head,
    .customer-detail .section-title {
        padding: 10px 12px;
    }

    .customer-detail .panel-head h2,
    .customer-detail .section-title h2 {
        font-size: 15px;
    }

    .customer-stats {
        grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
        gap: 7px;
        padding: 10px;
    }

    .customer-stats div {
        padding: 8px;
        border-radius: 6px;
    }

    .customer-stats span {
        font-size: 11px;
        margin-bottom: 3px;
    }

    .customer-stats strong {
        font-size: 18px;
    }

    .customer-table th,
    .customer-table td {
        padding: 7px 8px;
        font-size: 13px;
    }

    .customer-table th:nth-child(1),
    .customer-table td:nth-child(1) {
        width: 92px;
    }

    .customer-table th:last-child,
    .customer-table td:last-child {
        width: 96px;
    }

    .customer-jobs-table th:nth-child(1),
    .customer-jobs-table td:nth-child(1) {
        width: 104px;
    }

    .customer-jobs-table th:nth-child(2),
    .customer-jobs-table td:nth-child(2) {
        width: auto;
    }

    .customer-jobs-table th:nth-child(3),
    .customer-jobs-table td:nth-child(3) {
        width: 64px;
    }

    .customer-jobs-table th:nth-child(4),
    .customer-jobs-table td:nth-child(4),
    .customer-jobs-table th:nth-child(5),
    .customer-jobs-table td:nth-child(5),
    .customer-jobs-table th:nth-child(6),
    .customer-jobs-table td:nth-child(6) {
        width: 84px;
    }

    .customer-jobs-table .job-number-col { width: 104px; }
    .customer-jobs-table .job-status-col { width: 64px; }
    .customer-jobs-table .money-col { width: 84px; }

    .rate-grid,
    .colour-presets {
        padding: 10px;
        gap: 8px;
    }
}

body.theme-dark .schedule-date.weekend,
body.theme-vivid-dark .schedule-date.weekend {
    background: #4a321d;
}

body.theme-dark .schedule-cell.weekend,
body.theme-vivid-dark .schedule-cell.weekend {
    background: #2f281f;
}

body.theme-dark .schedule-cell.weekend.is-on-call,
body.theme-vivid-dark .schedule-cell.weekend.is-on-call {
    background: #4a321d;
}

body.theme-dark .schedule-cell.is-on-call.is-date-picked,
body.theme-vivid-dark .schedule-cell.is-on-call.is-date-picked {
    background: var(--panel);
    box-shadow: inset 0 0 0 2px var(--accent);
}

body.theme-dark .schedule-cell.weekend.is-on-call.is-date-picked,
body.theme-vivid-dark .schedule-cell.weekend.is-on-call.is-date-picked {
    background: #4a321d;
    box-shadow: inset 0 0 0 2px var(--accent);
}

body.theme-dark .schedule-visit[style*="--tile-bg"],
body.theme-dark .job-tile[style*="--tile-bg"],
body.theme-vivid-dark .schedule-visit[style*="--tile-bg"],
body.theme-vivid-dark .job-tile[style*="--tile-bg"] {
    background: var(--tile-bg);
    color: var(--tile-fg);
    border-color: transparent;
    border-width: 3px;
    box-shadow: none;
}

body.theme-vivid-dark .schedule-visit[style*="--tile-bg"],
body.theme-vivid-dark .job-tile[style*="--tile-bg"] {
    background: var(--tile-neon-bg);
    color: var(--tile-neon-fg);
    border-color: transparent;
    box-shadow: none;
}

body.theme-dark .schedule-visit[style*="--tile-bg"] span,
body.theme-dark .schedule-visit[style*="--tile-bg"] small,
body.theme-dark .job-tile[style*="--tile-bg"] span,
body.theme-dark .job-tile[style*="--tile-bg"] small,
body.theme-vivid-dark .schedule-visit[style*="--tile-bg"] span,
body.theme-vivid-dark .schedule-visit[style*="--tile-bg"] small,
body.theme-vivid-dark .job-tile[style*="--tile-bg"] span,
body.theme-vivid-dark .job-tile[style*="--tile-bg"] small {
    color: var(--tile-muted);
}

body.theme-vivid-dark .schedule-visit[style*="--tile-bg"] span,
body.theme-vivid-dark .schedule-visit[style*="--tile-bg"] small,
body.theme-vivid-dark .job-tile[style*="--tile-bg"] span,
body.theme-vivid-dark .job-tile[style*="--tile-bg"] small {
    color: var(--tile-neon-muted);
}

.schedule-visit[style*="--tile-bg"].is-selected,
.job-tile[style*="--tile-bg"].is-selected,
body.theme-dark .schedule-visit[style*="--tile-bg"].is-selected,
body.theme-dark .job-tile[style*="--tile-bg"].is-selected,
body.theme-vivid-dark .schedule-visit[style*="--tile-bg"].is-selected,
body.theme-vivid-dark .job-tile[style*="--tile-bg"].is-selected {
    border-color: var(--danger) !important;
    outline: 0;
    box-shadow: inset 0 0 0 2px var(--danger) !important;
}

body.theme-vivid-dark .panel,
body.theme-vivid-dark dialog,
body.theme-vivid-dark .server-pill {
    border-color: var(--accent);
}

body.theme-vivid-dark .button,
body.theme-vivid-dark .icon-button {
    border-color: #3541ff;
    background: #02030a;
    color: var(--ink);
}

body.theme-vivid-dark .button.primary {
    color: var(--accent-ink);
    background: var(--accent);
    border-color: var(--accent);
}

body.theme-dark .button.save-button.is-dirty,
body.theme-dark .icon-button.save-button.is-dirty,
body.theme-vivid-dark .button.save-button.is-dirty,
body.theme-vivid-dark .icon-button.save-button.is-dirty {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    opacity: 1;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

body.theme-dark .button.danger:not(:disabled),
body.theme-vivid-dark .button.danger:not(:disabled) {
    background: #2a0709;
    color: #ff6b6b;
    box-shadow: 0 0 22px rgba(239, 68, 68, 0.32);
}

.button.danger[data-delete-selected-visit]:not(:disabled),
body.theme-dark .button.danger[data-delete-selected-visit]:not(:disabled),
body.theme-vivid-dark .button.danger[data-delete-selected-visit]:not(:disabled) {
    min-height: 48px;
    padding: 0 16px;
    gap: 9px;
    border: 2px solid #ef4444;
    border-radius: 8px;
    background: #2a0709;
    color: #ff6b6b;
    font-weight: 800;
    box-shadow: 0 0 22px rgba(239, 68, 68, 0.32);
}

.button.danger[data-delete-selected-visit]:not(:disabled) span,
.button.danger[data-delete-selected-visit]:not(:disabled) svg,
body.theme-dark .button.danger[data-delete-selected-visit]:not(:disabled) span,
body.theme-dark .button.danger[data-delete-selected-visit]:not(:disabled) svg,
body.theme-vivid-dark .button.danger[data-delete-selected-visit]:not(:disabled) span,
body.theme-vivid-dark .button.danger[data-delete-selected-visit]:not(:disabled) svg {
    color: #ff6b6b;
    stroke: #ff6b6b;
}

.settings-layout {
    max-width: 980px;
    display: grid;
    gap: 14px;
}

.users-layout {
    max-width: 1180px;
}

.settings-panel {
    overflow: hidden;
}

.settings-section {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.settings-section h3 {
    margin: 0;
    font-size: 16px;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
}

.inline-check input,
.access-days input,
.permission-grid input {
    width: auto;
}

.access-days,
.permission-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.access-days label,
.permission-grid label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
    font-weight: 700;
    font-size: 13px;
}

.permission-row {
    align-items: start;
}

.user-list {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.user-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--panel);
}

.user-summary-row {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto 24px;
    gap: 12px;
    align-items: center;
    padding: 12px;
    cursor: pointer;
    list-style: none;
}

.user-summary-row::-webkit-details-marker {
    display: none;
}

.user-summary-row:hover {
    background: var(--soft);
}

.user-summary-row > svg {
    width: 18px;
    height: 18px;
    color: var(--muted);
    transition: transform 140ms ease;
}

.user-card[open] .user-summary-row > svg {
    transform: rotate(180deg);
}

.user-summary-avatar {
    display: inline-flex;
}

.user-summary-main {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.user-summary-main strong,
.user-summary-main small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-summary-main small {
    color: var(--muted);
    font-weight: 700;
}

.user-summary-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.user-settings-panel {
    border-top: 1px solid var(--line);
}

.user-avatar-row {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
    padding: 12px;
    border-bottom: 1px solid var(--line);
}

.avatar-upload-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
}

.avatar-cropper {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 82px minmax(160px, 1fr);
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
}

.avatar-cropper[hidden] {
    display: none;
}

.avatar-cropper canvas {
    width: 82px;
    height: 82px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--panel);
    object-fit: cover;
}

.avatar-cropper label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.avatar-cropper input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.panel-head.compact {
    padding: 10px 12px;
}

.panel-head.compact h3 {
    margin: 0;
}

.reset-password-row {
    border-top: 1px solid var(--line);
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: end;
}

.reset-password-action {
    border-top: 1px solid var(--line);
    justify-items: start;
}

.muted-text {
    margin: 0;
    color: var(--muted);
}

.audit-table td {
    overflow-wrap: anywhere;
}

.theme-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.theme-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    display: grid;
    gap: 8px;
    cursor: pointer;
    background: var(--panel);
}

.theme-card input {
    width: auto;
}

.theme-preview {
    height: 72px;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.theme-preview-light {
    background: linear-gradient(135deg, #f5f7f8 0 50%, #ffffff 50%);
}

.theme-preview-dark {
    background: linear-gradient(135deg, #111820 0 50%, #18222c 50%);
}

.theme-preview-vivid {
    background:
        linear-gradient(135deg, #000000 0 50%, #05070d 50%),
        radial-gradient(circle at 70% 30%, #39ff14, transparent 35%);
    box-shadow: inset 0 0 0 2px #39ff14, 0 0 14px rgba(57, 255, 20, 0.45);
}

.swatch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.swatch-choice {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: var(--panel);
    cursor: pointer;
}

.swatch-choice input {
    width: auto;
}

.swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--swatch);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.logo-preview-row {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
    align-items: center;
}

.settings-logo-preview {
    max-width: 220px;
    max-height: 90px;
    width: auto;
    height: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.logo-upload-form {
    display: grid;
    gap: 10px;
    justify-items: start;
}

.selected-date-list {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafb;
    color: var(--muted);
    font-size: 13px;
}

.bulk-section {
    display: grid;
    gap: 12px;
}

.is-hidden {
    display: none !important;
}

@media (max-width: 980px) {
    body { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        display: flex;
        align-items: center;
        gap: 12px;
        overflow: auto;
    }
    .brand {
        padding: 0;
        order: 4;
        margin-left: auto;
    }
    .sidebar-user {
        order: 1;
        margin-top: 0;
        padding: 0;
        border-top: 0;
        min-width: 46px;
        position: relative;
    }
    .sidebar-user-summary {
        justify-content: flex-start;
        width: auto;
    }
    .sidebar-user-summary div {
        display: none;
    }
    .sidebar-account-menu {
        position: absolute;
        top: calc(100% + 8px);
        left: 0;
        z-index: 20;
        width: min(280px, calc(100vw - 28px));
        box-shadow: 0 18px 42px rgba(0, 0, 0, 0.3);
    }
    .nav { display: flex; }
    .sidebar .nav { order: 2; }
    .nav a { white-space: nowrap; }
    .split, .diary-layout, .sites-layout, .customers-layout { grid-template-columns: 1fr; }
    .customers-layout .list-panel {
        max-height: 260px;
        overflow: auto;
    }
    .customer-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-grid { grid-template-columns: 1fr; }
    .logo-preview-row { grid-template-columns: 1fr; }
    .calendar-head, .calendar-grid { grid-template-columns: repeat(7, minmax(78px, 1fr)); }
    .calendar-cell { min-height: calc(104px * var(--calendar-zoom)); }
    .fields-2, .fields-3, .form-grid, .two-factor-actions, .user-avatar-row, .avatar-upload-form { grid-template-columns: 1fr; }
    .user-summary-row { grid-template-columns: 46px minmax(0, 1fr) 24px; }
    .user-summary-row .avatar-large { width: 46px; height: 46px; }
    .user-summary-meta { grid-column: 2 / -1; justify-content: flex-start; }
    .topbar { flex-direction: column; }
    .topbar-right { width: 100%; justify-content: space-between; }
    .top-logo { width: 118px; }
    .notification-content header {
        display: grid;
        gap: 3px;
    }
    .notification-content time {
        justify-self: start;
    }
}

@media (max-width: 640px) {
    dialog {
        width: calc(100vw - 8px);
        max-width: calc(100vw - 8px);
        max-height: calc(100svh - 12px);
        overflow: hidden;
    }

    #visit-dialog,
    #bulk-job-dialog {
        width: calc(100vw - 8px);
        max-width: calc(100vw - 8px);
    }

    #visit-dialog {
        width: calc(100vw - 2px);
        max-width: calc(100vw - 2px);
    }

    #bulk-job-dialog {
        width: calc(100vw - 2px);
        max-width: calc(100vw - 2px);
    }

    .dialog-form {
        max-height: calc(100svh - 12px);
        overflow-y: auto;
        gap: 9px;
        padding: 10px;
    }

    #visit-dialog .dialog-form {
        gap: 7px;
        padding: 8px;
    }

    #bulk-job-dialog .dialog-form {
        gap: 7px;
        padding: 8px;
    }

    .dialog-form header {
        gap: 8px;
    }

    .dialog-form header h2 {
        min-width: 0;
        font-size: 18px;
    }

    .dialog-form footer {
        position: sticky;
        bottom: -10px;
        margin: 0 -10px -10px;
        padding: 10px;
        border-top: 1px solid var(--line);
        background: var(--panel);
    }

    .dialog-form footer .button {
        width: 100%;
        justify-content: center;
    }

    #visit-dialog .dialog-form footer {
        bottom: -8px;
        margin: 0 -8px -8px;
        padding: 8px;
    }

    #bulk-job-dialog .dialog-form footer {
        bottom: -8px;
        margin: 0 -8px -8px;
        padding: 8px;
    }

    #bulk-job-dialog .dialog-form input,
    #bulk-job-dialog .dialog-form select,
    #bulk-job-dialog .dialog-form textarea {
        min-width: 0;
        max-width: 100%;
        padding: 7px 6px;
        border-radius: 8px;
    }

    #bulk-job-dialog .fields-3 {
        gap: 7px;
    }

    #bulk-job-dialog .bulk-section {
        gap: 8px;
    }

    #bulk-job-dialog .selected-date-list {
        padding: 8px 9px;
        border-radius: 8px;
    }

    .dialog-form textarea {
        min-height: 84px;
        max-height: 150px;
    }

    .dialog-form .visit-date-range,
    .dialog-form .visit-time-range {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .dialog-form .visit-date-range label,
    .dialog-form .visit-time-range label {
        min-width: 0;
        overflow: hidden;
    }

    .dialog-form .visit-date-range input,
    .dialog-form .visit-time-range input {
        box-sizing: border-box;
        height: 32px;
        min-width: 0;
        max-width: 100%;
        padding: 6px 2px;
        font-size: 10px;
        line-height: 1.1;
        letter-spacing: 0;
    }

    .dialog-form .visit-date-range input::-webkit-date-and-time-value,
    .dialog-form .visit-time-range input::-webkit-date-and-time-value {
        min-width: 0;
        text-align: center;
    }

    .dialog-form .visit-date-range input::-webkit-calendar-picker-indicator,
    .dialog-form .visit-time-range input::-webkit-calendar-picker-indicator {
        width: 12px;
        margin: 0;
        padding: 0;
    }

    .job-picker {
        gap: 5px;
    }

    .shell {
        width: 100%;
        max-width: 100vw;
        padding: 12px;
    }

    .toolbar {
        flex-wrap: wrap;
    }

    .toolbar.wrap .search,
    .toolbar.wrap .toolbar-form,
    .toolbar.wrap .upload {
        flex: 1 1 100%;
        min-width: 0;
    }

    .toolbar.wrap .search input {
        min-width: 0;
    }

    .toolbar.wrap .upload {
        align-items: stretch;
    }

    .toolbar.wrap .upload input[type="file"] {
        min-width: 0;
        max-width: 100%;
    }

    .toolbar-title {
        min-width: 0;
        flex: 1 1 140px;
    }

    .sites-layout {
        width: 100%;
        max-width: 100%;
        gap: 10px;
    }

    .sites-layout > .panel {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    .sites-layout .list-panel {
        max-height: 280px;
        overflow: auto;
    }

    .sites-layout .list-row,
    .sites-layout .detail-form {
        padding-left: 12px;
        padding-right: 12px;
    }

    .sites-layout .panel-head,
    .sites-layout .section-title {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .column-picker-menu {
        left: auto;
        right: 0;
    }

    .controller-group-head {
        align-items: stretch;
        flex-direction: column;
    }

    .controller-group-title {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 8px;
        width: 100%;
    }

    .controller-group-title h3 {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .controller-group-title .column-picker {
        justify-self: end;
    }

    .controller-group-title .column-picker summary.icon-button {
        width: 34px;
        height: 34px;
        min-width: 34px;
        padding: 0;
    }

    .controller-group-title .column-picker-menu {
        left: auto;
        right: 0;
        width: min(210px, calc(100vw - 28px));
        max-height: min(360px, calc(100svh - 120px));
        overflow: auto;
    }

    .controller-group-actions {
        justify-content: flex-start;
    }

    .controller-group-actions .lookup-status {
        min-width: 0;
        text-align: left;
    }

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

    .sites-layout .panel-head h2,
    .sites-layout .section-title h2 {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .sites-layout .table-scroll {
        border-top: 0;
    }

    .sites-layout .data-table.compact {
        min-width: 620px;
    }

    .rate-grid {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .rate-mode {
        padding: 12px 12px 0;
    }

    .detail-grid .panel,
    .rate-settings,
    .rate-grid {
        width: 100%;
        max-width: 100%;
    }

    .data-table.compact {
        min-width: 430px;
    }

    .reports-table {
        display: none;
    }

    .report-template-summary,
    .report-upload-form,
    .job-subsetting-add,
    .job-visit-category-list form {
        grid-template-columns: minmax(0, 1fr);
    }

    .report-template-summary .button,
    .report-upload-form .button,
    .job-subsetting-add .button {
        width: 100%;
    }

    .mobile-report-list {
        display: grid;
        gap: 8px;
        padding: 12px;
    }

    .mobile-report-item {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px;
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 10px;
        background: var(--panel);
    }

    .mobile-report-item strong,
    .mobile-report-item span {
        display: block;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-report-item span {
        color: var(--muted);
        font-size: 12px;
        margin-top: 3px;
    }

    .calendar-head,
    .calendar-grid {
        grid-template-columns: repeat(7, minmax(38px, 1fr));
    }

    .calendar-head span {
        padding: 8px 2px;
        font-size: 11px;
    }

    .calendar-cell {
        min-height: max(42px, calc(86px * var(--calendar-zoom)));
        padding: max(2px, calc(5px * var(--calendar-zoom))) max(1px, calc(3px * var(--calendar-zoom)));
        gap: max(1px, calc(3px * var(--calendar-zoom)));
    }

    .day-number,
    .chip,
    .more {
        font-size: max(7px, calc(10px * var(--calendar-zoom)));
    }

    .day-number {
        width: max(18px, calc(28px * var(--calendar-zoom)));
        height: max(18px, calc(28px * var(--calendar-zoom)));
    }

    .chip {
        padding: max(1px, calc(4px * var(--calendar-zoom))) max(2px, calc(6px * var(--calendar-zoom)));
    }

    .engineer-schedule,
    .table-panel {
        width: 100%;
        overflow-x: auto;
    }

    .schedule-grid {
        grid-template-columns: calc(112px * var(--schedule-zoom)) repeat(var(--schedule-days), minmax(calc(108px * var(--schedule-zoom)), 1fr));
        min-width: calc((112px * var(--schedule-zoom)) + (var(--schedule-days) * (108px * var(--schedule-zoom))));
    }

    .schedule-grid-day {
        grid-template-columns: calc(112px * var(--schedule-zoom)) minmax(calc(230px * var(--schedule-zoom)), 1fr);
        min-width: calc((112px * var(--schedule-zoom)) + (230px * var(--schedule-zoom)));
    }

    .schedule-grid-month {
        grid-template-columns: calc(104px * var(--schedule-zoom)) repeat(var(--schedule-days), minmax(calc(70px * var(--schedule-zoom)), 1fr));
        min-width: calc((104px * var(--schedule-zoom)) + (var(--schedule-days) * (70px * var(--schedule-zoom))));
    }

    .schedule-corner,
    .schedule-date,
    .schedule-engineer,
    .schedule-cell {
        font-size: max(9px, calc(13px * var(--schedule-zoom)));
    }

    .schedule-corner,
    .schedule-engineer {
        padding: max(5px, calc(10px * var(--schedule-zoom)));
    }

    .schedule-date {
        padding: max(4px, calc(8px * var(--schedule-zoom))) max(3px, calc(6px * var(--schedule-zoom)));
    }

    .schedule-date span,
    .schedule-engineer span,
    .schedule-visit span,
    .schedule-visit small {
        font-size: max(8px, calc(11px * var(--schedule-zoom)));
    }

    .schedule-engineer,
    .schedule-cell {
        height: max(62px, calc(104px * var(--schedule-zoom)));
        min-height: max(62px, calc(104px * var(--schedule-zoom)));
    }

    .schedule-cell {
        padding: max(3px, calc(7px * var(--schedule-zoom)));
        gap: max(2px, calc(6px * var(--schedule-zoom)));
    }

    .schedule-visit {
        padding: max(3px, calc(7px * var(--schedule-zoom)));
        gap: max(1px, calc(2px * var(--schedule-zoom)));
    }

    .schedule-grid-month .schedule-visit {
        min-height: max(30px, calc(44px * var(--schedule-zoom)));
    }
}
