:root {
    --bg: #f4f6f3;
    --sidebar: #17251b;
    --sidebar-soft: #203326;
    --surface: #ffffff;
    --surface-soft: #f8faf7;
    --text: #17251b;
    --muted: #667266;
    --line: #dfe6dc;
    --green: #2f6846;
    --green-dark: #245237;
    --green-soft: #e5f1e8;
    --red: #9c3d2e;
    --red-soft: #f6e3df;
    --yellow-soft: #f4ead3;
    --shadow: 0 18px 48px rgba(23, 37, 27, 0.08);
    --radius: 16px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
    background: linear-gradient(180deg, var(--sidebar), #101912);
    color: #ffffff;
    padding: 26px 20px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 13px;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: #ffffff;
    color: var(--green-dark);
    font-weight: 900;
    letter-spacing: -0.06em;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 17px;
    line-height: 1.2;
}

.brand small {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.64);
    font-size: 13px;
}

.side-nav {
    display: grid;
    gap: 7px;
}

.side-nav a {
    min-height: 44px;
    padding: 11px 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: rgba(255, 255, 255, 0.72);
    transition: background 0.18s ease, color 0.18s ease;
}

.side-nav a:hover,
.side-nav a.active {
    background: var(--sidebar-soft);
    color: #ffffff;
}

.side-nav a[aria-disabled="true"] {
    opacity: 0.62;
    cursor: default;
}

.side-nav small {
    min-width: 30px;
    padding: 3px 8px;
    border-radius: 999px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    font-size: 12px;
}

.sidebar-note {
    margin-top: auto;
    padding: 14px;
    border-radius: 14px;
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-note strong {
    display: block;
    font-size: 14px;
}

.sidebar-note p {
    margin: 3px 0 0;
    color: rgba(255, 255, 255, 0.62);
    font-size: 12px;
    line-height: 1.45;
}

.status-dot {
    width: 9px;
    height: 9px;
    margin-top: 5px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: #65c879;
    box-shadow: 0 0 0 4px rgba(101, 200, 121, 0.16);
}

.main {
    min-width: 0;
    padding: 30px;
}

.topbar {
    margin-bottom: 22px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.section-label {
    margin: 0 0 6px;
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(30px, 4vw, 44px);
    line-height: 1.08;
    letter-spacing: -0.04em;
}

h2 {
    margin-bottom: 0;
    font-size: 24px;
    letter-spacing: -0.03em;
}

.connection-pill {
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: var(--surface);
    color: var(--green-dark);
    font-size: 14px;
    font-weight: 800;
    box-shadow: 0 10px 26px rgba(23, 37, 27, 0.05);
}

.connection-pill .status-dot {
    margin-top: 0;
}

.alert {
    margin-bottom: 18px;
    padding: 16px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
}

.alert strong {
    display: block;
    margin-bottom: 4px;
}

.alert p {
    margin-bottom: 0;
    color: var(--muted);
}

.alert-error {
    border-color: #e2b9b0;
    background: var(--red-soft);
    color: var(--red);
}

.kpi-grid {
    margin-bottom: 22px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.kpi-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(23, 37, 27, 0.05);
}

.kpi-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.kpi-card strong {
    display: block;
    margin-top: 8px;
    font-size: 34px;
    line-height: 1;
    letter-spacing: -0.05em;
}

.kpi-card p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header {
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    background: var(--surface-soft);
}

.result-count {
    padding: 8px 11px;
    border-radius: 999px;
    background: var(--green-soft);
    color: var(--green-dark);
    font-size: 13px;
    font-weight: 800;
}

.filter-bar {
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: 1.25fr 1fr 1fr auto;
    gap: 14px;
    align-items: end;
}

.filter-bar label {
    display: grid;
    gap: 7px;
}

.filter-bar label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

input,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #ffffff;
    color: var(--text);
    padding: 9px 11px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
select:focus {
    border-color: rgba(47, 104, 70, 0.62);
    box-shadow: 0 0 0 4px rgba(47, 104, 70, 0.1);
}

.filter-actions {
    display: flex;
    gap: 9px;
}

.button {
    min-height: 42px;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    background: var(--green);
    color: #ffffff;
}

.button-primary:hover {
    background: var(--green-dark);
}

.button-secondary {
    border-color: var(--line);
    background: #ffffff;
    color: var(--text);
}

.button-secondary:hover {
    border-color: rgba(47, 104, 70, 0.32);
}

.active-filters {
    padding: 12px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background: #fbfcfa;
}

.active-filters span,
.active-filters strong {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
}

.active-filters span {
    background: var(--green-soft);
    color: var(--green-dark);
}

.active-filters strong {
    background: var(--yellow-soft);
    color: #75591e;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    padding: 12px 16px;
    background: #fbfcfa;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    text-align: left;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.data-table td {
    padding: 15px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.data-table tbody tr {
    transition: background 0.16s ease;
}

.data-table tbody tr:hover {
    background: #fbfcfa;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.id-badge {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 999px;
    background: #eef2ec;
    color: var(--green-dark);
    font-size: 12px;
    font-weight: 900;
}

.recipe-title {
    display: block;
    margin-bottom: 5px;
    font-size: 15px;
}

.recipe-description {
    display: block;
    max-width: 420px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.badge-green {
    background: var(--green-soft);
    color: var(--green-dark);
}

.badge-red {
    background: var(--red-soft);
    color: var(--red);
}

.badge-neutral {
    background: #eef2ec;
    color: var(--muted);
}

.muted {
    color: var(--muted);
}

.table-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 8px 11px;
    border-radius: 10px;
    background: var(--green);
    color: #ffffff;
    font-size: 13px;
    font-weight: 900;
    transition: background 0.16s ease, transform 0.16s ease;
}

.table-action:hover {
    background: var(--green-dark);
    transform: translateY(-1px);
}

.empty-state {
    margin: 22px;
    padding: 22px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.empty-state strong {
    display: block;
    margin-bottom: 6px;
}

.empty-state p {
    margin-bottom: 0;
    color: var(--muted);
}

@media (max-width: 1120px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding: 18px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .side-nav {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .sidebar-note {
        display: none;
    }

    .main {
        padding: 22px;
    }

    .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .brand {
        align-items: flex-start;
    }

    .side-nav {
        display: flex;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .side-nav a {
        min-width: 150px;
    }

    .main {
        padding: 16px;
    }

    .topbar {
        flex-direction: column;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .panel-header {
        flex-direction: column;
    }

    .filter-bar {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .filter-actions {
        flex-direction: column;
    }

    .button {
        width: 100%;
    }

    .table-wrap {
        overflow: visible;
    }

    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table tr,
    .data-table th,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table thead {
        display: none;
    }

    .data-table tr {
        padding: 14px;
        border-bottom: 1px solid var(--line);
    }

    .data-table td {
        padding: 10px 0;
        border-bottom: 0;
        display: grid;
        grid-template-columns: 120px minmax(0, 1fr);
        gap: 12px;
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 900;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .recipe-description {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .data-table td {
        grid-template-columns: 1fr;
        gap: 5px;
    }
}
.detail-grid {
    margin-bottom: 22px;
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.75fr);
    gap: 16px;
}

.detail-card {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(23, 37, 27, 0.05);
}

.detail-card-main h2 {
    margin: 18px 0 10px;
    font-size: clamp(26px, 4vw, 38px);
    letter-spacing: -0.04em;
}

.record-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.small-pill {
    padding: 7px 10px;
    font-size: 12px;
    box-shadow: none;
}

.detail-description {
    max-width: 760px;
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.65;
}

.detail-meta {
    margin-top: 22px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.detail-meta div {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-soft);
}

.detail-meta span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.detail-meta strong {
    display: block;
    margin-top: 7px;
    font-size: 24px;
    letter-spacing: -0.04em;
}

.spacing-top {
    margin-top: 22px;
}

.detail-panel {
    margin-top: 0;
}

.ingredient-table {
    min-width: 1180px;
}

.nutrition-line {
    white-space: nowrap;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 980px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .ingredient-table {
        min-width: 0;
    }
}

@media (max-width: 760px) {
    .record-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .detail-meta {
        grid-template-columns: 1fr;
    }
}