:root {
    /* Tema Oscuro (por defecto) */
    --bg: #0b1220;
    --panel: #121b2e;
    --panel-2: #18243b;
    --text: #e8eefc;
    --muted: #9fb0d1;
    --ok: #1fb97a;
    --warn: #ffb020;
    --bad: #ef5350;
    --line: #263552;
    --accent: #4da3ff;
    --shadow: rgba(0, 0, 0, .2);
}

[data-theme="light"] {
    /* Tema Claro */
    --bg: #f0f4f8;
    --panel: #ffffff;
    --panel-2: #f7f9fc;
    --text: #1a202c;
    --muted: #4a5568;
    --ok: #059669;
    --warn: #d97706;
    --bad: #dc2626;
    --line: #e2e8f0;
    --accent: #2563eb;
    --shadow: rgba(0, 0, 0, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(180deg, #09101c 0%, #0b1220 100%);
    color: var(--text);
}

.wrap {
    width: min(1100px, calc(100% - 24px));
    margin: 24px auto 40px;
}

h1,
h2,
h3 {
    margin: 0 0 12px;
}

p {
    color: var(--muted);
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 10px 30px var(--shadow);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(77, 163, 255, .12);
    border: 1px solid rgba(77, 163, 255, .25);
    color: #b7d7ff;
    font-size: 12px;
}

label {
    display: block;
    margin: 10px 0 6px;
    font-size: 14px;
    color: var(--muted);
}

input,
select,
textarea,
button {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
}

textarea {
    min-height: 84px;
    resize: vertical;
}

button {
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 700;
}

button.secondary {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
}

.actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
}

.stat {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
}

.stat small {
    color: var(--muted);
    display: block;
    margin-bottom: 6px;
}

.stat strong {
    font-size: 22px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 600;
}

.status-ok {
    color: var(--ok);
    font-weight: 700;
}

.status-warn {
    color: var(--warn);
    font-weight: 700;
}

.status-bad {
    color: var(--bad);
    font-weight: 700;
}

.muted {
    color: var(--muted);
}

.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

/* Toggle de tema */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--line);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow);
}

.theme-toggle:hover {
    transform: scale(1.1);
    background: var(--panel-2);
}

/* Estadísticas avanzadas */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.stat-card {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin: 8px 0;
}

.stat-card .label {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .trend {
    font-size: 11px;
    margin-top: 4px;
}

.trend-up { color: var(--ok); }
.trend-down { color: var(--bad); }
.trend-stable { color: var(--muted); }

/* Botón de exportar gráfico */
.chart-export-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: auto;
    padding: 6px 12px;
    font-size: 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
    opacity: 0;
    transition: opacity 0.2s;
}

.chart-container:hover .chart-export-btn {
    opacity: 1;
}

.chart-export-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    animation: fadeIn 0.3s ease;
}

/* Scrollbar personalizada */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--panel);
}

::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 4px;
}

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

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 14px;
    z-index: 1000;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow);
}

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

.toast.success { border-left: 3px solid var(--ok); }
.toast.error { border-left: 3px solid var(--bad); }
.toast.warning { border-left: 3px solid var(--warn); }

@media (max-width: 720px) {

    .row-2,
    .row-3 {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .actions {
        flex-direction: column;
    }

    .theme-toggle {
        top: auto;
        bottom: 20px;
        right: 20px;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }
}

/* Estilos para el selector de tipo de acuario */
.aquarium-type-selector {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.aquarium-type-card {
    flex: 1;
    min-width: 150px;
    max-width: 200px;
    padding: 24px 16px;
    border: 2px solid var(--line);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--panel);
}

.aquarium-type-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow);
}

.aquarium-type-card.selected {
    border-color: var(--accent);
    background: rgba(77, 163, 255, 0.15);
    box-shadow: 0 0 20px rgba(77, 163, 255, 0.3);
}

.aquarium-type-card .icon {
    font-size: 48px;
    margin-bottom: 8px;
    display: block;
}

.aquarium-type-card .name {
    font-weight: 600;
    color: var(--text);
    font-size: 16px;
}

/* Calculadora */
.calculator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.calc-result {
    background: var(--panel-2);
    padding: 16px;
    border-radius: 8px;
    margin-top: 12px;
    border-left: 4px solid var(--accent);
}

.calc-result .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}

.calc-result .label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

/* Recordatorios */
.reminder-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--panel-2);
    border-radius: 10px;
    margin-bottom: 10px;
    border-left: 4px solid var(--warn);
    transition: all 0.2s;
}

.reminder-item:hover {
    background: var(--panel);
}

.reminder-item.completed {
    border-left-color: var(--ok);
    opacity: 0.7;
}

.reminder-item.overdue {
    border-left-color: var(--bad);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.reminder-checkbox {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: var(--accent);
}

.reminder-info {
    flex: 1;
}

.reminder-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.reminder-due {
    font-size: 13px;
    color: var(--muted);
}

/* Consumibles */
.consumable-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--panel-2);
    border-radius: 10px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.consumable-item:hover {
    background: var(--panel);
}

.consumable-stock {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stock-bar {
    width: 120px;
    height: 10px;
    background: var(--line);
    border-radius: 5px;
    overflow: hidden;
}

.stock-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ok), #4ade80);
    border-radius: 5px;
    transition: width 0.5s ease;
}

.stock-fill.low {
    background: linear-gradient(90deg, var(--warn), #fbbf24);
}

.stock-fill.critical {
    background: linear-gradient(90deg, var(--bad), #f87171);
}

/* Secciones condicionales */
.param-section {
    display: none;
}

.param-section.visible {
    display: block;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 14px;
    z-index: 1000;
    animation: slideInRight 0.3s ease;
    box-shadow: 0 8px 24px var(--shadow);
    max-width: 350px;
}

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

.toast.success {
    border-left: 4px solid var(--ok);
}

.toast.error {
    border-left: 4px solid var(--bad);
}

.toast.warning {
    border-left: 4px solid var(--warn);
}

/* Responsive mejoras */
@media (max-width: 640px) {
    .aquarium-type-selector {
        flex-direction: column;
        align-items: center;
    }

    .aquarium-type-card {
        max-width: 100%;
        width: 100%;
    }

    .calculator-grid {
        grid-template-columns: 1fr;
    }

    .calc-result .value {
        font-size: 24px;
    }
}
