:root {
    --bg: #f4f2ec;
    --bg-deep: #dce6ea;
    --panel: rgba(251, 252, 250, 0.95);
    --panel-soft: #e9eff0;
    --panel-strong: #fffdf9;
    --text: #24313a;
    --muted: #667784;
    --line: rgba(96, 124, 139, 0.18);
    --accent: #6f8fa1;
    --accent-strong: #4f6d7c;
    --accent-soft: #b7d3cf;
    --success: #1d6b45;
    --danger: #8e2f2f;
    --warning: #8a6419;
    --radius: 22px;
    --shadow: 0 24px 60px rgba(72, 96, 112, 0.12);
    --shadow-soft: 0 14px 30px rgba(82, 106, 120, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Trebuchet MS", "Helvetica Neue", Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(111, 143, 161, 0.16), transparent 24%),
        radial-gradient(circle at 85% 10%, rgba(183, 211, 207, 0.24), transparent 22%),
        linear-gradient(180deg, #fffdf9 0%, var(--bg) 42%, var(--bg-deep) 100%);
    color: var(--text);
    overflow-x: hidden;
    line-height: 1.55;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
}

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

.site-shell {
    min-height: 100vh;
    position: relative;
}

.site-shell::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(120deg, rgba(255, 255, 255, 0.24), transparent 30%),
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.16), transparent 24%);
    opacity: 0.8;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    border-bottom: 1px solid rgba(111, 143, 161, 0.14);
    background:
        linear-gradient(180deg, rgba(252, 253, 251, 0.97), rgba(234, 241, 242, 0.93));
    backdrop-filter: blur(16px);
    box-shadow: 0 10px 30px rgba(90, 112, 127, 0.08);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.03em;
    color: var(--accent-strong);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.topnav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: center;
    justify-content: flex-end;
}

.topnav-mobile {
    display: none;
}

.topnav a,
.topnav-button,
.nav-dropdown summary,
.topnav-mobile__toggle,
.topnav-mobile__grid a {
    padding: 0.7rem 0.95rem;
    border-radius: 999px;
    color: var(--muted);
    background: rgba(249, 251, 249, 0.52);
    border: 0;
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
    text-align: center;
    transition: transform 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.topnav a:hover,
.topnav-button:hover,
.topnav-mobile__toggle:hover,
.topnav-mobile__grid a:hover,
.nav-dropdown summary:hover,
.nav-dropdown[open] summary {
    background: rgba(240, 246, 247, 0.96);
    color: var(--accent-strong);
    box-shadow: inset 0 0 0 1px rgba(111, 143, 161, 0.12);
    transform: translateY(-1px);
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown summary::-webkit-details-marker {
    display: none;
}

.topnav-mobile__toggle::-webkit-details-marker {
    display: none;
}

.nav-dropdown__menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 220px;
    max-width: min(92vw, 320px);
    display: grid;
    gap: 0.25rem;
    padding: 0.5rem;
    background: rgba(250, 252, 251, 0.98);
    border: 1px solid rgba(111, 143, 161, 0.12);
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
    z-index: 20;
}

.nav-dropdown__menu a {
    border-radius: 12px;
}

.logout-form {
    margin: 0;
}

.topnav-mobile__grid {
    display: grid;
    gap: 0.65rem;
}

.page-wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2.25rem 2rem 3rem;
    width: 100%;
    position: relative;
    z-index: 1;
}

.hero,
.panel,
.auth-card,
.subpanel,
.stat-card {
    background: var(--panel);
    border: 1px solid rgba(111, 143, 161, 0.1);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero {
    padding: 2.4rem;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(255, 252, 247, 0.96), rgba(232, 241, 244, 0.94)),
        var(--panel);
}

.hero::after {
    content: "";
    position: absolute;
    inset: auto -12% -28% auto;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(183, 211, 207, 0.28), transparent 65%);
    pointer-events: none;
}

.hero-media {
    display: grid;
    gap: 1.5rem;
}

.hero-media--with-image {
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
    align-items: center;
}

.hero-media__visual img,
.media-preview img {
    width: 100%;
    display: block;
    border-radius: 16px;
    object-fit: cover;
}

.hero-media__visual img {
    max-height: 360px;
    box-shadow: 0 24px 40px rgba(88, 111, 126, 0.18);
}

.hero-tight {
    padding: 1.5rem 2rem;
}

.panel,
.auth-card,
.subpanel {
    padding: 1.6rem;
}

.auth-card {
    max-width: 680px;
    margin: 4rem auto;
    display: grid;
    gap: 1.5rem;
}

.auth-helper {
    margin: 0;
    color: var(--muted);
}

.auth-helper a {
    color: var(--accent);
    font-weight: 600;
}

.eyebrow {
    margin: 0 0 0.5rem;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

h1,
h2,
h3,
.brand {
    font-family: Georgia, "Times New Roman", serif;
}

h1,
h2,
h3 {
    margin-top: 0;
    color: #324651;
    line-height: 1.15;
}

h1 {
    font-size: clamp(2rem, 4vw, 3.6rem);
    margin-bottom: 0.9rem;
}

h2 {
    font-size: clamp(1.35rem, 2.8vw, 2rem);
}

h3 {
    font-size: 1.25rem;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.cards-grid,
.stats-grid,
.details-grid {
    display: grid;
    gap: 1rem;
}

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

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

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

.formula-card {
    border: 1px solid var(--line);
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(246, 234, 221, 0.98));
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.formula-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 6px;
    background: linear-gradient(180deg, var(--accent-soft), var(--accent));
}

.formula-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 26px 46px rgba(92, 117, 132, 0.14);
    border-color: rgba(111, 143, 161, 0.22);
}

.formula-card__body {
    padding: 1.4rem 1.4rem 1.5rem;
    display: grid;
    gap: 1.15rem;
}

.formula-card__top {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.meta-list {
    margin: 0;
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 16px;
    background: rgba(243, 248, 248, 0.86);
    border: 1px solid rgba(111, 143, 161, 0.08);
}

.meta-list div {
    display: grid;
    gap: 0.2rem;
}

.meta-list dt {
    color: var(--muted);
    font-size: 0.85rem;
}

.meta-list dd {
    margin: 0;
}

.grid-form,
.ingredient-row,
.inline-form,
.actions,
.stack-md,
.stack-lg,
.stack-xl {
    display: grid;
    gap: 1rem;
}

.two-cols {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.grid-form label,
.stack-md label,
.stack-lg label {
    display: grid;
    gap: 0.45rem;
}

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

input,
textarea,
select {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.95);
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: rgba(111, 143, 161, 0.42);
    box-shadow: 0 0 0 4px rgba(111, 143, 161, 0.12);
}

textarea {
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.15rem;
    border-radius: 999px;
    border: 0;
    cursor: pointer;
    font-weight: 600;
    transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    box-shadow: 0 14px 24px rgba(79, 109, 124, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #9a5331, #6c341c);
    transform: translateY(-1px);
}

.btn-light {
    background: rgba(233, 239, 240, 0.92);
    color: var(--text);
    box-shadow: inset 0 0 0 1px rgba(111, 143, 161, 0.08);
}

.btn-danger {
    background: #f3d8d8;
    color: var(--danger);
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.check input {
    width: auto;
}

.flash {
    margin-bottom: 1rem;
    padding: 1rem 1.15rem;
    border-radius: 16px;
    border: 1px solid transparent;
    box-shadow: var(--shadow-soft);
}

.flash-success {
    background: rgba(29, 107, 69, 0.1);
    border-color: rgba(29, 107, 69, 0.2);
    color: var(--success);
}

.flash-danger {
    background: rgba(142, 47, 47, 0.1);
    border-color: rgba(142, 47, 47, 0.2);
    color: var(--danger);
}

.flash-warning {
    background: rgba(138, 100, 25, 0.1);
    border-color: rgba(138, 100, 25, 0.2);
    color: var(--warning);
}

.flash-persistent {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.flash-persistent a {
    font-weight: 700;
    color: inherit;
    text-decoration: underline;
}

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

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

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

.plain-list {
    padding-left: 1.2rem;
    margin: 0;
}

.text-muted {
    color: var(--muted);
    font-size: 0.92rem;
}

.message-thread {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.message {
    padding: 1rem;
    border-radius: 14px;
    border: 1px solid var(--line);
}

.message-user {
    background: #fff;
}

.message-admin {
    background: var(--panel-soft);
}

.message-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.status-badge {
    align-self: start;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    background: rgba(233, 239, 240, 0.92);
    color: var(--accent-strong);
    font-weight: 700;
}

.status-badge-muted {
    background: rgba(109, 98, 87, 0.12);
    color: var(--muted);
}

.stat-card {
    padding: 1.4rem;
    display: grid;
    gap: 0.4rem;
    background:
        linear-gradient(180deg, rgba(255, 251, 246, 0.98), rgba(245, 233, 220, 0.96));
}

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

.stat-card strong {
    font-size: 2rem;
}

.ingredient-row {
    grid-template-columns: minmax(0, 2fr) minmax(110px, 1fr) minmax(110px, 1fr);
}

.quote-line-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(110px, 0.8fr) minmax(140px, 1fr) minmax(180px, 1.1fr);
    gap: 1rem;
}

.quote-document {
    display: grid;
    gap: 1.5rem;
}

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

.quote-total-line {
    font-size: 1.1rem;
}

.table-form {
    display: contents;
}

.table-form__cell {
    min-width: 220px;
}

.inline-split {
    display: grid;
    grid-template-columns: minmax(100px, 1fr) minmax(100px, 1fr);
    gap: 0.6rem;
}

.table-actions {
    display: grid;
    gap: 0.5rem;
}

.actions-inline {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.75rem;
}

.ingredient-unit-hint {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px dashed var(--line);
    background: var(--panel-soft);
    color: var(--muted);
    min-height: 52px;
}

.ingredient-row__remove {
    min-height: 52px;
    width: 100%;
}

.ingredient-rows {
    display: grid;
    gap: 1rem;
}

.ingredient-row__add {
    justify-self: start;
}

.ingredients-admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}

.ingredient-admin-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 1rem 1.1rem;
    background: linear-gradient(180deg, rgba(250, 252, 251, 0.98), rgba(238, 244, 245, 0.98));
    box-shadow: 0 10px 20px rgba(82, 106, 120, 0.06);
}

.ingredient-admin-card--warning {
    border-color: rgba(138, 100, 25, 0.35);
    box-shadow: 0 12px 24px rgba(138, 100, 25, 0.1);
}

.ingredient-admin-form {
    display: grid;
    gap: 0.9rem;
}

.ingredient-admin-card__head {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 0.8rem;
}

.ingredient-admin-card__badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4rem;
}

.ingredient-admin-card__head h2 {
    margin: 0;
    font-size: 1.05rem;
}

.ingredient-admin-fields {
    display: grid;
    grid-template-columns: minmax(180px, 1.3fr) repeat(3, minmax(140px, 1fr));
    gap: 0.75rem;
}

.ingredient-admin-fields label {
    display: grid;
    gap: 0.35rem;
}

.ingredient-admin-fields label span {
    font-size: 0.82rem;
    color: var(--muted);
}

.ingredient-admin-card__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.status-badge-warning {
    background: rgba(138, 100, 25, 0.12);
    color: var(--warning);
}

.admin-inline-note {
    margin-bottom: 1rem;
    padding: 0.8rem 0.95rem;
    border-radius: 12px;
    background: rgba(138, 100, 25, 0.1);
    color: var(--warning);
    border: 1px solid rgba(138, 100, 25, 0.16);
}

.recipes-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.admin-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.admin-summary-card {
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 1.25rem;
    background: linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(246, 234, 221, 0.98));
    display: grid;
    gap: 1rem;
    box-shadow: var(--shadow-soft);
}

.admin-summary-card__head {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
}

.admin-summary-card__head h2 {
    margin: 0;
    font-size: 1.15rem;
}

.check-panel {
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.recipe-admin-card {
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 1.25rem;
    background: linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(246, 234, 221, 0.98));
    display: grid;
    gap: 1rem;
    box-shadow: var(--shadow-soft);
}

.media-preview {
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
}

.media-preview-card {
    margin-bottom: 1rem;
}

.media-preview-card img {
    height: 220px;
}

.recipe-admin-card__head {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
}

.recipe-admin-card__head h2 {
    margin: 0;
    font-size: 1.15rem;
}

.recipe-admin-card__footer {
    display: grid;
    gap: 1rem;
}

.stack-md {
    gap: 0.9rem;
}

.stack-lg {
    gap: 1.25rem;
}

.stack-xl {
    gap: 2rem;
}

@media (max-width: 1024px) {
    .topbar {
        padding: 1rem 1.25rem;
        align-items: flex-start;
    }

    .page-wrap {
        padding: 1.25rem;
    }

    .cards-grid,
    .recipes-admin-grid,
    .admin-summary-grid,
    .ingredients-admin-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
}

@media (max-width: 720px) {
    .page-wrap {
        padding: 1rem;
    }

    .topbar {
        padding: 0.85rem 1rem;
        align-items: center;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .brand {
        text-align: left;
        font-size: 0.98rem;
    }

    .topnav--desktop {
        display: none;
    }

    .topnav-mobile {
        margin-left: auto;
        width: auto;
        display: block;
        position: relative;
    }

    .topnav-mobile__shell {
        display: block;
    }

    .topnav-mobile__toggle {
        min-width: 112px;
        display: block;
        padding-inline: 1rem;
    }

    .topnav-mobile__panel {
        width: 100%;
        display: none;
        position: absolute;
        top: calc(100% + 0.5rem);
        left: 0;
        right: 0;
        background: var(--panel);
        border: 1px solid rgba(111, 143, 161, 0.12);
        border-radius: 18px;
        box-shadow: var(--shadow);
        z-index: 30;
    }

    .topnav-mobile__shell[open] .topnav-mobile__panel {
        display: block;
        padding: 0.85rem;
    }

    .topnav-mobile__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: stretch;
    }

    .topnav-mobile__grid a,
    .topnav-button,
    .topnav-mobile .nav-dropdown summary,
    .logout-form {
        width: 100%;
    }

    .topnav-mobile__grid a,
    .topnav-button,
    .topnav-mobile .nav-dropdown summary {
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: normal;
        line-height: 1.2;
        font-size: 0.92rem;
    }

    .logout-form {
        display: flex;
    }

    .logout-form .topnav-button {
        width: 100%;
    }

    .topnav-mobile .nav-dropdown {
        width: 100%;
        position: relative;
    }

    .topnav-mobile .nav-dropdown__menu {
        position: static;
        min-width: 0;
        max-width: none;
        margin-top: 0.5rem;
        box-shadow: none;
    }

    .section-head,
    .admin-summary-card__head,
    .recipe-admin-card__head,
    .ingredient-admin-card__head,
    .formula-card__top,
    .message-meta {
        flex-direction: column;
    }

    .actions-inline {
        justify-content: stretch;
    }

    .actions-inline .btn {
        width: 100%;
    }

    .ingredient-row {
        grid-template-columns: 1fr;
    }

    .quote-line-row {
        grid-template-columns: 1fr;
    }

    .quote-line-row,
    .ingredient-row {
        gap: 0.75rem;
    }

    .hero-media--with-image {
        grid-template-columns: 1fr;
    }

    .hero,
    .panel,
    .auth-card,
    .subpanel,
    .stat-card {
        padding: 1.1rem;
    }

    .cards-grid,
    .stats-grid,
    .details-grid,
    .recipes-admin-grid,
    .admin-summary-grid,
    .ingredients-admin-grid,
    .two-cols,
    .quote-totals-grid,
    .inline-split {
        grid-template-columns: 1fr;
    }

    .cards-grid,
    .recipes-admin-grid,
    .admin-summary-grid,
    .ingredients-admin-grid {
        gap: 0.85rem;
    }

    .formula-card__body,
    .ingredient-admin-card,
    .recipe-admin-card,
    .admin-summary-card {
        padding: 1rem;
    }

    .table-wrap {
        margin: 0 -0.25rem;
    }

    th,
    td {
        padding: 0.8rem 0.65rem;
    }

    .table-form__cell {
        min-width: 160px;
    }

    .message {
        padding: 0.85rem;
    }

    .stat-card strong {
        font-size: 1.6rem;
    }
}

@media (max-width: 420px) {
    .topbar {
        align-items: stretch;
    }

    .brand,
    .topnav-mobile {
        width: 100%;
    }

    .topnav-mobile {
        margin-left: 0;
    }

    .topnav-mobile__toggle {
        width: 100%;
    }

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

@media print {
    .topbar,
    .flash,
    .actions-inline,
    .topnav,
    .logout-form {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .page-wrap {
        max-width: none;
        padding: 0;
    }

    .panel,
    .subpanel {
        box-shadow: none;
        border-color: #ddd;
    }
}

@media (max-width: 900px) {
    .page-wrap,
    .topbar {
        padding: 1rem;
    }

    .section-head,
    .formula-card__top,
    .message-meta {
        grid-template-columns: 1fr;
        display: grid;
    }

    .ingredient-row {
        grid-template-columns: 1fr;
    }

    .quote-totals-grid {
        grid-template-columns: 1fr;
    }
}
