/* css/style.css — в стиле golos.rureef.ru с поддержкой темы */
:root {
    --primary: #4a6fa5;
    --primary-light: #6b8cbe;
    --accent: #7eb8da;
    --aqua: #5ba3b0;
    --deep-blue: #0d47a1;
    --bg: #f4f5f6;
    --card: #fafbfc;
    --text: #374151;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --coral: #e07a7a;
    --success: #4caf50;
    --warning: #d97706;
    --danger: #dc2626;
    --text-color: var(--text);
    --border-color: var(--border);
    --light-bg: var(--bg);
    --gray-btn: #6c757d;
    --gray-btn-hover: #5a6268;
    --white: #ffffff;
    --off-white: var(--card);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    --glass-blue: rgba(74, 111, 165, 0.08);
    --sump-green: rgba(40, 167, 69, 0.1);
    --transition: all 0.3s ease;
    --radius: 16px;
}

[data-theme="dark"] {
    --primary: #1e3a8a;
    --primary-light: #3b82f6;
    --aqua: #7eb8da;
    --deep-blue: #1e3a8a;
    --bg: #0f172a;
    --card: #1e293b;
    --text: #e2e8f0;
    --text-light: #94a3b8;
    --border: #334155;
    --text-color: var(--text);
    --border-color: var(--border);
    --coral: #f87171;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --glass-blue: rgba(30, 58, 138, 0.2);
}
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--card);
    color: var(--text);
    border-color: var(--border);
}

/* Ползунки в тёмной теме — видимый трек и бегунок */
[data-theme="dark"] input[type="range"] {
    background: var(--border);
}
[data-theme="dark"] input[type="range"]::-webkit-slider-thumb {
    background: var(--aqua);
    border-color: var(--card);
    box-shadow: 0 0 0 2px var(--border), 0 2px 6px rgba(0,0,0,0.3);
}
[data-theme="dark"] input[type="range"]::-webkit-slider-runnable-track {
    background: var(--border);
}
[data-theme="dark"] input[type="range"]::-moz-range-track {
    background: var(--border);
}
[data-theme="dark"] input[type="range"]::-moz-range-thumb {
    background: var(--aqua);
    border: 3px solid var(--card);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Видимый фокус при навигации с клавиатуры (Tab) */
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
.unit-label:focus-visible,
.modal-close:focus-visible {
    outline: 2px solid var(--aqua);
    outline-offset: 2px;
}

button:focus-visible,
[type="button"]:focus-visible,
[type="submit"]:focus-visible {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--aqua);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 16px;
    padding-bottom: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow-x: hidden;
}

.bubbles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}
.bubble {
    position: absolute;
    bottom: -100px;
    border-radius: 50%;
    background: var(--glass-blue);
    box-shadow: 0 0 8px var(--aqua);
    animation: rise 15s infinite ease-in;
}
@keyframes rise {
    0% { transform: translateY(0) scale(0.8); opacity: 0; }
    10% { opacity: 0.7; }
    90% { opacity: 0.4; }
    100% { transform: translateY(-100vh) scale(1.2); opacity: 0; }
}
.wave {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 40px;
    background: radial-gradient(circle at 10% 50%, transparent 45%, var(--aqua) 50%),
        radial-gradient(circle at 30% 50%, transparent 45%, var(--aqua) 50%),
        radial-gradient(circle at 50% 50%, transparent 45%, var(--aqua) 50%),
        radial-gradient(circle at 70% 50%, transparent 45%, var(--aqua) 50%),
        radial-gradient(circle at 90% 50%, transparent 45%, var(--aqua) 50%);
    background-size: 20% 100%;
    animation: wave 8s linear infinite;
    opacity: 0.12;
    pointer-events: none;
    z-index: -1;
}
[data-theme="dark"] .wave { opacity: 0.2; }
@keyframes wave {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Защитный экран */
#protectionOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--deep-blue) 0%, var(--aqua) 100%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    padding: 20px;
}

/* Общая ширина контента */
body > header,
body > .container,
body > .footer {
    width: 100%;
    max-width: 1400px;
}

/* Шапка — как в hcalc.rureef.ru */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--aqua) 100%);
    border-radius: 14px;
    padding: 10px 14px 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    color: #fff;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.15);
}
[data-theme="dark"] .header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--aqua) 100%);
    border-color: rgba(255, 255, 255, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    position: relative;
    z-index: 1;
    flex-wrap: wrap;
}

.header .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    flex-shrink: 0;
}
.header .logo i {
    font-size: 1.4rem;
    color: white;
}

.header-text {
    flex: 1;
    min-width: 200px;
}
.header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    color: #fff;
}
.header .tagline {
    font-size: 0.9rem;
    opacity: 0.95;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.95);
}

/* Кнопка «Поддержать проект» (из donate-button-embed.html) */
.donate-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
    color: #ffb3c1;
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    box-shadow: 0 0 12px rgba(255, 180, 195, 0.4);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
    white-space: nowrap;
}
.donate-btn:hover {
    box-shadow: 0 0 18px rgba(255, 180, 195, 0.6);
    transform: translateY(-1px);
}
.donate-btn:active { transform: translateY(0); }
.donate-btn svg { flex-shrink: 0; }
.donate-btn--header { font-size: 11px; padding: 6px 10px; }

.protection-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 4px 10px;
    background: var(--accent);
    color: #2c5282;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}
[data-theme="dark"] .protection-badge { color: #e3f2fd; }

.header-widgets {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    margin-left: auto;
}

/* Переключатель языков RU/EN (Яндекс.Переводчик) */
.lang-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}
.lang-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    opacity: 0.5;
}
.lang-btn:hover {
    opacity: 0.85;
    border-color: var(--primary);
    background: rgba(74, 111, 165, 0.08);
}
.lang-btn-active {
    opacity: 1;
    border: 2px solid var(--primary);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.35), inset 0 0 0 1px rgba(74, 111, 165, 0.15);
}
[data-theme="dark"] .lang-btn {
    background: var(--card);
    border-color: var(--border);
}
[data-theme="dark"] .lang-btn:hover {
    border-color: var(--aqua);
    background: rgba(91, 163, 176, 0.15);
}
[data-theme="dark"] .lang-btn-active {
    border: 2px solid var(--aqua);
    background: rgba(91, 163, 176, 0.25);
    box-shadow: 0 0 0 3px rgba(91, 163, 176, 0.4), inset 0 0 0 1px rgba(91, 163, 176, 0.2);
}
.lang-btn:focus-visible {
    outline: 2px solid var(--aqua);
    outline-offset: 2px;
}

.theme-toggle-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.theme-icon { font-size: 1rem; color: var(--text-light); pointer-events: none; }
.theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: inline-block; color: var(--aqua); }
.theme-toggle {
    background: var(--card);
    border: 1px solid var(--border);
    width: 52px;
    height: 26px;
    border-radius: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px;
    transition: var(--transition);
    flex-shrink: 0;
}
.theme-toggle-wrap:focus-visible {
    outline: 2px solid var(--aqua);
    outline-offset: 4px;
    border-radius: 8px;
}
.toggle-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    transition: transform 0.3s;
}
[data-theme="dark"] .toggle-thumb {
    transform: translateX(26px);
    background: #94a3b8;
}

/* Основной контейнер — колонки всегда одной высоты по низу */
.container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Панель настроек — тянется по высоте до уровня правой колонки при любых параметрах */
.settings-panel {
    flex: 0 0 420px;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--border);
    padding: 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
    min-width: 0;
    max-width: 100%;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
}
[data-theme="dark"] .settings-header { border-bottom-color: var(--aqua); }

.settings-title {
    font-size: 1.4rem;
    color: var(--primary);
    font-weight: 600;
}
[data-theme="dark"] .settings-title { color: var(--aqua); }

/* Группы настроек */
.setting-group {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.setting-group:last-child {
    border-bottom: none;
}

.setting-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary);
    font-size: 1.05rem;
}
[data-theme="dark"] .setting-label { color: var(--aqua); }

/* Единицы измерения */
.unit-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
}

.unit-label {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--off-white);
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    min-width: 80px;
    min-height: 44px;
    text-align: center;
    line-height: 1.3;
    position: relative;
    user-select: none;
}

.unit-label input[type="radio"] {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.unit-label:hover {
    background: var(--border);
    border-color: var(--aqua);
}

.unit-label.selected {
    background: var(--aqua);
    color: white;
    border-color: var(--aqua);
    box-shadow: 0 2px 8px rgba(0, 188, 212, 0.3);
}

/* Размеры */
.dimensions {
    display: flex;
    gap: 10px;
}

.dimension-input {
    flex: 1;
}

.dimension-input label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: var(--gray-btn);
}

.dimension-input input {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.1rem;
    text-align: center;
    transition: all 0.3s;
}

.dimension-input input:focus {
    outline: none;
    border-color: var(--aqua);
    box-shadow: 0 0 0 3px rgba(0, 188, 212, 0.1);
}

.unit-display {
    display: block;
    text-align: center;
    margin-top: 5px;
    font-size: 0.9rem;
    color: var(--gray-btn);
}

/* Ползунки */
.glass-thickness,
.underfill,
.sump-fill,
.rock-porosity {
    margin-bottom: 6px;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
    transition: background 0.3s;
}

input[type="range"]:hover {
    background: #dee2e6;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    background: var(--aqua);
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: all 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #00acc1;
    transform: scale(1.1);
}

.thickness-value,
.underfill-value,
.fill-value,
.porosity-value {
    text-align: center;
    font-weight: 600;
    color: var(--deep-blue);
    margin-top: 6px;
    font-size: 1rem;
    padding: 6px 8px;
    background: var(--off-white);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
[data-theme="dark"] .thickness-value,
[data-theme="dark"] .underfill-value,
[data-theme="dark"] .fill-value,
[data-theme="dark"] .porosity-value {
    color: var(--text);
    background: var(--card);
    border-color: var(--border);
}

.thickness-info,
.underfill-info {
    font-size: 0.85rem;
    color: var(--gray-btn);
    margin-top: 5px;
    text-align: center;
}

/* Переключатель сампа */
.sump-toggle {
    display: flex;
    justify-content: center;
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 10px;
    font-weight: 600;
}

.toggle-label input {
    display: none;
}

.toggle-slider {
    width: 50px;
    height: 26px;
    background: var(--gray-btn);
    border-radius: 13px;
    position: relative;
    transition: all 0.3s;
}

.toggle-slider:before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--card);
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: all 0.3s;
}

.toggle-label input:checked + .toggle-slider {
    background: var(--aqua);
}

.toggle-label input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Настройки сампа */
.sump-settings {
    margin-top: 12px;
    padding: 14px;
    background: var(--off-white);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.setting-subgroup {
    margin-bottom: 20px;
}

.setting-subgroup:last-child {
    margin-bottom: 0;
}

.subgroup-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--deep-blue);
    font-size: 1rem;
}

/* Оборудование */
.equipment-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.equipment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex: 1;
}

.checkbox-label.small {
    font-size: 0.9rem;
}

.checkbox-label input {
    display: none;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--aqua);
    border-color: var(--aqua);
}

.checkbox-label input:checked + .checkbox-custom:after {
    content: '✓';
    color: white;
    font-size: 12px;
}

.equip-input-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.equip-volume {
    width: 80px;
    padding: 8px 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    text-align: center;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.equip-volume:focus {
    outline: none;
    border-color: var(--aqua);
    box-shadow: 0 0 0 2px rgba(0, 188, 212, 0.1);
}

.equip-volume:disabled {
    background: #f5f5f5;
    color: #999;
    border-color: #eee;
}

.equip-volume.editable {
    background: var(--card);
    color: var(--text-color);
}

.equip-unit {
    min-width: 20px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--gray-btn);
}

.custom-equipment {
    background: #fff9db;
    border-color: #ffecb3;
}

/* Наполнители аквариума - ОБНОВЛЕННЫЕ СТИЛИ */
.fillers-group {
    margin-bottom: 16px;
}

.substrate-settings,
.rock-settings,
.aquarium-equipment {
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--off-white);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.substrate-header,
.rock-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 12px;
}

.substrate-header h4,
.rock-header h4 {
    color: var(--deep-blue);
    font-size: 1.2rem;
    font-weight: 600;
    flex: 1;
    margin: 0;
}

.toggle-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 120px;
}

.equipment-header {
    margin-bottom: 10px;
}

.equipment-header h4 {
    color: var(--deep-blue);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.substrate-details,
.rock-details {
    margin-top: 10px;
}

.substrate-inputs,
.rock-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.substrate-input,
.rock-input,
.rock-method {
    flex: 1;
    min-width: 180px;
}

.substrate-input label,
.rock-input label,
.rock-method label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: var(--gray-btn);
    font-weight: 500;
}

/* Стилизованный select */
.select-wrapper {
    position: relative;
    width: 100%;
}

.styled-select {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--card);
    color: var(--text);
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300bcd4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 15px;
    appearance: none;
    cursor: pointer;
    transition: all 0.3s;
}

.styled-select:focus {
    outline: none;
    border-color: var(--aqua);
    box-shadow: 0 0 0 3px rgba(0, 188, 212, 0.1);
}

.styled-select option {
    padding: 10px;
}

.substrate-input input,
.rock-input input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.1rem;
    text-align: center;
    transition: all 0.3s;
}

.substrate-input input:focus,
.rock-input input:focus {
    outline: none;
    border-color: var(--aqua);
    box-shadow: 0 0 0 3px rgba(0, 188, 212, 0.1);
}

.rock-porosity {
    flex: 100%;
    margin-top: 15px;
}

.rock-porosity label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: var(--gray-btn);
    font-weight: 500;
}

.porosity-value {
    text-align: center;
    font-weight: 600;
    color: var(--deep-blue);
    margin-top: 10px;
    font-size: 1.1rem;
    padding: 10px;
    background: var(--card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.aquarium-equipment-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Кнопки управления */
.control-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.control-buttons .btn {
    min-height: 44px;
    min-width: 0;
}

.btn {
    padding: 14px 25px;
    border-radius: 8px;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    min-height: 44px;
}

.calculate-btn {
    background: linear-gradient(135deg, var(--aqua) 0%, #00acc1 100%);
    color: white;
}

.calculate-btn:hover {
    background: linear-gradient(135deg, #00acc1 0%, #0097a7 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 188, 212, 0.3);
}

.reset-btn {
    background: linear-gradient(135deg, var(--gray-btn) 0%, #5a6268 100%);
    color: white;
}

.reset-btn:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.save-btn {
    background: linear-gradient(135deg, var(--success) 0%, #218838 100%);
    color: white;
}

.save-btn:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* Основной контент с результатами — всегда одной высоты с левой колонкой */
.results-section {
    flex: 1 1 300px;
    min-width: 0;
    max-width: 100%;
    align-self: stretch;
    display: flex;
    flex-direction: column;
}

.results-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
}
[data-theme="dark"] .results-header { border-bottom-color: var(--aqua); }

.results-header h2 {
    color: var(--primary);
    font-size: 1.5rem;
    margin: 0;
}
[data-theme="dark"] .results-header h2 { color: var(--aqua); }

.results-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.results-actions .btn {
    flex: 0 0 auto;
    padding: 10px 16px;
    font-size: 0.95rem;
    min-height: 44px;
}

.share-btn {
    background: linear-gradient(135deg, #1565c0 0%, #0d47a1 100%);
    color: white;
}

.share-btn:hover {
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.4);
}

.export-btn {
    background: linear-gradient(135deg, var(--danger) 0%, #c62828 100%);
    color: white;
    padding: 10px 16px;
    width: auto;
}

.export-btn:hover {
    background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(183, 28, 28, 0.3);
}

.download-json-btn {
    background: linear-gradient(135deg, #5e35b1 0%, #4527a0 100%);
    color: white;
}

.download-json-btn:hover {
    background: linear-gradient(135deg, #673ab7 0%, #512da8 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(94, 53, 177, 0.3);
}

.compare-open-btn, .compare-add-btn {
    background: linear-gradient(135deg, #7b1fa2 0%, #6a1b9a 100%);
    color: white;
}

.compare-open-btn:hover, .compare-add-btn:hover {
    background: linear-gradient(135deg, #8e24aa 0%, #7b1fa2 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(123, 31, 162, 0.3);
}

.shortlink-btn {
    background: linear-gradient(135deg, #00838f 0%, #006064 100%);
    color: white;
}

.shortlink-btn:hover {
    background: linear-gradient(135deg, #0097a7 0%, #00838f 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 131, 143, 0.3);
}

/* Карточки сводки */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
    align-items: stretch;
}

.summary-card {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    transition: transform 0.3s;
    min-height: 72px;
}

.summary-card:hover {
    transform: translateY(-3px);
}

.summary-icon {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    max-width: 44px;
    max-height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    background: linear-gradient(135deg, var(--deep-blue) 0%, var(--aqua) 100%);
    overflow: hidden;
    box-sizing: border-box;
}

.summary-icon i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: inherit;
}

.summary-content {
    min-width: 0;
    flex: 1;
}

.summary-content h3 {
    font-size: 0.95rem;
    color: var(--deep-blue);
    margin-bottom: 2px;
}

.summary-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 2px;
}

.summary-detail {
    font-size: 0.8rem;
    color: var(--gray-btn);
    line-height: 1.25;
}

/* Специфичные стили для карточек */
.total-volume .summary-icon {
    background: linear-gradient(135deg, #0d47a1 0%, #1565c0 100%);
}

.aquarium-volume .summary-icon {
    background: linear-gradient(135deg, #00bcd4 0%, #00acc1 100%);
}

.sump-volume .summary-icon {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
}

.recommended-volume .summary-icon {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
}

/* Детальная разбивка */
.detailed-breakdown {
    background: var(--card);
    padding: 18px 20px;
    border-radius: 15px;
    box-shadow: 0 4px 12px var(--shadow);
}

.breakdown-section {
    margin-bottom: 24px;
}

.breakdown-section:last-child {
    margin-bottom: 0;
}

.breakdown-section h3 {
    color: var(--deep-blue);
    margin-bottom: 12px;
    font-size: 1.25rem;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

/* Сетка разбивки */
.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 18px;
}

.breakdown-item {
    padding: 14px 16px;
    background: var(--off-white);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.breakdown-item h4 {
    color: var(--deep-blue);
    margin-bottom: 10px;
    font-size: 1.05rem;
}

.breakdown-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row.total {
    font-weight: 700;
    color: var(--deep-blue);
    font-size: 1.1rem;
    border-top: 2px solid var(--aqua);
    border-bottom: none;
    margin-top: 10px;
    padding-top: 15px;
}

/* Расчёт стекла */
.glass-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 14px;
}

.glass-item {
    padding: 14px 16px;
    background: var(--glass-blue);
    border-radius: 10px;
    border: 1px solid rgba(0, 188, 212, 0.3);
}

.glass-item h4 {
    color: var(--deep-blue);
    margin-bottom: 10px;
    font-size: 1.05rem;
}

.glass-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Визуализация */
.visualization {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.chart-container {
    flex: 1;
    min-width: 300px;
    height: 300px;
}

.chart-legend {
    flex: 0 0 200px;
    padding: 20px;
    background: var(--off-white);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 8px;
    background: var(--card);
    border-radius: 5px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.legend-label {
    font-size: 0.9rem;
    color: var(--text-color);
}

/* Рекомендации */
.recommendations .recommendations-list {
    background: #fff9db;
    padding: 14px 16px;
    border-radius: 10px;
    border-left: 5px solid var(--warning);
}
[data-theme="dark"] .recommendations .recommendations-list {
    background: rgba(251, 191, 36, 0.12);
    border-left-color: #fbbf24;
}

.recommendations-list p {
    margin-bottom: 6px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--text);
    line-height: 1.4;
}
[data-theme="dark"] .recommendations-list p {
    color: var(--text);
}

.recommendations-list p:last-child {
    margin-bottom: 0;
}

.recommendations-list i {
    color: var(--warning);
    margin-top: 3px;
}
[data-theme="dark"] .recommendations-list i {
    color: #fbbf24;
}

/* Футер — по ширине и центру как основные блоки */
.footer {
    width: 100%;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 24px;
    padding: 16px 20px;
    border-radius: var(--radius);
    background: var(--card);
    border: 1px solid var(--border);
    text-align: center;
    box-shadow: var(--shadow);
    box-sizing: border-box;
}

.footer-line {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-color);
    line-height: 1.5;
}

.footer-link {
    color: var(--aqua);
    text-decoration: none;
}

.footer-link:hover {
    text-decoration: underline;
}

.footer-link-tg {
    color: #0088cc;
}

.footer-link-tg:hover {
    color: #006699;
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Уведомление «Ссылка скопирована» */
.copy-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10002;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 10px;
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease;
}

.copy-notification i {
    font-size: 1.25rem;
}

/* Медиа-запросы для адаптивности */
@media (max-width: 1200px) {
    .container {
        flex-direction: column;
        gap: 14px;
    }
    
    .settings-panel {
        width: 100%;
        flex: 1 1 auto;
    }
    
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 14px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 8px 10px 20px;
    }
    
    .container {
        gap: 12px;
    }
    
    .header {
        padding: 8px 10px 10px;
        margin-bottom: 8px;
    }
    
    .header-content {
        gap: 0.5rem;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    .header .tagline {
        font-size: 0.85rem;
    }
    
    .settings-panel {
        padding: 12px 12px;
    }
    
    .settings-header {
        margin-bottom: 10px;
        padding-bottom: 8px;
    }
    
    .settings-title {
        font-size: 1.2rem;
    }
    
    .setting-group {
        margin-bottom: 12px;
        padding-bottom: 12px;
    }
    
    .setting-label {
        margin-bottom: 6px;
        font-size: 1rem;
    }
    
    .unit-label {
        min-height: 40px;
        padding: 6px 10px;
    }
    
    .dimensions {
        flex-direction: column;
        gap: 8px;
    }
    
    .dimension-input input {
        padding: 8px 10px;
    }
    
    /* Результаты расчёта — компактно */
    .results-section {
        gap: 10px;
    }
    
    .results-header {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 8px;
        padding-bottom: 6px;
    }
    
    .results-header h2 {
        font-size: 1.1rem;
    }
    
    .results-actions {
        justify-content: stretch;
    }
    
    .results-actions .btn {
        flex: 1 1 auto;
        min-height: 40px;
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    /* Карточки результатов: сетка 2×2, горизонтальная раскладка */
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        margin-bottom: 8px;
    }
    
    .summary-card {
        flex-direction: row;
        align-items: center;
        padding: 6px 8px;
        min-height: 0;
        gap: 6px;
        text-align: left;
    }
    
    .summary-icon {
        flex: 0 0 auto;
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        max-width: 28px;
        max-height: 28px;
        font-size: 0.85rem;
    }
    
    .summary-content {
        min-width: 0;
        flex: 1;
    }
    
    .summary-content h3 {
        font-size: 0.7rem;
        margin-bottom: 0;
        line-height: 1.2;
    }
    
    .summary-value {
        font-size: 1rem;
        margin-bottom: 0;
        line-height: 1.25;
    }
    
    .summary-detail {
        font-size: 0.65rem;
        line-height: 1.2;
    }
    
    .detailed-breakdown {
        padding: 10px 12px;
    }
    
    .breakdown-section {
        margin-bottom: 14px;
    }
    
    .breakdown-section h3 {
        margin-bottom: 8px;
        padding-bottom: 6px;
        font-size: 1.1rem;
    }
    
    .breakdown-grid,
    .glass-breakdown {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .breakdown-item,
    .glass-item {
        padding: 10px 12px;
    }
    
    .breakdown-item h4,
    .glass-item h4 {
        margin-bottom: 6px;
        font-size: 1rem;
    }
    
    .breakdown-details,
    .glass-details {
        gap: 6px;
    }
    
    .detail-row {
        padding: 5px 0;
    }
    
    .detail-row.total {
        margin-top: 6px;
        padding-top: 8px;
        font-size: 1rem;
    }
    
    .visualization {
        flex-direction: column;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .chart-legend {
        flex: 1;
        padding: 10px 12px;
    }
    
    .legend-item {
        margin-bottom: 6px;
        padding: 5px 6px;
    }
    
    .legend-label {
        font-size: 0.85rem;
    }
    
    .control-buttons {
        flex-direction: column;
        gap: 6px;
        margin-top: 10px;
    }
    
    .control-buttons .btn {
        width: 100%;
    }
    
    .substrate-header,
    .rock-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .toggle-right {
        justify-content: flex-start;
    }
    
    .recommendations .recommendations-list {
        padding: 8px 10px;
    }
    
    .recommendations-list p {
        margin-bottom: 3px;
        font-size: 0.9rem;
    }
    
    .footer {
        margin-top: 16px;
        padding: 12px 14px;
    }
    
    /* Предотвращение горизонтального скролла и наползания текста */
    .container,
    .settings-panel,
    .results-section,
    .header-content,
    .summary-cards,
    .breakdown-grid,
    .control-buttons {
        min-width: 0;
    }
    
    .recommendations-list p,
    .footer-line {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

@media (max-width: 480px) {
    body {
        padding: 6px 8px 16px;
    }
    
    .container {
        gap: 10px;
    }
    
    .header {
        padding: 6px 8px 8px;
        margin-bottom: 6px;
    }
    
    .header h1 {
        font-size: 1.1rem;
    }
    
    .header .tagline {
        font-size: 0.75rem;
    }
    
    .logo {
        width: 40px;
        height: 40px;
    }
    
    .logo i {
        font-size: 1.1rem;
    }
    
    .settings-panel {
        padding: 10px 10px;
    }
    
    .settings-header {
        margin-bottom: 8px;
        padding-bottom: 6px;
    }
    
    .settings-title {
        font-size: 1.1rem;
    }
    
    .setting-group {
        margin-bottom: 10px;
        padding-bottom: 10px;
    }
    
    .setting-label {
        margin-bottom: 4px;
        font-size: 0.95rem;
    }
    
    .unit-label {
        min-height: 38px;
        padding: 5px 8px;
        font-size: 0.9rem;
    }
    
    .dimension-input input {
        font-size: 1rem;
        padding: 8px;
    }
    
    .thickness-value,
    .underfill-value,
    .fill-value,
    .porosity-value {
        margin-top: 4px;
        padding: 5px 6px;
        font-size: 0.95rem;
    }
    
    /* Результаты расчёта — максимально компактно */
    .results-section {
        gap: 6px;
    }
    
    .results-header {
        margin-bottom: 6px;
        padding-bottom: 5px;
    }
    
    .results-header h2 {
        font-size: 1rem;
    }
    
    .results-actions .btn {
        min-height: 38px;
        padding: 6px 10px;
        font-size: 0.85rem;
    }
    
    /* Карточки: 2×2, максимально плотно */
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
        margin-bottom: 6px;
    }
    
    .summary-card {
        flex-direction: row;
        align-items: center;
        text-align: left;
        padding: 4px 6px;
        min-height: 0;
        gap: 4px;
    }
    
    .summary-icon {
        flex: 0 0 auto;
        margin-bottom: 0;
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        max-width: 24px;
        max-height: 24px;
        font-size: 0.75rem;
    }
    
    .summary-content h3 {
        font-size: 0.6rem;
    }
    
    .summary-value {
        font-size: 0.9rem;
    }
    
    .summary-detail {
        font-size: 0.6rem;
    }
    
    .detailed-breakdown {
        padding: 8px 10px;
    }
    
    .breakdown-section {
        margin-bottom: 10px;
    }
    
    .breakdown-section h3 {
        margin-bottom: 6px;
        padding-bottom: 4px;
        font-size: 1rem;
    }
    
    .breakdown-item,
    .glass-item {
        padding: 6px 8px;
    }
    
    .breakdown-item h4,
    .glass-item h4 {
        margin-bottom: 4px;
        font-size: 0.9rem;
    }
    
    .breakdown-details,
    .glass-details {
        gap: 4px;
    }
    
    .detail-row {
        padding: 3px 0;
    }
    
    .detail-row.total {
        margin-top: 4px;
        padding-top: 6px;
        font-size: 0.95rem;
    }
    
    .chart-container {
        height: 160px;
    }
    
    .chart-legend {
        padding: 6px 8px;
    }
    
    .legend-item {
        margin-bottom: 4px;
        padding: 3px 4px;
    }
    
    .legend-color {
        width: 16px;
        height: 16px;
    }
    
    .legend-label {
        font-size: 0.8rem;
    }
    
    .recommendations .recommendations-list {
        padding: 6px 8px;
    }
    
    .recommendations-list p {
        margin-bottom: 2px;
        font-size: 0.85rem;
    }
    
    .sump-settings {
        margin-top: 8px;
        padding: 10px;
    }
    
    .btn {
        min-height: 44px;
        padding: 10px 14px;
        font-size: 0.9rem;
    }
    
    .calculate-btn, .share-btn {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
    
    input[type="range"] {
        min-height: 32px;
        padding: 6px 0;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    .footer {
        padding: 10px 12px;
        margin-top: 12px;
        font-size: 0.85rem;
    }
}
/* PDF экспорт стили */
.pdf-preview {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pdf-preview-content {
    background: var(--card);
    max-width: 800px;
    max-height: 90vh;
    width: 100%;
    border-radius: 10px;
    padding: 20px;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
}

.pdf-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--aqua);
}

.pdf-preview-title {
    color: var(--deep-blue);
    font-size: 1.5rem;
    margin: 0;
}

.pdf-preview-actions {
    display: flex;
    gap: 10px;
}

.pdf-preview-close {
    background: var(--danger);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.pdf-preview-download {
    background: var(--success);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Модальное окно сравнения */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card);
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 90vw;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.compare-modal .modal-body {
    overflow: auto;
    padding: 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 2px solid var(--aqua);
    background: var(--off-white);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--deep-blue);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    color: var(--gray-btn);
    padding: 0 8px;
    min-height: 44px;
    min-width: 44px;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-actions {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.compare-table-wrap {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.compare-empty {
    color: var(--gray-btn);
    font-style: italic;
    margin: 0;
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.compare-table th,
.compare-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.compare-table th {
    background: var(--off-white);
    color: var(--deep-blue);
    font-weight: 600;
}

.compare-table tr:hover td {
    background: rgba(0, 188, 212, 0.05);
}

/* Футер — блок API */
.footer-api {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    text-align: left;
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

.footer-api-title {
    font-weight: 600;
    color: var(--deep-blue);
    margin-bottom: 8px;
}

.footer-api-desc {
    font-size: 0.85rem;
    color: var(--gray-btn);
    margin: 4px 0;
}

.footer-api-desc code {
    background: var(--off-white);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    word-break: break-all;
}

/* Скрыть элементы при экспорте */
@media print {
    .no-print,
    .settings-panel,
    .control-buttons,
    .export-btn,
    .results-actions {
        display: none !important;
    }
    
    .results-section {
        width: 100% !important;
    }
    
    .detailed-breakdown {
        break-inside: avoid;
    }
}

/* Загрузка PDF */
.pdf-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.9);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.pdf-loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top: 5px solid var(--aqua);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}