:root {
    --bg: #05080e;
    --bg-elevated: #0c1018;
    --surface: rgba(22, 30, 44, 0.72);
    --surface-solid: #161e2c;
    --surface-hover: rgba(36, 48, 68, 0.85);
    --border: rgba(96, 165, 250, 0.14);
    --border-strong: rgba(255, 255, 255, 0.08);
    --text: #e8edf4;
    --text-muted: #8b9cb3;
    --primary: #4ade80;
    --primary-dim: #22c55e;
    --accent: #60a5fa;
    --warning: #fbbf24;
    --orange: #fb923c;
    --danger: #f87171;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --glow-green: rgba(74, 222, 128, 0.2);
    --glow-blue: rgba(96, 165, 250, 0.18);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse 90% 60% at 10% -10%, var(--glow-blue), transparent 50%),
        radial-gradient(ellipse 70% 50% at 100% 0%, var(--glow-green), transparent 45%),
        radial-gradient(ellipse 50% 40% at 50% 100%, rgba(99, 102, 241, 0.08), transparent 50%);
}

.app {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px 88px;
}

.header {
    text-align: center;
    margin-bottom: 28px;
}

.header-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 8px 12px;
    min-height: 2.75rem;
}

.header-row h1 {
    grid-column: 2;
    justify-self: center;
    text-align: center;
    max-width: 100%;
}

.user-info {
    grid-column: 3;
    justify-self: end;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px 8px;
    min-width: 0;
    max-width: 100%;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.user-info #user-login {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: min(42vw, 168px);
}

@media (max-width: 480px) {
    .header-row {
        grid-template-columns: 1fr;
        justify-items: center;
        min-height: 0;
        padding-bottom: 4px;
    }

    .header-row h1 {
        grid-column: 1;
        width: 100%;
    }

    .user-info {
        grid-column: 1;
        justify-self: stretch;
        justify-content: center;
        max-width: 100%;
    }

    .user-info #user-login {
        max-width: min(72vw, 280px);
    }
}

.header-eyebrow {
    font-size: 0.65rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
    opacity: 0.9;
    margin-top: 10px;
}

.user-info #user-login:not(:empty) {
    margin-right: 8px;
}

.logout-btn {
    padding: 6px 14px !important;
    font-size: 0.78rem !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid var(--border-strong) !important;
    color: var(--text-muted) !important;
    text-decoration: none;
    border-radius: 999px !important;
}

.logout-btn:hover {
    border-color: rgba(248, 113, 113, 0.5) !important;
    color: var(--danger) !important;
    background: rgba(248, 113, 113, 0.08) !important;
}

.header h1 {
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--primary);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 6px;
    font-size: 0.95rem;
}

.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(5, 8, 14, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(96, 165, 250, 0.15), transparent 55%),
        radial-gradient(ellipse at 80% 70%, rgba(74, 222, 128, 0.1), transparent 50%);
    pointer-events: none;
}

.login-card {
    position: relative;
    background: linear-gradient(165deg, rgba(22, 30, 44, 0.95), rgba(12, 16, 24, 0.98));
    border: 1px solid rgba(96, 165, 250, 0.25);
    border-radius: 20px;
    padding: 48px 32px;
    text-align: center;
    box-shadow: var(--shadow), 0 0 48px rgba(96, 165, 250, 0.08);
    max-width: 380px;
    width: 100%;
}

.login-card h1,
.login-card .login-brand {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.login-card .subtitle {
    margin-bottom: 24px;
}

.login-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: rgba(248, 113, 113, 0.1);
    border-radius: 6px;
}

.yandex-btn {
    display: inline-block;
    padding: 12px 24px;
    background: #ff5a3d;
    color: #fff;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    border: 1px solid #ffc4b8;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
    transition: background 0.2s, transform 0.15s;
}

.yandex-btn:hover {
    background: #ff6b52;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.header-login-btn {
    padding: 8px 12px;
    font-size: 0.78rem;
    white-space: normal;
    line-height: 1.25;
    text-align: center;
}

.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 24px;
    background: rgba(15, 20, 28, 0.92);
    padding: 5px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.tab {
    flex: 1;
    padding: 11px 14px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.tab.active {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.95), rgba(74, 222, 128, 0.85));
    color: #05080e;
}

.tab-content {
    display: none;
}

@keyframes tabIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.tab-content.active {
    display: block;
    animation: tabIn 0.35s ease;
}

.card {
    position: relative;
    background: linear-gradient(165deg, #1a2332, #0c1018);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse 80% 50% at 100% 0%, rgba(96, 165, 250, 0.06), transparent);
    opacity: 0.9;
}

.card > * {
    position: relative;
    z-index: 1;
}

.card h2, .card h3 {
    margin-bottom: 16px;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.card h2::after, .card h3::after {
    content: '';
    display: block;
    width: 32px;
    height: 2px;
    margin-top: 8px;
    border-radius: 1px;
    background: linear-gradient(90deg, var(--primary), transparent);
    opacity: 0.7;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.form-grid .full-width {
    grid-column: 1 / -1;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

input, select {
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: rgba(5, 8, 14, 0.55);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    color-scheme: dark;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-text-fill-color: var(--text);
    caret-color: var(--text);
    box-shadow: 0 0 0 1000px #0c1018 inset;
    transition: background-color 99999s ease-out;
}

input:focus, select:focus {
    outline: none;
    border-color: rgba(74, 222, 128, 0.55);
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12);
}

.btn {
    padding: 11px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary-dim), var(--primary));
    color: #05080e;
    box-shadow: 0 4px 20px var(--glow-green);
}

.btn.primary:hover {
    box-shadow: 0 6px 28px rgba(74, 222, 128, 0.35);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border: 1px solid var(--border-strong);
}

.btn.secondary:hover {
    border-color: rgba(96, 165, 250, 0.45);
    background: rgba(96, 165, 250, 0.08);
}

.btn.quick {
    background: rgba(96, 165, 250, 0.08);
    color: var(--accent);
    border: 1px solid rgba(96, 165, 250, 0.25);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
}

.btn.quick:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(74, 222, 128, 0.1);
}

.result-card {
    border-color: rgba(74, 222, 128, 0.35);
    box-shadow: var(--shadow), 0 0 32px rgba(74, 222, 128, 0.08);
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.result-item {
    text-align: center;
    padding: 18px 12px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
}

.result-item.highlight {
    border-color: rgba(74, 222, 128, 0.4);
    background: linear-gradient(145deg, rgba(74, 222, 128, 0.08), rgba(12, 16, 24, 0.5));
}

.result-label {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.result-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--primary);
    background: linear-gradient(135deg, var(--primary), #fff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.result-unit {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.custom-calories-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.custom-calories-label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.custom-calories-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.custom-calories-input-row input {
    flex: 1;
    max-width: 180px;
}

.custom-calories-input-row .btn.secondary {
    padding: 8px 14px;
    font-size: 0.85rem;
}

.hidden {
    display: none !important;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 48px 24px;
    font-size: 0.95rem;
}

.counter-card {
    text-align: center;
    padding-top: 20px;
}

.counter-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.date-header {
    color: var(--text-muted);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0;
}

.weight-display {
    position: relative;
    cursor: help;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: right;
}

.weight-display .weight-value {
    font-size: 1.3rem;
}

.weight-display .weight-value.bmi-underweight { color: var(--danger); }
.weight-display .weight-value.bmi-normal { color: var(--primary); }
.weight-display .weight-value.bmi-overweight { color: var(--warning); }
.weight-display .weight-value.bmi-obesity1 { color: var(--orange); }
.weight-display .weight-value.bmi-obesity2 { color: var(--orange); }
.weight-display .weight-value.bmi-obesity3 { color: var(--danger); }

.bmi-indicator {
    font-size: 0.8rem;
    font-weight: 400;
    margin-top: 2px;
}

.bmi-tooltip {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    white-space: nowrap;
    z-index: 100;
    box-shadow: var(--shadow);
    font-weight: 400;
    font-size: 0.8rem;
    line-height: 1.7;
}

.weight-display:hover .bmi-tooltip {
    display: block;
}

.bmi-tooltip .range-normal { color: var(--primary); }
.bmi-tooltip .range-overweight { color: var(--warning); }
.bmi-tooltip .range-obesity1 { color: var(--orange); }
.bmi-tooltip .range-obesity2 { color: var(--orange); }
.bmi-tooltip .range-obesity3 { color: var(--danger); }
.bmi-tooltip .range-underweight { color: var(--danger); }
.bmi-tooltip .current-mark {
    font-weight: 700;
}

.bmi-tooltip .range-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.bmi-tooltip .range-row.current {
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    padding: 0 4px;
}

.counter-display {
    display: flex;
    justify-content: center;
    margin: 20px 0 8px;
    filter: drop-shadow(0 0 24px rgba(74, 222, 128, 0.15));
}

.counter-ring {
    position: relative;
    width: 228px;
    height: 228px;
}

.counter-ring svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 12;
}

.ring-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.5s ease, stroke 0.3s;
    filter: drop-shadow(0 0 8px rgba(74, 222, 128, 0.45));
}

.counter-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.counter-number {
    font-size: 3.1rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--primary);
    background: linear-gradient(180deg, #fff 20%, var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.counter-number.counter-tone-warn {
    color: var(--warning);
    background: linear-gradient(180deg, #fff 15%, var(--warning));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.counter-number.counter-tone-danger {
    color: var(--danger);
    background: linear-gradient(180deg, #fff 15%, var(--danger));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.counter-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.counter-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-strong);
}

.stat-value {
    display: block;
    font-size: 1.45rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.meal-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.weight-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.meal-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    flex-wrap: wrap;
}

.meal-row-desc {
    flex-wrap: nowrap;
}

.meal-row-desc input[type="text"] {
    flex: 1;
    min-width: 0;
}

.meal-tools {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.meal-tool-btn {
    width: 44px;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: rgba(96, 165, 250, 0.1) !important;
    border: 1px solid rgba(96, 165, 250, 0.3) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--accent) !important;
    transition: background 0.2s, border-color 0.2s, opacity 0.2s, transform 0.15s;
}

.meal-tool-btn:hover:not(:disabled) {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    background: rgba(74, 222, 128, 0.12) !important;
}

.meal-tool-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.meal-llm-btn:not(:disabled) {
    border-color: rgba(167, 139, 250, 0.4) !important;
    color: #c4b5fd !important;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.12), rgba(167, 139, 250, 0.14)) !important;
}

.meal-llm-btn.loading {
    opacity: 0.5;
    pointer-events: none;
}

.meal-row-meta input[type="time"] {
    width: 118px;
    flex: 0 0 auto;
}

.meal-row-meta input[type="number"] {
    width: 96px;
    flex: 0 0 auto;
}

.meal-submit {
    flex: 1;
    min-width: 120px;
}

.meal-hint {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.quick-add {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-strong);
}

.quick-add-label {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.quick-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
}

.quick-buttons .btn.quick {
    flex: 0 0 auto;
}

.weight-form input {
    width: 100px;
}

/* Voice UI: скрыт только на boot-splash (body.app-booting в index.html) */

/* Клики по калькулятору под шторкой — body.voice-sheet-open в voice-sheet.css */

/* Toggles: нативный checkbox не рисуем (глобальные input { padding, border }) */
#voice-sheet .voice-toggle-input {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    opacity: 0 !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    background: transparent !important;
    box-shadow: none !important;
    min-height: 0 !important;
    cursor: pointer;
    z-index: 2;
}

#voice-sheet label.voice-toggle-pill {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
    padding: 0;
    font-size: inherit;
    color: inherit;
    cursor: pointer;
}

#voice-sheet .voice-toggle-switch {
    display: block;
    width: 40px;
    height: 22px;
    position: relative;
    flex-shrink: 0;
}

#voice-sheet label.voice-toggle-pill.is-on .voice-toggle-ui,
#voice-sheet label.voice-toggle-pill:has(.voice-toggle-input:checked) .voice-toggle-ui {
    background: var(--primary-dim);
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.35);
}

#voice-sheet label.voice-toggle-pill.is-on .voice-toggle-ui::after,
#voice-sheet label.voice-toggle-pill:has(.voice-toggle-input:checked) .voice-toggle-ui::after {
    transform: translateX(18px);
}

#voice-sheet .voice-toggle-ui {
    display: block;
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.1);
    position: relative;
    pointer-events: none;
    transition: background 0.2s, box-shadow 0.2s;
}

#voice-sheet .voice-toggle-ui::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.03); }
}

.meals-list {
    list-style: none;
}

.meals-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 10px;
    margin-bottom: 6px;
    border-bottom: none;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-strong);
    cursor: grab;
    transition: background 0.15s, border-color 0.15s;
}

.meals-list li:hover {
    border-color: rgba(96, 165, 250, 0.2);
}

.meals-list li:last-child {
    margin-bottom: 0;
}

.meals-list li.dragging {
    opacity: 0.4;
}

.meals-list li.drag-over {
    border-top: 2px solid var(--primary);
}

.drag-handle {
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: grab;
    user-select: none;
    padding: 0 4px;
}

.meal-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.15s;
}

.btn-icon:hover {
    color: var(--danger);
    background: rgba(248, 113, 113, 0.1);
}

.meal-desc {
    font-weight: 500;
}

.meal-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.meal-kcal {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--warning);
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.25);
}

.chart-container {
    position: relative;
    height: 280px;
}

.timeline-chart-container {
    margin-top: 16px;
    height: 120px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.history-table th, .history-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.history-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.history-table tbody tr {
    transition: background 0.15s;
}

.history-table tbody tr:hover {
    background: rgba(96, 165, 250, 0.06);
}

.toast {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom, 0));
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(165deg, #1a2332, #0c1018);
    border: 1px solid rgba(74, 222, 128, 0.45);
    color: var(--text);
    padding: 14px 22px;
    border-radius: 14px;
    box-shadow: var(--shadow), 0 0 32px rgba(74, 222, 128, 0.12);
    z-index: 1060;
    max-width: min(90vw, 420px);
    text-align: center;
    font-size: 0.92rem;
    animation: fadeIn 0.3s;
}

.toast.error-toast,
.toast[data-error="true"] {
    border-color: rgba(248, 113, 113, 0.5);
    box-shadow: var(--shadow), 0 0 32px rgba(248, 113, 113, 0.12);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 520px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid input,
    .form-grid select {
        width: 100%;
    }

    .form-grid select {
        font-size: 0.8rem;
    }

    .custom-calories-input-row {
        flex-wrap: wrap;
    }

    .custom-calories-input-row input {
        max-width: 100%;
        flex: 1 1 100%;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    .counter-number {
        font-size: 2.5rem;
    }
}


.guest-login-fallback {
    margin: 0 0 16px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(255, 90, 61, 0.08);
    border: 1px solid rgba(255, 90, 61, 0.25);
    text-align: center;
}

.guest-login-fallback p {
    margin: 0 0 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Cookie / login legal — на главной (раньше в legal.css) */
.js-fail-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    padding: 12px 16px;
    background: rgba(127, 29, 29, 0.95);
    color: #fecaca;
    font-size: 0.9rem;
    text-align: center;
    border-bottom: 1px solid rgba(248, 113, 113, 0.4);
}

.js-fail-banner a {
    color: #fff;
    font-weight: 600;
}

.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    background: linear-gradient(180deg, #0c1018, #05080e);
    border-top: 1px solid rgba(96, 165, 250, 0.2);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
    padding: 16px 20px;
}

.cookie-banner.hidden {
    display: none;
}

.cookie-banner-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
}

.cookie-banner-text {
    flex: 1 1 240px;
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.cookie-banner-text a {
    color: var(--accent);
}

.login-legal-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.4;
}

.login-legal-note a {
    color: var(--accent);
}

.guest-mode .requires-auth {
    opacity: 0.85;
}

.guest-mode .requires-auth.btn.primary::after,
.guest-mode .requires-auth.btn.secondary::after,
.guest-mode .requires-auth.btn.quick::after {
    content: ' — нужен вход';
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
    font-weight: 400;
}

.app-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px 20px;
    margin-top: 32px;
    padding: 20px 16px;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-strong);
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.2));
}

.app-footer a {
    color: var(--accent);
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}

#app-version {
    font-variant-numeric: tabular-nums;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: rgba(255, 255, 255, 0.03);
}

.seo-content {
    margin-top: 28px;
    padding: 20px 16px 24px;
    border-top: 1px solid var(--border-strong);
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.55;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.seo-content h2 {
    font-size: 1.05rem;
    color: var(--text);
    margin: 0 0 12px;
}

.seo-content p {
    margin: 0 0 12px;
}

.seo-content ul {
    margin: 0 0 16px;
    padding-left: 1.25rem;
}

.seo-content li {
    margin-bottom: 6px;
}

.seo-faq {
    margin-top: 8px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.02);
}

.seo-faq summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
}

.seo-faq dl {
    margin: 12px 0 0;
}

.seo-faq dt {
    font-weight: 600;
    color: var(--text);
    margin-top: 10px;
}

.seo-faq dd {
    margin: 4px 0 0;
}

.seo-more-links {
    margin-top: 12px;
    font-size: 0.88rem;
}

.seo-more-links a {
    color: var(--accent);
}

.ymyl-disclaimer {
    flex: 1 1 100%;
    margin: 0;
    text-align: center;
    font-size: 0.78rem;
    line-height: 1.45;
    max-width: 640px;
}

.ymyl-disclaimer a {
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}

.ymyl-disclaimer a:hover {
    text-decoration: underline;
}
