/* Shared light workspace language with Whistle. */
:root {
    color-scheme: light;
    --paper: #fff; --nav: #f1f3f7; --ink: #202c40; --muted: #5e6c80;
    --line: #e0e5ed; --blue: #3152a0; --blue-soft: #e8eefb;
    --green: #247457; --amber: #8c460c; --red: #a12a31;
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--paper); color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { touch-action: manipulation; }
a { color: var(--blue); }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.2; font-weight: 650; letter-spacing: -.9px; }
h2 { font-size: 18px; line-height: 1.35; font-weight: 600; letter-spacing: -.35px; }
h3 { font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
h4 { font-size: 13px; font-weight: 600; }
p { margin: 7px 0; font-size: 13px; color: var(--muted); }

/* Navigation and working area */
.app-container { display: grid; grid-template-columns: 184px minmax(0,1fr); min-height: 100svh; }
.app-sidebar { position: sticky; top: 0; height: 100svh; overflow-y: auto; padding: 30px 18px; background: var(--nav); border-right: 1px solid #e9edf4; display: flex; flex-direction: column; }
.sidebar-caption { font-size: 9px; letter-spacing: 1.6px; color: var(--muted); padding-left: 11px; margin: 5px 0 34px; }
.tab-navigation { display: flex; flex-direction: column; gap: 6px; }
.tab-button { border: 0; background: transparent; display: flex; justify-content: space-between; text-align: left; padding: 11px 12px; color: #5c687c; font-size: 14px; font-weight: 400; width: 100%; white-space: nowrap; }
.tab-button:hover { background: #e6ebf5; }
.tab-button.active { background: #e2e8f5; color: #294a94; font-weight: 600; }
.tab-button.active::after { content: "↗"; margin-left: 8px; }
.sidebar-bottom { margin-top: auto; padding: 24px 10px 0; }
.user-info { display: block; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.lock-button { border: 0; border-top: 1px solid #dce2ec; border-radius: 0; background: transparent; width: 100%; text-align: left; justify-content: flex-start; color: #546276; margin-top: 16px; padding: 12px 8px; font-size: 12px; }
.lock-button:hover { background: transparent; color: var(--blue); }
.workspace { min-width: 0; width: 100%; }
.workspace-header { padding: 40px 40px 0; margin-bottom: 30px; }
.workspace-header p { margin-top: 9px; }
.main-content { min-width: 0; padding: 0 40px 36px; width: 100%; }
.tab-content { display: none; }
.tab-content.active { display: block; animation: enter .16s ease-out; }
#messages { padding: 0 40px; }
#messages:empty { display: none; }
#messages .alert { margin: 0 0 22px; }

/* Flat sections */
.card { margin: 0 0 32px; min-width: 0; }
.card-header { padding: 0 0 18px; }
.card-header p { margin-top: 7px; }
.card-body { min-width: 0; padding: 0; }
.card .card { margin-bottom: 0; padding-top: 25px; border-top: 1px solid var(--line); }
.location-panel { padding-bottom: 27px; border-bottom: 1px solid var(--line); }
.empty-state { padding: 60px 20px 80px; text-align: center; }
.empty-state h3 { font-size: 16px; font-weight: 550; }
.empty-state p { font-size: 12px; margin-top: 8px; }
.loading { padding: 28px 0; color: var(--muted); font-size: 13px; }

/* Forms and actions */
.form-group { margin-bottom: 18px; min-width: 0; }
label { display: block; font-size: 12px; font-weight: 500; color: #526176; margin-bottom: 6px; }
input, select, textarea { display: block; width: 100%; min-width: 0; padding: 10px 11px; background: white; border: 1px solid #d7deea; border-radius: 6px; color: var(--ink); }
textarea { resize: vertical; min-height: 80px; }
input::placeholder, textarea::placeholder { color: #748094; }
input[readonly] { background: #f8f9fc; color: #526176; }
/* Keep rings inside controls so scroll containers cannot cut their side edges. */
input:focus, select:focus, textarea:focus { outline: 2px solid #91a9e3; outline-offset: -2px; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--ink); font-weight: 500; font-size: 12px; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, border-color .15s, transform .15s; }
button:hover:not(:disabled) { background: #f3f6fc; }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible, a:focus-visible, [tabindex="0"]:focus-visible { outline: 3px solid #94adea; outline-offset: -3px; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary, .btn-success { color: white; border-color: var(--blue); background: var(--blue); }
.btn-primary:hover:not(:disabled), .btn-success:hover:not(:disabled) { background: #254282; border-color: #254282; color: white; }
.btn-secondary, .btn-warning { border-color: var(--line); background: white; color: #41516a; }
.btn-danger { color: var(--red); background: white; border-color: #ebd5d8; }
.btn-danger:hover:not(:disabled) { background: #fff0f1; border-color: #dcaeb4; color: #89232b; }
.btn-small { padding: 6px 9px; font-size: 11px; }
.form-actions { display: flex; justify-content: flex-end; }
.location-controls, .backup-filters { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.location-controls .form-group, .backup-filters .form-group { margin-bottom: 0; min-width: 230px; flex: 0 1 310px; }
.location-controls > button, .backup-filters > button { min-height: 42px; }
.connection-status { align-self: center; margin-top: 22px; padding: 6px 0; font-size: 11px; }
.connected { color: var(--green); }
.disconnected { color: var(--muted); }
.connection-status::before { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; margin-right: 7px; vertical-align: middle; }

/* Keep times legible and scrolling within the rota */
.week-selector { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 20px; }
.week-selector input { width: 175px; padding: 8px 10px; font-size: 12px; }
.rota-table-scroll { position: relative; overflow: auto; scroll-padding-inline-start: 140px; max-height: 70svh; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); scrollbar-color: #bbc5d5 #f5f7fb; }
.table-container { position: relative; overflow-x: auto; width: 100%; margin: 20px 0 0; }
table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
thead th { text-align: left; color: #667388; font-size: 10px; font-weight: 500; letter-spacing: .25px; }
td, th { padding: 14px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .13s; }
tbody tr:hover { background: #fafbfd; }
.backups-table th:first-child, .backups-table td:first-child, .locations-table th:first-child, .locations-table td:first-child { padding-left: 0; }
.backups-table th:last-child, .backups-table td:last-child, .locations-table th:last-child, .locations-table td:last-child { text-align: right; padding-right: 0; }
.backups-table td:first-child { overflow-wrap: anywhere; min-width: 230px; max-width: 420px; }
.backups-table td:nth-child(2), .locations-table td:first-child { font-weight: 550; }
.backups-table td:nth-child(3), .backups-table td:nth-child(6) { white-space: nowrap; }
.rota-table { table-layout: fixed; min-width: 1450px; border-collapse: separate; border-spacing: 0; }
.rota-table thead th { position: sticky; top: 0; z-index: 2; background: #f7f9fc; text-align: center; padding: 13px 6px; }
.rota-table td { padding: 12px 6px; text-align: center; }
.rota-table th:first-child { width: 140px; }
.rota-table th:nth-last-child(3), .rota-table th:nth-last-child(2) { width: 75px; }
.rota-table th:last-child { width: 180px; }
.rota-table .staff-name { position: sticky; left: 0; z-index: 1; background: white; font-weight: 550; font-size: 12px; text-align: left; padding: 14px 12px; border-right: 1px solid var(--line); overflow-wrap: anywhere; }
.rota-table tbody tr:hover .staff-name { background: #fafbfd; }
.rota-table thead th:first-child { position: sticky; left: 0; z-index: 3; text-align: left; padding-left: 12px; border-right: 1px solid var(--line); }
.time-inputs { display: flex; align-items: center; justify-content: center; gap: 4px; }
.time-inputs > span { color: #778499; font-size: 10px; }
.time-input { width: 54px; flex: 0 0 54px; text-align: center; padding: 7px 3px; border-radius: 4px; font-size: 12px; font-variant-numeric: tabular-nums; }
.hours-display { font-weight: 600; font-size: 13px; color: var(--ink); }
.staff-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.staff-actions .btn-success { background: white; color: var(--blue); border-color: #c6d4f3; }
.staff-actions .btn-success:hover:not(:disabled) { background: var(--blue-soft); color: #254282; }
.rota-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 20px; }
.rota-actions > .btn-success:not(.push-btn) { background: white; color: var(--blue); border-color: #c6d4f3; }
.rota-actions > .btn-success:not(.push-btn):hover { background: var(--blue-soft); }
.push-btn { font-weight: 550; }
.push-range-btn { background: white; color: var(--blue); border-color: #c6d4f3; }
.push-range-btn:hover:not(:disabled) { background: var(--blue-soft); color: #254282; border-color: #b3c4e9; }

/* Report context and automation controls */
.backup-stats, .automation-status { display: flex; gap: 38px; flex-wrap: wrap; margin: 28px 0 22px; }
.stat-item { display: flex; flex-direction: column; align-items: flex-start; }
.stat-label { color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.stat-value { color: var(--ink); font-size: 28px; font-weight: 500; letter-spacing: -.7px; font-variant-numeric: tabular-nums; }
#nextRunTime { font-size: 18px; letter-spacing: -.2px; line-height: 1.7; }
.automation-status { margin-top: 0; }
.automation-controls { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 25px; }
.location-control-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.location-control-item:first-child { padding-top: 0; }
.location-control-info { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.location-control-info strong { font-weight: 550; }
.location-control-actions { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.automation-toggle { position: relative; display: inline-block; flex: 0 0 36px; width: 36px; height: 22px; margin: 0; cursor: pointer; }
.automation-toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.automation-slider { position: absolute; inset: 0; border-radius: 20px; background: #bbc5d5; transition: background .15s; pointer-events: none; }
.automation-slider::before { position: absolute; content: ""; width: 16px; height: 16px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: transform .15s; }
.automation-toggle input:checked + .automation-slider { background: var(--blue); }
.automation-toggle input:checked + .automation-slider::before { transform: translateX(14px); }
.automation-toggle input:focus-visible + .automation-slider { outline: 3px solid #94adea; outline-offset: -3px; }
#manualTestSection { scroll-margin-top: 25px; }
#manualTestSection .form-group { max-width: 380px; }
.settings-actions { display: flex; justify-content: flex-end; margin-bottom: 10px; }
#settingsTab > .card + .card { border-top: 1px solid var(--line); padding-top: 25px; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px; margin-top: 22px; }
.pagination [role="status"] { width: 100%; text-align: center; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.pagination button { font-size: 11px; padding: 6px 10px; }
.pagination button.active { background: var(--blue-soft); color: var(--blue); border-color: #c6d4f3; }

/* Light dialogs and a dedicated sign-in page */
.modal { display: none; position: fixed; z-index: 1000; inset: 0; width: 100%; height: 100%; padding: 20px; background: #17213366; }
.modal.show { display: flex; justify-content: center; align-items: center; }
.modal-content { background: white; border-radius: 10px; border: 1px solid var(--line); box-shadow: 0 18px 70px #15203633; width: min(100%,600px); max-height: calc(100svh - 40px); overflow-y: auto; animation: enter .16s ease-out; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 17px; font-weight: 600; color: var(--ink); }
.modal-close { background: transparent; border: 0; padding: 0; flex: 0 0 30px; width: 30px; height: 30px; font-size: 24px; font-weight: 400; color: #637189; }
.modal-close:hover { color: var(--ink); background: #f3f6fc; }
.modal-body { padding: 22px 24px; }
.modal-body > .alert:first-child { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; flex-wrap: wrap; margin-top: 26px; }
#loginModal { background: #f5f7fb; min-height: 100svh; }
#loginModal .modal-content { width: min(100%,372px); padding: 6px; background: transparent; border: 0; box-shadow: none; border-radius: 0; }
#loginModal .modal-header { padding: 0 0 27px; border: 0; }
#loginModal .modal-title { font-size: 24px; font-weight: 600; letter-spacing: -.6px; }
#loginModal .modal-body { padding: 0; }
#loginModal .form-group { margin-bottom: 18px; }
#loginModal .form-actions button { justify-content: space-between; padding: 12px 15px; width: 100%; margin-top: 2px; font-size: 13px; }
#loginModal #loginError { margin: 0 0 18px; }

/* Status and progress */
.alert { padding: 12px 15px; border-radius: 6px; margin: 16px 0; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.alert h4 { margin-bottom: 7px; }
.alert ul { margin: 7px 0 0; padding-left: 20px; }
.alert-success { background: #eef8f3; color: #206044; }
.alert-error { background: #fff0f1; color: #942a32; }
.alert-info { background: #f0f4fc; color: #345183; }
.alert-warning { background: #fff7e9; color: var(--amber); }
.push-status { display: none; margin-top: 20px; padding: 14px; border-radius: 6px; font-size: 12px; }
.progress-bar { height: 6px; background: #e9edf4; border-radius: 4px; overflow: hidden; margin: 14px 0; }
.progress-fill { height: 100%; background: var(--blue); width: 0%; transition: width .2s ease; }
.push-range-status-bar { display: flex; align-items: center; gap: 14px; margin: 0 40px 22px; padding: 12px 14px; background: #f0f4fc; border: 1px solid #dbe4f5; border-radius: 6px; color: #345183; font-size: 12px; }
.push-range-status-bar__bar { flex: 1; min-width: 60px; margin: 0; }
.push-range-status-bar .modal-close { flex-shrink: 0; }
.push-range-week-list { display: flex; flex-direction: column; gap: 7px; margin: 20px 0; max-height: 320px; overflow-y: auto; }
.push-range-week-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }
.push-range-week-row__label { font-weight: 550; white-space: nowrap; }
.push-range-week-row__status { color: var(--muted); text-align: right; }
.push-range-week-row--success { background: #eef8f3; border-color: #cde5da; }
.push-range-week-row--success .push-range-week-row__status { color: #206044; }
.push-range-week-row--error { background: #fff0f1; border-color: #efd2d6; }
.push-range-week-row--error .push-range-week-row__status { color: #942a32; }
.push-range-week-row--active { background: #f0f4fc; border-color: #dbe4f5; }
.push-range-week-row--active .push-range-week-row__status { color: #345183; }
.push-range-week-row--skipped { border-style: dashed; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@keyframes enter { from { opacity: .4; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

@media (min-width: 1800px) {
    .workspace-header, .main-content { padding-left: 46px; padding-right: 46px; }
    #messages { padding: 0 46px; }
    .push-range-status-bar { margin-left: 46px; margin-right: 46px; }
}
@media (max-width: 1100px) {
    .workspace-header { padding: 32px 28px 0; }
    .main-content { padding: 0 28px 30px; }
    #messages { padding: 0 28px; }
    .push-range-status-bar { margin-left: 28px; margin-right: 28px; flex-wrap: wrap; }
    .push-range-status-bar__bar { order: 3; flex-basis: 100%; }
    .backups-table { min-width: 800px; }
}
@media (max-width: 760px) {
    .app-container { grid-template-columns: minmax(0,1fr); }
    .app-sidebar { position: static; height: auto; overflow: visible; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; }
    .sidebar-caption { display: none; }
    .tab-navigation { flex-direction: row; gap: 2px; overflow-x: auto; scrollbar-width: thin; }
    .tab-button { width: auto; flex: 0 0 auto; padding: 9px 10px; font-size: 12px; }
    .tab-button.active::after { display: none; }
    .sidebar-bottom { margin: 0; padding: 0 0 0 8px; }
    .user-info { display: none; }
    .lock-button { padding: 7px 6px; margin: 0; border: 0; font-size: 11px; }
    .workspace-header { padding: 27px 18px 0; margin-bottom: 26px; }
    h1 { font-size: 27px; }
    .workspace-header p { font-size: 12px; }
    .main-content { padding: 0 18px 28px; }
    #messages { padding: 0 18px; }
    .location-controls, .backup-filters { gap: 11px; }
    .location-controls .form-group, .backup-filters .form-group { flex: 1 1 100%; min-width: 0; }
    .connection-status { margin-top: 0; padding: 0; }
    .location-panel { padding-bottom: 23px; }
    .card-header { padding-bottom: 15px; }
    .rota-table-scroll { max-height: 65svh; }
    .week-selector { gap: 7px; }
    .week-selector button { padding: 8px 9px; font-size: 11px; }
    .week-selector input { width: 154px; }
    .rota-actions { gap: 7px; }
    .rota-actions button { padding: 8px 10px; font-size: 11px; }
    .backup-stats, .automation-status { gap: 28px; }
    .stat-value { font-size: 25px; }
    .locations-table { min-width: 560px; }
    .modal { padding: 16px; }
    .modal-content { max-height: calc(100svh - 32px); }
    .modal-header { padding: 17px 18px; }
    .modal-body { padding: 18px; }
    .form-row { flex-wrap: wrap; }
    .form-row .form-group { min-width: 190px; }
    .push-range-status-bar { margin: 0 18px 20px; gap: 9px; }
    .push-range-status-bar__text { flex: 1 1 160px; }
    .push-range-week-row { align-items: flex-start; flex-direction: column; gap: 6px; }
    .push-range-week-row__status { text-align: left; }
}
@media (max-width: 400px) {
    /* Leave enough room beside sticky names for the complete row-action group. */
    .rota-table thead th:first-child { width: 100px !important; }
    .rota-table-scroll { scroll-padding-inline-start: 100px; }
    .rota-table .staff-name { padding-left: 8px; padding-right: 8px; }
    .app-sidebar { grid-template-columns: minmax(0,1fr); gap: 6px; padding: 9px 12px; }
    .tab-navigation { justify-content: space-between; }
    .tab-button { padding: 9px 7px; font-size: 11px; }
    .sidebar-bottom { justify-self: end; padding: 0; }
    .lock-button { padding: 6px; }
    .week-selector { display: grid; grid-template-columns: 1fr 1fr; }
    .week-selector input { width: 100%; grid-column: 2; grid-row: 1; }
    .automation-controls button { flex: 1 1 auto; }
}
