:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --panel-soft: #f0f2f5;
    --text: #20242a;
    --muted: #66727f;
    --line: #dde3ea;
    --primary: #d89f12;
    --primary-hover: #be8c10;
    --danger-bg: #fff1f1;
    --danger-text: #922d2d;
    --success-bg: #edf9f1;
    --success-text: #1e7140;
    --warning-bg: #fff8e8;
    --warning-text: #8a6500;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #fbfbfc 0%, var(--bg) 100%);
    color: var(--text);
}

.shell {
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 14px 34px;
}

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

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

.brand-lockup {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.brand-logo {
    display: block;
    width: min(100%, 520px);
    height: auto;
}

.brand-copy h1,
h2,
h3 {
    margin: 0 0 12px;
}

.brand-copy h1 {
    font-size: clamp(1.2rem, 2vw, 1.9rem);
    font-weight: 700;
}

p {
    margin: 0 0 8px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: 0 8px 22px rgba(18, 24, 32, 0.06);
}

.card.narrow {
    max-width: 440px;
}

.card.warning {
    background: #fffdf6;
    border-color: #f0d69a;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

label {
    display: block;
    font-weight: 600;
    margin: 10px 0 6px;
}

input,
select,
textarea,
button {
    width: 100%;
    font: inherit;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
}

textarea {
    resize: vertical;
    min-height: 96px;
}

button {
    border: 0;
    border-radius: 10px;
    margin-top: 14px;
    padding: 11px 14px;
    color: #fff;
    background: var(--primary);
    font-weight: 700;
    cursor: pointer;
}

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

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    background: #fff;
    text-align: center;
}

.button-link-primary {
    border-color: var(--primary);
    color: #fff;
    background: var(--primary);
    font-weight: 700;
}

.button-link:hover {
    background: var(--panel-soft);
}

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

.logout-form {
    width: auto;
}

.logout-form button {
    margin-top: 0;
    width: auto;
}

.flash {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    border: 1px solid transparent;
}

.flash-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: #f2bcbc;
}

.flash-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #b9e8c9;
}

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

.choice-group {
    margin: 14px 0 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fafbfc;
}

.choice-group legend {
    font-weight: 700;
    padding: 0 6px;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 10px;
}

.choice-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    font-weight: 500;
}

.choice-item input {
    width: auto;
    margin: 0;
    accent-color: var(--primary);
}

.field-note {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.95rem;
}

.stored-list {
    display: grid;
    gap: 10px;
}

.stored-item,
.stored-item-link {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.stored-item-link {
    text-decoration: none;
    color: inherit;
}

.stored-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.stored-actions .button-link {
    flex: 1 1 180px;
}

code {
    background: #f1f4f7;
    color: #8d6500;
    padding: 1px 5px;
    border-radius: 4px;
}

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

@media (max-width: 640px) {
    .shell {
        padding: 12px 10px 24px;
    }

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

    .topbar-actions {
        width: 100%;
    }

    .topbar-actions .button-link,
    .topbar-actions .logout-form,
    .topbar-actions .logout-form button {
        width: 100%;
    }

    .brand-logo {
        width: min(100%, 360px);
    }

    .card {
        padding: 14px;
    }

    .meta-grid,
    .choice-grid {
        grid-template-columns: 1fr;
    }

    .stored-actions {
        flex-direction: column;
    }

    .stored-actions .button-link {
        width: 100%;
        flex-basis: auto;
    }
}
