/* =========================================
   Kitchen Planner — CSS Variables & Reset
   ========================================= */
:root {
    color-scheme: dark;
    /* Dark theme (default) - deep blue-gray, not black */
    --bg-primary: #0f1419;
    --bg-secondary: #151c24;
    --bg-tertiary: #1c252e;
    --bg-card: #1a212c;
    --bg-input: #1e2732;
    --bg-hover: #232d3a;
    --bg-active: #2a3644;

    --text-primary: #e8ecf1;
    --text-secondary: #a0aab8;
    --text-muted: #6b7888;
    --text-on-accent: #0d1117;

    --accent: #ff8c00;           /* warm amber-orange */
    --accent-hover: #ff9f1f;
    --accent-light: rgba(255, 140, 0, 0.15);
    --accent-glow: rgba(255, 140, 0, 0.3);

    --border: #2a3644;
    --border-light: #354050;

    --success: #22c55e;
    --success-light: rgba(34, 197, 94, 0.15);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    --shadow-glass: 0 8px 32px rgba(0,0,0,0.3);

    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --radius-xl: 24px;

    --glass-bg: rgba(26, 33, 44, 0.8);
    --glass-border: rgba(255, 140, 0, 0.1);
    --glass-blur: blur(12px);

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    --header-h: 56px;
    --nav-h: 72px;
    --max-w: 480px;
    --safe-bottom: env(safe-area-inset-bottom, 0);
}

/* Light theme */
[data-theme="light"] {
    color-scheme: light;
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #edf1f5;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --bg-hover: #eef2f7;
    --bg-active: #e2e8f0;

    --text-primary: #1a1f2e;
    --text-secondary: #5a6878;
    --text-muted: #9aa7b8;
    --text-on-accent: #ffffff;

    --accent: #e67300;
    --accent-hover: #cc6600;
    --accent-light: rgba(230, 115, 0, 0.12);
    --accent-glow: rgba(230, 115, 0, 0.25);

    --border: #e2e8f0;
    --border-light: #d1d9e3;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.12);
    --shadow-glass: 0 8px 32px rgba(15, 23, 42, 0.08);

    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(230, 115, 0, 0.12);
}

/* =========================================
   Base Styles
   ========================================= */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-tap-highlight-color: transparent; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    overscroll-behavior: none;
}

.app {
    min-height: 100vh;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    max-width: var(--max-w);
    margin: 0 auto;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    position: relative;
}

/* =========================================
   Header
   ========================================= */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
}

.app-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--accent), #ffb84d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions { display: flex; gap: 8px; }

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.icon-btn:active { transform: scale(0.95); }
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .icon-sun { display: none; }
[data-theme="light"] .icon-btn .icon-sun { display: block; }
[data-theme="light"] .icon-btn .icon-moon { display: none; }

/* =========================================
   Main Content
   ========================================= */
.main {
    flex: 1;
    min-height: 0;
    padding: 16px;
    padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-panel {
    display: none;
    animation: fadeIn var(--transition-normal);
}
.tab-panel.active { display: block; }

/* Панель «Меню» — колонка, чтобы слайдер занял ровно остаток
   и не распирал .main (иначе .app выше вьюпорта и страница едет). */
#tab-menu.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}
.tab-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    min-width: 0;
}

/* =========================================
   Buttons
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px;
    min-width: 44px;
    white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: var(--text-on-accent);
    box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-light); }

.btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: white; }

/* =========================================
   Accordion (Products)
   ========================================= */
.accordion { display: flex; flex-direction: column; gap: 10px; }

.accordion-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: none;
    width: 100%;
    text-align: left;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.accordion-header:hover { background: var(--bg-hover); }
.accordion-header:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.accordion-header .count {
    background: var(--accent-light);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
}

.accordion-icon {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-normal);
    flex-shrink: 0;
}
.accordion-section.open .accordion-icon { transform: rotate(180deg); }

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow), padding var(--transition-normal);
}
.accordion-section.open .accordion-content {
    max-height: 2000px;
    padding: 12px 16px 16px;
}

/* Product Groups */
.category-group { margin-bottom: 16px; }
.category-group:last-child { margin-bottom: 0; }

.category-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0 4px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.category-title::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: var(--accent);
}

.product-list { display: flex; flex-direction: column; gap: 8px; }

/* Product Card */
.product-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
    overflow: hidden;
}
.product-card:active { background: var(--bg-hover); }
.product-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.product-card.state-запас { border-left: 3px solid var(--success); }
.product-card.state-использование { border-left: 3px solid var(--accent); }
.product-card.state-кончилось {
    opacity: 0.5;
    border-left: 3px solid var(--text-muted);
}
.product-card.state-кончилось .product-name { text-decoration: line-through; }

.product-info { flex: 1; min-width: 0; }
.product-name {
    font-weight: 500;
    font-size: 0.9375rem;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.product-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.product-note { color: var(--accent); font-weight: 500; }

.product-qty {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.card-arrow {
    flex-shrink: 0;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--text-muted);
    margin-left: -4px;
}
.qty-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px;
    min-width: 44px;
}
.qty-btn:active { transform: scale(0.9); background: var(--accent); color: var(--text-on-accent); }
.qty-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.qty-value {
    min-width: 36px;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
}

/* =========================================
   Empty States
   ========================================= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}
.empty-icon { width: 64px; height: 64px; color: var(--text-muted); opacity: 0.5; margin-bottom: 16px; }
.empty-state h3 { margin: 0 0 8px; font-size: 1rem; font-weight: 600; color: var(--text-secondary); }
.empty-state p { margin: 0 0 20px; font-size: 0.875rem; line-height: 1.5; }

/* =========================================
   Menu Tab — Week Slider
   ========================================= */
.week-slider {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    height: calc(100vh - 230px);
    height: calc(100dvh - 230px);
    min-height: 360px;
    max-height: 100%;
    overflow: hidden;
}
.slides-container {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
}
.week-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 0;
}
.week-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all var(--transition-normal);
    cursor: pointer;
}
.week-dot.active {
    background: var(--accent);
    transform: scale(1.3);
    box-shadow: 0 0 8px var(--accent-glow);
}

.slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    transition: opacity var(--transition-normal), background var(--transition-fast);
}
.week-slider:hover .slider-nav,
.week-slider:focus-within .slider-nav { opacity: 1; }
.slider-nav:hover { background: var(--bg-hover); }
.slider-nav.prev { left: 8px; }
.slider-nav.next { right: 8px; }

.day-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%);
    transition: all var(--transition-slow);
    pointer-events: none;
}
.day-slide.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
    z-index: 5;
}
.day-slide.prev { transform: translateX(-100%); }

.day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 0 12px;
    flex-shrink: 0;
}
.day-label {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.day-nav {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 1;
    transition: background var(--transition-fast), transform var(--transition-fast);
}
.day-nav:hover { background: var(--bg-hover); }
.day-nav:active { transform: scale(0.94); }
.day-nav:disabled { opacity: 0.35; cursor: default; }

/* Стрелки дней теперь живут в заголовке дня (.day-nav), старые убираем */
.slider-nav,
#week-prev,
#week-next { display: none !important; }

.meals-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 4px 12px;
}

.meal-section { margin-bottom: 20px; }
.meal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.meal-title::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.meal-section[data-meal="обед"] .meal-title::before { background: #f59e0b; }
.meal-section[data-meal="ужин"] .meal-title::before { background: #8b5cf6; }

.dish-carousel {
    display: block;
    overflow: hidden;
    padding: 0 0 8px;
    flex: 0 0 auto;
    touch-action: pan-y;
    position: relative;
}
.dish-track {
    display: flex;
    will-change: transform;
}
.dish-carousel::-webkit-scrollbar { display: none; }

.dish-card {
    flex: 0 0 100%;
    max-width: 100%;
    scroll-snap-align: start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}
.dish-like {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-input);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.dish-like:active { transform: scale(0.94); }
.dish-card.has-recipe { cursor: pointer; }
.dish-card:active { background: var(--bg-hover); }

.dish-slot { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.dish-name { font-size: 1rem; font-weight: 600; margin: 0 0 8px; line-height: 1.3; }
.dish-empty { color: var(--text-muted); font-size: 0.875rem; }
.dish-ingredients {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}
.ingredient-tag {
    font-size: 0.6875rem;
    padding: 3px 8px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 100px;
    white-space: nowrap;
}

.dish-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    padding-bottom: 4px;
    flex-shrink: 0;
}
.dish-dot {
    width: 10px;
    height: 10px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--border);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.dish-dot.active { background: var(--accent); transform: scale(1.25); }

.menu-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
    justify-content: flex-end;
}

/* =========================================
   Recipes Tab
   ========================================= */
.sub-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}
.sub-tab {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.sub-tab.active {
    background: var(--accent);
    color: var(--text-on-accent);
    box-shadow: var(--shadow-sm);
}
.sub-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.recipes-list { display: flex; flex-direction: column; gap: 10px; }

.recipe-card {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}
.recipe-card:active { background: var(--bg-hover); }

.recipe-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.recipe-icon svg { width: 28px; height: 28px; }

.recipe-info { flex: 1; min-width: 0; }
.recipe-title { font-weight: 600; font-size: 0.9375rem; margin: 0 0 4px; }
.recipe-meta { display: flex; gap: 12px; font-size: 0.75rem; color: var(--text-muted); }
.recipe-source { font-weight: 500; color: var(--accent); }
.recipe-rating { display: flex; align-items: center; gap: 4px; }
.recipe-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-icon:hover { background: var(--accent-light); color: var(--accent); }
.btn-icon:active { transform: scale(0.9); }
.btn-icon svg { width: 20px; height: 20px; }

.recipe-suggested .btn-icon.save-btn {
    background: var(--success-light);
    color: var(--success);
}
.recipe-suggested .btn-icon.save-btn:hover { background: var(--success); color: white; }

/* =========================================
   Settings
   ========================================= */
.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}
.settings-section h3 { margin: 0 0 12px; font-size: 0.875rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.settings-section:last-of-type { margin-bottom: 0; }

.gateway-info {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.6;
}
.gateway-info .gateway { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.gateway-info .status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}
.gateway-info .status.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.gateway-info .status.offline { background: var(--danger); }

/* Toggle */
.toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 8px 0;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-slider {
    position: relative;
    width: 48px;
    height: 28px;
    border-radius: 100px;
    background: var(--border);
    transition: background var(--transition-normal);
}
.toggle-slider::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-normal);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle input:focus-visible + .toggle-slider { outline: 2px solid var(--accent); outline-offset: 2px; }

.password-field { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.password-section { margin-top: 16px; padding: 0; }
.password-section > summary { padding: 14px 16px; }
.password-section[open] > summary { border-bottom: 1px solid var(--border); }
.password-field input[type="password"] {
    flex: none;
    width: 100%;
    min-width: 0;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9375rem;
}
.password-field .btn { width: 100%; padding: 12px 18px; white-space: normal; }
.password-field small { flex-basis: auto; color: var(--text-muted); font-size: 0.75rem; line-height: 1.35; }
.password-body { padding: 14px 16px 16px; }

/* Categories Manage */
.categories-manage { display: flex; flex-direction: column; gap: 8px; }
.category-manage-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.category-manage-item input[type="text"] { flex: 1; background: transparent; border: none; color: var(--text-primary); font-size: 0.9375rem; outline: none; }
.category-manage-item .category-count {
    min-width: 40px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 600;
    text-align: center;
}
.category-manage-item .btn-icon { opacity: 0; transition: opacity var(--transition-fast); }
.category-manage-item:hover .btn-icon { opacity: 1; }

.danger-zone { border-color: var(--danger); }
.danger-zone h3 { color: var(--danger); }

/* =========================================
   Modals
   ========================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: var(--max-w);
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    z-index: 201;
    transform: translateY(100%);
    transition: transform var(--transition-slow);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.modal.open { transform: translateY(0); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }

.modal-body { padding: 16px; overflow-y: auto; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-group textarea {
    min-height: 140px;
    resize: vertical;
    line-height: 1.5;
}

/* Batch photo recognition rows */
.batch-hint { margin: 0 0 12px; font-size: 0.8125rem; color: var(--text-muted); }
.batch-row {
    display: grid;
    grid-template-columns: auto 1fr 76px;
    grid-template-areas: "check name qty" "check state state";
    gap: 6px 10px;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.batch-row .b-check { grid-area: check; width: 20px; height: 20px; accent-color: var(--accent); }
.batch-row .b-name { grid-area: name; font-size: 0.9375rem; color: var(--text-primary); word-break: break-word; }
.batch-row .b-qty {
    grid-area: qty;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.875rem;
    text-align: center;
}
.batch-row .b-state { grid-area: state; display: flex; gap: 4px; }
.batch-row .b-state button {
    flex: 1;
    padding: 7px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.batch-row .b-state button.active { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }
.batch-row.is-known { border-color: var(--accent); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.form-group input::placeholder { color: var(--text-muted); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; margin-bottom: 0; }

.modal-actions {
    display: flex;
    gap: 12px;
    padding-top: 8px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}
.modal-actions .btn { flex: 1; }

/* Long Press Modal */
#modal-lp-body { display: flex; flex-direction: column; gap: 8px; }
.lp-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.lp-action:active { background: var(--accent-light); color: var(--accent); }
.lp-action.danger { color: var(--danger); }
.lp-action.danger:active { background: var(--danger-light); }
.lp-action svg { width: 22px; height: 22px; flex-shrink: 0; }

/* =========================================
   Bottom Navigation
   ========================================= */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    height: var(--nav-h);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--glass-border);
    z-index: 100;
    padding-bottom: var(--safe-bottom);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 8px 4px;
    cursor: pointer;
    transition: color var(--transition-normal);
    min-height: 44px;
}
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-item svg { width: 24px; height: 24px; stroke-width: 2; transition: stroke var(--transition-normal); }
.nav-item span { font-size: 0.6875rem; font-weight: 500; }
.nav-item.active { color: var(--accent); }
.nav-item.active svg { stroke: var(--accent); }

/* =========================================
   Toasts
   ========================================= */
.toast-container {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    bottom: auto;
    left: 12px;
    right: 12px;
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 300;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(26, 34, 45, 0.78);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
    animation: slideDown var(--transition-normal);
    pointer-events: auto;
}
[data-theme="light"] .toast {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(0, 0, 0, 0.08);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
.toast-icon { width: 16px; height: 16px; flex-shrink: 0; }
.toast-message { flex: 1; font-size: 0.8125rem; line-height: 1.3; }
.toast-close { color: var(--text-muted); cursor: pointer; padding: 4px; }

/* =========================================
   Inputs & Forms (general)
   ========================================= */
input, select, textarea {
    font-family: inherit;
}

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* Focus visible for all interactive */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* =========================================
   Segmented control (куда добавить)
   ========================================= */
.segmented {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.seg-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding: 10px 6px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: normal;
}
.seg-btn.active {
    background: var(--accent);
    color: #fff;
}

/* Фото в модалке продукта */
.photo-upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.photo-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =========================================
   Свои рецепты: строки ингредиентов
   ========================================= */
.ingredient-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.ingredient-row .ing-name,
.ingredient-row .ing-qty {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9375rem;
    outline: none;
}
.ingredient-row .ing-name:focus,
.ingredient-row .ing-qty:focus { border-color: var(--accent); }
.btn-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}
.btn-icon:active { background: var(--bg-hover); }

.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 0.8125rem; }

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 480px) {
    .app { max-width: 100%; }
    .modal { border-radius: 0; max-height: 90vh; }
    .seg-btn { font-size: 0.72rem; padding: 10px 4px; }
    .day-label { font-size: 1.125rem; }
}
/* =========================================
   Цвет акцента (палитра в настройках)
   ========================================= */
.accent-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 4px 0;
}
.accent-swatch {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}
.accent-swatch:active { transform: scale(0.92); }
.accent-swatch.active { border-color: var(--text-primary); }

/* =========================================
   Просмотр рецепта: бейджи + таймлайн
   ========================================= */
.recipe-view-ingredients {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 14px;
}
.recipe-view-ingredients .ingredient-tag {
    font-size: 0.8125rem;
    padding: 5px 10px;
}
.recipe-view-steps-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 10px;
    color: var(--text-secondary);
}
.recipe-timeline {
    list-style: none;
    margin: 0;
    padding: 0 0 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.recipe-timeline li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    position: relative;
    padding-left: 0;
}
.recipe-timeline li:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 13px;
    top: 30px;
    bottom: -12px;
    width: 2px;
    background: var(--border);
}
.step-num {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}
.step-text {
    font-size: 0.9375rem;
    line-height: 1.45;
    padding-top: 3px;
}
.recipe-view-empty {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* =========================================
   Полоса дней недели (Меню)
   ========================================= */
.week-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 0;
    flex-wrap: wrap;
}
.day-chip {
    touch-action: manipulation;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 42px;
    padding: 6px 4px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.day-chip-wd { font-size: 0.625rem; font-weight: 700; letter-spacing: .4px; }
.day-chip-num { font-size: 0.9375rem; font-weight: 700; }
.day-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 10px var(--accent-glow);
    transform: translateY(-1px);
}

/* =========================================
   Покупки
   ========================================= */
.shopping-list { display: flex; flex-direction: column; gap: 16px; padding-bottom: 12px; }
.shopping-group { display: flex; flex-direction: column; gap: 8px; }
.shopping-group-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    padding-left: 4px;
}
.shopping-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    cursor: pointer;
}
.shopping-item input { width: 20px; height: 20px; accent-color: var(--accent); }
.shopping-name { flex: 1; font-size: 0.9375rem; }
.shopping-qty { font-size: 0.8125rem; color: var(--text-muted); }
.shopping-item.checked .shopping-name { text-decoration: line-through; opacity: .55; }
.shopping-item.checked .shopping-qty { opacity: .55; }

/* =========================================
   Редактор шагов (визуальный)
   ========================================= */
.steps-editor { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.step-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.step-row .step-num { margin-top: 6px; }
.step-input {
    flex: 1;
    resize: none;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.4;
}
.step-remove { margin-top: 6px; flex-shrink: 0; }

/* =========================================
   Спойлеры предложенных рецептов
   ========================================= */
.recipe-spoiler {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    margin-bottom: 12px;
    overflow: hidden;
}
.recipe-spoiler > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.recipe-spoiler > summary::-webkit-details-marker { display: none; }
.recipe-spoiler > summary::after {
    content: "›";
    margin-left: auto;
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}
.recipe-spoiler[open] > summary::after { transform: rotate(90deg); }
.spoiler-count {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 100px;
    background: var(--accent-light);
    color: var(--accent);
}
.recipe-spoiler .recipes-list { padding: 0 10px 10px; }

/* Бейдж источника рецепта в карточке меню */
.dish-source {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 100px;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
    background: var(--accent-light);
    color: var(--accent);
    vertical-align: middle;
}

/* Опасная зона под спойлером */
.danger-zone.recipe-spoiler > summary { color: var(--danger); }
.danger-zone-body { padding: 0 14px 14px; }

/* Отступ кнопки «+ Добавить категорию» от списка категорий */
.categories-manage { margin-bottom: 12px; }
#btn-add-category { margin-top: 4px; }

/* Покупки: действия в один ряд, компактные кнопки */
#tab-shopping .shopping-actions {
    flex-wrap: nowrap;
    gap: 8px;
}
#tab-shopping .shopping-actions .btn {
    white-space: nowrap;
    padding-left: 10px;
    padding-right: 10px;
    font-size: 0.8125rem;
}

/* Индикатор фоновой генерации */
.global-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    z-index: 3000;
    background: var(--border);
    overflow: visible;
}
.global-progress-bar {
    height: 100%;
    width: 40%;
    background: var(--accent);
    animation: gp-slide 1.1s ease-in-out infinite;
}
@keyframes gp-slide {
    0% { margin-left: -40%; }
    100% { margin-left: 100%; }
}
.global-progress-label {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3001;
    padding: 6px 14px;
    border-radius: 100px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--accent);
    white-space: nowrap;
}

/* =========================================
   Login page
   ========================================= */
.login-page {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 30% 20%, var(--accent-light), transparent 60%), var(--bg-primary);
}
.login-card {
    width: 100%;
    max-width: 360px;
    padding: 32px 24px 28px;
    border-radius: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-logo {
    width: 96px;
    height: 96px;
    margin: 0 auto 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 52px;
    line-height: 1;
    background: var(--accent-light);
    border: 2px solid var(--accent);
}
.login-title {
    margin: 0 0 4px;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.login-subtitle {
    margin: 0 0 22px;
    color: var(--text-muted);
    font-size: 0.875rem;
}
#login-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#login-page-password {
    width: 100%;
    padding: 13px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
    text-align: center;
    letter-spacing: 2px;
}
#login-page-password:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.login-btn {
    width: 100%;
    padding: 13px;
    font-size: 1rem;
}
.login-error {
    min-height: 18px;
    color: var(--danger);
    font-size: 0.8125rem;
}
.password-error { flex-basis: 100%; min-height: 16px; color: var(--danger); font-size: 0.75rem; line-height: 1.35; }
.install-hint { margin: 0 0 12px; color: var(--text-muted); font-size: 0.8125rem; line-height: 1.4; }
#btn-install-app { width: 100%; }

/* Покупки: ручное добавление и удаление строк */
.shopping-add { display: flex; gap: 8px; margin: 0 0 14px; }
.shopping-add input {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9375rem;
}
.shopping-add-btn {
    width: 48px;
    min-width: 48px;
    font-size: 1.35rem;
    line-height: 1;
    padding: 0;
}
.shopping-item-label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.shopping-del {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}
.shopping-del:hover { background: rgba(255, 80, 80, 0.12); color: var(--danger); }

/* Generation icon spinner */
.icon-btn.is-loading svg {
    animation: kitchen-spin 1s linear infinite;
}
@keyframes kitchen-spin {
    to { transform: rotate(360deg); }
}

/* Generation buttons in header */
.icon-btn { position: relative; }
.regen-btn .regen-badge {
    position: absolute;
    right: 1px;
    bottom: 1px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    padding: 1px 3px;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
}
.regen-btn#btn-regen-week { color: var(--accent); }
.regen-btn#btn-regen-day { color: var(--accent); }

/* Время готовки */
.dish-time, .recipe-time {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-input);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.recipe-time { margin-left: 8px; font-size: 0.75rem; }

/* Автофилл/нативные контролы: не даём браузеру красить поля в белый */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-text-fill-color: var(--text-primary);
    -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset;
    box-shadow: 0 0 0 1000px var(--bg-input) inset;
    transition: background-color 9999s ease-out 0s;
}
input, textarea, select {
    -webkit-appearance: none;
    appearance: none;
    color-scheme: inherit;
}

/* Кнопки «Приложение»: одинаковые, с отступом, без вылезания за карточку */
#install-app-section .btn {
    display: flex;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.25;
    text-align: center;
}
#btn-reset-cache { margin-bottom: 12px; }

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


/* Шлюзы LLM: редактируемые поля */
.gw-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
}
.gw-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}
.gw-name { font-weight: 600; font-size: 0.9375rem; }
.gw-card input,
.gw-vision input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.875rem;
}
.gw-vision {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    margin: 4px 0 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
}
.gw-vision h4 { margin: 0; font-size: 0.9375rem; }
.gw-vision small { color: var(--text-muted); font-size: 0.75rem; line-height: 1.35; }
#btn-save-gateways { width: 100%; }

.gw-bottom { display: flex; gap: 8px; align-items: stretch; }
.gw-bottom input { flex: 1; min-width: 0; }
.gw-prio { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.gw-prio select {
    padding: 8px 6px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.gw-head { display: flex; align-items: center; gap: 8px; }
.gw-title {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.875rem;
}
.gw-move { display: flex; gap: 4px; }
.gw-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
}
.gw-icon:hover { border-color: var(--accent); }
.gw-icon.gw-del { color: var(--danger); }
#btn-add-gateway { width: 100%; margin-bottom: 12px; }
