:root {
    --purple-950: #27033b;
    --purple-900: #3b0757;
    --purple-800: #58057f;
    --purple-700: #8617b5;
    --purple-600: #9519c3;
    --lime-500: #c8de3f;
    --lime-300: #d9ea69;
    --slate-950: #1d1d25;
    --slate-700: #50515e;
    --slate-500: #858692;
    --slate-300: #d8d9df;
    --slate-100: #f2f3f6;
    --white: #ffffff;
    --danger: #c94758;
    --success: #3b8f68;
    --shadow: 0 18px 50px rgba(48, 15, 67, .09);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-width: 320px;
    background: #f7f7fa;
    color: var(--slate-950);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 254px;
    display: flex;
    flex-direction: column;
    padding: 30px 20px 24px;
    background:
        radial-gradient(circle at 14% 86%, rgba(200, 222, 63, .15), transparent 25%),
        linear-gradient(160deg, var(--purple-950), var(--purple-800));
    color: var(--white);
}

.brand {
    display: block;
    width: 150px;
    margin: 0 auto 42px;
}

.brand img { display: block; width: 100%; height: auto; }

.navigation { display: grid; gap: 8px; }

.nav-item {
    position: relative;
    display: grid;
    grid-template-columns: 30px 1fr auto;
    align-items: center;
    min-height: 50px;
    padding: 0 14px;
    border-radius: 13px;
    color: rgba(255,255,255,.76);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background .2s ease, color .2s ease;
}

.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,.11);
    color: var(--white);
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: -20px;
    width: 4px;
    height: 28px;
    border-radius: 0 4px 4px 0;
    background: var(--lime-500);
}

.nav-icon { font-size: 19px; color: var(--lime-300); }
.nav-item small { font-size: 9px; font-weight: 700; opacity: .55; text-transform: uppercase; }
.nav-item.disabled { cursor: default; opacity: .72; }

.sidebar-footer {
    display: flex;
    gap: 11px;
    align-items: center;
    margin-top: auto;
    padding: 17px 13px;
    border-top: 1px solid rgba(255,255,255,.12);
}

.sidebar-footer div { display: grid; gap: 3px; }
.sidebar-footer strong { font-size: 12px; text-transform: capitalize; }
.sidebar-footer span:not(.environment-dot), .sidebar-footer a { color: rgba(255,255,255,.58); font-size: 11px; text-decoration: none; }
.environment-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--lime-500); box-shadow: 0 0 0 5px rgba(200,222,63,.12); }

.content {
    width: calc(100% - 254px);
    margin-left: 254px;
    padding: 40px clamp(28px, 4vw, 68px) 26px;
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.eyebrow { margin: 0 0 7px; color: var(--purple-700); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 3vw, 38px); letter-spacing: -.035em; }

.health-badge, .safe-mode, .state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.health-badge { padding: 11px 15px; background: var(--white); box-shadow: 0 8px 24px rgba(25,22,31,.06); }
.health-badge span { width: 8px; height: 8px; border-radius: 50%; }
.health-badge.success span { background: var(--success); box-shadow: 0 0 0 4px rgba(59,143,104,.12); }
.health-badge.danger span { background: var(--danger); }

.hero-card {
    position: relative;
    display: flex;
    min-height: 236px;
    overflow: hidden;
    padding: clamp(30px, 4vw, 52px);
    border-radius: 26px;
    background: linear-gradient(122deg, var(--purple-900), var(--purple-700));
    box-shadow: var(--shadow);
    color: var(--white);
}

.hero-copy { position: relative; z-index: 2; max-width: 700px; }
.section-tag { display: inline-block; margin-bottom: 20px; padding: 7px 11px; border: 1px solid rgba(217,234,105,.35); border-radius: 8px; background: rgba(200,222,63,.11); color: var(--lime-300); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.hero-card h2 { max-width: 650px; margin-bottom: 14px; font-size: clamp(27px, 3.2vw, 43px); line-height: 1.08; letter-spacing: -.04em; }
.hero-card p { max-width: 660px; margin-bottom: 0; color: rgba(255,255,255,.74); font-size: 15px; line-height: 1.65; }
.hero-mark { position: absolute; inset: auto -45px -80px auto; width: 265px; height: 265px; border: 34px solid rgba(200,222,63,.14); border-radius: 50%; }
.hero-mark::after { content: ""; position: absolute; inset: 46px; border: 19px solid rgba(255,255,255,.06); border-radius: 50%; }
.hero-mark span { position: absolute; top: -55px; right: 84px; width: 18px; height: 54px; border-radius: 20px; background: var(--lime-500); transform: rotate(-26deg); opacity: .8; }
.hero-mark span:nth-child(2) { right: 50px; height: 70px; opacity: .35; }
.hero-mark span:nth-child(3) { display: none; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin: 24px 0; }
.metric-card { position: relative; display: grid; min-height: 145px; padding: 24px; border: 1px solid #ececf1; border-radius: 19px; background: var(--white); box-shadow: 0 10px 34px rgba(44,31,52,.045); }
.metric-card::before { content: ""; position: absolute; top: 24px; right: 22px; width: 8px; height: 8px; border-radius: 50%; background: var(--slate-300); }
.metric-card.accent::before { background: var(--lime-500); box-shadow: 0 0 0 5px rgba(200,222,63,.15); }
.metric-label { color: var(--slate-700); font-size: 12px; font-weight: 700; }
.metric-card strong { align-self: end; color: var(--purple-800); font-size: 38px; line-height: 1; letter-spacing: -.04em; }
.metric-detail { align-self: end; color: var(--slate-500); font-size: 11px; }

.lower-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .8fr); gap: 18px; }
.panel { padding: 27px; border: 1px solid #ececf1; border-radius: 20px; background: var(--white); box-shadow: 0 10px 34px rgba(44,31,52,.045); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.panel h3 { margin-bottom: 0; font-size: 20px; letter-spacing: -.02em; }
.safe-mode { padding: 8px 11px; background: rgba(200,222,63,.18); color: #667213; white-space: nowrap; }
.feature-list { display: grid; }
.feature-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 0; border-top: 1px solid var(--slate-100); }
.feature-row div { display: grid; gap: 5px; }
.feature-row strong { font-size: 13px; }
.feature-row div span { color: var(--slate-500); font-size: 11px; }
.state { min-width: 86px; justify-content: center; padding: 7px 10px; }
.state.enabled { background: rgba(59,143,104,.12); color: var(--success); }
.state.disabled { background: var(--slate-100); color: var(--slate-500); }
.next-step { background: linear-gradient(155deg, #fff, #faf8fc); }
.next-step > p:not(.eyebrow) { margin: 18px 0 30px; color: var(--slate-700); font-size: 13px; line-height: 1.65; }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: #ececf1; }
.progress-track span { display: block; width: 25%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--purple-700), var(--lime-500)); }
.progress-label { display: flex; justify-content: space-between; gap: 15px; margin-top: 12px; color: var(--slate-500); font-size: 10px; }
.progress-label strong { color: var(--purple-700); }
.page-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 28px; color: var(--slate-500); font-size: 10px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 43px; padding: 0 18px; border: 0; border-radius: 11px; font: inherit; font-size: 12px; font-weight: 800; text-decoration: none; cursor: pointer; }
.button.primary { background: linear-gradient(135deg, var(--purple-800), var(--purple-600)); color: #fff; box-shadow: 0 9px 24px rgba(134,23,181,.2); }
.button.secondary { border: 1px solid var(--slate-300); background: #fff; color: var(--slate-700); }
.button.full { width: 100%; }
.alert { margin-bottom: 20px; padding: 15px 18px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.alert.danger { border: 1px solid rgba(201,71,88,.25); background: rgba(201,71,88,.08); color: #913240; }
.alert.success { border: 1px solid rgba(59,143,104,.25); background: rgba(59,143,104,.09); color: #27694c; }
.alert ul { margin: 8px 0 0; padding-left: 20px; }

.login-page { min-height: 100vh; background: linear-gradient(125deg, var(--purple-950) 0 48%, #f7f7fa 48%); }
.login-shell { display: grid; grid-template-columns: 1fr minmax(370px, 470px); align-items: center; gap: clamp(50px, 9vw, 150px); width: min(1180px, calc(100% - 48px)); min-height: 100vh; margin: auto; padding: 40px 0; }
.login-brand { max-width: 580px; color: #fff; }
.login-brand img { width: 190px; margin-bottom: 58px; }
.login-brand h1 { margin-bottom: 20px; font-size: clamp(40px, 6vw, 72px); line-height: .98; }
.login-brand p { max-width: 520px; color: rgba(255,255,255,.68); font-size: 16px; line-height: 1.7; }
.login-card { padding: clamp(30px, 4vw, 46px); border: 1px solid #ececf1; border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.login-card h2 { margin-bottom: 10px; font-size: 28px; }
.form-intro { margin-bottom: 28px; color: var(--slate-500); font-size: 13px; }
.login-help { display: block; margin-top: 20px; color: var(--slate-500); line-height: 1.5; text-align: center; }

.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field > span { color: var(--slate-700); font-size: 11px; font-weight: 800; }
.field input { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--slate-300); border-radius: 10px; outline: 0; color: var(--slate-950); font: inherit; font-size: 13px; transition: border .2s, box-shadow .2s; }
.field input:focus { border-color: var(--purple-600); box-shadow: 0 0 0 4px rgba(149,25,195,.09); }
.field input[readonly] { background: var(--slate-100); color: var(--slate-700); }
.field small { margin-top: -2px; color: var(--slate-500); font-size: 10px; line-height: 1.4; }
.form-section > .form-grid > .field {
    grid-template-rows: minmax(14px, auto) 46px 16px;
    align-content: start;
    gap: 7px;
    margin-bottom: 12px;
}
.form-section > .form-grid > .field > input,
.form-section > .form-grid > .field > .input-suffix {
    grid-row: 2;
}
.form-section > .form-grid > .field > small {
    grid-row: 3;
    min-height: 16px;
    margin: 0;
}

.table-panel { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 17px 20px; border-bottom: 1px solid var(--slate-100); text-align: left; white-space: nowrap; }
th { background: #fafafd; color: var(--slate-500); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
td { color: var(--slate-700); font-size: 12px; }
td strong, td small { display: block; }
td strong { color: var(--slate-950); font-size: 13px; }
td small { margin-top: 4px; color: var(--slate-500); }
.status-pill { display: inline-block; padding: 6px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.status-pill.on { background: rgba(59,143,104,.1); color: var(--success); }
.status-pill.off { background: var(--slate-100); color: var(--slate-500); }
.table-action { color: var(--purple-700); font-weight: 800; text-decoration: none; }
.button-link { min-height: 0; padding: 0; border: 0; background: transparent; font-size: 10px; cursor: pointer; }
.table-actions { display: flex; gap: 14px; }
.empty-state { max-width: 560px; margin: auto; padding: 70px 30px; text-align: center; }
.empty-state > span { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 20px; border-radius: 17px; background: rgba(149,25,195,.1); color: var(--purple-700); font-size: 25px; }
.empty-state h2 { margin-bottom: 10px; font-size: 22px; }
.empty-state p { margin-bottom: 24px; color: var(--slate-500); font-size: 13px; line-height: 1.6; }

.form-content { max-width: 1480px; }
.config-form { display: grid; gap: 18px; }
.form-section { padding: 28px 30px 12px; }
.form-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--slate-100); }
.form-section-heading h2 { margin: 0; font-size: 21px; }
.section-title { display: flex; align-items: center; gap: 14px; }
.section-number { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, rgba(134,23,181,.13), rgba(200,222,63,.2)); color: var(--purple-700); font-size: 10px; font-weight: 900; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 18px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.form-grid.identity-grid { grid-template-columns: minmax(260px, 1.35fr) minmax(220px, 1fr) minmax(220px, .95fr); }
.form-grid.zpro-grid { grid-template-columns: repeat(3, minmax(210px, 1fr)); }
.form-grid.inline-times { gap: 12px; }
.span-2 { grid-column: span 2; }
.switch { display: flex; align-items: center; gap: 9px; color: var(--slate-700); font-size: 11px; font-weight: 800; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--slate-300); transition: background .2s; }
.switch > span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.15); transition: transform .2s; }
.switch input:checked + span { background: var(--purple-700); }
.switch input:checked + span::after { transform: translateX(16px); }
.option-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin-top: 8px; }
.check-option { display: flex; gap: 11px; padding: 15px; border: 1px solid var(--slate-300); border-radius: 12px; cursor: pointer; }
.check-option input { margin-top: 2px; accent-color: var(--purple-700); }
.check-option span { display: grid; gap: 5px; }
.check-option strong { font-size: 11px; }
.check-option small { color: var(--slate-500); font-size: 9px; line-height: 1.45; }
.form-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 18px 0; background: rgba(247,247,250,.94); backdrop-filter: blur(8px); }
.connection-tests { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-bottom: 18px; padding: 16px 18px; border: 1px solid #e6e2e9; border-radius: 15px; background: #fff; box-shadow: 0 8px 24px rgba(44,31,52,.035); }
.connection-copy { display: grid; gap: 4px; }
.connection-copy span { color: var(--slate-950); font-size: 12px; font-weight: 900; }
.connection-copy small { color: var(--slate-500); font-size: 10px; }
.connection-actions { display: flex; gap: 9px; }
.connection-actions .button { gap: 8px; }
.connection-actions b { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 7px; background: rgba(149,25,195,.1); color: var(--purple-700); font-size: 9px; }
.field input { background: #fcfcfd; }
.field input:hover { border-color: #c5c1cb; }

.page-subtitle { margin: 9px 0 0; color: var(--slate-500); font-size: 13px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-actions form { margin: 0; }
.safe-notice { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; padding: 14px 17px; border: 1px solid rgba(200,222,63,.45); border-radius: 14px; background: rgba(200,222,63,.11); }
.safe-notice > span { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 50%; background: var(--lime-500); color: var(--purple-950); font-weight: 900; }
.safe-notice strong { font-size: 12px; }
.safe-notice p { margin: 3px 0 0; color: var(--slate-700); font-size: 11px; }
.agenda-grid { display: grid; gap: 18px; }
.agenda-card { padding: 26px 28px 20px; }
.agenda-card.is-inactive { opacity: .68; }
.agenda-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--slate-100); }
.agenda-heading h2 { margin: 6px 0 5px; font-size: 20px; }
.agenda-heading p { margin: 0; color: var(--slate-500); font-size: 11px; }
.agenda-id { color: var(--purple-700); font-size: 9px; font-weight: 900; letter-spacing: .1em; }
.agenda-switches { display: flex; gap: 28px; padding: 18px 0; }
.agenda-fields { align-items: end; }
.agenda-save { display: flex; align-items: center; min-height: 46px; }
.agenda-save .button { width: 100%; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 65px; }
.input-suffix b { position: absolute; top: 16px; right: 12px; color: var(--slate-500); font-size: 10px; }
.agenda-footer { padding-top: 13px; border-top: 1px solid var(--slate-100); color: var(--slate-500); font-size: 9px; text-align: right; }
.operation-bar { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; padding: 20px 24px; }
.operation-bar form { display: flex; align-items: end; gap: 12px; margin: 0; }
.operation-bar .field { min-width: 160px; margin: 0; }
.panel-title { display: flex; align-items: center; justify-content: space-between; padding: 23px 25px 17px; }
.panel-title h2 { margin: 0; font-size: 20px; }
.count-badge { display: grid; place-items: center; min-width: 34px; height: 28px; padding: 0 9px; border-radius: 999px; background: rgba(149,25,195,.1); color: var(--purple-700); font-size: 11px; font-weight: 900; }
.queue-panel { margin-top: 18px; }
.empty-state.compact { padding: 25px; }
.preview { position: relative; }
.preview summary { color: var(--purple-700); font-size: 10px; font-weight: 900; cursor: pointer; }
.preview div { position: absolute; z-index: 5; right: 0; width: 270px; display: grid; gap: 7px; padding: 15px; border: 1px solid var(--slate-300); border-radius: 12px; background: #fff; box-shadow: var(--shadow); white-space: normal; }
.preview span, .preview small { color: var(--slate-700); font-size: 10px; }
.preview small { color: var(--slate-500); line-height: 1.4; }

@media (max-width: 1100px) {
    .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lower-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .sidebar { position: static; width: 100%; padding: 18px 20px; flex-direction: row; align-items: center; }
    .brand { width: 90px; margin: 0; }
    .navigation { display: none; }
    .sidebar-footer { margin: 0 0 0 auto; padding: 0; border: 0; }
    .content { width: 100%; margin-left: 0; padding: 27px 18px 22px; }
    .topbar { align-items: flex-start; }
    .hero-card { min-height: 280px; }
    .hero-mark { opacity: .65; }
    .login-page { background: var(--purple-950); }
    .login-shell { grid-template-columns: 1fr; width: min(100% - 32px, 500px); gap: 28px; }
    .login-brand img { width: 120px; margin-bottom: 25px; }
    .login-brand h1 { font-size: 37px; }
    .login-brand p { display: none; }
    .form-grid, .form-grid.three, .form-grid.identity-grid, .form-grid.zpro-grid, .option-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .form-section-heading { display: grid; }
    .header-actions, .agenda-heading, .agenda-switches { align-items: flex-start; flex-wrap: wrap; }
    .operation-bar, .operation-bar form { align-items: stretch; flex-direction: column; }
    .connection-tests { align-items: stretch; flex-direction: column; }
    .connection-actions { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (min-width: 761px) and (max-width: 1180px) {
    .form-grid.identity-grid, .form-grid.zpro-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 520px) {
    .metrics-grid { grid-template-columns: 1fr; }
    .topbar { display: grid; }
    .health-badge { justify-self: start; }
    .sidebar-footer strong { display: none; }
    .hero-card { padding: 29px 24px; }
    .panel-heading, .feature-row, .page-footer { align-items: flex-start; }
    .feature-row { display: grid; }
}
