:root {
    color-scheme: light;
    --font-sans: "Manrope", "Segoe UI", sans-serif;
    --font-display: "Syne", "Segoe UI", sans-serif;
    --ink: #121a22;
    --ink-soft: #3a4a58;
    --muted: #677887;
    --paper: #e8eef2;
    --surface: #f7fafb;
    --border: #cfd8df;
    --border-strong: #b5c1cb;
    --primary: #1a5f4a;
    --primary-hover: #144c3b;
    --primary-soft: #e4f0eb;
    --danger: #9b2c2c;
    --danger-soft: #fce8e8;
    --success: #1b6b45;
    --success-soft: #e6f5ee;
    --focus: #2a8f70;
    --header: #14212b;
    --radius: 14px;
    --shadow: 0 1px 0 rgba(20, 33, 43, 0.04),
        0 12px 32px rgba(20, 33, 43, 0.06);
    font-family: var(--font-sans);
    line-height: 1.5;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(
            ellipse 80% 50% at 100% -10%,
            rgba(26, 95, 74, 0.08),
            transparent 55%
        ),
        radial-gradient(
            ellipse 60% 40% at 0% 100%,
            rgba(20, 33, 43, 0.05),
            transparent 50%
        ),
        var(--paper);
}

a {
    color: var(--primary);
}

.admin-shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    min-height: 100vh;
}

.admin-sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 24px 16px;
    color: #f7f4ef;
    background: var(--header);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
    margin: 0 8px 20px;
    color: inherit;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.sidebar-user {
    margin: 0 8px 16px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-user-name {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.sidebar-user-email {
    margin-top: 4px;
    color: rgba(247, 244, 239, 0.55);
    font-size: 0.78rem;
    overflow-wrap: anywhere;
}

.sidebar-label {
    margin: 0 12px 4px;
    color: rgba(247, 244, 239, 0.45);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    color: rgba(247, 244, 239, 0.72);
    font-size: 0.925rem;
    font-weight: 500;
    text-decoration: none;
    transition:
        color 0.15s ease,
        background 0.15s ease;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-link.is-active {
    color: #fff;
    background: rgba(26, 95, 74, 0.45);
}

.admin-main {
    min-width: 0;
}

.page-content {
    width: min(1080px, calc(100% - 40px));
    margin-inline: auto;
    padding-block: 40px 64px;
}

.sidebar-link:focus-visible,
.button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.page-heading,
.actions,
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.page-heading h1 {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 3vw, 2.15rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.page-heading .muted {
    margin: 0;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.card,
.table-wrap,
.notice {
    margin-block: 20px;
    padding: 22px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 28px;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.panel p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.95rem;
}

.panel .button {
    margin-top: auto;
    align-self: flex-start;
}

.panel-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.panel-meta::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
}

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

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

th,
td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

.details {
    display: grid;
    grid-template-columns: minmax(160px, 0.35fr) 1fr;
    margin: 0;
}

.details dt,
.details dd {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.details dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #fff;
    background: var(--primary);
    font: inherit;
    font-size: 0.925rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.button:hover {
    background: var(--primary-hover);
}

.button-secondary {
    border-color: var(--border-strong);
    color: var(--ink);
    background: var(--surface);
}

.button-secondary:hover {
    background: var(--paper);
}

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

.button-danger:hover {
    background: #7f2323;
}

.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: #eef1f4;
    font-size: 0.8125rem;
    font-weight: 600;
}

.status-captured,
.status-succeeded {
    color: var(--success);
    background: var(--success-soft);
}

.status-failed,
.status-canceled {
    color: var(--danger);
    background: var(--danger-soft);
}

.notice-success {
    color: var(--success);
    border-color: #b7e4cb;
    background: var(--success-soft);
}

.notice-error {
    color: var(--danger);
    border-color: #f0bdbd;
    background: var(--danger-soft);
}

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

.form-card {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--ink-soft);
    font-size: 0.875rem;
    font-weight: 600;
}

.form-label-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-label-row label {
    margin: 0;
}

.field-help {
    position: relative;
    display: inline-flex;
}

.field-help-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    color: var(--ink-soft);
    background: var(--paper);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    list-style: none;
    cursor: help;
}

.field-help-trigger::-webkit-details-marker {
    display: none;
}

.field-help-trigger:hover,
.field-help-trigger:focus-visible,
.field-help[open] .field-help-trigger {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
}

.field-help-trigger:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.field-help-popup {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 20;
    width: min(340px, 70vw);
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow);
    font-weight: 500;
}

.field-help-title {
    margin: 0 0 6px;
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 700;
}

.field-help-popup p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.82rem;
    line-height: 1.45;
}

.field-help-popup p + p {
    margin-top: 8px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.form-field-wide {
    grid-column: 1 / -1;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    font-weight: 500;
}

.form-field textarea {
    min-height: 140px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.45;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
}

.metadata {
    margin: 0;
    padding-left: 20px;
}

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

.auth-gate {
    width: min(420px, 100%);
}

.auth-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 32px 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-card h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.auth-card .muted {
    margin: 0;
}

.auth-card .button {
    align-self: flex-start;
    margin-top: 8px;
}

.auth-card .notice {
    margin: 0;
}

.auth-brand {
    margin: 0;
    color: var(--primary);
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.metadata {
    margin: 0;
    padding-left: 20px;
}

@media (max-width: 860px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        padding-bottom: 16px;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .brand {
        margin-bottom: 12px;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }

    .sidebar-link {
        padding: 8px 12px;
    }

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

@media (max-width: 680px) {
    .page-heading,
    .page-actions,
    .actions,
    .pagination {
        align-items: stretch;
        flex-direction: column;
    }

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

    .details dt {
        padding-bottom: 0;
        border-bottom: 0;
    }

    .details dd {
        padding-top: 3px;
    }
}
