/* ── Vida Feliz Staff Portal — Mobile-First CSS ────────────────────────── */

:root {
    --primary: #0F4C5C;
    --primary-light: #14667a;
    --secondary: #F4E3A1;
    --secondary-light: #faf0d0;
    --text: #222222;
    --text-muted: #888888;
    --text-light: #aaaaaa;
    --bg: #ffffff;
    --bg-subtle: #f8f9fa;
    --border: #e8e8e8;
    --border-light: #f0f0f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --vf: #00C2CB;
    --aurora: #FF5757;
    --karma: #DBB98D;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Poppins', -apple-system, sans-serif;
    letter-spacing: -0.01em;
    color: var(--text);
    background: var(--bg);
    height: 100%;
    overflow: hidden;
}


/* ── Header ──────────────────────────────────────────────────────────── */

.app-header {
    background: var(--primary);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 600px;
    margin: 0 auto;
}

.header-logo {
    height: 28px;
    width: auto;
}

.header-subtitle {
    color: var(--secondary);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.header-gauges {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-gauge {
    position: relative;
    width: 36px;
    height: 36px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-gauge-ring {
    position: absolute;
    inset: 0;
    transform: rotate(-90deg);
}

.header-gauge-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 3;
}

.header-gauge-fill {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 1s ease;
}

.header-gauge-pct {
    font-size: 0.5rem;
    font-weight: 700;
    z-index: 1;
    line-height: 1;
}
.header-gauge-warn {
    position: absolute;
    bottom: -8px;
    right: -8px;
    font-size: 1.7rem;
    color: #ff4444;
    z-index: 3;
    filter: drop-shadow(0 0 4px rgba(0,0,0,0.6));
    line-height: 1;
}

/* ── Nav Critical Badge ─────────────────────────────────────────────── */

.nav-item {
    position: relative;
}
.nav-critical-badge {
    position: absolute;
    top: -4px;
    right: 50%;
    transform: translateX(22px);
    font-size: 1.2rem;
    color: #ff4444;
    filter: drop-shadow(0 0 3px rgba(0,0,0,0.3));
    line-height: 1;
}


/* ── Main Content ────────────────────────────────────────────────────── */

.app-main {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 16px calc(60px + env(safe-area-inset-bottom) + 20px);
    background: var(--bg-subtle);
    height: calc(100dvh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}


/* ── Bottom Navigation ───────────────────────────────────────────────── */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-light);
    font-size: 0.65rem;
    font-weight: 500;
    padding: 4px 16px;
    transition: color 0.2s;
    min-width: 64px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.nav-icon {
    width: 22px;
    height: 22px;
}


/* ── Cards ────────────────────────────────────────────────────────────── */

.card {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 16px;
}

.card-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

/* ── Refresh Icon Button ────────────────────────────────────────────── */

.refresh-icon-btn {
    position: absolute;
    right: 0;
    top: 0;
    background: none;
    border: none;
    color: var(--primary);
    opacity: 0.5;
    padding: 4px;
    cursor: pointer;
    border-radius: 50%;
    transition: opacity 0.2s, transform 0.3s;
}
.refresh-icon-btn:active {
    opacity: 0.8;
}
.refresh-icon-btn svg {
    width: 18px;
    height: 18px;
    opacity: 1;
}
.refresh-icon-btn.spinning svg {
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ── Form Elements ───────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-label-en {
    font-weight: 400;
    color: var(--text-light);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 76, 92, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-light);
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.form-textarea {
    resize: vertical;
    min-height: 60px;
}

.form-input-currency {
    padding-left: 28px;
}

.currency-wrapper {
    position: relative;
}

.currency-symbol {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    pointer-events: none;
}


/* ── Receipt Upload ──────────────────────────────────────────────────── */

.receipt-upload-split {
    display: flex;
    gap: 10px;
}

.receipt-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 18px 12px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    font-family: inherit;
}

.receipt-option:active {
    border-color: var(--primary);
    background: rgba(15, 76, 92, 0.03);
    transform: scale(0.98);
}

.receipt-option svg {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.receipt-option-text {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.receipt-option-hint {
    font-size: 0.65rem;
    color: var(--text-light);
}

.receipt-preview {
    display: none;
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}

.receipt-preview.visible {
    display: block;
}

.receipt-preview img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--radius);
}

.receipt-preview-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* ── OCR Loading ─────────────────────────────────────────────────────── */

.ocr-loading {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--secondary-light);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.ocr-loading.visible {
    display: flex;
}

.ocr-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.ocr-loading-text {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 500;
}


/* ── Property Selector ───────────────────────────────────────────────── */

.property-selector {
    display: flex;
    gap: 8px;
}

.property-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 48px;
}

.property-btn:active {
    transform: scale(0.97);
}

.property-btn.selected {
    border-color: var(--prop-color);
    background: color-mix(in srgb, var(--prop-color) 8%, white);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--prop-color) 15%, transparent);
}

.property-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.property-btn-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text);
    text-align: center;
    line-height: 1.2;
}


/* ── Split Mode ──────────────────────────────────────────────────────── */

.split-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.split-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 4px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.split-checkbox:checked {
    background: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

.split-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.split-panel {
    display: none;
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
}

.split-panel.visible {
    display: block;
}

.split-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.split-row:last-of-type {
    margin-bottom: 0;
}

.split-prop-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.split-prop-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    flex: 1;
    min-width: 0;
}

.split-pct-input {
    width: 60px;
    padding: 8px 4px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    text-align: center;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s;
}

.split-pct-input:focus {
    outline: none;
    border-color: var(--primary);
}

.split-pct-label {
    font-size: 0.75rem;
    color: var(--text-light);
}

.split-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
    font-size: 0.8rem;
    font-weight: 600;
}

.split-total-value {
    display: flex;
    align-items: center;
    gap: 6px;
}

.split-total-value.valid {
    color: var(--success);
}

.split-total-value.invalid {
    color: var(--error);
}

.split-quick-btns {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}

.split-quick-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.split-quick-btn:active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}


/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 48px;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-primary:disabled {
    background: #b0c4cb;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg);
    color: var(--primary);
    border: 1.5px solid var(--border);
}

.btn-danger {
    background: var(--bg);
    color: var(--error);
    border: 1.5px solid var(--error);
    font-size: 0.8rem;
    padding: 8px 16px;
    min-height: 36px;
}

.btn-full {
    width: 100%;
}

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


/* ── Confirmation ────────────────────────────────────────────────────── */

.confirm-card {
    text-align: center;
    padding: 32px 20px;
}

.confirm-icon {
    width: 56px;
    height: 56px;
    background: color-mix(in srgb, var(--success) 12%, white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.confirm-icon svg {
    width: 28px;
    height: 28px;
    color: var(--success);
}

.confirm-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.confirm-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.confirm-details {
    text-align: left;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 20px;
    font-size: 0.8rem;
}

.confirm-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.confirm-row-label {
    color: var(--text-muted);
}

.confirm-row-value {
    font-weight: 500;
    color: var(--text);
}


/* ── Recent Submissions ──────────────────────────────────────────────── */

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

.recent-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.recent-count {
    font-size: 0.7rem;
    color: var(--text-light);
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.15s;
}

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

.recent-item:active {
    background: var(--bg-subtle);
    margin: 0 -20px;
    padding: 12px 20px;
}

.recent-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.recent-info {
    flex: 1;
    min-width: 0;
}

.recent-info-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.recent-category {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-amount {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
}

.recent-meta {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 2px;
}

.recent-actions {
    display: flex;
    gap: 6px;
}

.recent-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: var(--bg-subtle);
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.recent-action-btn:hover {
    background: var(--border);
    color: var(--text);
}

.recent-action-btn.delete:hover {
    background: color-mix(in srgb, var(--error) 10%, white);
    color: var(--error);
}

.factura-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.payment-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

.payment-debit {
    color: #028484;
    background: color-mix(in srgb, #028484 10%, white);
}

.payment-credit {
    color: #C9A227;
    background: color-mix(in srgb, #C9A227 12%, white);
}

.payment-cash {
    color: #2E7D32;
    background: color-mix(in srgb, #2E7D32 10%, white);
}

.factura-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--success);
    background: color-mix(in srgb, var(--success) 10%, white);
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

.recent-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-light);
    font-size: 0.82rem;
}


/* ── Login Page ──────────────────────────────────────────────────────── */

.login-body {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 360px;
}

.login-card {
    text-align: center;
    padding: 40px 24px;
}

.login-logo {
    height: 48px;
    width: auto;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 40px;
}

.login-form {
    text-align: left;
}

.login-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.pin-input {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.3em;
    color: var(--primary);
    background: var(--bg);
    transition: border-color 0.2s;
    margin-bottom: 16px;
}

.pin-input:focus {
    outline: none;
    border-color: var(--primary);
}

.login-error {
    text-align: center;
    font-size: 0.8rem;
    color: var(--error);
    margin-bottom: 12px;
    font-weight: 500;
}


/* ── Utility ─────────────────────────────────────────────────────────── */

.section-divider {
    height: 1px;
    background: var(--border-light);
    margin: 20px 0;
}

.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-flex;
}

.htmx-request .htmx-hide-on-request {
    display: none;
}


/* ── Edit Modal ──────────────────────────────────────────────────────── */

.edit-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.edit-sheet {
    background: var(--bg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 85dvh;
    overflow-y: auto;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

.edit-title {
    font-size: 1rem;
    font-weight: 600;
}

.edit-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* ── Delete Confirmation ─────────────────────────────────────────────── */

.delete-confirm {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: color-mix(in srgb, var(--error) 6%, white);
    border: 1px solid color-mix(in srgb, var(--error) 20%, white);
    border-radius: var(--radius-sm);
    margin-top: 8px;
}

.delete-confirm-text {
    flex: 1;
    font-size: 0.78rem;
    color: var(--error);
}

.delete-confirm-actions {
    display: flex;
    gap: 6px;
}


/* ── Water Meters ──────────────────────────────────────────────────── */

.water-meters {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 8px 0;
}

.water-meter-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 120px;
}

.water-meter-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.water-meter {
    width: 100%;
    aspect-ratio: 1 / 2.2;
    max-height: 200px;
}

.water-meter-glass {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, var(--bg-subtle) 0%, #f0f4f5 100%);
    border: 2px solid var(--border);
    border-radius: 12px 12px 20px 20px;
    overflow: hidden;
}

.water-meter-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--fill-level, 0%);
    background: linear-gradient(
        180deg,
        #6dd5fa 0%,
        #3db8e8 15%,
        #2196F3 40%,
        #1976D2 70%,
        #1565C0 100%
    );
    transition: height 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 0 0 18px 18px;
    overflow: hidden;
}

/* Wave layers — 3 independent SVG "sheets" sliding across the surface */
.water-meter-wave {
    position: absolute;
    top: -10px;
    height: 20px;
    left: -100%;
    width: 300%;
    background-repeat: repeat-x;
    background-size: 33.33% 100%;
    animation: waveSlide1 6s linear infinite;
}

.water-meter-wave.wave-2 {
    top: -6px;
    height: 14px;
    left: -100%;
    animation: waveSlide2 8s linear infinite;
}

.water-meter-wave.wave-3 {
    top: -3px;
    height: 10px;
    left: -100%;
    animation: waveSlide3 11s linear infinite;
}

/* Each wave has a distinct shape */
.water-meter-wave {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 60' preserveAspectRatio='none'%3E%3Cpath d='M0,30 C60,10 100,50 200,30 C300,10 340,50 400,30 L400,60 L0,60 Z' fill='rgba(255,255,255,0.3)'/%3E%3C/svg%3E");
}

.water-meter-wave.wave-2 {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 60' preserveAspectRatio='none'%3E%3Cpath d='M0,25 C80,45 150,15 250,35 C320,48 370,20 400,25 L400,60 L0,60 Z' fill='rgba(255,255,255,0.2)'/%3E%3C/svg%3E");
}

.water-meter-wave.wave-3 {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 60' preserveAspectRatio='none'%3E%3Cpath d='M0,35 C120,15 180,50 280,25 C350,10 380,40 400,35 L400,60 L0,60 Z' fill='rgba(255,255,255,0.12)'/%3E%3C/svg%3E");
}

/* Each sheet slides at a constant speed in one direction */
@keyframes waveSlide1 {
    from { transform: translateX(0); }
    to   { transform: translateX(33.33%); }
}

@keyframes waveSlide2 {
    from { transform: translateX(0); }
    to   { transform: translateX(-33.33%); }
}

@keyframes waveSlide3 {
    from { transform: translateX(0); }
    to   { transform: translateX(33.33%); }
}

/* Tiny bubbles */
.water-bubble {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    animation: bubbleRise linear infinite;
}

.water-bubble:nth-child(4) {
    width: 3px; height: 3px;
    left: 25%; bottom: 10%;
    animation-duration: 4s;
    animation-delay: 0s;
}
.water-bubble:nth-child(5) {
    width: 2px; height: 2px;
    left: 60%; bottom: 6%;
    animation-duration: 5s;
    animation-delay: 1.5s;
}
.water-bubble:nth-child(6) {
    width: 3px; height: 3px;
    left: 45%; bottom: 15%;
    animation-duration: 6s;
    animation-delay: 3s;
}

@keyframes bubbleRise {
    0%   { transform: translateY(0); opacity: 0; }
    10%  { opacity: 0.5; }
    80%  { opacity: 0.2; }
    100% { transform: translateY(-100px); opacity: 0; }
}

.water-meter-pct {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    z-index: 2;
    transition: color 0.5s ease;
}

.water-meter-pct.in-water {
    color: white;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.water-meter-offline {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-light);
}

.water-meter-offline span {
    font-size: 0.65rem;
    font-weight: 500;
}

.water-meter-ticks {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.water-meter-tick {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

.water-meter-tick span {
    position: absolute;
    right: 4px;
    top: -8px;
    font-size: 0.5rem;
    color: var(--text-light);
    opacity: 0.6;
}

.water-status {
    margin-top: 8px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 10px;
    border-radius: 12px;
}

.water-status-ok {
    background: color-mix(in srgb, var(--success) 12%, white);
    color: var(--success);
}

.water-status-low {
    background: color-mix(in srgb, var(--warning) 12%, white);
    color: var(--warning);
}

.water-status-critical {
    background: color-mix(in srgb, var(--error) 12%, white);
    color: var(--error);
    animation: pulse 2s ease-in-out infinite;
}

/* ── Water Split Options ────────────────────────────────────────────── */

.water-split-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.water-split-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
    transition: all 0.2s;
}

.water-split-btn:active {
    transform: scale(0.97);
}

.water-split-btn.selected {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 6%, white);
    box-shadow: 0 0 0 3px rgba(15, 76, 92, 0.12);
}

.water-split-btn-dots {
    display: flex;
    gap: 4px;
}

.water-split-btn-dots .split-prop-dot {
    width: 10px;
    height: 10px;
}

.water-split-btn-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
}

.water-split-btn-detail {
    font-size: 0.62rem;
    color: var(--text-light);
}

.water-status-nosensor {
    background: var(--bg-subtle);
    color: var(--text-light);
}

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


/* ── Monthly Summary ───────────────────────────────────────────────── */

.summary-stats {
    display: flex;
    justify-content: space-around;
    text-align: center;
    gap: 8px;
}

.summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.summary-stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.summary-stat-num {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.summary-stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}


/* ── Celebration Overlay ───────────────────────────────────────────── */

.celebration-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    pointer-events: none;
}

.celebration-overlay.playing {
    animation: celebFade 2.8s ease forwards;
}

@keyframes celebFade {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
}

.celebration-burst {
    position: absolute;
    width: 300px;
    height: 300px;
}

.burst-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
}

.playing .burst-ring {
    animation: burstExpand 1.2s ease-out forwards;
}

.ring-1 { border-color: var(--secondary); animation-delay: 0.1s; }
.ring-2 { border-color: var(--vf); animation-delay: 0.25s; }
.ring-3 { border-color: var(--aurora); animation-delay: 0.4s; }

.playing .ring-1 { animation-delay: 0.1s; }
.playing .ring-2 { animation-delay: 0.25s; }
.playing .ring-3 { animation-delay: 0.4s; }

@keyframes burstExpand {
    0% { transform: scale(0.3); opacity: 1; }
    100% { transform: scale(2.5); opacity: 0; }
}

.celebration-thumb {
    width: 120px;
    height: 120px;
    background: var(--secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transform: scale(0);
    box-shadow: 0 0 60px rgba(244, 227, 161, 0.4);
    z-index: 2;
}

.playing .celebration-thumb {
    animation: thumbPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.celebration-thumb svg {
    width: 56px;
    height: 56px;
}

@keyframes thumbPop {
    0% { transform: scale(0) rotate(-20deg); }
    60% { transform: scale(1.15) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.celebration-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 24px;
    z-index: 2;
    opacity: 0;
}

.playing .celebration-text {
    animation: textSlide 0.5s ease 0.3s both;
}

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

.celebration-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--secondary);
    letter-spacing: -0.02em;
}

.celebration-subtitle {
    font-size: 0.9rem;
    color: rgba(244, 227, 161, 0.7);
    font-weight: 400;
    margin-top: 4px;
}

.celebration-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    border-radius: 50%;
}

.playing .particle {
    animation: particleFloat 1.8s ease-out forwards;
}

@keyframes particleFloat {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}


/* ── PWA Install Banner ──────────────────────────────────────────────── */

.install-banner {
    position: fixed;
    bottom: calc(60px + env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    transform: translateY(calc(100% + 80px));
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.install-banner.visible {
    transform: translateY(0);
}

.install-banner-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.install-banner-icon svg {
    width: 22px;
    height: 22px;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
}

.install-banner-text {
    flex: 1;
    min-width: 0;
}

.install-banner-title {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
}

.install-banner-subtitle {
    font-size: 0.7rem;
    opacity: 0.75;
    line-height: 1.3;
    margin-top: 1px;
}

.install-banner-btn {
    background: #fff;
    color: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.install-banner-btn:active {
    opacity: 0.8;
}

.install-banner-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

/* iOS-specific instruction overlay */
.install-ios-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 20px 40px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.install-ios-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.install-ios-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    max-width: 320px;
    width: 100%;
}

.install-ios-card h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    color: var(--text);
}

.install-ios-steps {
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.8;
}

.install-ios-steps .step-icon {
    display: inline-block;
    width: 20px;
    text-align: center;
}

.install-ios-dismiss {
    margin-top: 18px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 24px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
