:root {
    color-scheme: dark;
    --bg: #0b101c;
    --panel: rgba(17, 24, 39, 0.78);
    --panel-strong: rgba(12, 18, 31, 0.92);
    --line: rgba(255, 255, 255, 0.12);
    --line-strong: rgba(255, 255, 255, 0.2);
    --text: #f8fafc;
    --muted: #aab2c0;
    --accent: #ff7a45;
    --danger: #ff5a5f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    letter-spacing: 0;
}

button,
.button-link {
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #ffffff, #eceff5);
    color: #111827;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    min-height: 42px;
    padding: 0 18px;
    text-decoration: none;
    white-space: nowrap;
}

button.danger {
    background: linear-gradient(135deg, #ff6b6b, #ff9f43);
}

.ghost-button,
.button-link.ghost {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    color: var(--text);
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    background: rgba(4, 9, 18, 0.7);
    color: var(--text);
    font: inherit;
    padding: 12px 13px;
}

textarea {
    resize: vertical;
}

label {
    color: var(--muted);
    display: grid;
    gap: 7px;
    font-weight: 700;
}

.admin-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% 20%, rgba(255, 79, 114, 0.18), transparent 28%),
        radial-gradient(circle at 78% 8%, rgba(89, 121, 255, 0.2), transparent 26%),
        linear-gradient(180deg, #0b101c 0%, #101522 100%);
    color: var(--text);
}

.admin-shell {
    width: min(1320px, calc(100% - 32px));
    margin: 0 auto;
    padding: 18px 0 48px;
}

.admin-topbar {
    align-items: center;
    background: rgba(14, 20, 33, 0.72);
    border: 1px solid var(--line);
    border-radius: 22px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 14px;
    padding: 18px 20px;
}

.admin-topbar h1,
.login-panel h1,
.admin-panel h2,
.source-editor h3,
.menu-line-card h2,
.display-hero h1 {
    margin: 0;
}

.brand-mark {
    display: flex;
    height: 24px;
    margin-bottom: 10px;
    position: relative;
    width: 86px;
}

.brand-mark span {
    border: 5px solid #16c784;
    border-radius: 999px;
    display: block;
    height: 24px;
    position: absolute;
    width: 24px;
}

.brand-mark span:nth-child(2) {
    border-color: #ffd166;
    left: 25px;
}

.brand-mark span:nth-child(3) {
    border-color: #ff4d4d;
    left: 50px;
}

.admin-tabs {
    background: rgba(14, 20, 33, 0.66);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
    padding: 8px;
}

.admin-tabs a,
.row-actions a {
    border-radius: 999px;
    color: var(--muted);
    font-weight: 800;
    padding: 10px 14px;
    text-decoration: none;
}

.admin-tabs a.active,
.row-actions a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.status-banner,
.admin-panel,
.metric-panel,
.login-panel {
    backdrop-filter: blur(18px);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.3);
}

.status-banner {
    margin-bottom: 18px;
    padding: 14px 18px;
}

.status-banner.error {
    border-color: rgba(255, 90, 95, 0.55);
}

.admin-panel {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
    padding: 22px;
}

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

.panel-head p,
.muted,
.import-summary span {
    color: var(--muted);
    margin: 5px 0 0;
}

.metric-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    margin-bottom: 18px;
}

.metric-panel {
    display: grid;
    gap: 8px;
    padding: 22px;
}

.metric-panel span {
    color: var(--muted);
    font-weight: 800;
    text-transform: uppercase;
}

.metric-panel strong {
    font-size: 3rem;
    line-height: 1;
}

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

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

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

.check-row input {
    width: auto;
}

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

.row-actions {
    justify-content: flex-end;
}

.row-actions.forms button {
    min-height: 36px;
}

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

.table-row,
.import-row {
    align-items: center;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--line);
    border-radius: 16px;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 14px;
}

.table-row > div:first-child {
    display: grid;
    gap: 4px;
}

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

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

.source-editor {
    border: 1px solid var(--line);
    border-radius: 18px;
    display: grid;
    gap: 12px;
    padding: 16px;
}

.allergen-chip {
    align-items: center;
    background: #fff;
    border-radius: 999px;
    color: #111827;
    display: inline-flex;
    font-size: 0.8rem;
    font-weight: 900;
    justify-content: center;
    min-height: 28px;
    min-width: 28px;
    padding: 0 8px;
}

.import-row {
    align-items: stretch;
    display: grid;
}

.discovery-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.discovery-list span {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    color: var(--muted);
    padding: 7px 10px;
}

.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
}

.login-panel {
    display: grid;
    gap: 18px;
    padding: 34px;
    width: min(460px, calc(100% - 28px));
}

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

.field-error {
    color: #fecaca;
    font-weight: 700;
}

.role-help {
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--line);
    border-radius: 16px;
    color: var(--muted);
    display: grid;
    gap: 6px;
    padding: 14px;
}

.role-help p {
    margin: 0;
}

.discord-preview {
    background: #11151c;
    border-left: 5px solid #8b5cf6;
    border-radius: 8px;
    display: grid;
    gap: 10px;
    max-width: 640px;
    padding: 16px 18px;
}

.discord-preview h3,
.discord-preview p {
    margin: 0;
}

.discord-preview p {
    color: #d1d5db;
}

.discord-fields {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    margin-top: 14px;
}

.discord-fields span {
    color: #d1d5db;
    display: grid;
    gap: 4px;
}

.discord-fields strong {
    color: #f8fafc;
    font-size: 0.82rem;
}

.display-body {
    background: #090d16;
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.display-body::before {
    background:
        radial-gradient(circle at 15% 82%, rgba(255, 76, 112, 0.52), transparent 24%),
        radial-gradient(circle at 86% 70%, rgba(255, 128, 56, 0.5), transparent 28%),
        radial-gradient(circle at 55% 18%, rgba(91, 111, 255, 0.32), transparent 24%),
        linear-gradient(180deg, #101622 0%, #080d16 100%);
    content: "";
    inset: 0;
    position: fixed;
    z-index: -2;
}

.display-body::after {
    background: linear-gradient(180deg, rgba(7, 11, 19, 0.22), rgba(7, 11, 19, 0.72));
    content: "";
    inset: 0;
    position: fixed;
    z-index: -1;
}

.display-shell {
    display: grid;
    gap: 16px;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    min-height: 100vh;
    padding: 28px;
}

.display-shell.is-embed {
    padding: 18px;
}

.display-hero,
.menu-glass {
    backdrop-filter: blur(20px);
    background: rgba(13, 19, 32, 0.78);
    border: 1px solid var(--line-strong);
    border-radius: 24px;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.34);
}

.display-hero {
    display: grid;
    min-height: clamp(116px, 15vh, 172px);
    padding: clamp(18px, 2vw, 28px);
}

.hero-title-row {
    align-items: center;
    display: flex;
    gap: 18px;
    justify-content: space-between;
}

.display-kicker {
    color: var(--display-accent, #ff7a45);
    display: block;
    font-weight: 900;
    letter-spacing: 0.14em;
    margin-bottom: 7px;
    text-transform: uppercase;
}

.display-hero h1 {
    font-size: clamp(2.4rem, 4.35vw, 5.7rem);
    line-height: 0.98;
    overflow-wrap: anywhere;
}

.display-muted {
    color: var(--muted);
    font-size: 1.2rem;
}

.display-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.display-pills span {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #f8fafc;
    font-size: clamp(1rem, 1.2vw, 1.35rem);
    font-weight: 900;
    padding: 10px 16px;
    white-space: nowrap;
}

.menu-glass {
    display: grid;
    gap: 16px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 0;
    overflow: hidden;
    padding: 18px;
}

.menu-glass::before {
    background: linear-gradient(90deg, var(--display-accent, #ff7a45), #5eead4);
    border-radius: 999px;
    content: "";
    height: 4px;
    width: 100%;
}

.menu-columns {
    display: grid;
    gap: clamp(12px, 1vw, 18px);
    align-content: start;
    grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
    min-height: 0;
    overflow: hidden;
}

.menu-line-card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 18px;
    color: #0b1020;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    min-height: 0;
    overflow: hidden;
    padding: clamp(16px, 1.2vw, 22px);
}

.menu-line-card h2 {
    color: #0b1020;
    font-size: clamp(1.05rem, 1.2vw, 1.45rem);
}

.menu-line-card ul {
    display: grid;
    align-content: start;
    gap: clamp(8px, 0.75vw, 12px);
    list-style: none;
    margin: 0;
    min-height: 0;
    overflow: hidden;
    padding: 0;
}

.menu-line-card li {
    align-items: center;
    background: linear-gradient(180deg, #ffffff, #f4f7fb);
    border: 1px solid #dde5ef;
    border-radius: 14px;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: clamp(58px, 6vh, 86px);
    overflow: hidden;
    padding: clamp(11px, 1vw, 16px);
}

.menu-line-card li > span:first-child {
    font-size: calc(clamp(1.18rem, 1.65vw, 2.38rem) * var(--item-scale, 1));
    font-weight: 900;
    line-height: 1.08;
    min-width: 0;
    overflow-wrap: anywhere;
}

.density-compact .menu-line-card li > span:first-child,
.menu-line-card li.item-long > span:first-child {
    font-size: calc(clamp(1.08rem, 1.42vw, 2.05rem) * var(--item-scale, 1));
}

.menu-line-card li.item-very-long > span:first-child {
    font-size: calc(clamp(0.98rem, 1.22vw, 1.72rem) * var(--item-scale, 1));
}

.menu-line-card li.item-many-allergens.item-long {
    align-items: start;
    grid-template-columns: minmax(0, 1fr);
}

.menu-line-card li.item-many-allergens.item-long .allergen-badges {
    justify-content: flex-start;
}

.error-card {
    background: rgba(255, 237, 237, 0.96);
}

.allergen-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    min-width: 0;
}

.allergen-badges b,
.allergen-key b {
    align-items: center;
    background: #111827;
    border: 2px solid rgba(255, 255, 255, 0.88);
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 1rem;
    font-weight: 900;
    justify-content: center;
    line-height: 1;
    min-height: 42px;
    min-width: 42px;
    padding: 0 11px;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.42);
}

.allergen-badges b {
    box-shadow: 0 9px 18px rgba(15, 23, 42, 0.26);
    font-size: clamp(0.86rem, 0.8vw, 1.12rem);
    min-height: clamp(34px, 2.3vw, 46px);
    min-width: clamp(34px, 2.3vw, 46px);
    padding: 0 9px;
}

.allergen-badges b[data-allergen="milk"],
.allergen-key b[data-allergen="milk"] {
    background: #2563eb;
}

.allergen-badges b[data-allergen="egg"],
.allergen-key b[data-allergen="egg"] {
    background: #ca8a04;
}

.allergen-badges b[data-allergen="wheat"],
.allergen-key b[data-allergen="wheat"] {
    background: #9a3412;
}

.allergen-badges b[data-allergen="soy"],
.allergen-key b[data-allergen="soy"] {
    background: #15803d;
}

.allergen-badges b[data-allergen="peanut"],
.allergen-key b[data-allergen="peanut"] {
    background: #be123c;
}

.allergen-badges b[data-allergen="tree-nut"],
.allergen-key b[data-allergen="tree-nut"] {
    background: #7c3aed;
}

.allergen-badges b[data-allergen="fish"],
.allergen-key b[data-allergen="fish"] {
    background: #0891b2;
}

.allergen-badges b[data-allergen="sesame"],
.allergen-key b[data-allergen="sesame"] {
    background: #c2410c;
}

.allergen-key {
    align-items: center;
    background: rgba(6, 10, 18, 0.55);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
}

.closed-board {
    align-items: center;
    backdrop-filter: blur(20px);
    background:
        radial-gradient(circle at 18% 18%, rgba(255, 122, 69, 0.32), transparent 28%),
        linear-gradient(135deg, rgba(13, 19, 32, 0.88), rgba(6, 10, 18, 0.92));
    border: 1px solid var(--line-strong);
    border-radius: 24px;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.34);
    display: grid;
    gap: clamp(24px, 4vw, 70px);
    grid-template-columns: minmax(190px, 0.32fr) minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
    padding: clamp(32px, 5vw, 84px);
}

.closed-board h2 {
    font-size: clamp(4rem, 10vw, 12rem);
    line-height: 0.9;
    margin: 0;
}

.closed-board p {
    color: var(--muted);
    font-size: clamp(1.35rem, 2vw, 2.6rem);
    font-weight: 800;
    margin: 18px 0 0;
}

.closed-orbit {
    aspect-ratio: 1;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    display: grid;
    max-width: 360px;
    place-items: center;
    position: relative;
}

.closed-orbit::before {
    background: linear-gradient(135deg, var(--display-accent, #ff7a45), #5eead4);
    border-radius: 999px;
    content: "";
    height: 34%;
    width: 34%;
}

.closed-orbit span {
    border: 8px solid rgba(255, 255, 255, 0.18);
    border-left-color: var(--display-accent, #ff7a45);
    border-radius: 999px;
    inset: 14%;
    position: absolute;
}

.closed-orbit span:nth-child(2) {
    inset: 27%;
}

.closed-orbit span:nth-child(3) {
    inset: 40%;
}

.allergen-key strong {
    color: var(--text);
}

.allergen-key span {
    align-items: center;
    display: inline-flex;
    gap: 8px;
    font-size: 1.02rem;
    font-weight: 800;
}

.allergen-key b {
    font-size: 0.9rem;
    min-height: 32px;
    min-width: 32px;
    padding: 0 9px;
}

@media (max-width: 760px) {
    .admin-shell,
    .display-shell,
    .display-shell.is-embed {
        width: 100%;
        padding: 10px;
    }

    .admin-topbar,
    .hero-title-row,
    .panel-head,
    .table-row {
        align-items: stretch;
        flex-direction: column;
    }

    .display-hero h1 {
        font-size: 2.4rem;
    }

    .display-pills {
        justify-content: flex-start;
    }

    .closed-board {
        grid-template-columns: 1fr;
    }
}
