:root {
    --bg: #f4f8fc;
    --page: #ffffff;
    --panel: #f8fbff;
    --line: #dfeaf5;
    --ink: #12273b;
    --muted: #5b7285;
    --blue: #1769aa;
    --blue-soft: #edf6ff;
    --purple: #5b3ec8;
    --purple-soft: #f0ebff;
    --green: #1d8f5f;
    --green-soft: #e7f7ef;
    --orange: #ea8d2e;
    --orange-soft: #fff3e7;
    --shadow: 0 18px 40px rgba(18, 39, 59, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'DM Sans', sans-serif;
    background: linear-gradient(135deg, #f7fbff 0%, #eef7ff 45%, #f1faf4 100%);
    color: var(--ink);
}

button,
input,
select {
    font: inherit;
}

.page-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem 3rem;
}

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    display: inline-block;
    margin-bottom: 0.45rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
}

h1 {
    font-size: clamp(2rem, 4vw, 3rem);
}

.topbar-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1.3rem 0 1.6rem;
}

.tab {
    appearance: none;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.7);
    color: var(--muted);
    border-radius: 999px;
    padding: 0.7rem 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.tab.is-active,
.tab:hover {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

main {
    display: grid;
}

.panel {
    display: none;
}

.panel.is-active {
    display: block;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.metric-box,
.card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.metric-box {
    padding: 1rem 1.1rem;
}

.metric-box .label {
    color: var(--muted);
    font-size: 0.76rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.metric-box .value {
    display: block;
    margin-top: 0.65rem;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    font-weight: 700;
    color: var(--ink);
}

.grid {
    display: grid;
    gap: 1rem;
}

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

.card {
    padding: 1rem 1rem 1.2rem;
}

.card-header {
    margin-bottom: 0.9rem;
}

.card-header h2 {
    font-size: 1.15rem;
}

.recipe-list,
.inventory-list,
.sales-list,
.share-list {
    display: grid;
    gap: 0.75rem;
}

.recipe-item,
.inventory-item,
.sale-item,
.share-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.75rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.recipe-item strong,
.inventory-item strong,
.sale-item strong,
.share-item strong {
    display: block;
    color: var(--ink);
}

.recipe-item span,
.inventory-item span,
.sale-item span,
.share-item span {
    color: var(--muted);
    font-size: 0.82rem;
}

.tag {
    display: inline-block;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 0.7rem;
    font-weight: 700;
}

.break-even-card {
    display: grid;
    gap: 0.7rem;
    min-height: 100%;
}

.break-even-box {
    padding: 0.8rem;
    border-radius: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
}

.break-even-box strong {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 1.2rem;
}

.form-card {
    margin-top: 1rem;
}

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

.field-row {
    display: grid;
    gap: 0.8rem;
}

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

label {
    display: grid;
    gap: 0.45rem;
    color: var(--muted);
    font-size: 0.9rem;
}

input,
select {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
}

input:focus,
select:focus {
    outline: 2px solid rgba(23, 105, 170, 0.2);
    border-color: var(--blue);
}

.primary-button {
    align-self: end;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    color: #fff;
    padding: 0.8rem 1rem;
    cursor: pointer;
    font-weight: 700;
}

.primary-button:hover {
    filter: brightness(1.04);
}

.recipes-table {
    display: grid;
    gap: 0.8rem;
}

.table-row {
    display: grid;
    grid-template-columns: minmax(140px, 2fr) repeat(4, minmax(100px, 1fr));
    gap: 0.6rem;
    align-items: center;
    padding: 0.75rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
}

.table-row.header {
    background: rgba(23, 105, 170, 0.06);
    color: var(--blue);
    font-weight: 700;
}

.share-item {
    align-items: flex-start;
}

.progress {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: #edf3f8;
    border: 1px solid var(--line);
}

.progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--purple), var(--blue));
}

@media (max-width: 640px) {
    .page-shell {
        padding: 1.2rem 0.8rem 2.2rem;
    }

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

    .tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .metrics {
        grid-template-columns: repeat(2, minmax(130px, 1fr));
    }

    .metric-box {
        padding: 0.9rem 0.8rem;
    }

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

    .table-row.header {
        display: none;
    }

    .recipe-item,
    .inventory-item,
    .sale-item,
    .share-item {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: start;
        gap: 0.35rem 0.6rem;
    }

    .recipe-item>div:last-child,
    .inventory-item>div:last-child,
    .sale-item>div:last-child,
    .share-item>div:last-child {
        justify-self: end;
        text-align: right;
    }

    .share-item {
        grid-template-columns: 1fr;
    }

    .share-item>div:last-child {
        width: 100%;
        justify-self: stretch;
        text-align: left;
    }

    .inventory-item strong,
    .recipe-item strong,
    .sale-item strong,
    .share-item strong {
        font-size: 0.96rem;
    }
}

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

    .tab {
        padding: 0.75rem 0.5rem;
        font-size: 0.92rem;
    }

    .primary-button {
        width: 100%;
    }

    .recipe-item,
    .inventory-item,
    .sale-item,
    .share-item {
        grid-template-columns: 1fr;
    }

    .recipe-item>div:last-child,
    .inventory-item>div:last-child,
    .sale-item>div:last-child,
    .share-item>div:last-child {
        justify-self: start;
        text-align: left;
    }
}