:root {
    --bg: #f9fafb;
    --panel: #ffffff;
    --line: #e5e7eb;
    --line-strong: #d1d5db;
    --text: #1f2937;
    --muted: #6b7280;
    --muted-light: #9ca3af;
    --brand: #3b5bdb;
    --brand-dark: #2f4ac7;
    --brand-soft: #f0f4ff;
    --green: #22c55e;
    --green-dark: #16a34a;
    --red: #ef4444;
    --red-dark: #dc2626;
    --console: #111827;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 12.5px;
    line-height: 1.34;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

h1, h2, h3, p { margin: 0; letter-spacing: 0; }
h1 { font-size: 22px; line-height: 1.12; font-weight: 800; color: #111827; }
h2 { font-size: 14px; line-height: 1.25; font-weight: 750; color: #1f2937; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 204px minmax(0, 1fr);
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 204px;
    min-width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 10px 10px;
    background: #ffffff;
    border-right: 1px solid var(--line);
    overflow-y: auto;
    z-index: 20;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 26px;
    padding: 0 4px;
    color: #1f2937;
    font-size: 16px;
    font-weight: 800;
}
.brand:hover { color: #1f2937; }
.brand-icon {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    color: var(--brand);
    font-size: 19px;
    line-height: 1;
}
.brand-logo {
    display: block;
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex: 0 0 auto;
}
.version-pill {
    margin-left: auto;
    padding: 2px 6px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #f9fafb;
    color: #6b7280;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.1;
}

.nav {
    display: grid;
    gap: 2px;
    margin-top: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 29px;
    padding: 0 8px;
    border-radius: 7px;
    color: #5b6472;
    font-size: 12.5px;
    font-weight: 700;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.nav-link span {
    width: 16px;
    color: currentColor;
    font-size: 16px;
    text-align: center;
    opacity: .92;
}
.nav-link:hover {
    color: #374151;
    background: #f3f4f6;
}
.nav-link.active {
    color: #ffffff;
    background: var(--brand);
    box-shadow: 0 5px 12px rgba(59, 91, 219, 0.16);
}
.muted-link { margin-top: 5px; }
.nav-section {
    margin: 6px 4px 2px;
    color: var(--muted-light);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.sidebar-account {
    margin-top: auto;
    padding-top: 6px;
    border-top: 1px solid #f3f4f6;
    display: grid;
    gap: 4px;
}
.account-name,
.account-city {
    display: block;
    padding: 0 4px;
}
.account-name {
    color: #9ca3af;
    font-size: 12px;
}
.account-city {
    margin-top: 2px;
    color: #6b7280;
    font-size: 11px;
}
.logout-button {
    width: 100%;
    min-height: 28px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 6px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #5b6472;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
}
.logout-button:hover {
    color: var(--red-dark);
    background: #fef2f2;
}

.page {
    width: min(100%, 1500px);
    min-width: 0;
    padding: 18px 18px 28px;
    grid-column: 2;
}
.system-alert {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid #fde68a;
    border-radius: 10px;
    background: #fffbeb;
    color: #92400e;
    font-weight: 650;
}
.system-alert span {
    color: #78350f;
}
.system-alert-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.system-alert-row form {
    margin: 0;
    flex: 0 0 auto;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.page-actions form {
    margin: 0;
}
.muted {
    color: var(--muted);
    margin-top: 4px;
}

.panel, .auth-card, .stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.panel { margin-bottom: 10px; }

.panel-head,
.panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
}
.panel-head { border-bottom: 1px solid var(--line); }
.panel-title-row a,
.muted-action {
    color: var(--brand);
    font-size: 13px;
    font-weight: 700;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, .98fr);
    gap: 10px;
    margin-bottom: 10px;
}
.control-panel,
.latest-panel {
    min-height: 168px;
    padding: 12px;
}
.control-panel {
    display: grid;
    align-content: start;
    gap: 9px;
}
.latest-panel .panel-title-row,
.log-panel .panel-title-row {
    padding: 0;
    margin-bottom: 8px;
}
.status-line {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 24px;
}
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #9ca3af;
}
.status-dot.running {
    background: var(--green);
    box-shadow: 0 0 0 5px rgba(34, 197, 94, .13);
}
.control-form {
    display: grid;
    gap: 8px;
}
.switch-row {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
    color: #5b6472;
    font-weight: 700;
    cursor: default;
}
.switch {
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: #d1d5db;
}
.switch input { display: none; }
.switch i {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: white;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .18);
}
.live-browser-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: #5b6472;
    font-weight: 700;
}
.live-browser-row .button {
    margin-left: auto;
}
.button-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.compact-list {
    display: grid;
    gap: 3px;
}
.compact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #f3f4f6;
    color: var(--text);
}
.compact-row:last-child { border-bottom: 0; }
.compact-row strong { display: block; font-size: 13px; color: #374151; }
.compact-row small { display: block; margin-top: 2px; color: var(--muted-light); }

.log-panel { padding: 12px; }
.title-with-badge {
    display: flex;
    align-items: center;
    gap: 8px;
}
.terminal-mark {
    color: #6b7280;
    margin-right: 6px;
    font-weight: 900;
}
.dashboard-log {
    min-height: 220px;
    max-height: 320px;
    border-radius: 9px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}
.admin-search-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.auth-event-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.subtle-stats { opacity: .92; }
.stat { padding: 10px 12px; }
.stat span { display: block; color: var(--muted); margin-bottom: 3px; font-weight: 700; }
.stat strong { font-size: 19px; line-height: 1; }

.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
th, td {
    padding: 6px 8px;
    border-bottom: 1px solid #f0f2f5;
    text-align: left;
    vertical-align: middle;
}
td {
    height: 34px;
    line-height: 1.25;
}
th {
    color: #9ca3af;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .025em;
}
tbody tr:hover td { background: #fafbff; }
tr:last-child td { border-bottom: 0; }
.clickable-row {
    cursor: pointer;
}
.clickable-row:hover td {
    background: #f5f7ff;
}
.subline {
    display: block;
    color: var(--muted-light);
    margin-top: 2px;
    font-size: 11px;
}
.actions {
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
}
.actions form { margin: 0; }
.users-panel {
    overflow: hidden;
}
.users-table th:first-child,
.users-table td:first-child {
    width: 44px;
}
.users-table td {
    height: 36px;
}
.muted-label {
    color: #6b7280;
    font-weight: 700;
}
.city-dot {
    display: inline-block;
    margin-right: 8px;
    color: var(--brand);
    font-weight: 900;
}
.role-admin {
    background: #fef3c7;
    color: #b45309;
}
.icon-actions {
    gap: 4px;
}
.icon-button {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #9ca3af;
    font: inherit;
    font-size: 16px;
    cursor: pointer;
}
.icon-button:hover {
    background: #f3f4f6;
    color: #4b5563;
}
.icon-button.bordered {
    border: 1px solid var(--line-strong);
    background: #ffffff;
    font-size: 18px;
    line-height: 1;
}
.icon-button.is-on {
    color: var(--green-dark);
}
.icon-button svg {
    width: 16px;
    height: 16px;
    display: block;
}
.icon-button path,
.icon-button circle {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-button.reset-password:hover {
    color: var(--brand);
}
.icon-button.danger-icon:hover {
    color: var(--red-dark);
}
.icon-button:disabled {
    opacity: .28;
    cursor: not-allowed;
}
.icon-button:disabled:hover {
    background: transparent;
    color: #9ca3af;
}
.cities-table th:first-child,
.cities-table td:first-child {
    width: 44px;
}
.city-modal-card {
    width: min(560px, 100%);
}
.subprofiles-panel {
    overflow: hidden;
}
.subprofiles-table th:first-child,
.subprofiles-table td:first-child {
    width: 44px;
}
.subprofiles-table td {
    height: 36px;
}
.admin-subprofile-panel {
    margin-bottom: 0;
}
.search-card-list {
    display: grid;
    gap: 5px;
}
.admin-search-user-list {
    display: grid;
    gap: 12px;
}
.admin-search-user-group {
    display: grid;
    gap: 6px;
}
.admin-search-user-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}
.admin-search-user-head h2 {
    margin: 0;
    color: var(--text);
    font-size: 17px;
}
.admin-search-user-head p {
    margin: 2px 0 0;
}
.admin-search-user-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}
.admin-search-group-items {
    padding-left: 10px;
    border-left: 2px solid var(--line);
}
.appointment-list {
    display: grid;
    gap: 6px;
}
.appointment-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 7px;
    margin-bottom: 8px;
    padding: 8px 10px;
}
.appointment-filter label {
    flex: 1 1 320px;
    max-width: 520px;
}
.expired-appointments {
    background: #fcfcfd;
}
.cancelled-appointments {
    background: #fffafa;
}
.appointment-group {
    display: grid;
    gap: 2px;
}
.appointment-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    color: #1f2937;
}
.appointment-group-head h2 {
    margin: 0;
    font-size: 14px;
    line-height: 1.22;
}
.appointment-group-head span {
    color: var(--muted);
    font-weight: 700;
}
.appointment-subsection-label {
    margin: 10px 8px 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.appointments-panel {
    margin-bottom: 0;
    overflow: hidden;
}
.appointments-table {
    font-size: 12px;
    table-layout: auto;
}
.appointments-table th,
.appointments-table td {
    padding: 5px 7px;
}
.appointments-table th {
    font-size: 10px;
    letter-spacing: .02em;
}
.appointments-table th:first-child,
.appointments-table td:first-child {
    width: 32px;
    min-width: 32px;
    text-align: center;
    padding-left: 5px;
    padding-right: 5px;
}
.appointments-table td {
    height: 32px;
    vertical-align: middle;
    line-height: 1.22;
}
.appointments-table th:nth-child(2),
.appointments-table td:nth-child(2) {
    min-width: 92px;
}
.appointments-table th:nth-child(3),
.appointments-table td:nth-child(3) {
    min-width: 98px;
}
.appointments-table td:nth-child(4) {
    max-width: 190px;
    color: #4b5563;
}
.appointments-table th:nth-child(5),
.appointments-table td:nth-child(5) {
    min-width: 54px;
    white-space: nowrap;
}
.appointments-table th:nth-child(6),
.appointments-table td:nth-child(6) {
    min-width: 90px;
    white-space: nowrap;
}
.appointments-table th:nth-child(7),
.appointments-table td:nth-child(7) {
    min-width: 78px;
    white-space: nowrap;
}
.appointments-table th:nth-child(8),
.appointments-table td:nth-child(8) {
    min-width: 112px;
}
.appointments-table th:nth-child(9),
.appointments-table td:nth-child(9) {
    min-width: 68px;
    white-space: nowrap;
}
.appointments-table th:nth-child(10),
.appointments-table td:nth-child(10) {
    min-width: 112px;
    white-space: nowrap;
}
.appointments-table th:nth-child(11),
.appointments-table td:nth-child(11) {
    min-width: 66px;
    text-align: center;
    white-space: nowrap;
}
.staff-badge {
    display: inline-block;
    min-width: 28px;
    padding: 2px 6px;
    border-radius: 6px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 10px;
    font-weight: 800;
    text-align: center;
}
.staff-with_staff {
    background: #ecfdf5;
    color: #047857;
}
.staff-without_staff {
    background: #fef2f2;
    color: #b91c1c;
}
.staff-unverified {
    background: #f3f4f6;
    color: #4b5563;
}
.staff-label {
    display: block;
    margin-top: 2px;
    color: #4b5563;
    font-size: 11px;
    line-height: 1.15;
}
.appointment-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
}
.appointment-actions form {
    margin: 0;
}
.appointment-actions-empty {
    color: var(--muted-light);
    font-weight: 800;
}
.open-appointment-icon {
    width: 22px;
    height: 22px;
    border: 1px solid #dbeafe;
    background: #eff6ff;
    color: var(--brand);
}
.open-appointment-icon svg {
    width: 13px;
    height: 13px;
}
.staff-verify-appointment-icon {
    width: 22px;
    height: 22px;
    border: 1px solid #e0e7ff;
    background: #eef2ff;
    color: #4338ca;
}
.staff-verify-appointment-icon svg {
    width: 13px;
    height: 13px;
}
.cancel-appointment-icon {
    width: 22px;
    height: 22px;
    border: 1px solid #fee2e2;
    background: #fff5f5;
    color: var(--red);
}
.cancel-appointment-icon svg {
    width: 13px;
    height: 13px;
}
.transfer-appointment-icon {
    width: 22px;
    height: 22px;
    border: 1px solid #d1fae5;
    background: #ecfdf5;
    color: #047857;
}
.transfer-appointment-icon svg {
    width: 13px;
    height: 13px;
}
.range-down-appointment-icon {
    width: 22px;
    height: 22px;
    border: 1px solid #fde68a;
    background: #fffbeb;
    color: #b45309;
}
.range-down-appointment-icon svg {
    width: 13px;
    height: 13px;
}
.transfer-summary {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: #374151;
    font-size: 13px;
    font-weight: 800;
}
.transfer-modal-card {
    width: min(560px, 100%);
}
.search-card {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    padding: 8px 10px;
    margin-bottom: 0;
}
.other-search-card {
    grid-template-columns: 30px minmax(0, 1fr) minmax(140px, auto);
}
.other-search-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}
.search-main {
    display: grid;
    gap: 3px;
    min-width: 0;
}
.search-topline {
    display: flex;
    align-items: center;
    gap: 6px 8px;
    flex-wrap: wrap;
}
.search-main strong {
    color: #1f2937;
    font-size: 13px;
    line-height: 1.2;
}
.search-details {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 3px 10px;
    line-height: 1.25;
}
.search-details .muted-label {
    font-size: 12px;
}
.badge-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.scheduler-fields {
    display: grid;
    gap: 9px;
    padding-top: 2px;
}
.scheduler-fields h3 {
    margin: 0;
    color: #374151;
    font-size: 15px;
    font-weight: 800;
}
.field-notice {
    margin: -4px 0 4px;
    color: #b45309;
    font-size: 13px;
    font-weight: 700;
}

.compact-help {
    margin: -8px 0 0;
    font-size: .88rem;
    font-weight: 700;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 31px;
    padding: 0 10px;
    border-radius: 7px;
    border: 1px solid var(--line-strong);
    background: #ffffff;
    color: #4b5563;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease, opacity .15s ease;
}
.button:hover { background: #f9fafb; color: #374151; }
.button:disabled {
    opacity: .42;
    cursor: not-allowed;
}
.button.primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #ffffff;
}
.button.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.button.success {
    background: var(--green);
    border-color: var(--green);
    color: #ffffff;
}
.button.success:hover { background: var(--green-dark); border-color: var(--green-dark); }
.button.danger {
    background: var(--red);
    border-color: var(--red);
    color: #ffffff;
}
.button.danger:hover { background: var(--red-dark); border-color: var(--red-dark); }
.button.ghost { background: #ffffff; }
.button.full { width: 100%; }
.button.compact {
    min-height: 26px;
    padding: 0 8px;
    border-radius: 7px;
}
.button.disabled {
    pointer-events: none;
    opacity: .45;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
    background: #f3f4f6;
    color: #6b7280;
}
.badge.running { background: #dcfce7; color: #15803d; }
.badge.enabled, .badge.succeeded { background: #dcfce7; color: #15803d; }
.badge.schedule-days { background: #dbeafe; color: #1d4ed8; }
.badge.inactive { background: #fee2e2; color: #b91c1c; }
.badge.failed { background: #fee2e2; color: #b91c1c; }
.badge.queued { background: #e0e7ff; color: #3730a3; }
.badge.skipped { background: #fef3c7; color: #b45309; }
.badge.stopped, .badge.idle { background: #f3f4f6; color: #6b7280; }
.badge.pending { background: #f3f4f6; color: #6b7280; }
.badge.previewing, .badge.previewed { background: #fef3c7; color: #b45309; }
.badge.cancelled { background: #e0f2fe; color: #0369a1; }

.empty {
    color: var(--muted-light);
    text-align: center;
    padding: 14px 10px;
}
.empty.subtle {
    text-align: left;
    padding: 8px 0;
}

.run-list { display: grid; }
.history-filter-panel {
    padding: 9px 10px;
    margin-bottom: 8px;
}
.history-filter-form {
    display: grid;
    grid-template-columns: minmax(200px, 340px) auto auto;
    gap: 8px;
    align-items: end;
    justify-content: start;
}
.auth-event-filter-form {
    grid-template-columns: minmax(180px, 260px) minmax(180px, 260px) minmax(150px, 210px) auto auto;
}
.auth-events-table {
    min-width: 1180px;
}
.auth-events-table th,
.auth-events-table td {
    vertical-align: top;
}
.auth-events-table th:nth-child(1),
.auth-events-table td:nth-child(1) {
    width: 150px;
}
.auth-events-table th:nth-child(2),
.auth-events-table td:nth-child(2) {
    width: 150px;
}
.auth-events-table th:nth-child(3),
.auth-events-table td:nth-child(3) {
    width: 140px;
}
.auth-events-table th:nth-child(4),
.auth-events-table td:nth-child(4) {
    width: 180px;
}
.auth-events-table th:nth-child(5),
.auth-events-table td:nth-child(5) {
    width: 260px;
}
.auth-events-table th:nth-child(6),
.auth-events-table td:nth-child(6) {
    width: 135px;
}
.auth-events-table th:nth-child(8),
.auth-events-table td:nth-child(8) {
    width: 130px;
}
.auth-user-agent {
    max-width: 240px;
    overflow-wrap: anywhere;
}
.auth-event-details summary {
    color: var(--brand);
    cursor: pointer;
    font-weight: 800;
}
.auth-event-details dl {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 4px 8px;
    min-width: 280px;
    margin: 8px 0 0;
}
.auth-event-details dt {
    color: var(--muted-light);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}
.auth-event-details dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}
.auth-event-details code {
    white-space: normal;
}
.run-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 7px 10px;
    border-bottom: 1px solid #f3f4f6;
    color: var(--text);
}
.run-row:last-child { border-bottom: 0; }

.calendar-panel,
.holidays-panel,
.blocked-days-panel {
    padding: 10px;
    margin-bottom: 8px;
}
.calendar-head,
.blocked-days-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
}
.calendar-head h2,
.blocked-days-head h2,
.holidays-panel h2 {
    font-size: 15px;
    color: #111827;
}
.calendar-nav {
    display: flex;
    gap: 4px;
}
.calendar-nav .icon-button {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    font-size: 15px;
}
.calendar-weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}
.calendar-weekdays {
    margin-bottom: 4px;
    color: #4b5563;
    font-size: 11px;
    font-weight: 800;
    text-align: center;
}
.calendar-day {
    display: grid;
    place-items: center;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: #111827;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}
.calendar-day:hover {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(59, 91, 219, .12);
}
.calendar-day.outside {
    color: transparent;
    pointer-events: none;
}
.calendar-day.weekend {
    background: #f8fafc;
    color: #94a3b8;
}
.calendar-day.blocked {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #be123c;
}
.calendar-day.target {
    border-color: #a5b4fc;
    box-shadow: inset 0 0 0 1px #c7d2fe;
}
.calendar-day.blocked.target {
    background: #fff1f2;
    border-color: #818cf8;
}
.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    color: #4b5563;
    font-size: 12px;
    font-weight: 750;
}
.calendar-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.legend-box {
    width: 11px;
    height: 11px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: #ffffff;
}
.legend-box.weekend { background: #f8fafc; }
.legend-box.blocked { background: #fff1f2; border-color: #fecdd3; }
.legend-box.target { background: #eef2ff; border-color: #a5b4fc; }
.holiday-actions {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.2fr);
    gap: 10px;
    align-items: end;
    margin-top: 12px;
}
.holiday-year-form,
.holiday-import-form {
    display: grid;
    gap: 8px;
    align-items: end;
}
.holiday-year-form {
    grid-template-columns: 140px minmax(180px, 1fr);
}
.holiday-import-form {
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
}
.holiday-scope-summary {
    min-height: 38px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
}
.holiday-loaded-note {
    grid-column: 1 / -1;
}
.scope-summary,
.field-display {
    min-height: 36px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #f9fafb;
}
.holiday-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 6px 14px;
    margin-top: 12px;
    color: #6b7280;
    font-weight: 650;
}
.blocked-inline-form {
    display: grid;
    grid-template-columns: 220px minmax(260px, 1fr) 230px 180px;
    gap: 8px;
    align-items: end;
    margin-bottom: 12px;
}
.non-working-table th:first-child,
.non-working-table td:first-child {
    width: 72px;
}
.pager {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}
.auth-version {
    position: fixed;
    right: 18px;
    bottom: 14px;
    color: #9ca3af;
    font-size: 12px;
    font-weight: 800;
}
.auth-shell {
    width: min(390px, 100%);
}
.auth-shell.password-change-shell {
    width: min(680px, 100%);
}
.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 18px;
    color: #1f2937;
    font-size: 24px;
    font-weight: 850;
}
.auth-brand .brand-icon {
    width: 34px;
    height: 34px;
    font-size: 28px;
}
.auth-logo {
    width: 42px;
    height: 42px;
}
.auth-card {
    padding: 22px;
    border-radius: 12px;
}
.auth-card h1 {
    font-size: 22px;
    margin-bottom: 6px;
}
.auth-card .muted { margin-bottom: 16px; }
.auth-card label + label,
.auth-card .button { margin-top: 12px; }
.password-change-card {
    display: grid;
}
.password-rules {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, .85fr);
    gap: 8px 24px;
    margin-top: 12px;
    color: #5f6f8c;
    font-size: 15px;
    font-weight: 650;
}
.password-rules-group {
    display: grid;
    gap: 8px;
    align-content: start;
}
.password-rule {
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.25;
    transition: color .16s ease;
}
.password-rule-dot {
    width: 18px;
    height: 18px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 18px;
    border: 1px solid #dbe3ef;
    border-radius: 50%;
    background: #f8fafc;
    color: #ffffff;
    transition: background .16s ease, border-color .16s ease;
}
.password-rule-dot::after {
    content: "";
    width: 8px;
    height: 5px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg) translate(1px, -1px);
    opacity: 0;
}
.password-rule.is-valid {
    color: #15803d;
}
.password-rule.is-valid .password-rule-dot {
    background: #16a34a;
    border-color: #16a34a;
}
.password-rule.is-valid .password-rule-dot::after {
    opacity: 1;
}

.alert {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 9px 10px;
    margin: 10px 0;
    color: #9a3412;
    font-weight: 650;
}
.alert.wide { margin-bottom: 12px; }
.alert.success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #15803d;
}

label {
    display: grid;
    gap: 5px;
    color: #374151;
    font-weight: 750;
}

input, select {
    width: 100%;
    height: 32px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    padding: 0 9px;
    color: var(--text);
    background: #ffffff;
    font: inherit;
    outline: none;
}
input:disabled,
select:disabled {
    background: #f9fafb;
    color: #6b7280;
}
input:focus, select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(59, 91, 219, .16);
}
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
}
.password-field {
    position: relative;
}
.password-field input {
    padding-right: 38px;
}
.password-toggle {
    position: absolute;
    top: 50%;
    right: 5px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
}
.password-toggle svg {
    width: 15px;
    height: 15px;
    display: block;
}
.password-toggle path,
.password-toggle circle {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.password-toggle:hover {
    background: #f3f4f6;
    color: #4b5563;
}
.password-toggle.is-active {
    color: var(--brand);
}

.form-grid {
    display: grid;
    gap: 9px;
}
.form-section {
    padding: 12px;
    display: grid;
    gap: 9px;
}
.settings-form {
    gap: 9px;
}
.settings-form .panel {
    margin-bottom: 0;
}
.settings-form .form-section {
    padding: 10px 12px;
    gap: 8px;
}
.settings-form h2 {
    font-size: 14px;
    line-height: 1.2;
    margin: 0;
}
.settings-form label {
    gap: 4px;
}
.settings-form input,
.settings-form select {
    min-height: 32px;
    padding: 5px 9px;
}
.settings-form .three-col,
.settings-form .four-col,
.settings-base-grid {
    gap: 8px;
}
.settings-base-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(220px, .7fr);
}
.section-title h2 {
    font-size: 16px;
    color: #111827;
}
.section-title.divider {
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}
.profile-form {
    gap: 8px;
}
.profile-form .panel {
    margin-bottom: 0;
}
.profile-form .form-section {
    padding: 10px 12px;
    gap: 8px;
}
.profile-account-panel {
    padding: 10px 12px;
}
.profile-account-panel .section-title h2 {
    font-size: 15px;
}
.profile-account-grid {
    display: grid;
    gap: 6px;
    align-items: end;
}
.profile-account-grid.is-admin {
    grid-template-columns: minmax(170px, 1.2fr) minmax(130px, 1fr) minmax(210px, 1.25fr) minmax(95px, .65fr) minmax(150px, 1fr);
}
.profile-account-grid.is-user {
    grid-template-columns: minmax(170px, 1.2fr) minmax(130px, 1fr) minmax(210px, 1.25fr) minmax(150px, 1fr);
}
.profile-telegram-grid {
    display: grid;
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
    gap: 10px;
    align-items: start;
}
.telegram-panel {
    min-width: 0;
    padding: 10px 12px;
    gap: 8px;
}
.telegram-panel .section-title.divider {
    padding-bottom: 8px;
}
.telegram-panel .form-grid {
    gap: 9px;
}
.telegram-panel label {
    gap: 5px;
}
.telegram-panel .muted.flat {
    margin: 0;
    font-size: 13px;
    overflow-wrap: anywhere;
}
.telegram-quick-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 2px;
}
.telegram-quick-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px;
    gap: 8px;
    align-items: center;
    min-width: 0;
}
.telegram-quick-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}
.telegram-quick-copy strong {
    font-size: 14px;
    color: #111827;
}
.telegram-quick-copy span,
.telegram-setup-note {
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.telegram-quick-item .button {
    grid-column: 1 / -1;
    justify-self: start;
    max-width: 100%;
    white-space: normal;
    text-align: center;
}
.telegram-qr {
    width: 96px;
    height: 96px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.telegram-setup-note {
    margin-top: 4px;
}
.telegram-setup-note a {
    color: var(--primary);
    font-weight: 700;
}
.field-label {
    display: inline-flex;
    gap: 4px;
    align-items: baseline;
}
.observer-list {
    display: grid;
    gap: 5px;
}
.observer-item {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}
.observer-item span {
    display: grid;
    gap: 2px;
    min-width: 0;
}
.observer-item small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    overflow-wrap: anywhere;
}
.muted.flat {
    margin-top: 0;
}
.optional {
    color: var(--muted-light);
    font-weight: 650;
}
.two-col, .three-col, .four-col {
    display: grid;
    gap: 8px;
}
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.four-col { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.checks, .weekday-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
}
.checks label, .weekday-row label,
.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 750;
}
.form-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-bottom: 8px;
}
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 12px;
    background: rgba(17, 24, 39, .48);
}
.modal-backdrop[hidden] {
    display: none;
}
.modal-card {
    width: min(640px, 100%);
    max-height: calc(100vh - 24px);
    overflow: auto;
    padding: 16px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .24);
}
.modal-card h2 {
    margin-bottom: 10px;
    color: #111827;
    font-size: 18px;
}
.modal-check {
    justify-content: flex-start;
    min-height: 26px;
    color: #374151;
    font-size: 13px;
}
.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}
.modal-actions .button {
    min-height: 32px;
    font-size: 13px;
}
.confirm-pop-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 14px;
    background: rgba(17, 24, 39, .42);
    backdrop-filter: blur(2px);
}
.confirm-pop-backdrop[hidden] {
    display: none;
}
.confirm-pop {
    width: min(420px, 100%);
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 10px;
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .22);
}
.confirm-pop-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #eff6ff;
    color: var(--brand);
    font-weight: 900;
}
.confirm-pop-content {
    min-width: 0;
}
.confirm-pop h2 {
    margin: 0 0 5px;
    color: #111827;
    font-size: 16px;
    line-height: 1.2;
}
.confirm-pop p {
    color: #4b5563;
    font-size: 13px;
    line-height: 1.38;
}
.confirm-pop-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 4px;
}
.search-modal-card {
    width: min(620px, 100%);
    max-height: calc(100vh - 24px);
    padding: 12px 16px;
}
.search-modal-card h2 {
    margin-bottom: 10px;
    font-size: 20px;
}
.search-modal-card .form-grid {
    gap: 9px;
}
.search-modal-card label {
    gap: 5px;
    font-size: 13px;
}
.search-modal-card input,
.search-modal-card select {
    height: 32px;
}
.search-modal-card .two-col {
    gap: 8px;
}
.search-modal-card .modal-check {
    min-height: 26px;
    margin-top: 2px;
    font-size: 13px;
}
.search-modal-card .scheduler-fields {
    gap: 8px;
    padding-top: 0;
}
.search-modal-card .scheduler-fields h3 {
    font-size: 14px;
}
.search-modal-card .weekday-row {
    gap: 8px 12px;
}
.search-modal-card .weekday-row label {
    gap: 6px;
}
.weekday-option {
    min-width: 92px;
}
.weekday-source {
    min-width: 24px;
}
.weekday-target {
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;
}
.search-modal-card .modal-actions {
    gap: 8px;
    margin-top: 2px;
}
.search-modal-card .modal-actions .button {
    min-height: 34px;
    font-size: 13px;
}

.inline-form {
    display: grid;
    grid-template-columns: 1fr 1fr 140px 180px auto;
    gap: 8px;
    align-items: end;
}
.city-form { grid-template-columns: 1fr 160px 160px 110px auto; }

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    overflow: hidden;
    border-radius: 10px;
}
.meta-grid div {
    background: #ffffff;
    padding: 14px 16px;
    border-right: 1px solid var(--line);
}
.meta-grid div:last-child { border-right: 0; }
.meta-grid span {
    display: block;
    color: var(--muted);
    margin-bottom: 6px;
}

.logbox {
    margin: 0;
    padding: 12px;
    min-height: 360px;
    max-height: 68vh;
    overflow: auto;
    background: var(--console);
    color: #d1d5db;
    font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    border-radius: 0 0 10px 10px;
    white-space: pre-wrap;
}
.run-video-wrap {
    padding: 12px 16px 16px;
}
.run-video {
    display: block;
    width: 100%;
    max-height: 620px;
    border-radius: 10px;
    background: var(--console);
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: static;
        width: auto;
        height: auto;
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        overflow: visible;
    }
    .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sidebar-account { margin-top: 8px; }
    .page { grid-column: 1; padding: 14px 10px 24px; }
    .dashboard-grid,
    .stats-grid,
    .two-col,
    .three-col,
    .four-col,
    .settings-base-grid,
    .meta-grid,
    .inline-form,
    .history-filter-form,
    .auth-event-filter-form,
    .password-rules,
    .city-form,
    .holiday-actions,
    .holiday-year-form,
    .holiday-import-form,
    .blocked-inline-form,
    .profile-account-grid.is-admin,
    .profile-account-grid.is-user,
    .profile-telegram-grid,
    .telegram-quick-grid {
        grid-template-columns: 1fr;
    }
    .telegram-quick-item {
        grid-template-columns: minmax(0, 1fr) 96px;
    }
    .telegram-qr {
        width: 96px;
        height: 96px;
    }
    .calendar-day { min-height: 46px; font-size: 15px; }
    .calendar-weekdays,
    .calendar-grid { gap: 5px; }
    .page-head { flex-direction: column; }
    .appointment-list { gap: 6px; }
    .appointment-filter {
        margin-bottom: 6px;
        padding: 7px 8px;
    }
    .appointment-subsection-label { margin-top: 0; }
    .appointments-table {
        font-size: 11.5px;
    }
    .appointments-table th,
    .appointments-table td {
        padding: 5px 7px;
    }
    .appointments-table td {
        height: 34px;
    }
    .appointments-table th:first-child,
    .appointments-table td:first-child {
        width: 30px;
        min-width: 30px;
        padding-left: 4px;
        padding-right: 4px;
    }
    .appointments-table th:nth-child(2),
    .appointments-table td:nth-child(2),
    .appointments-table th:nth-child(3),
    .appointments-table td:nth-child(3) {
        min-width: 90px;
    }
    .appointments-table td:nth-child(4) {
        max-width: 170px;
    }
    .appointments-table th:nth-child(6),
    .appointments-table td:nth-child(6) {
        min-width: 86px;
    }
    .appointments-table th:nth-child(10),
    .appointments-table td:nth-child(10) {
        min-width: 106px;
    }
    .appointments-table th:nth-child(11),
    .appointments-table td:nth-child(11) {
        min-width: 62px;
    }
    .search-card,
    .other-search-card {
        grid-template-columns: 1fr;
    }
    .admin-search-user-head {
        align-items: flex-start;
        flex-direction: column;
    }
    .admin-search-user-meta {
        justify-content: flex-start;
    }
    .admin-search-group-items {
        padding-left: 0;
        border-left: 0;
    }
    .actions { justify-content: flex-start; flex-wrap: wrap; }
    .run-row { grid-template-columns: 1fr; }
}
