/**
 * myCulligan — Customer Portal Design System
 * Culligan UAE B2B portal. Co-branded layouts; one Culligan look, customer logo
 * shown on the right-hand side when configured.
 */

:root {
    /* --- Brand --------------------------------------------------------- */
    --culligan: #2596be;
    --culligan-dark: #1E7BA1;
    --culligan-deep: #176280;
    --culligan-tint: #E5F2F8;
    --culligan-wash: #F4F9FB;
    --aqua: #4DC3E0;
    --aqua-soft: #E0F4FE;
    --teal: #00C9A7;

    /* --- Neutrals ------------------------------------------------------ */
    --ink: #0F172A;
    --ink-2: #1E293B;
    --ink-3: #334155;
    --muted: #64748B;
    --muted-2: #94A3B8;
    --line: #E2E8F0;
    --line-2: #EDF1F6;
    --surface: #F8FAFC;
    --surface-2: #F1F5F9;
    --white: #FFFFFF;

    /* --- Status -------------------------------------------------------- */
    --ok: #10B981;
    --ok-soft: #ECFDF5;
    --warn: #F59E0B;
    --warn-soft: #FFFBEB;
    --bad: #EF4444;
    --bad-soft: #FEF2F2;

    /* --- Typography ---------------------------------------------------- */
    --font: 'Manrope', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Manrope', 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    /* --- Shadow / radius ---------------------------------------------- */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow:    0 4px 12px -2px rgba(15, 23, 42, .08), 0 2px 4px -2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 16px 40px -12px rgba(15, 23, 42, .14), 0 4px 12px -4px rgba(15, 23, 42, .06);
    --shadow-brand: 0 12px 28px -8px rgba(27, 79, 154, .28);

    --radius-xs: 6px;
    --radius:    10px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 999px;

    /* --- Motion -------------------------------------------------------- */
    --ease: cubic-bezier(.22, .61, .36, 1);
    --t-fast: 160ms;
    --t: 240ms;

    /* --- Layout -------------------------------------------------------- */
    --container: 1280px;
    --header-h: 72px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink-2);
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
img { display: block; max-width: 100%; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ============================================================
   HEADER — Co-branded top bar
   ============================================================ */
.portal-header {
    height: var(--header-h);
    background: var(--white);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(180%) blur(8px);
}
.portal-header-inner {
    max-width: var(--container);
    height: 100%;
    margin: 0 auto;
    padding: 0 28px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.brand-logo {
    height: 30px;
    width: auto;
    display: block;
}
.brand-divider {
    width: 1px;
    height: 22px;
    background: var(--line);
}
.brand-portal {
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: -0.005em;
}
.brand-portal strong { color: var(--ink); font-weight: 700; }

.portal-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}
.portal-nav a {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.portal-nav a:hover { color: var(--ink); background: var(--surface-2); }
.portal-nav a.active { color: var(--culligan); background: var(--culligan-tint); }

.portal-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 20px;
}

.customer-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px 6px 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-full);
}
.customer-chip-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--white);
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
}
.customer-chip-logo img {
    width: 24px;
    height: auto;
    object-fit: contain;
}
.customer-chip-text { line-height: 1.1; }
.customer-chip-label { font-size: 10px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.customer-chip-name { font-size: 13px; font-weight: 600; color: var(--ink); }

.user-menu-wrap { position: relative; }
.user-menu {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--culligan-tint);
    color: var(--culligan);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    border: 1px solid var(--line);
    cursor: pointer;
    transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
    padding: 0;
    line-height: 1;
}
.user-menu:hover { transform: translateY(-1px); background: #DCEEF5; }
.user-menu[aria-expanded="true"] { background: var(--culligan); color: var(--white); }

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
}
.user-dropdown-head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line-2);
    background: var(--surface);
}
.user-dropdown-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
}
.user-dropdown-email {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 2px;
}
.user-dropdown-role {
    display: inline-block;
    margin-top: 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--culligan);
    background: var(--culligan-tint);
    padding: 3px 8px;
    border-radius: var(--radius-full);
}
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-2);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.user-dropdown-item:hover {
    background: var(--surface);
    color: var(--culligan);
}

/* ============================================================
   PAGE LAYOUT
   ============================================================ */
.page {
    max-width: var(--container);
    margin: 0 auto;
    padding: 36px 28px 72px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}
.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
}
.page-subtitle {
    font-size: 14px;
    color: var(--muted);
    margin-top: 4px;
}
.page-actions { display: flex; gap: 10px; }

/* Hero strip on dashboard */
.welcome-strip {
    background: linear-gradient(135deg, var(--culligan-deep) 0%, var(--culligan) 60%, #2A6FC7 100%);
    color: var(--white);
    border-radius: var(--radius-lg);
    padding: 32px 36px;
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-brand);
}
.welcome-strip::before {
    content: '';
    position: absolute;
    right: -80px;
    top: -80px;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(0,174,239,.35) 0%, transparent 70%);
    pointer-events: none;
}
.welcome-strip::after {
    content: '';
    position: absolute;
    right: 40px;
    bottom: -60px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,201,167,.28) 0%, transparent 70%);
    pointer-events: none;
}
.welcome-eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    opacity: .8;
    margin-bottom: 8px;
}
.welcome-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}
.welcome-sub {
    font-size: 14px;
    opacity: .85;
    max-width: 560px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
    border: 1px solid transparent;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
    background: var(--culligan);
    color: var(--white);
    box-shadow: var(--shadow-brand);
}
.btn-primary:hover { background: var(--culligan-dark); }
.btn-ghost {
    background: var(--white);
    color: var(--ink-2);
    border-color: var(--line);
    box-shadow: var(--shadow-xs);
}
.btn-ghost:hover { border-color: var(--culligan-tint); color: var(--culligan); }
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
}
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-lg { padding: 14px 22px; font-size: 15px; }

/* ============================================================
   KPI cards
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}
.kpi {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 20px 22px;
    position: relative;
    overflow: hidden;
    transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 12px;
}
.kpi-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1.1;
}
.kpi-unit {
    font-size: 13px;
    color: var(--muted);
    margin-left: 6px;
    font-weight: 500;
}
.kpi-trend {
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.kpi-trend.up { color: var(--ok); }
.kpi-trend.down { color: var(--bad); }
.kpi-trend.warn { color: var(--warn); }
.kpi-icon {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--culligan-tint);
    color: var(--culligan);
    display: grid;
    place-items: center;
    font-size: 18px;
}
.kpi.alert .kpi-icon { background: var(--bad-soft); color: var(--bad); }
.kpi.warn .kpi-icon { background: var(--warn-soft); color: var(--warn); }
.kpi.ok .kpi-icon { background: var(--ok-soft); color: var(--ok); }

/* ============================================================
   Module tiles (Dashboard)
   ============================================================ */
.section-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modules {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 36px;
}
.module {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
}
.module.available:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}
.module.available::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-md);
    padding: 1px;
    background: linear-gradient(135deg, var(--culligan), var(--aqua));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    opacity: 0;
    transition: opacity var(--t) var(--ease);
    pointer-events: none;
}
.module.available:hover::after { opacity: 1; }

.module.locked {
    background: var(--surface);
    color: var(--muted);
    border-style: dashed;
}
.module-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: var(--culligan-tint);
    color: var(--culligan);
    display: grid;
    place-items: center;
    margin-bottom: 16px;
    font-size: 22px;
}
.module.locked .module-icon { background: var(--surface-2); color: var(--muted-2); }
.module-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}
.module.locked .module-title { color: var(--ink-3); }
.module-desc {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
    flex: 1;
}
.module-cta {
    margin-top: 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--culligan);
    display: flex;
    align-items: center;
    gap: 6px;
}
.module.locked .module-cta { color: var(--muted-2); }
.module-badge {
    position: absolute;
    top: 18px;
    right: 18px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    background: var(--surface-2);
    padding: 4px 10px;
    border-radius: var(--radius-full);
}
.module.available .module-badge { color: var(--ok); background: var(--ok-soft); }

/* ============================================================
   Cards (generic)
   ============================================================ */
.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.card-head {
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.card-body { padding: 22px; }

/* ============================================================
   Activity feed
   ============================================================ */
.activity {
    display: flex;
    flex-direction: column;
}
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 22px;
    border-top: 1px solid var(--line-2);
}
.activity-item:first-child { border-top: 0; }
.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--culligan);
    margin-top: 8px;
    flex-shrink: 0;
}
.activity-dot.ok { background: var(--ok); }
.activity-dot.warn { background: var(--warn); }
.activity-text { flex: 1; font-size: 13.5px; color: var(--ink-2); }
.activity-text strong { font-weight: 600; color: var(--ink); }
.activity-time { font-size: 12px; color: var(--muted-2); white-space: nowrap; }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.table thead th {
    text-align: left;
    padding: 12px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    white-space: nowrap;
}
.table tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-2);
    color: var(--ink-2);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface); }
.table .num { font-variant-numeric: tabular-nums; text-align: right; }
.table .part {
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink);
}
.table .date { color: var(--muted); font-variant-numeric: tabular-nums; }
.table .desc { color: var(--ink-2); }
.table tbody tr.reorder td { background: var(--bad-soft); }
.table tbody tr.reorder:hover td { background: #FDE6E6; }

/* ============================================================
   SOH (Stock-on-Hand) wide-pivot table
   ============================================================ */
.soh-wrap {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    position: relative;
}
.soh-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}
.soh-table th, .soh-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line-2);
    border-right: 1px solid var(--line-2);
    background: var(--white);
    white-space: nowrap;
    vertical-align: middle;
}
.soh-table thead th {
    background: var(--surface);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 3;
}
.soh-table tbody tr:hover td { background: var(--surface); }
.soh-table tbody tr:hover .soh-sticky { background: var(--surface); }

.soh-table .soh-num { text-align: right; }
.soh-table .soh-ir {
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink);
}
.soh-table .soh-name {
    color: var(--ink-2);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.soh-table .soh-uom {
    text-align: center;
    color: var(--muted);
    font-size: 11.5px;
}
.soh-table .soh-day {
    text-align: right;
    width: 56px;
    min-width: 56px;
    color: var(--muted);
    padding: 8px 8px;
}
.soh-table .soh-day.has-in { color: var(--ok); font-weight: 600; }
.soh-table .soh-day.has-out { color: var(--bad); font-weight: 600; }
.soh-table .soh-day.is-today { background: var(--culligan-tint); }
.soh-table .soh-day-empty { color: var(--muted-2); }
.soh-table .soh-opening { font-weight: 500; color: var(--ink-2); text-align: right; }
.soh-table .soh-closing {
    text-align: right;
    font-weight: 700;
    color: var(--ink);
    background: var(--culligan-wash);
}

/* Sticky left columns (IR, Name, UoM, Opening) */
.soh-table .soh-sticky {
    position: sticky;
    background: var(--white);
    z-index: 1;
}
.soh-table thead th.soh-sticky { z-index: 4; background: var(--surface); }
.soh-table .soh-sticky-1 { left: 0; min-width: 76px; }
.soh-table .soh-sticky-2 { left: 76px; min-width: 240px; }
.soh-table .soh-sticky-3 { left: 316px; min-width: 50px; }
.soh-table .soh-sticky-4 { left: 366px; min-width: 90px; border-right: 1px solid var(--line); box-shadow: 1px 0 0 var(--line); }

/* Sticky right column (Closing) */
.soh-table .soh-sticky-r {
    position: sticky;
    right: 0;
    z-index: 1;
    border-left: 1px solid var(--line);
    box-shadow: -1px 0 0 var(--line);
}
.soh-table thead th.soh-sticky-r { z-index: 4; }

.soh-day-click { cursor: pointer; }
.soh-day-click:hover {
    outline: 2px solid var(--culligan);
    outline-offset: -2px;
    background: var(--culligan-tint) !important;
}
.soh-day-click:hover.is-today { background: #D6E9F2 !important; }

.row-below-min .soh-sticky { background: #FFF8E6; }
.row-below-min:hover .soh-sticky { background: #FEF0CC; }

.reorder-flag {
    display: inline-grid;
    place-items: center;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--warn);
    color: var(--white);
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    cursor: help;
    vertical-align: 1px;
}

/* ---- Row stagger fade-in on page load ---- */
.soh-table tbody tr {
    opacity: 0;
    transform: translateY(8px);
    animation: soh-row-in 520ms var(--ease) forwards;
}
@keyframes soh-row-in {
    to { opacity: 1; transform: translateY(0); }
}
.soh-table tbody tr:nth-child(1)  { animation-delay:   0ms; }
.soh-table tbody tr:nth-child(2)  { animation-delay:  55ms; }
.soh-table tbody tr:nth-child(3)  { animation-delay: 110ms; }
.soh-table tbody tr:nth-child(4)  { animation-delay: 165ms; }
.soh-table tbody tr:nth-child(5)  { animation-delay: 220ms; }
.soh-table tbody tr:nth-child(6)  { animation-delay: 275ms; }
.soh-table tbody tr:nth-child(7)  { animation-delay: 330ms; }
.soh-table tbody tr:nth-child(8)  { animation-delay: 385ms; }
.soh-table tbody tr:nth-child(9)  { animation-delay: 440ms; }
.soh-table tbody tr:nth-child(10) { animation-delay: 495ms; }
.soh-table tbody tr:nth-child(11) { animation-delay: 550ms; }
.soh-table tbody tr:nth-child(12) { animation-delay: 605ms; }
.soh-table tbody tr:nth-child(13) { animation-delay: 660ms; }
.soh-table tbody tr:nth-child(14) { animation-delay: 715ms; }
.soh-table tbody tr:nth-child(15) { animation-delay: 770ms; }
.soh-table tbody tr:nth-child(n+16) { animation-delay: 825ms; }

/* ---- Today-column gentle pulse (fires once after rows have settled) ---- */
.soh-table thead th.soh-day.is-today {
    animation: soh-today-bg 1.4s var(--ease) 1100ms 1;
}
.soh-table thead th.soh-day.is-today .soh-day-num {
    display: inline-block;
    animation: soh-today-num 1.2s var(--ease) 1100ms 1;
}
@keyframes soh-today-bg {
    0%   { background: var(--culligan-tint); }
    35%  { background: #A8D5E5; }
    100% { background: var(--culligan-tint); }
}
@keyframes soh-today-num {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.32); }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .soh-table tbody tr               { animation: none; opacity: 1; transform: none; }
    .soh-table thead th.soh-day.is-today,
    .soh-table thead th.soh-day.is-today .soh-day-num { animation: none; }
}

.soh-day-name {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted-2);
    font-weight: 500;
    display: block;
    margin-bottom: 1px;
}
.soh-month-tag {
    display: block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--culligan);
    margin-bottom: 2px;
}
.soh-table thead th.has-month-tag {
    border-left: 2px solid var(--culligan-tint);
}
.soh-day-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-3);
}
.soh-day.is-today .soh-day-num { color: var(--culligan); }

/* ============================================================
   Badges / pills
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-ok    { background: var(--ok-soft);   color: #047857; }
.badge-warn  { background: var(--warn-soft); color: #B45309; }
.badge-bad   { background: var(--bad-soft);  color: #B91C1C; }
.badge-info  { background: var(--culligan-tint); color: var(--culligan); }
.badge-mute  { background: var(--surface-2); color: var(--muted); }
.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ============================================================
   Filter bar
   ============================================================ */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.filter-field {
    display: flex;
    align-items: center;
    gap: 8px;
}
.filter-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.input, .select {
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    background: var(--white);
    border-radius: var(--radius-xs);
    font-size: 13px;
    color: var(--ink-2);
    transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
    outline: none;
    min-width: 160px;
}
.input:focus, .select:focus {
    border-color: var(--culligan);
    box-shadow: 0 0 0 3px var(--culligan-tint);
}
.input[type="search"] { background: var(--white) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>") no-repeat 12px center; padding-left: 34px; }
.filter-bar .right { margin-left: auto; display: flex; gap: 8px; }

.filter-range { gap: 6px; }
.filter-range .input-date {
    min-width: 138px;
    padding: 0 8px;
}
.filter-range-sep {
    color: var(--muted-2);
    font-size: 13px;
    padding: 0 2px;
    user-select: none;
}

/* ============================================================
   Chart placeholder
   ============================================================ */
.chart {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-top: 20px;
}
.chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.chart-legend {
    display: flex;
    gap: 18px;
    font-size: 12.5px;
    color: var(--muted);
}
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .dot {
    width: 10px; height: 10px; border-radius: 3px;
}
.chart-canvas {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 200px;
    padding: 12px 0 28px;
    position: relative;
}
.bar-pair { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; }
.bar-pair-bars { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.bar {
    width: 14px;
    border-radius: 4px 4px 0 0;
    transition: opacity var(--t-fast) var(--ease);
}
.bar.in { background: linear-gradient(180deg, var(--aqua) 0%, var(--culligan) 100%); }
.bar.out { background: linear-gradient(180deg, var(--teal) 0%, #009C82 100%); }
.bar-pair-label {
    position: absolute;
    bottom: -22px;
    font-size: 11px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   AUTH (login) — split layout
   ============================================================ */
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    background: var(--surface);
}
.auth-hero {
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(0,201,167,.32) 0%, transparent 60%),
        radial-gradient(80% 60% at 0% 100%, rgba(0,174,239,.40) 0%, transparent 70%),
        linear-gradient(135deg, var(--culligan-deep) 0%, var(--culligan) 100%);
    color: var(--white);
    padding: 56px 64px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.auth-hero::before {
    content: '';
    position: absolute;
    bottom: -120px;
    left: -100px;
    width: 480px;
    height: 480px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.12);
    pointer-events: none;
}
.auth-hero::after {
    content: '';
    position: absolute;
    bottom: -200px;
    left: -180px;
    width: 640px;
    height: 640px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.07);
    pointer-events: none;
}
.auth-hero-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 700;
    font-size: 18px;
}
.auth-hero-logo {
    height: 32px;
    width: auto;
    filter: brightness(0) invert(1);
}
.auth-hero-spacer { flex: 1; }
.auth-hero-eyebrow {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-weight: 600;
    opacity: .8;
    margin-bottom: 16px;
}
.auth-hero-headline {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 18px;
    max-width: 480px;
}
.auth-hero-sub {
    font-size: 16px;
    line-height: 1.55;
    opacity: .85;
    max-width: 480px;
    margin-bottom: 36px;
}
.auth-hero-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 32px;
    max-width: 480px;
}
.auth-feature {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13.5px;
    opacity: .9;
}
.auth-feature .tick {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,201,167,.20);
    color: var(--teal);
    display: grid;
    place-items: center;
    font-size: 12px;
    flex-shrink: 0;
}
.auth-hero-footer {
    margin-top: auto;
    font-size: 12px;
    opacity: .65;
    padding-top: 32px;
}

.auth-form {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}
.auth-form-inner {
    width: 100%;
    max-width: 400px;
}
.auth-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}
.auth-sub {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 32px;
}
.field {
    margin-bottom: 18px;
}
.field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-3);
    margin-bottom: 8px;
}
.field-input {
    width: 100%;
    height: 46px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
    font-size: 14px;
    color: var(--ink);
    transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
    outline: none;
}
.field-input:focus {
    border-color: var(--culligan);
    box-shadow: 0 0 0 4px var(--culligan-tint);
}
.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 6px 0 24px;
    font-size: 13px;
}
.field-row label {
    display: flex; align-items: center; gap: 8px;
    color: var(--muted);
    cursor: pointer;
}
.field-row a { color: var(--culligan); font-weight: 600; }
.auth-submit {
    width: 100%;
    height: 48px;
    background: var(--culligan);
    color: var(--white);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 15px;
    box-shadow: var(--shadow-brand);
    transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.auth-submit:hover { background: var(--culligan-dark); transform: translateY(-1px); }
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 28px 0 20px;
    color: var(--muted-2);
    font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}
.auth-help {
    text-align: center;
    font-size: 13px;
    color: var(--muted);
}
.auth-help a { color: var(--culligan); font-weight: 600; }

/* ============================================================
   Audit modal — cell drill-down
   ============================================================ */
.audit-modal[hidden] { display: none; }
.audit-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: am-fade 220ms var(--ease);
}
@keyframes am-fade { from { opacity: 0; } to { opacity: 1; } }
.audit-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(3px);
}
.audit-card {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px 36px 28px;
    width: 100%;
    max-width: 580px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    animation: am-rise 280ms var(--ease);
}
@keyframes am-rise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.audit-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface);
    color: var(--muted);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.audit-close:hover { background: var(--surface-2); color: var(--ink); }

.audit-eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 10px;
}
.audit-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
    line-height: 1.3;
    margin-bottom: 6px;
}
.audit-sub {
    font-size: 13.5px;
    color: var(--muted);
    margin-bottom: 24px;
}

.audit-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 22px;
}
.audit-stat {
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    padding: 14px 12px;
    text-align: center;
}
.audit-stat.highlight {
    background: var(--culligan-wash);
    border-color: var(--culligan-tint);
}
.audit-stat-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 6px;
}
.audit-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.audit-stat-value.pos { color: var(--ok); }
.audit-stat-value.neg { color: var(--bad); }

.audit-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--line-2);
    font-size: 13.5px;
}
.audit-info-row:first-of-type { border-top: 0; }
.audit-info-label {
    color: var(--muted);
}
.audit-info-value {
    font-weight: 600;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.audit-info-value.pos { color: var(--ok); }
.audit-info-value.neg { color: var(--bad); }

.audit-section {
    margin-top: 22px;
    padding: 18px 20px;
    background: var(--culligan-wash);
    border: 1px solid var(--culligan-tint);
    border-radius: var(--radius);
}
.audit-section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--culligan);
    font-weight: 700;
    margin-bottom: 8px;
}
.audit-section-body {
    font-size: 13px;
    color: var(--ink-3);
    line-height: 1.6;
}
.audit-section-body strong { color: var(--ink); }

@media (max-width: 560px) {
    .audit-card { padding: 24px 22px; }
    .audit-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   Loading overlay (shown during month change / slow nav)
   ============================================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .35);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: lo-fade 200ms var(--ease);
}
@keyframes lo-fade { from { opacity: 0; } to { opacity: 1; } }
.loading-card {
    background: var(--white);
    padding: 22px 28px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 260px;
}
.loading-spinner {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2.5px solid var(--line);
    border-top-color: var(--culligan);
    animation: lo-spin .9s linear infinite;
    flex-shrink: 0;
}
@keyframes lo-spin { to { transform: rotate(360deg); } }
.loading-text {
    font-size: 14px;
    color: var(--ink);
    line-height: 1.3;
}
.loading-text small {
    display: block;
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 2px;
    font-weight: 400;
}

/* ============================================================
   Footer
   ============================================================ */
.portal-footer {
    border-top: 1px solid var(--line);
    background: var(--white);
    padding: 24px 0;
    margin-top: 60px;
}
.portal-footer-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--muted);
}
.portal-footer a { color: var(--muted); }
.portal-footer a:hover { color: var(--culligan); }

/* ============================================================
   Utility
   ============================================================ */
.mt-0 { margin-top: 0 !important; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.text-muted { color: var(--muted); }
.text-mono { font-family: var(--font-mono); }
.dim { opacity: .55; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .modules { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-hero { padding: 36px; }
    .auth-hero-headline { font-size: 30px; }
}
@media (max-width: 720px) {
    .portal-header-inner { padding: 0 18px; gap: 14px; }
    .portal-nav { display: none; }
    .page { padding: 24px 18px 48px; }
    .welcome-strip { padding: 24px; }
    .welcome-title { font-size: 22px; }
    .kpi-grid { grid-template-columns: 1fr; }
    .modules { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar .right { margin-left: 0; }
    .table-wrap { overflow-x: auto; }
    .page-head { flex-direction: column; align-items: flex-start; }
}
