/* ============================================================
   ESCA Demo — Kuchařská kniha meets data visualization
   Aesthetic: Warm utilitarian. Earthy. Precise.
   ============================================================ */

:root {
    /* Earthy palette */
    --terracotta: #C4654A;
    --terracotta-light: #E8907A;
    --terracotta-dim: #9E4F3A;
    --sage: #7A9E7E;
    --sage-light: #A8C5AB;
    --sage-dim: #5B7D5F;
    --cream: #FAF6F1;
    --cream-dark: #F0EAE2;
    --parchment: #EDE7DD;
    --ink: #2C2420;
    --ink-light: #5C554E;
    --ink-faint: #9B938A;
    --wheat: #D4C5A9;
    --wheat-light: #E8DCCA;
    --ochre: #C9943E;
    --ochre-light: #E6C882;
    --ruby: #B83A3A;
    --ruby-light: #D96B6B;

    /* Meal type colors */
    --color-presnidavka: #D4A855;
    --color-presnidavka-bg: #FDF6E8;
    --color-presnidavka-border: #E8CC8A;
    --color-obed: #C4654A;
    --color-obed-bg: #FDF0EC;
    --color-obed-border: #E0977F;
    --color-polevka: #B08D57;
    --color-polevka-bg: #F9F3EA;
    --color-polevka-border: #D4B882;
    --color-svacina: #7A9E7E;
    --color-svacina-bg: #EFF6F0;
    --color-svacina-border: #A8C5AB;

    /* Layout */
    --radius: 6px;
    --radius-lg: 10px;

    /* Typography */
    --font-display: 'DM Serif Display', Georgia, serif;
    --font-body: 'IBM Plex Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--cream);
    color: var(--ink);
    line-height: 1.5;
    min-height: 100vh;
    /* Subtle paper texture via noise */
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
}

/* ============================================================
   HEADER
   ============================================================ */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    background: var(--ink);
    color: var(--cream);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px rgba(44, 36, 32, 0.15);
}

.header__title {
    font-family: var(--font-display);
    font-size: 28px;
    letter-spacing: 3px;
    font-weight: 400;
    line-height: 1;
}

.header__subtitle {
    font-size: 12px;
    color: var(--ink-faint);
    letter-spacing: 0.5px;
    margin-top: 4px;
    font-weight: 300;
}

.header__status {
    display: flex;
    align-items: center;
    gap: 24px;
}

.solver-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--ink-faint);
    font-weight: 400;
}

.solver-status__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ink-faint);
    transition: background 0.3s;
}

.solver-status--solving .solver-status__dot {
    background: var(--ochre);
    animation: pulse 1s ease-in-out infinite;
}

.solver-status--solving .solver-status__text {
    color: var(--ochre-light);
}

.solver-status--done .solver-status__dot {
    background: var(--sage);
}

.solver-status--done .solver-status__text {
    color: var(--sage-light);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.4); }
}

.header__actions {
    display: flex;
    gap: 8px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--terracotta);
    color: var(--cream);
}

.btn--primary:hover:not(:disabled) {
    background: var(--terracotta-dim);
    transform: translateY(-1px);
}

.btn--secondary {
    background: rgba(255,255,255,0.1);
    color: var(--cream);
    border: 1px solid rgba(255,255,255,0.15);
}

.btn--secondary:hover:not(:disabled) {
    background: rgba(255,255,255,0.18);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */

.main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 32px 60px;
}

/* ============================================================
   PARAMETERS
   ============================================================ */

.params-section {
    margin-bottom: 20px;
}

.params-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.param-group {
    background: white;
    border: 1px solid var(--parchment);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    flex: 1;
    min-width: 160px;
}

.param-group__title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ink-faint);
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

.param-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.param-row:last-child { margin-bottom: 0; }

.param-label {
    font-size: 12px;
    color: var(--ink-light);
    white-space: nowrap;
}

.param-input {
    width: 65px;
    padding: 3px 6px;
    border: 1px solid var(--parchment);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink);
    text-align: right;
    background: var(--cream);
    transition: border-color 0.2s;
}

.param-input:focus {
    outline: none;
    border-color: var(--terracotta-light);
}

.param-input-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

.param-unit {
    font-size: 11px;
    color: var(--ink-faint);
}

.param-group--summary {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    flex: 0;
}

.param-summary {
    text-align: center;
}

.param-summary__number {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 500;
    color: var(--ink);
    line-height: 1;
}

.param-summary__label {
    font-size: 11px;
    color: var(--ink-faint);
    margin-top: 2px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 400;
    color: var(--ink);
    margin-bottom: 16px;
}

/* ============================================================
   DASHBOARD
   ============================================================ */

.dashboard {
    margin-bottom: 32px;
}

.dashboard__scores {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.score-card {
    background: white;
    border: 1px solid var(--parchment);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}

.score-card--wide {
    flex: 1;
}

.score-card__label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ink-faint);
    font-weight: 500;
}

.score-card__value {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 500;
    color: var(--ink);
}

.score-card__value--ok {
    color: var(--sage-dim);
}

.score-card__value--bad {
    color: var(--ruby);
}

.score-card__value--soft {
    color: var(--ink-light);
}

/* Budget bar */
.budget-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 2px;
}

.budget-bar__track {
    flex: 1;
    height: 10px;
    background: var(--parchment);
    border-radius: 5px;
    position: relative;
    overflow: hidden;
}

.budget-bar__fill {
    height: 100%;
    background: var(--sage);
    border-radius: 5px;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s;
    width: 0%;
}

.budget-bar__fill--over {
    background: var(--ruby);
}

.budget-bar__limit-marker {
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 2px;
    background: var(--ink);
    border-radius: 1px;
    right: 0;
    opacity: 0.3;
}

.budget-bar__text {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--ink-light);
    white-space: nowrap;
    min-width: 110px;
    text-align: right;
}

/* Commodities */
.dashboard__commodities {
    background: white;
    border: 1px solid var(--parchment);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
}

.commodities-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px 20px;
}

.commodity {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.commodity__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.commodity__name {
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-light);
}

.commodity__pct {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    color: var(--ink-faint);
}

.commodity__pct--ok {
    color: var(--sage-dim);
}

.commodity__pct--bad {
    color: var(--ruby);
}

.commodity__bar {
    height: 6px;
    background: var(--parchment);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}

.commodity__bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s;
    width: 0%;
    background: var(--sage);
}

.commodity__bar-fill--under {
    background: var(--ruby);
}

.commodity__bar-fill--over {
    background: var(--ochre);
}

/* Small zone markers on the bar */
.commodity__bar-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    border-left: 1px dashed rgba(0,0,0,0.15);
}

/* ============================================================
   CALENDAR
   ============================================================ */

.calendar-section {
    margin-top: 8px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.calendar-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.view-toggle {
    display: flex;
    background: var(--parchment);
    border-radius: var(--radius);
    padding: 2px;
}

.view-toggle__btn {
    padding: 5px 14px;
    border: none;
    border-radius: 4px;
    background: none;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-faint);
    cursor: pointer;
    transition: all 0.15s;
}

.view-toggle__btn--active {
    background: white;
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Summary rows */
.calendar__row--summary {
    background: var(--cream) !important;
    font-weight: 500;
    border-bottom: 2px solid var(--wheat) !important;
}

.calendar__row--summary .calendar__day {
    font-weight: 600;
    color: var(--ink-light);
    font-size: 10px;
}

.calendar__row--total {
    background: var(--ink) !important;
    color: var(--cream);
}

.calendar__row--total .calendar__day {
    background: var(--ink);
    color: var(--cream);
    font-weight: 600;
    font-size: 10px;
}

.calendar__row--total .calendar__cell {
    color: var(--cream);
}

.cell-summary {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    width: 100%;
}

.cell-summary--total {
    color: var(--cream);
}

/* Commodity mini-bars in cells */
.cell-kos {
    font-family: var(--font-mono);
    font-size: 9px;
    line-height: 1.4;
    color: var(--ink-faint);
    margin-top: 2px;
}

.cell-kos__item {
    display: inline;
    white-space: nowrap;
}

.cell-kos__item::after {
    content: ' · ';
    color: var(--parchment);
}

.cell-kos__item:last-child::after {
    content: '';
}

.calendar-legend {
    display: flex;
    gap: 16px;
}

.legend-item {
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-light);
}

.legend-item::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.legend-item--presnidavka::before { background: var(--color-presnidavka); }
.legend-item--polevka::before { background: var(--color-polevka); }
.legend-item--obed::before { background: var(--color-obed); }
.legend-item--svacina::before { background: var(--color-svacina); }

.calendar {
    background: white;
    border: 1px solid var(--parchment);
    border-radius: var(--radius-lg);
    overflow: hidden;
    overflow-x: auto;
}

.calendar__head {
    display: grid;
    grid-template-columns: 56px repeat(4, minmax(0, 1fr));
    background: var(--ink);
    color: var(--cream);
    min-width: 700px;
}

.calendar__day-label,
.calendar__col-label {
    padding: 10px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

.calendar__body {
    min-width: 700px;
}

.calendar__row {
    display: grid;
    grid-template-columns: 56px repeat(4, minmax(0, 1fr));
    border-bottom: 1px solid var(--parchment);
    transition: background 0.2s;
}

.calendar__row:last-child {
    border-bottom: none;
}

.calendar__row:hover {
    background: rgba(250, 246, 241, 0.6);
}

.calendar__row--friday {
    border-bottom: 2px solid var(--wheat);
}

.calendar__day {
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-faint);
    display: flex;
    align-items: center;
    border-right: 1px solid var(--parchment);
    background: var(--cream);
    font-weight: 500;
}

/* Calendar cells */
.calendar__cell {
    padding: 6px 8px 6px 10px;
    min-height: 52px;
    border-right: 1px solid var(--parchment);
    cursor: pointer;
    position: relative;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.calendar__cell:last-child {
    border-right: none;
}

.calendar__cell:hover {
    background: rgba(0,0,0,0.02);
}

.calendar__cell--presnidavka {
    box-shadow: inset 3px 0 0 var(--color-presnidavka);
}

.calendar__cell--polevka {
    box-shadow: inset 3px 0 0 var(--color-polevka);
}

.calendar__cell--obed {
    box-shadow: inset 3px 0 0 var(--color-obed);
}

.calendar__cell--svacina {
    box-shadow: inset 3px 0 0 var(--color-svacina);
}

.cell-allergens {
    color: var(--ochre);
    font-size: 9px;
}

/* Empty cell */
.cell-empty {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--parchment);
    font-size: 20px;
    transition: color 0.2s;
}

.calendar__cell:hover .cell-empty {
    color: var(--ink-faint);
}

/* Filled cell */
.cell-filled {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
}

.cell-filled__info {
    flex: 1;
    min-width: 0;
}

.cell-filled__name {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.cell-filled__meta {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--ink-faint);
    margin-top: 1px;
}

.cell-filled__lock {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--terracotta);
    opacity: 0.7;
}

/* Cell update animation */
.calendar__cell--updating {
    animation: cellFlash 0.4s ease-out;
}

@keyframes cellFlash {
    0% { background: var(--wheat-light); }
    100% { background: transparent; }
}

/* Pinned cell */
.calendar__cell--pinned {
    background: rgba(196, 101, 74, 0.04);
}

/* Verified cell */
.calendar__cell--verified {
    background: rgba(122, 158, 126, 0.08);
}

.calendar__row--verified {
    background: rgba(122, 158, 126, 0.04);
}

.calendar__day--verified {
    color: var(--sage-dim);
}

/* Day verify button */
.calendar__day {
    flex-direction: column;
    gap: 2px;
    justify-content: center;
}

.day-text {
    line-height: 1;
}

.day-verify-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--parchment);
    background: none;
    color: var(--parchment);
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    line-height: 1;
}

.day-verify-btn:hover {
    border-color: var(--sage);
    color: var(--sage);
}

.day-verify-btn--active {
    background: var(--sage);
    border-color: var(--sage);
    color: white;
}

/* Cell verify button */
.cell-filled__actions {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-shrink: 0;
    align-items: center;
}

.cell-filled__icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell-verify-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--parchment);
    background: none;
    color: transparent;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    line-height: 1;
}

.calendar__cell:hover .cell-verify-btn {
    color: var(--ink-faint);
    border-color: var(--ink-faint);
}

.cell-verify-btn:hover {
    border-color: var(--sage) !important;
    color: var(--sage) !important;
}

.cell-verify-btn--active {
    background: var(--sage);
    border-color: var(--sage);
    color: white !important;
}

/* ============================================================
   POPOVER
   ============================================================ */

.popover-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(44, 36, 32, 0.3);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    backdrop-filter: blur(2px);
}

.popover-backdrop--open {
    opacity: 1;
    pointer-events: auto;
}

.popover {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(44, 36, 32, 0.2), 0 0 0 1px var(--parchment);
    z-index: 201;
    width: 420px;
    max-height: 500px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}

.popover--open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.popover__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--parchment);
}

.popover__title {
    font-family: var(--font-display);
    font-size: 16px;
}

.popover__close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--ink-faint);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.popover__close:hover {
    color: var(--ink);
}

.popover__body {
    overflow-y: auto;
    padding: 8px;
}

.recipe-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
    gap: 12px;
}

.recipe-option:hover {
    background: var(--cream);
}

.recipe-option__name {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    flex: 1;
}

.recipe-option__meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-faint);
    white-space: nowrap;
}

.recipe-option__tag {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--wheat-light);
    color: var(--ink-light);
    font-weight: 500;
}

/* Unpin button inside popover */
.popover__unpin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    margin: 8px;
    border: 1px dashed var(--parchment);
    border-radius: var(--radius);
    background: none;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--terracotta);
    cursor: pointer;
    transition: all 0.2s;
    width: calc(100% - 16px);
}

.popover__unpin:hover {
    background: var(--color-obed-bg);
    border-color: var(--terracotta-light);
}

/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--wheat);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ink-faint);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1100px) {
    .commodities-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 800px) {
    .header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .dashboard__scores {
        flex-direction: column;
    }

    .commodities-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .calendar__head,
    .calendar__row {
        grid-template-columns: 42px repeat(4, minmax(0, 1fr));
    }

    .cell-filled__name {
        font-size: 11px;
    }

    .main {
        padding: 16px;
    }
}

/* ============================================================
   LOADING STATE
   ============================================================ */

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--ink-faint);
    font-size: 14px;
    gap: 10px;
}

.loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--parchment);
    border-top-color: var(--terracotta);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   HELP TOOLTIPS (score explanation)
   ============================================================ */

.score-card--has-help {
    position: relative;
}

.score-card__top {
    display: flex;
    align-items: center;
    gap: 6px;
}

.help-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--wheat);
    background: var(--cream);
    color: var(--ink-faint);
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.help-btn:hover {
    background: var(--wheat-light);
    color: var(--ink-light);
    border-color: var(--ink-faint);
}

.help-tooltip {
    display: none !important;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 50;
    background: var(--ink);
    color: var(--cream);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-size: 12px;
    line-height: 1.6;
    width: 280px;
    box-shadow: 0 8px 30px rgba(44, 36, 32, 0.25);
}

.help-tooltip--open {
    display: block !important;
    animation: tooltipIn 0.2s ease-out;
}

@keyframes tooltipIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.help-tooltip strong {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
}

.help-tooltip ul {
    margin: 6px 0 0 16px;
    padding: 0;
}

.help-tooltip ul li {
    margin-bottom: 2px;
}

/* ============================================================
   COMMODITY DETAIL MODAL
   ============================================================ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(44, 36, 32, 0.3);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    backdrop-filter: blur(2px);
}

.modal-backdrop--open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(44, 36, 32, 0.2), 0 0 0 1px var(--parchment);
    z-index: 301;
    width: 520px;
    max-width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}

.modal--open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--parchment);
    flex-shrink: 0;
}

.modal__title {
    font-family: var(--font-display);
    font-size: 16px;
}

.modal__close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--ink-faint);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.modal__close:hover {
    color: var(--ink);
}

.modal__body {
    overflow-y: auto;
    padding: 8px;
    flex: 1;
}

.commodity-detail__summary {
    padding: 16px 20px 12px;
    display: flex;
    gap: 16px;
    align-items: center;
    border-bottom: 1px solid var(--parchment);
}

.commodity-detail__bar-wrap {
    flex: 1;
}

.commodity-detail__bar {
    height: 12px;
    background: var(--parchment);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

.commodity-detail__bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.4s;
}

.commodity-detail__bar-fill--ok { background: var(--sage); }
.commodity-detail__bar-fill--under { background: var(--ruby); }
.commodity-detail__bar-fill--over { background: var(--ochre); }

.commodity-detail__stats {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-light);
    margin-top: 6px;
    display: flex;
    gap: 16px;
}

.commodity-detail__stat-value {
    font-weight: 500;
    color: var(--ink);
}

.commodity-meal-item {
    display: grid;
    grid-template-columns: 48px 1fr 80px 60px;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--cream-dark);
    gap: 10px;
    font-size: 13px;
}

.commodity-meal-item:last-child {
    border-bottom: none;
}

.commodity-meal-item__day {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-faint);
    font-weight: 500;
}

.commodity-meal-item__name {
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.commodity-meal-item__bar {
    height: 6px;
    background: var(--parchment);
    border-radius: 3px;
    overflow: hidden;
}

.commodity-meal-item__bar-fill {
    height: 100%;
    background: var(--sage);
    border-radius: 3px;
}

.commodity-meal-item__grams {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-faint);
    text-align: right;
}

.commodity-meal-item--zero {
    opacity: 0.4;
}

/* ============================================================
   LIMITATIONS SECTION
   ============================================================ */

.limitations {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--parchment);
}

.limitations__intro {
    font-size: 13px;
    color: var(--ink-faint);
    margin-bottom: 16px;
    line-height: 1.6;
}

.limitations__list {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 10px;
}

.limitations__list li {
    font-size: 13px;
    color: var(--ink-light);
    line-height: 1.5;
    padding: 10px 14px;
    background: white;
    border: 1px solid var(--parchment);
    border-radius: var(--radius);
}

.limitations__list li strong {
    color: var(--ink);
}

/* ============================================================
   TABS & DOCUMENTATION
   ============================================================ */

.docs-section {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--parchment);
}

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 0;
    border-bottom: 2px solid var(--parchment);
}

.tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-faint);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--ink-light);
}

.tab--active {
    color: var(--terracotta);
    border-bottom-color: var(--terracotta);
}

.tab-content {
    display: none;
    padding: 24px;
    background: white;
    border: 1px solid var(--parchment);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.tab-content--active {
    display: block;
}

.tab-content h3 {
    font-family: var(--font-display);
    font-size: 17px;
    margin-bottom: 16px;
}

.tab-content p {
    font-size: 13px;
    line-height: 1.7;
    color: var(--ink-light);
    margin-bottom: 12px;
}

.tab-content ul {
    margin: 8px 0 16px 20px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--ink-light);
}

.tab-placeholder {
    font-style: italic;
    color: var(--ink-faint) !important;
}

/* PRD items */
.prd-item {
    background: var(--cream);
    border: 1px solid var(--parchment);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
}

.prd-item__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.prd-item__id {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    color: var(--ink-faint);
    background: var(--parchment);
    padding: 2px 8px;
    border-radius: 3px;
}

.prd-item__priority {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 3px;
}

.prd-item__priority--high {
    background: var(--color-obed-bg);
    color: var(--terracotta);
}

.prd-item__priority--medium {
    background: var(--color-presnidavka-bg);
    color: var(--color-presnidavka);
}

.prd-item h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--ink);
}

.prd-item p, .prd-item ul {
    font-size: 12.5px;
}

/* Notes */
.note {
    padding: 12px 16px;
    background: var(--cream);
    border-left: 3px solid var(--wheat);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 10px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--ink-light);
}

.note strong {
    color: var(--ink);
}

/* ============================================================
   SOLVER LOG
   ============================================================ */

.solver-log {
    margin-bottom: 20px;
}

.solver-log__toggle {
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-faint);
    padding: 10px 14px;
    background: white;
    border: 1px solid var(--parchment);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    list-style: none;
}

.solver-log__toggle::-webkit-details-marker { display: none; }

.solver-log__toggle::before {
    content: '▶';
    font-size: 9px;
    transition: transform 0.2s;
}

.solver-log[open] .solver-log__toggle::before {
    transform: rotate(90deg);
}

.solver-log__toggle:hover {
    color: var(--ink-light);
    border-color: var(--ink-faint);
}

.solver-log__count {
    font-family: var(--font-mono);
    font-size: 10px;
    background: var(--parchment);
    padding: 1px 6px;
    border-radius: 8px;
}

.solver-log__body {
    background: var(--ink);
    color: var(--cream);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    max-height: 350px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.6;
    padding: 12px 0;
    margin-top: -1px;
    border: 1px solid var(--ink);
}

.solver-log__empty {
    padding: 16px;
    color: var(--ink-faint);
    text-align: center;
    font-family: var(--font-body);
    font-size: 12px;
}

.log-entry {
    padding: 2px 14px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.log-entry:hover {
    background: rgba(255,255,255,0.04);
}

.log-entry__time {
    color: var(--ink-faint);
    white-space: nowrap;
    min-width: 55px;
}

.log-entry__type {
    font-weight: 500;
    white-space: nowrap;
    min-width: 60px;
}

.log-entry__type--start { color: var(--ochre-light); }
.log-entry__type--improve { color: var(--sage-light); }
.log-entry__type--done { color: var(--sage); }
.log-entry__type--stop { color: var(--wheat); }
.log-entry__type--pin { color: var(--terracotta-light); }
.log-entry__type--unpin { color: var(--wheat-light); }
.log-entry__type--error { color: var(--ruby-light); }

.log-entry__msg {
    color: var(--cream);
    flex-shrink: 0;
}

.log-entry__detail {
    color: var(--ink-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.log-entry__detail--expanded {
    white-space: normal;
    word-break: break-word;
}

/* ============================================================
   DATABASE SECTION
   ============================================================ */

.db-section {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--parchment);
}

.db-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.db-filter {
    padding: 5px 12px;
    border: 1px solid var(--parchment);
    border-radius: 20px;
    background: white;
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--ink-faint);
    cursor: pointer;
    transition: all 0.15s;
}

.db-filter:hover {
    border-color: var(--ink-faint);
    color: var(--ink-light);
}

.db-filter--active {
    background: var(--ink);
    color: var(--cream);
    border-color: var(--ink);
}

.db-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.db-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ink-faint);
    font-weight: 600;
    border-bottom: 2px solid var(--parchment);
    white-space: nowrap;
}

.db-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--cream-dark);
    color: var(--ink-light);
    vertical-align: top;
}

.db-table tbody tr:hover {
    background: var(--cream);
}

.db-table--compact {
    margin-bottom: 20px;
}

.db-mono {
    font-family: var(--font-mono);
    font-size: 11px;
}

.db-small {
    font-size: 11px;
    color: var(--ink-faint);
    max-width: 180px;
}

.db-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
}

.db-badge--ai {
    background: #EDE7FA;
    color: #6B4FA0;
}

.db-badge--real {
    background: var(--color-svacina-bg);
    color: var(--sage-dim);
}

.db-detail-btn {
    padding: 3px 10px;
    border: 1px solid var(--parchment);
    border-radius: var(--radius);
    background: white;
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--ink-faint);
    cursor: pointer;
    transition: all 0.15s;
}

.db-detail-btn:hover {
    border-color: var(--terracotta-light);
    color: var(--terracotta);
}

.db-detail-row td {
    padding: 0 10px 12px 10px;
    background: var(--cream);
}

.db-detail-content {
    padding: 8px 0;
}

.db-subtable {
    width: auto;
    border-collapse: collapse;
    font-size: 12px;
}

.db-subtable th {
    padding: 4px 12px 4px 0;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink-faint);
    font-weight: 600;
    border-bottom: 1px solid var(--parchment);
    text-align: left;
}

.db-subtable td {
    padding: 4px 12px 4px 0;
    border-bottom: 1px solid var(--cream-dark);
    color: var(--ink-light);
}

.db-group-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 400;
    margin: 16px 0 8px;
    color: var(--ink);
}

.db-group-title:first-child {
    margin-top: 0;
}

.db-group-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-faint);
    font-weight: 400;
}

/* ============================================================
   PRAVIDLA CARDS
   ============================================================ */

.pravidlo-card {
    padding: 14px 18px;
    background: white;
    border: 1px solid var(--parchment);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.pravidlo-card--planned {
    opacity: 0.65;
    border-style: dashed;
}

.pravidlo-card__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.pravidlo-card__status {
    font-size: 14px;
}

.pravidlo-card__badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
}

.pravidlo-card__name {
    font-size: 13px;
    color: var(--ink);
}

.pravidlo-card__desc {
    font-size: 12.5px;
    color: var(--ink-light);
    line-height: 1.6;
    margin: 0;
}

.pravidlo-card__params {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-faint);
    margin-top: 6px;
    padding: 4px 8px;
    background: var(--cream);
    border-radius: 3px;
    display: inline-block;
}

/* ============================================================
   AUDIT
   ============================================================ */

.audit-box {
    background: var(--cream);
    border: 1px solid var(--parchment);
    border-radius: var(--radius);
    padding: 12px 16px;
}

.audit-formula {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-light);
    line-height: 1.8;
}

.audit-result {
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
}

.audit-ok {
    color: var(--sage-dim);
}

.audit-fail {
    color: var(--ruby);
}

.audit-day {
    border: 1px solid var(--parchment);
    border-radius: var(--radius);
    margin-bottom: 4px;
}

.audit-day__summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    list-style: none;
    transition: background 0.15s;
}

.audit-day__summary::-webkit-details-marker { display: none; }

.audit-day__summary::before {
    content: '▶';
    font-size: 8px;
    color: var(--ink-faint);
    margin-right: 8px;
    transition: transform 0.2s;
}

.audit-day[open] .audit-day__summary::before {
    transform: rotate(90deg);
}

.audit-day__summary:hover {
    background: var(--cream);
}

.audit-day__name {
    font-weight: 500;
}

.audit-day__cost {
    font-size: 12px;
}

.audit-day__detail {
    padding: 0 14px 12px;
}

/* Clickable commodity */
.commodity {
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius);
    margin: -6px -8px;
    transition: background 0.15s;
}

.commodity:hover {
    background: var(--cream-dark);
}
