:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #17202a;
    --muted: #667085;
    --line: #d9dee7;
    --accent: #176b5d;
    --accent-dark: #105146;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.55;
}

h1,
h2,
h3 {
    color: var(--heading, var(--text));
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.topbar nav a {
    color: var(--accent-dark);
    font-weight: 650;
}

.brand {
    color: var(--text);
    font-weight: 700;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.page-menu {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    list-style: none;
}

.page-menu li {
    position: relative;
}

.page-menu .page-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 20;
    display: none;
    min-width: 220px;
    gap: 0;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 16px 40px rgba(16, 24, 40, 0.14);
}

.page-menu li:hover > .page-menu,
.page-menu li:focus-within > .page-menu {
    display: grid;
}

.page-menu .page-menu a {
    display: block;
    padding: 8px 10px;
    border-radius: 6px;
    white-space: nowrap;
}

.page-menu .page-menu a:hover {
    background: #eef2f6;
    text-decoration: none;
}

.container {
    width: min(1120px, calc(100% - 32px));
    margin: 32px auto;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
}

.panel + .panel {
    margin-top: 18px;
}

.narrow {
    max-width: 440px;
    margin: 56px auto;
}

.notice {
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid #9ed6c8;
    border-radius: 8px;
    background: #e9f8f4;
}

.muted {
    color: var(--muted);
}

.heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.heading-row h1,
.heading-row h2 {
    margin: 0;
}

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}

.button.secondary,
button.secondary {
    background: #eef2f6;
    color: var(--text);
}

.button.secondary:hover,
button.secondary:hover {
    background: #dfe6ef;
    color: var(--text);
}

.button:hover,
button:hover {
    background: var(--accent-dark);
    color: #fff;
    text-decoration: none;
}

button.danger,
.button.danger {
    background: var(--danger);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.form {
    display: grid;
    gap: 16px;
}

.form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 650;
}

.form input,
.form textarea,
.form select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font: inherit;
}

.form textarea {
    resize: vertical;
}

.form .check {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.form .check input {
    width: auto;
}

.editor textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
}

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

.checkbox-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.builder-shell {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    padding: 16px;
}

.admin-hero {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.admin-hero h1 {
    margin: 0;
    font-size: 34px;
    line-height: 1.1;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-module-grid,
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin: 18px 0;
}

.module-card,
.endpoint-card {
    display: grid;
    gap: 6px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

.module-card:hover {
    border-color: var(--accent);
    text-decoration: none;
}

.module-card span,
.endpoint-card span {
    color: var(--muted);
    font-size: 14px;
}

.endpoint-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    margin: 14px 0;
}

.endpoint-card code,
.break-anywhere {
    overflow-wrap: anywhere;
}

.danger-zone {
    border-color: #f1b4ae;
}

.pro-builder {
    display: grid;
    grid-template-columns: 190px minmax(360px, 1fr) minmax(280px, 420px);
    gap: 16px;
    align-items: start;
}

.builder-sidebar,
.builder-preview-panel {
    position: sticky;
    top: 16px;
}

.builder-sidebar {
    display: grid;
    gap: 10px;
}

.builder-sidebar h2,
.builder-preview-panel h2 {
    margin: 10px 0 0;
    font-size: 15px;
}

.builder-sidebar button,
.rich-toolbar button {
    width: 100%;
    min-height: 36px;
    justify-content: flex-start;
    background: #eef2f6;
    color: var(--text);
}

.builder-workspace {
    min-width: 0;
}

.builder-canvas {
    display: grid;
    gap: 14px;
}

.builder-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.builder-toolbar button,
.builder-block-head button {
    min-height: 34px;
    padding: 6px 10px;
    background: #eef2f6;
    color: var(--text);
}

.rich-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

.rich-toolbar button {
    width: auto;
}

.builder-block {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 14px;
}

.builder-block:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(23, 107, 93, 0.12);
}

.builder-block + .builder-block {
    margin-top: 12px;
}

.builder-block-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.builder-block-head div {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.builder-fields {
    display: grid;
    gap: 12px;
}

.rich-editor {
    min-height: 120px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.rich-editor:focus {
    outline: 2px solid rgba(23, 107, 93, 0.2);
}

.builder-preview {
    min-height: 420px;
    max-height: 70vh;
    overflow: auto;
    padding: 18px;
}

.html-output textarea {
    min-height: 150px;
}

.settings-group {
    display: grid;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.settings-group h2 {
    margin: 0;
}

.request-section {
    display: grid;
    gap: 16px;
    margin: 28px 0;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

.request-section h2 {
    margin: 0;
}

.request-form {
    max-width: 620px;
}

.hp-field {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.media-grid.compact {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.media-card,
.media-tile {
    display: grid;
    gap: 10px;
    text-align: left;
}

.media-card img,
.media-tile img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--line);
}

.media-tile {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

.media-tile span,
.media-card code {
    overflow-wrap: anywhere;
    font-size: 12px;
}

.profile-card {
    text-align: center;
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 78px;
    height: 78px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 34px;
    font-weight: 800;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #eef7f5;
    color: var(--accent-dark);
    font-weight: 700;
}

.content img,
.content video {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.video-embed {
    aspect-ratio: 16 / 9;
    width: 100%;
}

.video-embed iframe,
.video-embed video {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 8px;
}

.page-hero {
    display: grid;
    align-items: center;
    min-height: 420px;
    margin: -32px -32px 28px;
    padding: 56px 40px;
    border-radius: 8px 8px 0 0;
    background-position: center;
    background-size: cover;
}

.page-hero div {
    max-width: 760px;
}

.page-hero.align-center {
    justify-items: center;
    text-align: center;
}

.page-hero.align-right {
    justify-items: end;
    text-align: right;
}

.page-hero h1 {
    margin: 0 0 12px;
    color: inherit;
    font-size: clamp(34px, 7vw, 68px);
    line-height: 1.05;
}

.page-hero p {
    margin: 0;
    font-size: 20px;
}

.preview-modal {
    position: fixed;
    inset: 24px;
    z-index: 50;
    display: grid;
    grid-template-rows: auto 1fr;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
}

.preview-modal[hidden] {
    display: none;
}

.preview-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.preview-modal iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.stats div {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.stats strong {
    display: block;
    font-size: 32px;
    line-height: 1;
}

.stats span {
    color: var(--muted);
}

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

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

th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
}

.table-pre {
    max-width: 360px;
    max-height: 180px;
    overflow: auto;
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 12px;
}

.token-box {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0f172a;
    color: #e5edf6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.cookie-consent {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 60;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    width: min(560px, calc(100% - 36px));
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 50px rgba(16, 24, 40, 0.18);
}

.cookie-consent p {
    margin: 0;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #eef2f6;
    color: var(--text);
    font-size: 12px;
    font-weight: 750;
}

.status-pill.live {
    background: #e9f8f4;
    color: var(--accent-dark);
}

.status-pill.draft {
    background: #fff4e5;
    color: #92400e;
}

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

.content {
    max-width: 780px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 32px;
}

.content h1 {
    margin-top: 0;
}

@media (max-width: 720px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 16px;
    }

    .topbar nav,
    .page-menu {
        align-items: flex-start;
        flex-direction: column;
        width: 100%;
    }

    .page-menu .page-menu {
        position: static;
        display: grid;
        width: 100%;
        margin-top: 6px;
        box-shadow: none;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .form-grid,
    .account-layout,
    .admin-hero,
    .pro-builder {
        grid-template-columns: 1fr;
    }

    .admin-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .builder-sidebar,
    .builder-preview-panel,
    .rich-toolbar {
        position: static;
    }

    .page-hero {
        margin: -32px -32px 24px;
        min-height: 320px;
        padding: 36px 24px;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .cookie-consent {
        grid-template-columns: 1fr;
    }
}
