:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-muted: #eef3ff;
    --text: #14213d;
    --text-soft: #5c6b82;
    --line: #d8e1f0;
    --primary: #1f6feb;
    --primary-strong: #1554b5;
    --danger: #c0392b;
    --success: #16794d;
    --warning: #9a6700;
    --shadow: 0 18px 40px rgba(20, 33, 61, 0.08);
    --radius: 20px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(31, 111, 235, 0.12), transparent 34%),
        linear-gradient(180deg, #f7f9ff 0%, #eef3fb 100%);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

.page-shell {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto 48px;
}

.topbar {
    width: min(1240px, calc(100% - 32px));
    margin: 24px auto;
    padding: 28px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(216, 225, 240, 0.8);
    box-shadow: var(--shadow);
    border-radius: 28px;
    backdrop-filter: blur(16px);
}

.topbar h1,
.hero-card h2,
.auth-card h2 {
    margin: 0;
    font-size: clamp(1.8rem, 2vw, 2.4rem);
    line-height: 1.1;
}

.subtitle,
.hero-card p,
.auth-card p,
.panel-header p,
.empty-state p,
.field span,
.toggle-card span,
.condition-card p,
.help-card,
.preview-meta span,
.preview-secondary,
.site-cell span,
.eyebrow {
    color: var(--text-soft);
}

.eyebrow {
    margin: 0 0 8px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 700;
}

.topbar-actions,
.hero-actions,
.row-actions,
.code-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.danger-button {
    border: none;
    border-radius: 14px;
    padding: 12px 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
    color: #fff;
    box-shadow: 0 12px 24px rgba(31, 111, 235, 0.24);
}

.ghost-button {
    background: var(--surface-muted);
    color: var(--text);
    border: 1px solid rgba(31, 111, 235, 0.12);
}

.danger-button {
    background: rgba(192, 57, 43, 0.12);
    color: var(--danger);
    border: 1px solid rgba(192, 57, 43, 0.16);
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover {
    transform: translateY(-1px);
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.flash {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: var(--shadow);
}

.flash-success {
    border-color: rgba(22, 121, 77, 0.25);
    color: var(--success);
}

.flash-error {
    border-color: rgba(192, 57, 43, 0.25);
    color: var(--danger);
}

.hero-card,
.panel-card,
.help-card,
.auth-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(216, 225, 240, 0.8);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}

.hero-card,
.panel-card,
.auth-card {
    padding: 24px;
}

.hero-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 18px;
}

.help-card {
    margin-bottom: 18px;
    padding: 18px 22px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.panel-header h3,
.condition-card h4,
.empty-state h4 {
    margin: 0 0 6px;
}

.table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.admin-table th {
    font-size: 0.86rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.site-cell {
    display: grid;
    gap: 4px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}

.status-active {
    background: rgba(22, 121, 77, 0.12);
    color: var(--success);
}

.status-inactive {
    background: rgba(192, 57, 43, 0.12);
    color: var(--danger);
}

.inline-code {
    display: inline-block;
    padding: 8px 10px;
    border-radius: 12px;
    background: #111827;
    color: #f8fafc;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.9fr);
    gap: 18px;
    align-items: start;
}

.split-layout > * {
    min-width: 0;
}

.sidebar-stack,
.stack-form {
    display: grid;
    gap: 18px;
    align-content: start;
}

.wide-form .panel-card {
    overflow: hidden;
}

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

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

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

.field span {
    font-size: 0.92rem;
    font-weight: 600;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    padding: 12px 14px;
    border-radius: 14px;
    color: var(--text);
}

.field textarea {
    resize: vertical;
}

.field-error,
.inline-error {
    color: var(--danger);
    font-size: 0.88rem;
}

.inline-error {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(192, 57, 43, 0.08);
}

.toggle-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: linear-gradient(180deg, #fafcff 0%, #f3f7ff 100%);
    border: 1px solid rgba(216, 225, 240, 0.9);
    border-radius: 18px;
    padding: 16px;
}

.warning-toggle {
    border-color: rgba(154, 103, 0, 0.18);
}

.toggle-card strong,
.condition-card h4 {
    display: block;
    margin-bottom: 4px;
}

.toggle-card input,
.condition-toggle input {
    margin-top: 4px;
    width: 18px;
    height: 18px;
}

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

.condition-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
}

.condition-toggle {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.compact-field textarea,
.compact-field input {
    min-height: auto;
}

.preview-box {
    position: relative;
    min-height: 280px;
    overflow: hidden;
    border-radius: 22px;
    border: 1px solid rgba(216, 225, 240, 0.9);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.72) 0%, rgba(255,255,255,0.86) 100%),
        repeating-linear-gradient(90deg, rgba(31,111,235,.04) 0, rgba(31,111,235,.04) 1px, transparent 1px, transparent 22px);
}

.preview-overlay {
    position: absolute;
    inset: 0;
    opacity: 0.74;
}

.preview-gateway {
    position: absolute;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 420px;
    padding: 18px;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 18px 40px rgba(20, 33, 61, 0.14);
    text-align: center;
}

.preview-button {
    border: none;
    border-radius: 28px;
    padding: 14px 30px;
    min-width: 220px;
    font-weight: 700;
    cursor: pointer;
}

.preview-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
}

.sticky-card {
    position: sticky;
    top: 16px;
}

.flat-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 10px;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(560px, 100%);
}

.auth-card-copy {
    margin-bottom: 16px;
}

.empty-state {
    text-align: center;
    padding: 18px 8px;
}

@media (max-width: 1080px) {
    .split-layout {
        grid-template-columns: 1fr;
    }

    .sticky-card {
        position: static;
    }
}

@media (max-width: 760px) {
    .topbar,
    .hero-card,
    .panel-header,
    .form-grid,
    .conditions-grid {
        grid-template-columns: 1fr;
        display: grid;
    }

    .topbar {
        padding: 20px;
    }

    .page-shell,
    .topbar {
        width: min(100% - 20px, 1240px);
    }

    .admin-table th,
    .admin-table td {
        min-width: 140px;
    }
}
