:root {
    --bg: #f4efe6;
    --bg-accent: #e2d4b7;
    --panel: #fffaf0;
    --panel-edge: #d6c4a4;
    --text: #2d2418;
    --muted: #6d5d46;
    --brand: #7a2e1f;
    --brand-dark: #531d12;
    --danger: #b1361e;
    --success: #2f6f3e;
    --shadow: 0 14px 36px rgba(73, 51, 22, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(226, 212, 183, 0.9), transparent 30%),
        linear-gradient(180deg, #fbf6ed 0%, var(--bg) 100%);
}

a {
    color: inherit;
}

.page-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.brand-block {
    flex: 1 1 320px;
}

.brand {
    font-size: 2rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--brand);
}

.tagline {
    margin: 6px 0 0;
    color: var(--muted);
}

.nav-links {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
}

.nav-links a {
    text-decoration: none;
    padding: 10px 14px;
    border: 1px solid var(--panel-edge);
    border-radius: 999px;
    background: rgba(255, 250, 240, 0.85);
}

.menu-toggle {
    display: none;
    background: var(--brand-dark);
}

.admin-nav-panel {
    display: grid;
    gap: 16px;
}

.admin-subnav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-subnav a {
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--panel-edge);
    background: rgba(255, 255, 255, 0.65);
}

.admin-subnav a.is-active {
    background: var(--brand);
    color: #fff8ef;
    border-color: var(--brand);
}

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

.flash {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--panel-edge);
    background: #fff;
}

.flash.success {
    border-color: rgba(47, 111, 62, 0.3);
    background: rgba(47, 111, 62, 0.08);
}

.flash.error {
    border-color: rgba(177, 54, 30, 0.3);
    background: rgba(177, 54, 30, 0.08);
}

.popup-stack {
    position: fixed;
    inset: 0;
    z-index: 1100;
    pointer-events: none;
}

.popup-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(43, 36, 27, 0.32);
    pointer-events: auto;
}

.popup-message {
    width: min(100%, 520px);
    padding: 20px;
    border-radius: 22px;
    border: 1px solid var(--panel-edge);
    background: rgba(255, 250, 240, 0.98);
    box-shadow: var(--shadow);
}

.popup-message.success {
    border-color: rgba(47, 111, 62, 0.3);
}

.popup-message.error {
    border-color: rgba(177, 54, 30, 0.4);
}

.popup-close {
    margin-left: auto;
    margin-bottom: 12px;
    display: inline-flex;
    background: transparent;
    color: var(--muted);
    padding: 0;
}

.popup-content {
    white-space: pre-wrap;
}

.grid {
    display: grid;
    gap: 24px;
}

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

.panel {
    background: rgba(255, 250, 240, 0.94);
    border: 1px solid var(--panel-edge);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 24px;
}

.panel.narrow {
    max-width: 480px;
    margin: 40px auto 0;
}

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

label {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

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

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

.permission-form {
    margin: 16px 0;
}

button,
.button-link {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    background: var(--brand);
    color: #fff8ef;
    text-decoration: none;
    cursor: pointer;
}

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

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

.card-list {
    display: grid;
    gap: 16px;
}

.section-gap {
    margin-top: 24px;
}

.narrow-form {
    max-width: 520px;
}

.card {
    border: 1px solid var(--panel-edge);
    border-radius: 18px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.6);
}

.card-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
}

.action-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.copy-block {
    display: grid;
    gap: 8px;
}

.copy-button {
    justify-self: end;
    padding: 8px 12px;
    border-radius: 10px;
    background: #d7c19a;
    color: var(--text);
}

.filter-bar {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
    margin: 18px 0 22px;
}

.filter-bar label {
    min-width: 180px;
}

.secondary-link {
    background: #d7c19a;
    color: var(--text);
}

[hidden] {
    display: none !important;
}

.waiting-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(43, 36, 27, 0.42);
    backdrop-filter: blur(4px);
}

.waiting-modal-card {
    display: flex;
    align-items: center;
    gap: 16px;
    width: min(100%, 420px);
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid var(--panel-edge);
    background: rgba(255, 250, 240, 0.98);
    box-shadow: var(--shadow);
}

.spinner {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid rgba(122, 46, 31, 0.18);
    border-top-color: var(--brand);
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

body.modal-open {
    overflow: hidden;
}

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

.arg-builder-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.arg-row {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--panel-edge);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.65);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-row input {
    width: auto;
}

.muted,
.input-meta {
    color: var(--muted);
}

.input-meta {
    font-size: 0.9rem;
    font-weight: 400;
}

.credentials-box {
    margin-top: 18px;
    padding: 16px;
    border-radius: 16px;
    background: rgba(226, 212, 183, 0.3);
}

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

th,
td {
    text-align: left;
    padding: 10px 8px;
    border-top: 1px solid rgba(109, 93, 70, 0.18);
}

pre {
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: #2b241b;
    color: #f4efe6;
    padding: 14px;
    border-radius: 14px;
}

@media (max-width: 900px) {
    .page-shell {
        padding: 18px;
    }

    .two-col {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 12px;
    }

    .brand-block {
        flex-basis: auto;
    }

    .tagline {
        margin-top: 4px;
    }

    .menu-toggle {
        display: inline-flex;
        width: fit-content;
        align-self: flex-start;
    }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding-top: 8px;
    }

    .nav-links.is-open {
        display: flex;
    }

    .nav-links a {
        justify-content: center;
    }

    .admin-nav-panel,
    .panel.section-gap {
        margin-top: 12px;
    }

    .admin-subnav {
        flex-direction: column;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
}
