:root {
    --ink: #111827;
    --muted: #64748b;
    --line: #dbe3ec;
    --surface: #ffffff;
    --canvas: #f4f7fa;
    --nav: #0a1630;
    --nav-soft: #142341;
    --teal: #0f8a83;
    --teal-dark: #086c67;
    --green: #16a66a;
    --green-soft: #e9f8f0;
    --red: #dc4343;
    --red-soft: #fff0f0;
    --amber: #d98913;
    --amber-soft: #fff7e7;
    --blue: #2563eb;
    --chart-grid: #e5ebf1;
    --chart-text: #7a8899;
    --shadow: 0 10px 30px rgba(15, 23, 42, .08);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-width: 320px; min-height: 100vh; min-height: 100dvh; background: var(--canvas); }
body.tour-is-active { overflow: hidden; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin-top: 0; }
.is-hidden { display: none !important; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: 0; }
.brand-light { color: #fff; }
.brand-logo { display: block; width: 38px; height: 38px; filter: drop-shadow(0 7px 13px rgba(14, 165, 164, .2)); }
.eyebrow { display: block; margin-bottom: 9px; color: var(--teal); font-size: 11px; font-weight: 700; letter-spacing: .12em; }

.auth-view { display: grid; grid-template-columns: minmax(380px, .95fr) minmax(460px, 1.05fr); min-height: 100vh; min-height: 100dvh; }
.auth-brand { position: relative; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; padding: 44px clamp(36px, 5vw, 78px); color: #fff; background: var(--nav); }
.auth-brand::after { content: ""; position: absolute; inset: auto -15% -35% 15%; width: 680px; height: 680px; border: 1px solid rgba(56,189,248,.18); border-radius: 50%; box-shadow: 0 0 0 80px rgba(15,138,131,.06), 0 0 0 180px rgba(37,99,235,.04); pointer-events: none; }
.auth-copy { position: relative; z-index: 1; max-width: 610px; }
.auth-copy .eyebrow { color: #5eead4; }
.auth-copy h1 { max-width: 580px; margin-bottom: 22px; font-size: clamp(37px, 4.2vw, 62px); line-height: 1.08; letter-spacing: 0; }
.auth-copy > p { max-width: 560px; color: #b7c5da; font-size: 18px; line-height: 1.7; }
.auth-signals { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }
.auth-signals span { display: inline-flex; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid rgba(255,255,255,.13); border-radius: 6px; color: #dbe7f6; font-size: 12px; }
.auth-signals svg { width: 16px; color: #5eead4; }
.auth-foot { position: relative; z-index: 1; margin: 0; color: #7588a4; font-size: 12px; }
.auth-panel { display: grid; place-items: center; padding: 44px; background: #f8fafc; }
.auth-card { width: min(100%, 500px); padding: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.auth-heading { margin-bottom: 28px; }
.auth-heading h2 { margin-bottom: 8px; font-size: 30px; }
.auth-heading p { margin: 0; color: var(--muted); line-height: 1.55; }
.mobile-brand { display: none; margin-bottom: 28px; color: var(--ink); }

.stack-form, .stack-form label { display: grid; gap: 8px; }
.stack-form { gap: 19px; }
label { color: #253146; font-size: 13px; font-weight: 600; }
label small { color: var(--muted); font-size: 11px; font-weight: 400; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cbd6e2; border-radius: 6px; outline: none; background: #fff; color: var(--ink); transition: border-color .18s, box-shadow .18s; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,138,131,.13); }
input::placeholder, textarea::placeholder { color: #9aa8b9; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-alert { margin-top: 18px; padding: 11px 13px; border: 1px solid #fecaca; border-radius: 6px; background: var(--red-soft); color: #a61f1f; font-size: 13px; }
.text-button { width: 100%; margin-top: 24px; border: 0; background: none; color: var(--teal-dark); font-size: 13px; font-weight: 600; }
.text-button:hover { text-decoration: underline; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.auth-divider::before, .auth-divider::after { content: ''; height: 1px; flex: 1; background: var(--line); }
.btn-brandnova { min-height: 46px; border: 1px solid #235f6c; color: #fff; background: linear-gradient(135deg, #173b57, #247d83); box-shadow: 0 10px 24px rgba(25, 89, 102, .2); }
.btn-brandnova:hover { color: #fff; background: linear-gradient(135deg, #204d6e, #2a9296); transform: translateY(-1px); }
.sso-note { margin: 11px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px; border: 1px solid transparent; border-radius: 6px; font-size: 13px; font-weight: 700; transition: transform .16s, background .16s, border-color .16s, box-shadow .16s; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .58; transform: none; box-shadow: none; }
.btn:focus-visible, .icon-btn:focus-visible, .primary-nav a:focus-visible, .schedule-presets button:focus-visible { outline: 3px solid rgba(56,189,248,.42); outline-offset: 2px; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 5px 13px rgba(15,138,131,.17); }
.btn-primary:hover { background: var(--teal-dark); }
.btn-dashboard-return { border: 1px solid var(--nav); background: var(--nav); color: #fff; font-weight: 800; box-shadow: 0 7px 18px rgba(10, 22, 48, .16); }
.btn-dashboard-return:hover { border-color: var(--nav-soft); background: var(--nav-soft); color: #fff; box-shadow: 0 9px 22px rgba(10, 22, 48, .22); }
.btn-secondary { border-color: var(--line); background: #fff; color: #29364b; }
.btn-secondary:hover { border-color: #acbbcb; background: #f8fafc; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #bd3030; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.icon-btn { display: inline-grid; flex: 0 0 auto; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: inherit; }
.icon-btn:hover { background: rgba(100,116,139,.1); }
.icon-btn svg { width: 19px; height: 19px; }

.workspace { min-height: 100vh; min-height: 100dvh; }
.sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; display: flex; flex-direction: column; width: 248px; padding: 20px 15px 15px; color: #d9e3f1; background: var(--nav); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 9px 20px; }
.sidebar-close { display: none; color: #fff; }
.primary-nav { display: grid; gap: 4px; }
.primary-nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 9px 12px; border-radius: 6px; color: #aebdd2; font-size: 13px; font-weight: 600; }
.primary-nav a svg { width: 18px; height: 18px; }
.primary-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.primary-nav a.is-active { background: #1b3354; color: #fff; box-shadow: inset 3px 0 #2dd4bf; }
.nav-label { margin: 24px 12px 8px; color: #627590; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.sidebar-status { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 13px; border: 1px solid rgba(255,255,255,.1); border-radius: 7px; background: rgba(255,255,255,.035); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #31d28c; box-shadow: 0 0 0 4px rgba(49,210,140,.12); }
.sidebar-status div, .sidebar-user div { display: grid; gap: 2px; min-width: 0; }
.sidebar-status strong, .sidebar-user strong { overflow: hidden; color: #eef5ff; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-status small, .sidebar-user small { overflow: hidden; color: #8093ae; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 9px; margin-top: 12px; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user .icon-btn { color: #9eb0c7; }
.avatar { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 50%; background: #2a8f8a; color: #fff; font-size: 10px; font-weight: 800; }
.main-shell { min-height: 100vh; min-height: 100dvh; margin-left: 248px; }
.topbar { position: sticky; z-index: 30; top: 0; display: flex; align-items: center; justify-content: space-between; height: 70px; padding: 0 clamp(20px, 3vw, 42px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.menu-button { display: none; }
.topbar-start { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-context { display: grid; gap: 2px; }
.topbar-context small { color: var(--muted); font-size: 10px; }
.topbar-context strong { font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.topbar-actions .icon-btn { position: relative; border-color: var(--line); background: #fff; }
.theme-control { position: relative; }
.theme-menu { position: absolute; z-index: 65; top: calc(100% + 10px); right: 0; width: 246px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 18px 50px rgba(8, 19, 38, .2); }
.theme-menu::before { content: ""; position: absolute; top: -5px; right: 14px; width: 9px; height: 9px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--surface); transform: rotate(45deg); }
.theme-menu button { position: relative; display: grid; grid-template-columns: 30px minmax(0,1fr) 20px; align-items: center; gap: 8px; width: 100%; min-height: 52px; padding: 8px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); text-align: left; }
.theme-menu button:hover, .theme-menu button:focus-visible { outline: 0; background: rgba(15,138,131,.09); }
.theme-menu button > svg:first-child { width: 18px; color: var(--teal); }
.theme-menu button span { display: grid; gap: 3px; }
.theme-menu button strong { font-size: 12px; }
.theme-menu button small { color: var(--muted); font-size: 10px; }
.theme-menu .theme-check { visibility: hidden; width: 16px; color: var(--teal); }
.theme-menu button.is-active .theme-check { visibility: visible; }
.notification-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border: 2px solid #fff; border-radius: 50%; background: var(--red); }
.main-content { width: min(100%, 1500px); margin: 0 auto; padding: 34px clamp(20px, 3vw, 42px) 54px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-head h1 { margin-bottom: 7px; font-size: clamp(25px, 2.4vw, 34px); letter-spacing: 0; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }
.page-actions { display: flex; gap: 8px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.admin-metric-grid { grid-template-columns: repeat(3, minmax(0,1fr)); margin-bottom: 16px; }
.metric-card { min-height: 130px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: 0 5px 18px rgba(15,23,42,.045); }
.metric-card-link { color: inherit; cursor: pointer; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background-color .18s ease; }
.metric-card-link:hover { border-color: rgba(15,138,131,.58); box-shadow: 0 10px 26px rgba(15,138,131,.13); transform: translateY(-2px); }
.metric-card-link:focus-visible { outline: 3px solid rgba(56,189,248,.42); outline-offset: 3px; border-color: var(--teal); }
.metric-card-link:hover .metric-icon { background: var(--teal); color: #fff; }
.metric-card-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 600; }
.metric-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 6px; background: #e9f7f7; color: var(--teal); }
.metric-icon svg { width: 17px; height: 17px; }
.metric-value { margin: 14px 0 4px; font-size: 30px; font-weight: 700; line-height: 1; }
.metric-note { color: var(--muted); font-size: 11px; }
.metric-note.good { color: var(--green); }
.metric-note.bad { color: var(--red); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.7fr) minmax(320px,.9fr); gap: 16px; margin-top: 16px; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: 0 5px 18px rgba(15,23,42,.04); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 62px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.panel-link { border: 0; background: none; color: var(--teal-dark); font-size: 11px; font-weight: 700; }
.chart-wrap { height: 276px; padding: 22px 18px 16px; }
.chart-wrap canvas { width: 100%; height: 100%; }
.panel-stack { display: grid; gap: 16px; }
.upcoming-list, .notification-list { display: grid; }
.upcoming-item, .notification-item { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 14px 17px; border: 0; border-bottom: 1px solid #edf1f5; background: var(--surface); color: var(--ink); text-align: left; width: 100%; }
.upcoming-item:last-child, .notification-item:last-child { border-bottom: 0; }
.status-orb { width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; }
.status-orb.up { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.status-orb.down { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.item-copy { min-width: 0; }
.item-copy strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.item-copy small { display: block; overflow: hidden; margin-top: 4px; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { color: var(--muted); font-size: 10px; text-align: right; }
.notification-item { grid-template-columns: auto minmax(0,1fr); align-items: start; }
.notification-type { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; background: var(--red-soft); color: var(--red); }
.notification-type.recovery { background: var(--green-soft); color: var(--green); }
.notification-type svg { width: 15px; height: 15px; }

.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.filter-group { display: flex; flex-wrap: wrap; gap: 8px; }
.search-box { position: relative; width: min(310px, 100%); }
.user-search-box { width: min(390px, 100%); }
.search-box svg { position: absolute; top: 50%; left: 11px; width: 16px; transform: translateY(-50%); color: #8290a2; }
.search-box input { padding-left: 36px; }
.table-toolbar select { width: auto; min-width: 140px; }
.data-table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #fff; box-shadow: 0 5px 18px rgba(15,23,42,.04); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 12px 15px; border-bottom: 1px solid var(--line); background: #f8fafc; color: #637083; font-size: 10px; font-weight: 700; text-align: left; text-transform: uppercase; }
.data-table td { padding: 14px 15px; border-bottom: 1px solid #edf1f5; color: #334155; font-size: 12px; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfdfd; }
.table-primary { display: grid; gap: 4px; min-width: 180px; }
.table-primary strong { color: var(--ink); font-size: 12px; }
.table-primary small { overflow: hidden; max-width: 360px; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 5px; width: fit-content; padding: 4px 7px; border-radius: 999px; background: #eef2f6; color: #526176; font-size: 10px; font-weight: 700; }
.badge.up, .badge.active, .badge.success { background: var(--green-soft); color: #087348; }
.badge.down, .badge.failed { background: var(--red-soft); color: #b32d2d; }
.badge.paused { background: var(--amber-soft); color: #95600c; }
.badge.never, .badge.disabled { background: #eef2f6; color: #627184; }
.category-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; }
.category-chip::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--category-color, #94a3b8); }
.user-cell { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 10px; min-width: 220px; }
.user-cell .avatar { width: 36px; height: 36px; background: #dcefee; color: var(--teal-dark); }
.user-cell strong, .user-cell small { display: block; }
.user-cell small { overflow: hidden; max-width: 280px; margin-top: 3px; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.account-role { display: grid; gap: 5px; }
.account-role .badge.admin { background: #e8f0ff; color: #2857a6; }
.account-role .badge.client { background: #eef2f6; color: #526176; }
.account-role small { color: var(--muted); font-size: 10px; }
.admin-note { margin-bottom: 16px; padding: 13px 15px; border: 1px solid #b9ded9; border-radius: 7px; background: #f4fcfb; color: #285f5a; font-size: 12px; line-height: 1.55; }
.row-actions { display: flex; justify-content: flex-end; gap: 3px; }
.row-actions .icon-btn { width: 32px; height: 32px; color: #536176; }
.row-actions .icon-btn:hover { color: var(--teal-dark); }
.empty-state { display: grid; place-items: center; min-height: 320px; padding: 44px 20px; text-align: center; }
.empty-state .empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 15px; border-radius: 8px; background: #edf7f6; color: var(--teal); }
.empty-state .empty-icon svg { width: 25px; }
.empty-state h3 { margin-bottom: 8px; font-size: 16px; }
.empty-state p { max-width: 420px; margin-bottom: 20px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.pagination { display: flex; justify-content: flex-end; gap: 5px; margin-top: 14px; }
.pagination button { min-width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: #475569; }
.pagination button.is-active { border-color: var(--teal); background: var(--teal); color: #fff; }

.category-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.category-card { padding: 17px; border: 1px solid var(--line); border-top: 3px solid var(--category-color); border-radius: 7px; background: #fff; box-shadow: 0 5px 18px rgba(15,23,42,.04); }
.category-card-head { display: flex; align-items: center; justify-content: space-between; }
.category-card h3 { margin: 0; font-size: 14px; }
.category-card p { margin: 10px 0 0; color: var(--muted); font-size: 11px; }
.inline-form { display: grid; grid-template-columns: minmax(200px, 1fr) 90px auto; gap: 9px; margin-bottom: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.inline-form input[type=color] { padding: 4px; }

.settings-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(320px,.75fr); gap: 16px; }
.settings-panel { padding: 22px; }
.settings-panel h2 { margin-bottom: 6px; font-size: 16px; }
.settings-panel > p { margin-bottom: 22px; color: var(--muted); font-size: 12px; }
.settings-panel form { display: grid; gap: 16px; }
.timezone-control { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 10px; }
.timezone-control label { display: grid; gap: 7px; }
.timezone-control .btn { min-height: 44px; white-space: nowrap; }
.timezone-result { padding: 11px 13px; border: 1px solid #b9ded9; border-radius: 6px; background: #f4fcfb; color: #3b625f; font-size: 11px; line-height: 1.55; }
.timezone-result strong { color: #174b47; }
.worker-box { padding: 14px; border: 1px solid #b7e3dd; border-radius: 6px; background: #f1fbfa; }
.worker-box h3 { margin-bottom: 7px; font-size: 13px; }
.worker-box p { color: #56706e; font-size: 11px; line-height: 1.6; }
.copy-field { display: flex; gap: 7px; }
.copy-field input { min-width: 0; background: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }

.drawer-backdrop { position: fixed; z-index: 70; inset: 0; visibility: hidden; background: rgba(10,22,48,.42); opacity: 0; transition: opacity .2s, visibility .2s; }
.drawer { position: fixed; z-index: 80; inset: 0 0 0 auto; width: min(720px, 100%); overflow: hidden; border-left: 1px solid var(--line); background: #f8fafc; box-shadow: -18px 0 45px rgba(15,23,42,.16); transform: translateX(100%); transition: transform .25s ease; }
.drawer.is-open { transform: translateX(0); }
.drawer-backdrop.is-open { visibility: visible; opacity: 1; }
.drawer form { display: grid; grid-template-rows: auto minmax(0,1fr) auto; height: 100%; }
.drawer-head, .drawer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 19px 24px; border-bottom: 1px solid var(--line); background: #fff; }
.drawer-head h2 { margin: 0; font-size: 21px; }
.drawer-head .eyebrow { margin-bottom: 5px; }
.drawer-body { overflow-y: auto; padding: 22px 24px 38px; }
.drawer-foot { justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; }
.form-section { padding: 20px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.form-section + .form-section { margin-top: 15px; }
.form-section > label, .form-section > .form-grid, .form-section > .url-row, .form-section > .toggle-grid, .form-section > .advanced-block, .form-section > .schedule-presets, .form-section > .email-field, .form-section > .fallback-fields { margin-top: 16px; }
.section-heading { display: flex; align-items: center; gap: 11px; }
.section-heading h3 { margin: 0 0 3px; font-size: 14px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.section-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 6px; background: #eaf7f6; color: var(--teal); }
.section-icon svg { width: 17px; }
.url-row { display: grid; grid-template-columns: 125px minmax(0,1fr); gap: 12px; }
.advanced-block { border: 1px solid var(--line); border-radius: 6px; }
.advanced-block summary { display: flex; align-items: center; justify-content: space-between; padding: 12px 13px; color: #334155; cursor: pointer; font-size: 12px; font-weight: 600; list-style: none; }
.advanced-block summary::-webkit-details-marker { display: none; }
.advanced-block summary svg { width: 16px; transition: transform .2s; }
.advanced-block[open] summary svg { transform: rotate(180deg); }
.advanced-block > label, .advanced-block > .form-grid { margin: 0 13px 13px; }
.schedule-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.schedule-presets button { min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 5px; background: #f8fafc; color: #4c5a6f; font-size: 11px; font-weight: 600; }
.schedule-presets button:hover { border-color: var(--teal); color: var(--teal-dark); }
.toggle-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.toggle { position: relative; display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.toggle input { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.toggle span { position: relative; flex: 0 0 34px; width: 34px; height: 20px; border-radius: 999px; background: #dc2626; transition: background .2s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.toggle input:checked + span { background: #16a34a; }
.toggle input:checked + span::after { transform: translateX(14px); }
.toggle input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--teal) 34%, transparent); outline-offset: 3px; }
.toggle em { font-size: 11px; font-style: normal; font-weight: 600; }
.toggle::after { content: "OFF"; margin-left: auto; padding: 3px 7px; border-radius: 999px; background: #fee2e2; color: #991b1b; font-size: 9px; font-weight: 800; letter-spacing: .06em; }
.toggle:has(input:checked)::after { content: "ON"; background: #dcfce7; color: #166534; }
.sms-field { display: grid; gap: 7px; }
.sms-field > small { color: var(--muted); font-size: 11px; font-weight: 400; }
.sms-input-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.sms-input-row .btn { min-height: 44px; white-space: nowrap; }
.input-action-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.input-action-row .btn { min-height: 44px; white-space: nowrap; }
.email-field, .hosted-fallback-field { display: grid; gap: 7px; }
.email-field > label, .hosted-fallback-field > label { color: var(--text); font-size: 12px; font-weight: 600; }
.email-field > small, .hosted-fallback-field > small { color: var(--muted); font-size: 10px; line-height: 1.45; }
.fallback-fields { display: grid; gap: 16px; }
.fallback-fields > label { margin: 0; }
.fallback-note { padding: 14px; border: 1px solid #b7e3dd; border-radius: 7px; background: #f1fbfa; }
.fallback-note strong { color: #176e69; font-size: 12px; }
.fallback-note p { margin: 5px 0 0; color: #56706e; font-size: 11px; line-height: 1.55; }

.toast-region { position: fixed; z-index: 120; right: 18px; bottom: 18px; display: grid; gap: 9px; width: min(380px, calc(100vw - 36px)); }
.toast { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 13px 14px; border: 1px solid #b9ded9; border-radius: 7px; background: #f4fcfb; color: #174b47; box-shadow: var(--shadow); animation: toast-in .24s ease; }
.toast.error { border-color: #fecaca; background: #fff4f4; color: #8d2222; }
.toast svg { width: 17px; }
.toast span { font-size: 12px; font-weight: 600; }
.toast button { border: 0; background: none; color: inherit; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.product-tour { position: fixed; z-index: 200; inset: 0; visibility: hidden; opacity: 0; pointer-events: none; transition: opacity .18s, visibility .18s; }
.product-tour.is-active { visibility: visible; opacity: 1; pointer-events: auto; }
.tour-spotlight { position: fixed; z-index: 201; left: 50%; top: 50%; width: 0; height: 0; border: 2px solid #5eead4; border-radius: 8px; box-shadow: 0 0 0 9999px rgba(7, 16, 34, .72), 0 0 0 6px rgba(45, 212, 191, .15); pointer-events: none; transition: left .2s ease, top .2s ease, width .2s ease, height .2s ease; }
.product-tour.is-centered .tour-spotlight { left: 50%; top: 50%; width: 1px; height: 1px; border: 0; border-radius: 0; box-shadow: 0 0 0 9999px rgba(7, 16, 34, .76); }
.tour-card { position: fixed; z-index: 203; left: var(--tour-left, 50%); top: var(--tour-top, 50%); width: min(390px, calc(100vw - 32px)); padding: 22px; border: 1px solid #cfe0e7; border-radius: 8px; background: #fff; box-shadow: 0 22px 65px rgba(5, 15, 35, .28); transform: translate(0, 0); transition: left .2s ease, top .2s ease; }
.product-tour.is-centered .tour-card { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.tour-card-head { display: flex; align-items: center; justify-content: space-between; min-height: 34px; }
.tour-kicker { color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.tour-card-head .icon-btn { width: 34px; height: 34px; color: var(--muted); }
.tour-icon { display: grid; place-items: center; width: 42px; height: 42px; margin: 9px 0 15px; border-radius: 7px; background: #e9f7f7; color: var(--teal); }
.tour-icon svg { width: 21px; height: 21px; }
.tour-card h2 { margin-bottom: 8px; font-size: 21px; line-height: 1.25; }
.tour-card > p { margin-bottom: 18px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.tour-progress { display: flex; gap: 6px; margin-bottom: 20px; }
.tour-progress span { flex: 1 1 0; width: auto; min-width: 4px; max-width: 24px; height: 4px; border-radius: 99px; background: #dce5ed; }
.tour-progress span.is-current { background: var(--teal); }
.tour-progress span.is-complete { background: #8ed4cd; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 16px; border-top: 1px solid #e6edf3; }
.tour-actions > div { display: flex; gap: 7px; }
.tour-actions .text-button { width: auto; margin: 0; padding: 8px 0; color: var(--muted); }
.tour-actions .btn { min-width: 78px; }
.tour-highlight { scroll-margin: 90px; }

.confirm-dialog { width: min(430px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 8px; box-shadow: 0 24px 70px rgba(15,23,42,.28); }
.confirm-dialog::backdrop { background: rgba(10,22,48,.5); }
.confirm-dialog form { padding: 25px; text-align: center; }
.dialog-icon { display: grid; place-items: center; width: 42px; height: 42px; margin: 0 auto 14px; border-radius: 50%; background: var(--red-soft); color: var(--red); }
.dialog-icon svg { width: 20px; }
.role-dialog-icon { background: #e9f7f7; color: var(--teal); }
.confirm-dialog h3 { margin-bottom: 8px; font-size: 18px; }
.confirm-dialog p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.confirm-dialog form > div { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
.loading-state { display: grid; place-items: center; min-height: 60vh; color: var(--muted); font-size: 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid #d9e5ea; border-top-color: var(--teal); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.mobile-scrim { display: none; }

html[data-theme="dark"] {
    --ink: #e7eef8;
    --muted: #91a1b8;
    --line: #29384e;
    --surface: #121d2e;
    --canvas: #0a1321;
    --nav: #060e1c;
    --nav-soft: #15243a;
    --teal: #2dd4bf;
    --teal-dark: #64e6d3;
    --green: #39cf88;
    --green-soft: #102d25;
    --red: #ff6b6b;
    --red-soft: #341b25;
    --amber: #f2ad3d;
    --amber-soft: #342918;
    --blue: #6ea0ff;
    --chart-grid: #26364b;
    --chart-text: #8fa0b8;
    --shadow: 0 12px 34px rgba(0, 0, 0, .25);
    color-scheme: dark;
}
html, body, .auth-panel, .topbar, .panel, .metric-card, input, select, textarea, .btn, .icon-btn, .theme-menu, .drawer, .drawer-head, .drawer-foot, .form-section, .data-table-wrap, .category-card, .inline-form, .tour-card { transition: background-color .18s ease, border-color .18s ease, color .18s ease; }
html[data-theme="dark"] .auth-panel,
html[data-theme="dark"] .drawer { background: var(--canvas); }
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .data-table-wrap,
html[data-theme="dark"] .category-card,
html[data-theme="dark"] .inline-form,
html[data-theme="dark"] .drawer-head,
html[data-theme="dark"] .drawer-foot,
html[data-theme="dark"] .form-section,
html[data-theme="dark"] .tour-card,
html[data-theme="dark"] .confirm-dialog,
html[data-theme="dark"] .data-table tr { background: var(--surface); color: var(--ink); }
html[data-theme="dark"] .topbar { background: rgba(10, 19, 33, .94); }
html[data-theme="dark"] .btn-dashboard-return { border-color: rgba(251, 191, 36, .68); background: rgba(161, 98, 7, .12); color: #f6c95d; }
html[data-theme="dark"] .btn-dashboard-return:hover { border-color: rgba(251, 191, 36, .92); background: rgba(161, 98, 7, .22); color: #ffe198; }
html[data-theme="dark"] .topbar-actions .icon-btn,
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .pagination button { border-color: var(--line); background: #172337; color: var(--ink); }
html[data-theme="dark"] .topbar-actions .icon-btn:hover,
html[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .pagination button:hover { background: #1c2b42; }
html[data-theme="dark"] .mobile-brand,
html[data-theme="dark"] label,
html[data-theme="dark"] .data-table td,
html[data-theme="dark"] .advanced-block summary,
html[data-theme="dark"] .schedule-presets button { color: var(--ink); }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { border-color: #34455e; background: #0d1727; color: var(--ink); }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #6f8098; }
html[data-theme="dark"] .data-table th { border-color: var(--line); background: #172337; color: #9bacbf; }
html[data-theme="dark"] .data-table td,
html[data-theme="dark"] .upcoming-item,
html[data-theme="dark"] .notification-item { border-color: var(--line); }
html[data-theme="dark"] .data-table tbody tr:hover,
html[data-theme="dark"] .upcoming-item:hover { background: #162337; }
html[data-theme="dark"] .data-table td,
html[data-theme="dark"] .table-primary strong,
html[data-theme="dark"] .item-copy strong { color: var(--ink); }
html[data-theme="dark"] .user-cell .avatar { background: #193c45; color: #76eadb; }
html[data-theme="dark"] .account-role .badge.admin { background: #192d50; color: #9ebdff; }
html[data-theme="dark"] .account-role .badge.client,
html[data-theme="dark"] .badge.never,
html[data-theme="dark"] .badge.disabled { background: #202d40; color: #a6b4c8; }
html[data-theme="dark"] .metric-icon,
html[data-theme="dark"] .empty-state .empty-icon,
html[data-theme="dark"] .section-icon,
html[data-theme="dark"] .tour-icon,
html[data-theme="dark"] .role-dialog-icon { background: #15353a; }
html[data-theme="dark"] .admin-note,
html[data-theme="dark"] .timezone-result { border-color: #245a59; background: #102b2c; color: #a3cbc8; }
html[data-theme="dark"] .timezone-result strong { color: #70e1d2; }
html[data-theme="dark"] .worker-box { border-color: #245a59; background: #102829; }
html[data-theme="dark"] .worker-box p { color: #9db8b5; }
html[data-theme="dark"] .copy-field input { background: #0b1726; }
html[data-theme="dark"] .fallback-note { border-color: #245a59; background: #102829; }
html[data-theme="dark"] .fallback-note strong { color: #7ee0d7; }
html[data-theme="dark"] .fallback-note p { color: #9db8b5; }
html[data-theme="dark"] .schedule-presets button { background: #172337; }
html[data-theme="dark"] .toggle span { background: #dc2626; }
html[data-theme="dark"] .toggle input:checked + span { background: #16a34a; }
html[data-theme="dark"] .toast { border-color: #245a59; background: #102b2c; color: #a7e7df; }
html[data-theme="dark"] .toast.error { border-color: #713946; background: #321b24; color: #ffb0b0; }
html[data-theme="dark"] .tour-progress span { background: #34445a; }
html[data-theme="dark"] .tour-actions { border-color: var(--line); }
html[data-theme="dark"] .spinner { border-color: #33455d; border-top-color: var(--teal); }
html[data-theme="dark"] .notification-dot { border-color: #0a1321; }
html[data-theme="dark"] input[type="color"] { background: #172337; }
html[data-theme="dark"] ::selection { background: #176d68; color: #fff; }

@media (max-width: 1120px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .admin-metric-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
    .category-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .auth-copy h1 { font-size: 43px; }
}

@media (max-width: 860px) {
    .auth-view { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-panel { min-height: 100vh; min-height: 100dvh; padding: 28px 20px; }
    .mobile-brand { display: inline-flex; }
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-close, .menu-button { display: inline-grid; }
    .mobile-scrim { position: fixed; z-index: 35; inset: 0; display: block; visibility: hidden; background: rgba(10,22,48,.42); opacity: 0; transition: opacity .2s, visibility .2s; }
    .mobile-scrim.is-open { visibility: visible; opacity: 1; }
    .main-shell { margin-left: 0; }
    .topbar { height: 64px; }
    .topbar-start { flex: 1; gap: 8px; min-width: 0; }
    .topbar-context { margin-right: auto; }
    .data-table-wrap { overflow-x: auto; }
    .data-table { min-width: 760px; }
}

@media (max-width: 640px) {
    .auth-card { padding: 25px 20px; }
    .auth-heading h2 { font-size: 25px; }
    .form-grid.two, .form-grid.three, .url-row, .toggle-grid { grid-template-columns: 1fr; }
    .timezone-control { grid-template-columns: 1fr; }
    .timezone-control .btn { width: 100%; }
    .topbar { padding: 0 14px; }
    .topbar-context { display: none; }
    .btn-dashboard-return { min-width: 40px; width: 40px; padding: 0; }
    .btn-dashboard-return span { display: none; }
    .topbar-actions { margin-left: auto; }
    .topbar-actions .btn { width: 40px; padding: 0; }
    .topbar-actions .btn span { display: none; }
    .theme-menu { position: fixed; top: 58px; right: 14px; left: 14px; width: auto; }
    .theme-menu::before { display: none; }
    .tour-card, .product-tour.is-centered .tour-card { left: 14px !important; right: 14px; top: auto !important; bottom: 14px; width: auto; padding: 19px; transform: none; }
    .tour-card > p { font-size: 12px; }
    .tour-actions { align-items: stretch; }
    .tour-actions > div { margin-left: auto; }
    .tour-actions .btn { min-width: 68px; padding-right: 12px; padding-left: 12px; }
    .main-content { padding: 24px 14px 42px; }
    .page-head { align-items: flex-start; }
    .page-head h1 { font-size: 25px; }
    .page-head .btn span { display: none; }
    .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
    .admin-metric-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 116px; padding: 14px; }
    .metric-card-head > span:first-child { max-width: 88px; }
    .metric-value { font-size: 25px; }
    .dashboard-grid { gap: 12px; }
    .chart-wrap { height: 230px; }
    .table-toolbar { align-items: stretch; flex-direction: column; }
    .search-box { width: 100%; }
    .filter-group { display: grid; grid-template-columns: 1fr 1fr; }
    .table-toolbar select { width: 100%; min-width: 0; }
    .data-table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
    .data-table { display: block; min-width: 0; }
    .data-table thead { display: none; }
    .data-table tbody { display: grid; gap: 10px; }
    .data-table tr { display: block; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #fff; box-shadow: 0 5px 18px rgba(15,23,42,.04); }
    .data-table td { display: grid; grid-template-columns: 88px minmax(0,1fr); align-items: center; gap: 10px; padding: 10px 13px; border-bottom: 1px solid #edf1f5; overflow-wrap: anywhere; }
    .data-table td::before { content: attr(data-label); color: #6b788a; font-size: 9px; font-weight: 700; text-transform: uppercase; }
    .data-table .table-primary { min-width: 0; }
    .data-table .table-primary small { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
    .data-table .row-actions { justify-content: flex-start; }
    .category-grid { grid-template-columns: 1fr; }
    .inline-form { grid-template-columns: minmax(0,1fr) 74px; }
    .inline-form .btn { grid-column: 1 / -1; }
    .drawer-head, .drawer-foot { padding: 16px; }
    .drawer-body { padding: 16px 14px 32px; }
    .form-section { padding: 16px; }
    .drawer-foot .btn { flex: 1; }
    .upcoming-item { padding: 13px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
