/* ============================================================
   GANGA WATER – Professional Design System
   ============================================================ */

:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-alt: #f8f9fb;
    --surface-muted: #f1f3f5;
    --line: #e5e7eb;
    --line-strong: #d1d5db;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --muted: #6b7280;

    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #ccfbf1;
    --accent: #0d9488;
    --accent-dark: #0f766e;

    --danger: #ef4444;
    --danger-light: #fef2f2;
    --success: #059669;
    --success-light: #ecfdf5;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --info: #2563eb;
    --info-light: #eff6ff;

    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.03);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- RESET & BASE ---- */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
h1, h2, h3, h4, h5, h6 { margin: 0; line-height: 1.3; }
p { margin: 0; }
img { max-width: 100%; display: block; }

/* ---- LAYOUT SHELL ---- */

.app-shell {
    width: min(1340px, 100%);
    margin: 0 auto;
    min-height: 100vh;
    padding: 16px;
}

.page,
.workspace-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ---- TYPOGRAPHY ---- */

.eyebrow {
    display: inline-block;
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary);
}

.muted,
.lead { color: var(--text-secondary); }

/* ---- SURFACES & CARDS ---- */

.hero-card,
.panel,
.info-card,
.stat-card,
.list-card,
.surface-card,
.metric-card,
.mini-metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.hero-card,
.panel,
.surface-card { padding: 20px; }

.panel {
    width: min(480px, 100%);
    margin: 0 auto;
}

.info-card,
.stat-card,
.list-card,
.metric-card,
.mini-metric,
.detail-card {
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
}

.hero-card { position: relative; overflow: hidden; }
.hero-card::after { display: none; }

.hero-card h1,
.panel h1 {
    font-size: 20px;
    font-weight: 700;
}

/* ---- GRIDS ---- */

.grid-cards, .stats-grid, .list-stack, .form-stack,
.metric-grid, .content-stack, .dashboard-grid,
.dashboard-grid-wide, .data-list, .quick-actions,
.sidebar-stack, .hero-badge-stack, .detail-stack,
.field-grid, .detail-grid, .customer-admin-layout {
    display: grid;
    gap: 16px;
}

.grid-cards, .stats-grid, .metric-grid,
.dashboard-grid, .dashboard-grid-wide,
.detail-grid, .field-grid, .hero-badge-stack {
    grid-template-columns: 1fr;
}

.metric-card strong,
.mini-metric strong,
.hero-badge strong,
.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 22px;
    line-height: 1;
    font-weight: 700;
    color: var(--text);
}

.metric-card span,
.mini-metric span,
.stat-card span {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ---- BUTTONS ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
}
.btn-secondary:hover { background: var(--surface-muted); }

.btn-call { background: var(--primary); color: #fff; }
.btn-block, .quick-btn { width: 100%; }
.btn-small { min-height: 36px; padding: 8px 14px; font-size: 12px; }
.btn-icon { min-width: 36px; padding: 8px 10px; }

/* ---- FORMS ---- */

label {
    display: grid;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

input, textarea, select {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

select {
    appearance: none;
    -webkit-appearance: none;
    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='%236b7280' 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 12px center;
    background-size: 12px;
    padding-right: 36px;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.form-inline, .pause-form, .filter-inline, .inventory-form {
    display: grid;
    gap: 12px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 13px;
}

.checkbox-row input {
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin: 0;
    accent-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.compact-top { margin-top: 16px; }

/* ---- TOAST NOTIFICATIONS ---- */

.toast-wrapper {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 380px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--line);
    font-weight: 500;
    font-size: 13px;
    pointer-events: auto;
    cursor: pointer;
    opacity: 0;
    transform: translateX(100%);
    animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast:hover { box-shadow: var(--shadow-lg); }
.toast.hiding { animation: toastOut 0.25s ease forwards; }

@keyframes toastIn {
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
    to { transform: translateX(120%); opacity: 0; }
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-success .toast-icon { background: var(--success-light); color: var(--success); }

.toast-error { border-left: 3px solid var(--danger); }
.toast-error .toast-icon { background: var(--danger-light); color: var(--danger); }

/* ---- PILLS & TAGS ---- */

.tag, .pill, .status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.pill-warning, .status-pill-warning { background: var(--warning-light); color: var(--warning); }
.pill-success, .status-pill-success { background: var(--success-light); color: var(--success); }
.pill-danger, .status-pill-danger { background: var(--danger-light); color: var(--danger); }
.pill-info, .status-pill-info { background: var(--info-light); color: var(--info); }

/* ---- DATA ROWS ---- */

.data-row, .subscription-row, .quick-row, .list-link-card, .inventory-row {
    display: grid;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    transition: border-color var(--transition);
}

.data-row:hover, .list-link-card:hover { border-color: var(--line-strong); }

.data-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.card-head h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 4px;
}

.surface-card h3,
.surface-card h4,
.detail-card h4,
.list-link-card h4,
.data-row h4,
.subscription-row h4 {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
}

/* ---- AUTH ---- */

.auth-page {
    min-height: calc(100vh - 40px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card { width: min(440px, 100%); }
.landing-switcher { width: min(440px, 100%); }

.landing-auth-grid {
    display: grid;
    gap: 16px;
    width: min(960px, 100%);
    margin: 0 auto;
}

.segment-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    background: var(--surface-muted);
    border-radius: var(--radius-md);
}

.segment-btn {
    min-height: 36px;
    padding: 8px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all var(--transition);
}

.segment-btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

.auth-switch-copy {
    margin: 16px 0 0;
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-switch-link {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: inherit;
    color: var(--primary);
    font-weight: 600;
}

.centered, .centered-panel { text-align: center; }

/* ---- MISC UTILITY ---- */

.meta-line, .text-link { color: var(--primary); font-weight: 600; }

.section-divider {
    height: 1px;
    margin: 4px 0;
    background: var(--line);
}

.scroll-list {
    max-height: 460px;
    overflow: auto;
}

.list-link-card.is-active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.customer-admin-layout { align-items: start; }
.customer-card-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.compact-copy { margin-top: 6px; }
.detail-card { min-width: 0; }
.surface-card, .panel, .hero-card { min-width: 0; }
.empty-state-card h3 { margin: 0; }

.daily-entry-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.daily-entry-field {
    display: grid;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.daily-entry-form input {
    width: 84px;
    min-width: 84px;
    padding: 8px 10px;
}

.inventory-dashboard {
    gap: 20px;
}

.inventory-summary-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
}

.inventory-summary-card {
    background:
        radial-gradient(circle at top right, rgba(13, 148, 136, 0.12), transparent 38%),
        linear-gradient(180deg, #ffffff 0%, #f5fbfa 100%);
}

.inventory-dashboard-row {
    align-items: start;
}

.inventory-pills {
    justify-content: flex-end;
}

/* ---- MOBILE TOPBAR ---- */

.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* ---- MODAL ---- */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-card {
    width: min(560px, 100%);
    max-height: 90vh;
    overflow: auto;
    padding: 24px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition);
}

.modal-close:hover { background: var(--surface-muted); color: var(--text); }

/* ---- WORKSPACE LAYOUT ---- */

.workspace-shell {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.workspace-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    box-shadow: var(--shadow-xs);
}

.brand-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-block p,
.brand-block h1 { margin: 0; }

.brand-block h1 {
    font-size: 16px;
    font-weight: 700;
}

.mobile-close-btn { display: none; }

.workspace-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-tabs { display: none; }

.workspace-nav a,
.section-tabs a,
.mobile-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    text-decoration: none;
    transition: all var(--transition);
}

.workspace-nav a:hover, .section-tabs a:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.workspace-nav a.active,
.section-tabs a.active,
.mobile-nav a.active {
    background: var(--primary);
    color: #fff;
}

.workspace-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.workspace-hero { background: var(--surface); }

.hero-badge-stack { align-self: stretch; }

.hero-badge {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.hero-badge span {
    display: block;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.topbar h1 {
    font-size: 20px;
    font-weight: 700;
}

.mobile-nav {
    position: fixed;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    width: min(680px, calc(100% - 24px));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

/* ---- DRAWER OVERLAY (Mobile) ---- */

.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drawer-overlay.is-visible {
    display: block;
    opacity: 1;
}

/* ---- FILTER INLINE ---- */

.filter-inline {
    display: flex;
    gap: 8px;
    align-items: end;
}

.page-home .grid-cards { grid-template-columns: 1fr; }

/* ============================================================
   RESPONSIVE – DESKTOP (≥768px)
   ============================================================ */

@media (min-width: 768px) {
    .app-shell { padding: 24px; }

    .grid-cards, .stats-grid { grid-template-columns: repeat(3, 1fr); }

    .landing-auth-grid {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }

    .page-home .hero-card { padding: 32px; }

    .metric-grid { grid-template-columns: repeat(3, 1fr); }
    .metric-grid-admin { grid-template-columns: repeat(4, 1fr); }
    .compact-grid, .metric-grid-report { grid-template-columns: repeat(2, 1fr); }

    .dashboard-grid { grid-template-columns: 1.2fr 1fr; }
    .dashboard-grid-wide { grid-template-columns: 1fr 1fr; }
    .hero-badge-stack { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
    .inventory-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .form-inline, .pause-form, .field-grid, .inventory-form {
        grid-template-columns: 1fr 1fr;
        align-items: end;
    }

    .filter-inline {
        display: flex;
        gap: 8px;
        align-items: end;
    }

    .data-row, .subscription-row, .quick-row,
    .list-link-card, .inventory-row {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .inventory-note { grid-column: 1 / -1; }
    .detail-grid { grid-template-columns: 0.95fr 1.05fr; }
    .quick-actions { grid-template-columns: 1fr 1fr; }

    /* Desktop: horizontal navbar */
    .workspace-shell { flex-direction: column; gap: 20px; }
    .customer-shell { flex-direction: column; }

    .workspace-sidebar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 12px 20px;
        gap: 16px;
    }

    .brand-block {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        flex-shrink: 0;
    }

    .brand-block .eyebrow,
    .brand-block .muted { display: none; }
    .brand-block h1 { font-size: 16px; }

    .workspace-nav {
        flex-direction: row;
        align-items: center;
        gap: 2px;
        flex-wrap: wrap;
    }

    .sidebar-stack {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    .sidebar-stack .btn {
        min-height: 36px;
        padding: 8px 14px;
        font-size: 12px;
    }

    .customer-admin-layout { grid-template-columns: 320px minmax(0, 1fr); }
    .section-tabs { display: none; }
    .mobile-nav { display: none; }
}

@media (min-width: 1100px) {
    .compact-grid, .metric-grid-report { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   RESPONSIVE – MOBILE (<768px)
   ============================================================ */

@media (max-width: 767px) {
    .app-shell { padding: 12px 12px 32px; }

    .card-head, .topbar { flex-direction: column; align-items: stretch; gap: 12px; }

    .section-tabs { display: none; }

    .hero-badge-stack, .filter-inline { width: 100%; }
    .filter-inline { flex-direction: column; }

    .field-grid, .quick-actions { grid-template-columns: 1fr; }
    .daily-entry-form {
        width: 100%;
        justify-content: flex-start;
    }
    .inventory-pills {
        justify-content: flex-start;
    }

    .mobile-topbar { display: flex; }

    /* Slide-in drawer */
    .workspace-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 9999;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 24px 20px;
        border-radius: 0;
        border: none;
        box-shadow: var(--shadow-lg);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .workspace-sidebar.is-open { transform: translateX(0); }

    .brand-block {
        flex-direction: column;
        align-items: flex-start;
        position: relative;
    }

    .brand-block .eyebrow,
    .brand-block .muted { display: block; }

    .mobile-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: -4px;
        right: 0;
        width: 32px;
        height: 32px;
        border: 1px solid var(--line);
        background: var(--surface-muted);
        border-radius: var(--radius-full);
        color: var(--text-secondary);
        font-size: 14px;
        cursor: pointer;
        transition: all var(--transition);
    }

    .mobile-close-btn:hover { background: var(--line); color: var(--text); }

    .workspace-nav { flex-direction: column; }
    .sidebar-stack { margin-top: auto; }

    /* Modal adjustments */
    .modal-card { padding: 20px; }
}
