:root {
    /* Brand & core */
    --brand: #00093D;
    --brand-hover: #001060;
    --accent: #FFBA08;

    /* Status */
    --info: #007bff;
    --info-hover: #0056b3;

    /* Text */
    --ink: #1c1917;
    --ink-muted: #666;
    --ink-strong: #00093D;
    --on-dark: #ffffff;

    /* Surfaces */
    --bg: #ffffff;
    --bg-alt: #fafafa;
    --surface: #ffffff;
    --panel: #f9fafb;

    /* =========================
       Buttons — vivid + glossy
    ========================= */
    --btn-text: #111827;
    --border: #cbd5e1;
    --border-hover: #94a3b8;

    --success-main: #065f46;
    --success-top: #0b7a62;

    --danger-main: #d9534f;
    --danger-top: #ef4444;

    --warning-main: #ffba08;
    --warning-top: #ffc233;

    --info-main: #2563eb;
    --info-top: #3b82f6;

    /* Gradients (base) */
    --grad-page-a: #f5f6f8;
    --grad-page-b: #edeef0;
    --grad-auth-a: #b0b0b0;
    --grad-auth-b: #e0e0e0;
    --grad-sidebar-a: #e7f1fd;
    --grad-sidebar-b: #f4f8ff;

    /* Aliases used throughout CSS */
    --bg-page-a: var(--grad-page-a);
    --bg-page-b: var(--grad-page-b);
    --bg-auth-a: var(--grad-auth-a);
    --bg-auth-b: var(--grad-auth-b);

    /* Cards & elevation */
    --card-bg: #ffffff;
    --card-border: rgba(255, 255, 255, 0.3);
    --card-radius: 12px;
    --card-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
    --shadow-sm: rgba(0, 0, 0, 0.06);
    --shadow-md: rgba(0, 0, 0, 0.10);
    --shadow-lg: rgba(0, 0, 0, 0.15);

    /* Alerts */
    --alert-critical: #dc3545;
    --alert-warning: #fd7e14;
    --alert-watch: #ffc107;
    --alert-danger: #d9534f;
    --alert-bg: #ffffff;
    --alert-border: #cccccc;
    --alert-hover: #ffcccc;
    --alert-meta: #555;

    /* Misc tokens */
    --hover-bg: #f5f5f5;
    --focus-bg: #eaeaea;
    --purple: #6f42c1;
    /* gradient-divider */
    --error: #F5B700;
    /* flash-error */
    --mint: #d1fae5;
    /* optional tint */

    /* Flash colors */
    --success-bg: #d4edda;
    --success-text: #155724;
    --warning-bg: #fff3cd;
    --warning-text: #856404;
    --danger-bg: #f8d7da;
    --danger-text: #721c24;

    /* Typography */
    --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    /* Type scale */
    --fs-00: clamp(.95rem, .90rem + .15vw, 1.05rem);
    --fs-0: clamp(1.05rem, 1rem + .20vw, 1.175rem);
    --fs-1: clamp(1.15rem, 1.05rem + .30vw, 1.25rem);
    --fs-2: clamp(1.25rem, 1.1rem + .45vw, 1.4rem);
    --fs-3: clamp(1.4rem, 1.15rem + .7vw, 1.65rem);
    --fs-4: clamp(1.65rem, 1.25rem + 1.1vw, 1.95rem);
    --fs-5: clamp(1.95rem, 1.45rem + 1.6vw, 2.35rem);

    /* Specific sizes */
    --fs-body: 16px;
    --fs-icon: 20px;
    --fs-alert-title: 15px;
    --fs-alert-meta: 14px;

    /* Line heights */
    --lh-tight: 1.15;
    --lh-normal: 1.35;
    --lh-relaxed: 1.5;

    /* Density & spacing */
    --dens-pad: .65rem;
    --dens-gap: .65rem;
    --hit-min: 34px;
    --hit-xl: 42px;

    /* Table rhythm */
    --table-cell-vpad: .75rem;
    --table-cell-hpad: .35rem;

    /* Focus rings */
    --ring: rgba(0, 9, 61, .28);
    --ring-soft: rgba(0, 16, 96, .18);

    /* Nav */
    --nav-bg: rgba(255, 255, 255, .8);

    /* KPI / chip palettes */
    --chip-text: #0b1020;
    --chip-ring: rgba(2, 6, 23, .10);
    --chip-sky-a: #e0f2fe;
    --chip-sky-b: #bae6fd;
    --chip-vio-a: #ede9fe;
    --chip-vio-b: #ddd6fe;
    --chip-emer-a: #d1fae5;
    --chip-emer-b: #a7f3d0;
    --chip-amb-a: #fef3c7;
    --chip-amb-b: #fde68a;
    --chip-rose-a: #ffe4e6;
    --chip-rose-b: #fecdd3;
    --chip-sla-a: #e5e7eb;
    --chip-sla-b: #cbd5e1;
    --chip-teal-a: #ccfbf1;
    --chip-teal-b: #99f6e4;
    --chip-ora-a: #ffedd5;
    --chip-ora-b: #fed7aa;
    --chip-lime-a: #ecfccb;
    --chip-lime-b: #d9f99d;
    --chip-indigo-a: #e0e7ff;
    --chip-indigo-b: #c7d2fe;

    /* Table styling tokens */
    --table-head-start: #f3f4f6;
    --table-head-end: #e8eaed;
    --table-head-border: #d0d3d9;
    --table-cell-top: #e5e7eb;
    --table-cell-left: #f3f4f6;
    --table-row-odd: #ffffff;
    --table-row-even: #f9fafb;
    --table-row-hover: #f5f5f5;

    /* Semantic accents / badges */
    --good: #0b7a62;
    --bad: #b91c1c;
    --danger-border: #fca5a5;
    --danger-emph: #b91c1c;

    --amber-bg: #fef3c7;
    --amber-br: #fcd34d;
    --amber-ink: #92400e;
    --green-bg: #dcfce7;
    --green-br: #86efac;
    --green-ink: #14532d;
    --red-bg: #fee2e2;
    --red-br: #fca5a5;
    --red-ink: #7f1d1d;
    --indigo-bg: #e0e7ff;
    --indigo-br: #c7d2fe;
    --indigo-ink: #3730a3;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    background: var(--bg-page-a);
    max-width: 100%;
    box-sizing: border-box;
}

/* LOGIN PAGE */

body.auth-body.auth-geo,
body.auth-body.auth-geo html {
    overflow: hidden;
}

/* Form error message - positioned at top */
.form-error {
    background-color: rgba(229, 57, 53, 0.1);
    color: var(--danger-main);
    padding: 12px 16px;
    border-radius: 10px;
    margin: 0 0 20px 0;
    text-align: center;
    border: 1px solid rgba(229, 57, 53, 0.2);
    font-weight: 600;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

.form-error::before {
    content: "!";
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: var(--danger-main);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 20px;
    margin-right: 8px;
    font-size: 14px;
    font-weight: bold;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Extra-tight mode for ultra-small devices */
@media (max-width:360px) {
    .form-error {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

/* ========== Geometric brand background ========== */
.auth-body.auth-geo {
    position: fixed;
    inset: 0;
    width: 100%;
    display: grid;
    place-items: center;
    overflow: hidden;
    box-sizing: border-box;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    padding-top: calc(env(safe-area-inset-top, 0px) + clamp(12px, 4vmin, 24px));
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(12px, 4vmin, 24px));
    overscroll-behavior: none;
    background: linear-gradient(180deg, var(--grad-page-a), var(--grad-page-b));
    contain: paint;
}

.auth-body.auth-geo::before,
.auth-body.auth-geo::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    contain: strict;
}

/* Big angled brand panel (top-right sweep) */
.auth-body.auth-geo::before {
    background: linear-gradient(135deg, #00093d 0%, #001160 55%, #001a85 100%);
    clip-path: polygon(55% 0, 100% 0, 100% 65%, 70% 75%, 45% 55%, 55% 28%);
    opacity: 1;
}

/* Accent wedge (bottom-left) */
.auth-body.auth-geo::after {
    background: linear-gradient(135deg, #e6a800 0%, #ffba08 60%, #ffd04d 100%);
    clip-path: polygon(0 100%, 0 45%, 22% 58%, 40% 78%, 18% 100%);
    opacity: 1;
}

/* Shape tuning for small screens */
@media (max-width:720px) {
    .auth-body.auth-geo::before {
        clip-path: polygon(58% 0, 100% 0, 100% 60%, 74% 70%, 54% 54%, 60% 28%);
    }

    .auth-body.auth-geo::after {
        clip-path: polygon(0 100%, 0 52%, 28% 62%, 42% 80%, 18% 100%);
    }
}

/* ========== Login/Register card ========== */
.login-card {
    position: relative;
    z-index: 1;
    width: min(400px, 92vw);
    max-height: calc(100dvh - 2 * clamp(12px, 4vmin, 24px));
    max-height: calc(100svh - 2 * clamp(12px, 4vmin, 24px));
    max-height: calc(100vh - 2 * clamp(12px, 4vmin, 24px));
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 28px 26px 24px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Branding */
.login-brand {
    text-align: center;
    margin-bottom: 6px;
}

.login-brand img {
    width: clamp(52px, 14vw, 72px);
    height: auto;
    border-radius: 12%;
}

/* Title */
.login-card h4 {
    text-align: center;
    margin: 6px 0 18px;
    color: var(--brand);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.2px;
}

/* Form controls */
.form-group {
    margin: 0.85rem 0;
}

.login-card label {
    display: block;
    margin: 0 0 5px;
    font-weight: 600;
    color: var(--ink);
    font-size: 0.8rem;
}

.login-card input[type="text"],
.login-card input[type="password"],
.login-card input[type="tel"],
.login-card input[type="date"],
.login-card input[type="email"],
.login-card select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
    box-sizing: border-box;
    transition: border-color 150ms;
    outline: none;
}

.login-card input:focus,
.login-card select:focus {
    border-color: var(--brand);
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input {
    width: 100%;
    padding-right: 2.5rem;
    /* room for the eye */
    box-sizing: border-box;
}

.toggle-eye-inside {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    /* makes sure it’s always vertically centered */
    cursor: pointer;
    user-select: none;
    font-size: 1.1rem;
    /* eye size */
    color: var(--ink-muted);
}

/* Login submit button */
.login-card .btn.primary {
    width: 100%;
    padding: 11px 16px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 8px;
    margin-top: 4px;
}

/* Helper text & links */
.form-error {
    color: var(--danger-main);
    font-size: 0.82rem;
    background: #fee2e2;
    border-radius: 6px;
    padding: 7px 10px;
    margin-top: 8px;
}

.helper {
    margin-top: 14px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--ink-muted);
}

.helper a {
    color: var(--brand);
    font-weight: 600;
    text-decoration: none;
}

.helper a:hover {
    text-decoration: underline;
}

/* Extra-tight mode for ultra-small devices */
@media (max-width:360px) {
    .login-card {
        width: 94vw;
        padding: 16px 14px;
        border-radius: 14px;
    }

    .login-card input[type="text"],
    .login-card input[type="password"] {
        padding: 10px 12px;
    }
}

/* --- Neutralize wrappers that may left-align on auth page --- */
.auth-body.auth-geo .container,
.auth-body.auth-geo .page-wrapper,
.auth-body.auth-geo .page-layout,
.auth-body.auth-geo .main-content {
    display: block;
    width: 100%;
    max-width: none;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent;
    box-shadow: none;
}

/* --- Tablet fixes: ensure centering 600–999px --- */
@media (min-width:600px) and (max-width:999px) {
    .auth-body.auth-geo {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: clamp(16px, 4vmin, 28px);
    }

    .auth-body.auth-geo .login-card {
        width: min(520px, 86vw);
        margin-inline: auto !important;
    }
}

/* =========================
   Layout
========================= */

.legend.subtle {
    font-size: .9rem;
    color: var(--muted);
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

/* Quick actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin: .25rem 0 1rem;
}


/* =========================
   Tables
========================= */
.table {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
    border: 0;
    overflow: visible;
    margin: 1rem 0;
}

/* Header styling — no sticky (causes jank inside overflow-x containers) */
.table thead {
    z-index: 2;
}

/* wrapper for horizontal scroll */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overflow-anchor: none;   /* prevents scroll-anchor jumps */
}

/* header cells */
.table-responsive .table thead th {
    background: linear-gradient(180deg, var(--table-head-start) 0%, var(--table-head-end) 100%);
    color: var(--ink);
    border-bottom: 1px solid var(--table-head-border);
}

/* cells / banding */
.table tbody tr:first-child td {
    border-top: none;
}

.table th+th,
.table td+td {
    border-left: 1px solid var(--table-cell-left);
}

.table tbody tr:nth-child(odd) {
    background: var(--table-row-odd);
}

.table tbody tr:nth-child(even) {
    background: var(--table-row-even);
}

.table tbody tr+tr td {
    border-top-color: #eee;
}

.table tbody tr:hover {
    background: var(--table-row-hover);
}

/* Opt-out */
.table.no-stripe tbody tr:nth-child(odd),
.table.no-stripe tbody tr:nth-child(even) {
    background: transparent;
}

/* Dense variant */
.table.dense tbody td {
    padding-block: 6px;
    line-height: 1.2;
}

/* Mobile stacked cart rows stay white */
@media (max-width:560px) {
    #cartTable tbody tr {
        background: #fff;
    }
}

/* Rounded top corners */
.table thead th:first-child {
    border-top-left-radius: 10px;
}

.table thead th:last-child {
    border-top-right-radius: 10px;
}

/* Sort affordance */
.table thead th.sort {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.table thead th.sort::after {
    content: "↕";
    font-size: .8rem;
    color: #334155;
    margin-left: .35rem;
}

.table thead th.sort.is-asc,
.table thead th.sort.is-desc {
    background: linear-gradient(180deg, rgba(0,9,61,0.07) 0%, rgba(0,9,61,0.13) 100%);
    color: #0b132a;
}

.table thead th.sort.is-asc::after {
    content: "▲";
    color: #0b132a;
}

.table thead th.sort.is-desc::after {
    content: "▼";
    color: #0b132a;
}

.text-good {
    color: var(--good);
    font-weight: 600;
}

.text-bad {
    color: var(--bad);
    font-weight: 600;
}


.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: .5rem;
    margin-top: 16px;
}

.pagination-controls button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ACTIVITY LOG TABLE */
  .ledger-table th,
  .ledger-table td {
      padding: 8px 10px;
      font-size: 0.9rem;
  }

  .ledger-table thead th {
      background: #f8fafc;
      border-bottom: 2px solid #ddd;
  }

  .ledger-table tbody tr:nth-child(even) {
      background: #fafafa;
  }

  .ledger-table .debit {
      color: #c0392b;
      font-weight: 500;
  }

  .ledger-table .credit {
      color: #27ae60;
      font-weight: 500;
  }

  .ledger-table tfoot .summary-row {
      background: #edf2f7;
      font-weight: bold;
      border-top: 2px solid #999;
  }

/* =========================
   Toggle Sections
========================= */
.toggle-section {
    display: none;
}

.toggle-section.active {
    display: block;
}

/* =========================
   Modal
========================= */



/* Mobile-friendly cart table: stack rows as cards */
@media (max-width: 560px) {
    .flex-right-wide .card .table-responsive {
        padding-left: 6px !important;
        padding-right: 6px !important;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .cart-table thead {
        display: none;
    }

    .cart-table,
    .cart-table tbody,
    .cart-table tr,
    .cart-table td {
        display: block;
        width: 100%;
    }

    .cart-table tr {
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 0.6rem;
        padding: 0.4rem 0.5rem;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    }

    .cart-table td {
        border: none;
        padding: 0.35rem 0.25rem;
    }

    .cart-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.75rem;
        color: var(--muted);
        margin-bottom: 2px;
    }

    .cart-table td.col-center,
    .cart-table td.col-right {
        text-align: left;
    }
}


.btn {
    font-size: var(--fs-0);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.2;
    transition: background .15s ease, border-color .15s ease, transform .06s ease, box-shadow .15s ease, filter .15s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(2, 6, 23, .12);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(2, 6, 23, .12);
}

.btn:focus-visible {
    outline: 2px solid var(--info-main);
    outline-offset: 2px;
}

.btn[disabled],
.btn[aria-disabled="true"] {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
}

.btn.primary {
    color: #fff;
    border-color: var(--brand);
    background: linear-gradient(180deg, var(--brand-hover) 0%, var(--brand) 100%);
    box-shadow: 0 6px 16px rgba(0, 9, 61, .28);
}

.btn.primary:hover {
    background: linear-gradient(180deg, #001a78 0%, var(--brand-hover) 100%);
    box-shadow: 0 10px 22px rgba(0, 16, 96, .34);
}

.btn.success {
    color: #fff;
    border-color: var(--success-main);
    background: linear-gradient(180deg, var(--success-top) 0%, var(--success-main) 100%);
    box-shadow: 0 6px 16px rgba(6, 95, 70, .25);
}

.btn.success:hover {
    filter: saturate(1.05);
    box-shadow: 0 10px 22px rgba(6, 95, 70, .33);
}

.btn.danger {
    color: #fff;
    border-color: var(--danger-main);
    background: linear-gradient(180deg, var(--danger-top) 0%, var(--danger-main) 100%);
    box-shadow: 0 6px 16px rgba(220, 38, 38, .28);
}

.btn.danger:hover {
    background: linear-gradient(180deg, #f03a3a 0%, #b91c1c 100%);
    box-shadow: 0 10px 22px rgba(185, 28, 28, .34);
}

.btn.warning {
    color: #111827;
    border-color: var(--warning-main);
    background: linear-gradient(180deg, var(--warning-top) 0%, var(--warning-main) 100%);
    box-shadow: 0 6px 16px rgba(255, 186, 8, .28);
}

.btn.warning:hover {
    filter: saturate(1.05) brightness(.98);
    box-shadow: 0 10px 22px rgba(255, 186, 8, .36);
}

.btn.info {
    color: #fff;
    border-color: var(--info-main);
    background: linear-gradient(180deg, var(--info-top) 0%, var(--info-main) 100%);
    box-shadow: 0 6px 16px rgba(37, 99, 235, .28);
}

.btn.info:hover {
    filter: saturate(1.05);
    box-shadow: 0 10px 22px rgba(37, 99, 235, .36);
}

.btn.ghost {
    background: transparent;
    color: var(--btn-text);
    border-color: var(--border);
}

.btn.ghost:hover {
    background: #e5e7eb;
    border-color: var(--border-hover);
    box-shadow: 0 4px 12px rgba(2, 6, 23, .10);
}

.modal .btn.primary {
    background: linear-gradient(180deg, var(--danger-top) 0%, var(--danger-main) 100%);
    border-color: var(--danger-main);
}

.modal .btn.primary:hover {
    background: linear-gradient(180deg, #f03a3a 0%, #b91c1c 100%);
}

.btn.block {
    display: flex;
    width: 100%;
}

.btn.loading {
    position: relative;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    width: 1em;
    height: 1em;
    margin-left: .35rem;
    border: .16em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spin .8s linear infinite;
}


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

a.btn {
    color: inherit;
}


/* Slide in animation */
@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

#page-loading {
    z-index: 1300;
}

/* Mobile tweaks */
@media (max-width: 720px) {
    .user-name {
        display: none;
    }
}

/* RECORD SALE MODAL */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-wrap {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
}

.history-table th,
.history-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.history-table thead th {
    background: #f3f4f6;
    font-weight: 600;
    text-align: left;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    background: #f3f4f6;
    color: #374151;
}

.status-badge.pending {
    background: var(--amber-bg);
    border-color: var(--amber-br);
    color: var(--amber-ink);
}

.status-badge.approved {
    background: var(--green-bg);
    border-color: var(--green-br);
    color: var(--green-ink);
}

.status-badge.rejected {
    background: var(--red-bg);
    border-color: var(--red-br);
    color: var(--red-ink);
}


.notes-cell {
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.paginator {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 12px;
    font-size: 14px;
}

.paginator .page-link {
    color: #0046ad;
    text-decoration: none;
    font-weight: 600;
}

.paginator .page-link:hover {
    text-decoration: underline;
}

/* Upgrade plan banner */
.sticky-pending {
    border: 1px solid var(--indigo-br);
    background: var(--indigo-bg);
    color: #1f2937;
    padding: 10px 12px;
    border-radius: 10px;
    margin: 10px 0 16px;
}

.plan-actions {
    display: grid;
    gap: 10px 12px;
    align-items: center;
}

.months-label {
    display: flex;
    align-items: center;
    gap: 8px;
}


.total-line {
    text-align: right;
}


/* Sections / tables duplication kept for clarity */
.history-table thead th {
    background: #f3f4f6;
    font-weight: 600;
}

.status-badge.active {
    background: var(--green-bg);
    border-color: var(--green-br);
    color: var(--green-ink);
}

.status-badge.scheduled {
    background: var(--indigo-bg);
    border-color: var(--indigo-br);
    color: var(--indigo-ink);
}

.status-badge.expired {
    background: var(--red-bg);
    border-color: var(--red-br);
    color: var(--red-ink);
}

/* Invoice statuses */
.status-badge.paid {
    background: var(--green-bg);
    border-color: var(--green-br);
    color: var(--green-ink);
}

.status-badge.unpaid {
    background: var(--amber-bg);
    border-color: var(--amber-br);
    color: var(--amber-ink);
}

.status-badge.overdue {
    background: var(--red-bg);
    border-color: var(--red-br);
    color: var(--red-ink);
}

/* FONT STYLES AND SIZES */
/* Base */
html,
body {
    font-size: 17px;
    line-height: var(--lh-relaxed);
}

body,
.main-content {
    font-size: var(--fs-0);
}


/* Buttons (global + your .btn) */
/* Quick actions */
.quick-actions,
.page-anchors,
.page-nav-controls {
    gap: var(--dens-gap);
}


/* Modals */
.modal h5 {
    font-size: var(--fs-2);
}

.modal .body {
    font-size: var(--fs-0);
    line-height: var(--lh-relaxed);
}

.modal footer .btn {
    min-width: 8rem;
}

/* Tables */
.table thead th {
    font-size: var(--fs-0);
    line-height: var(--lh-normal);
    padding: calc(var(--table-cell-vpad) + 2px) var(--table-cell-hpad);
}

.table tbody td {
    font-size: var(--fs-0);
    line-height: var(--lh-normal);
    padding: var(--table-cell-vpad) var(--table-cell-hpad);
}

.table.dense thead th,
.table.dense tbody td {
    padding-block: .5rem;
}

/* ── Flash toasts ────────────────────────────────────────── */
.flash-messages {
    position: fixed;
    top: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    width: min(480px, calc(100vw - 2rem));
    pointer-events: none;
}

@media (max-width: 991px) {
    .flash-messages {
        top: calc(52px + 0.5rem);
    }
}

.flash {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .85rem 1rem;
    border-radius: .5rem;
    font-size: .9rem;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(0,0,0,.14);
    pointer-events: all;
    animation: flash-in .2s ease;
}

@keyframes flash-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.flash-text { flex: 1; }

.flash-close {
    flex-shrink: 0;
    background: none;
    border: none;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    opacity: .6;
    padding: 0;
    margin-top: .05rem;
}
.flash-close:hover { opacity: 1; }

/* colours */
.flash-success {
    background: #dcfce7;
    color: #166534;
    border-left: 4px solid #16a34a;
}
.flash-success .flash-close { color: #166534; }

.flash-warning {
    background: #fff7ed;
    color: #9a3412;
    border-left: 4px solid #f97316;
}
.flash-warning .flash-close { color: #9a3412; }

.flash-danger,
.flash-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #dc2626;
}
.flash-danger .flash-close,
.flash-error .flash-close { color: #991b1b; }

.flash-info {
    background: #eff6ff;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}
.flash-info .flash-close { color: #1e40af; }


.plan-actions .btn {
    min-height: var(--hit-min);
}

/* Pagination */
.paginator,
.pagination-controls {
    gap: var(--dens-gap);
}

/* Mobile tweaks: keep touch sizes generous */
@media (max-width: 720px) {

    .table th,
    .table td {
        font-size: var(--fs-0);
    }
}

/* PRODUCT REPORT */
.badge-category {
    background: #f1f3f5;
    color: #374151;
}

.mono {
    font-variant-numeric: tabular-nums
}

.table thead th.sort {
    cursor: pointer;
    user-select: none;
    position: relative
}

.table thead th.sort::after {
    content: "↕";
    font-size: .75rem;
    color: #9ca3af;
    margin-left: .35rem
}

.profit-positive {
    color: #16a34a;
    font-weight: 600
}

.profit-negative {
    color: #dc2626;
    font-weight: 600
}

/* --- Bootstrap modal hard fix --- */
.modal {
    display: none;
}

.modal.show {
    display: block !important;
}

.modal-backdrop {
    z-index: 1040 !important;
}

/* ============================================================
   RPT — Shared report / targets styles
   ============================================================ */

/* Filter panel */
.rpt-filter {
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.07);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.04);
}
.rpt-filter .filter-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.4rem;
  display: block;
}
.rpt-filter .form-control,
.rpt-filter .form-select,
.rpt-filter .form-control-sm,
.rpt-filter .form-select-sm {
  border-radius: 9px;
  border-color: #e2e8f0;
  background-color: #fafafa;
  font-size: 0.85rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}
.rpt-filter .form-control:focus,
.rpt-filter .form-select:focus,
.rpt-filter .form-control-sm:focus,
.rpt-filter .form-select-sm:focus {
  border-color: #4f7cff;
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(79,124,255,0.12);
}
.rpt-filter .btn {
  border-radius: 9px;
}

/* KPI cards */
.rpt-kpi {
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.07);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 6px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s ease;
  overflow: hidden;
}
.rpt-kpi:hover {
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.08);
}
.rpt-kpi .kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}
.rpt-kpi .kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.35rem;
}
.rpt-kpi .kpi-value {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.rpt-kpi .kpi-sub { font-size: 0.72rem; }

/* KPI accent borders — removed, cards are now borderless white */

/* KPI icon backgrounds */
.ico-qty    { background: #f1f5f9; color: #64748b; }
.ico-rev    { background: #dcfce7; color: #16a34a; }
.ico-cash   { background: #dbeafe; color: #2563eb; }
.ico-var    { background: #fef3c7; color: #d97706; }
.ico-profit { background: #d1fae5; color: #10b981; }
.ico-exp    { background: #fee2e2; color: #ef4444; }
.ico-target { background: #e0e7ff; color: #4338ca; }
.ico-achieve{ background: #dcfce7; color: #16a34a; }
.ico-pct    { background: #f0fdf4; color: #15803d; }
.ico-top    { background: #f3e8ff; color: #7c3aed; }
.ico-low    { background: #fef9c3; color: #b45309; }

/* Section headers */
.rpt-head {
  display: inline-flex;
  flex-direction: column;
  background: #f7f8fa;
  border-left: 3px solid #ffc107;
  border-radius: 0 10px 10px 0;
  padding: 0.55rem 1rem 0.55rem 0.85rem;
}
.rpt-head h6 {
  margin: 0 0 0.1rem;
  font-weight: 700;
  font-size: 0.88rem;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.rpt-head small { color: #64748b; font-size: 0.75rem; font-weight: 400; text-transform: none; letter-spacing: 0; }

/* Table wrapper */
.rpt-tbl {
  background: #fff;
  border: 1px solid #e9eef4;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.rpt-tbl .table { margin: 0; }
.rpt-tbl thead th {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #475569;
  padding: 1.1rem 1rem;
  white-space: nowrap;
}
.rpt-tbl tbody td {
  font-size: 0.78rem;
  padding: 0.6rem 1rem;
  border-color: #f1f5f9;
  vertical-align: middle;
}
.rpt-tbl tbody tr:last-child td { border-bottom: none; }
.rpt-tbl tbody tr:hover td { background: #f5f5f5; }
.rpt-tbl tfoot td {
  background: #f3f4f6;
  border-top: 2px solid #e2e8f0;
  font-weight: 700;
  padding: 0.85rem 1rem;
  color: #0f172a;
  font-size: 0.875rem;
}

/* Reconciliation row states */
.recon-ok   td { background: rgba(16,185,129,0.05); }
.recon-warn td { background: rgba(245,158,11,0.06); }
.recon-bad  td { background: rgba(239,68,68,0.06); }
.recon-ok:hover   td { background: rgba(16,185,129,0.10) !important; }
.recon-warn:hover td { background: rgba(245,158,11,0.11) !important; }
.recon-bad:hover  td { background: rgba(239,68,68,0.11) !important; }

/* Distribution pending table */
.rpt-pending-tbl {
  border: 1.5px solid #fcd34d;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(251,191,36,0.1);
}
.rpt-pending-tbl .table { margin: 0; }
.rpt-pending-tbl thead th {
  background: #fef9c3;
  border-bottom: 1px solid #fde68a;
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #92400e;
  padding: 0.9rem 1rem;
  white-space: nowrap;
}
.rpt-pending-tbl tbody td {
  padding: 0.85rem 1rem;
  border-color: #fef3c7;
  vertical-align: middle;
}
.rpt-pending-tbl tbody tr:last-child td { border-bottom: none; }
.rpt-pending-tbl tbody tr:hover td { background: #fefce8; }

/* From → To arrow */
.dist-arrow { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.82rem; }
.dist-arrow .arrow { color: #94a3b8; font-size: 0.7rem; }

/* Progress bar */
.rpt-progress { height: 8px; border-radius: 99px; background: #e5e7eb; overflow: hidden; }
.rpt-progress .bar { height: 100%; border-radius: 99px; transition: width 0.6s ease; }

/* Context chip */
.rpt-context-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #f3f4f6;
  border: 1px solid #d0d5dd;
  border-radius: 99px;
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
}

@media (max-width: 575px) {
  .rpt-filter { padding: 1rem; }
  .rpt-kpi .kpi-value { font-size: 1rem; }
  .rpt-kpi .kpi-icon { width: 32px; height: 32px; font-size: 0.82rem; }
  .rpt-tbl thead th,
  .rpt-tbl tbody td,
  .rpt-tbl tfoot td,
  .rpt-pending-tbl thead th,
  .rpt-pending-tbl tbody td { padding: 0.65rem 0.75rem; font-size: 0.82rem; }
  .rpt-head h6 { font-size: 0.88rem; }
}
@media (max-width: 380px) {
  .rpt-kpi .kpi-value { font-size: 0.88rem; }
  .rpt-kpi .kpi-sub { font-size: 0.67rem; }
}

.modal {
    z-index: 1055 !important;
}

/* ===============================
   DASHBOARD WARNING FEED
   =============================== */

.warn-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    border-left: 4px solid transparent;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    color: #1e293b;
    transition: background 0.15s ease;
}

.warn-row:hover {
    background: #f5f5f5;
    color: #0f172a;
}

.warn-icon {
    flex-shrink: 0;
    font-size: 1rem;
    width: 22px;
    text-align: center;
}

.warn-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.warn-title {
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.warn-meta {
    font-size: 0.78rem;
    color: #64748b;
}

.warn-action {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    white-space: nowrap;
}

.warn-row:hover .warn-action {
    color: #475569;
}

/* Severity colours */
.warn-danger  { border-left-color: #ef4444; }
.warn-danger .warn-icon  { color: #ef4444; }

.warn-warning { border-left-color: #f59e0b; }
.warn-warning .warn-icon { color: #f59e0b; }

.warn-caution { border-left-color: #3b82f6; }
.warn-caution .warn-icon { color: #3b82f6; }

.warn-pending { border-left-color: #a855f7; }
.warn-pending .warn-icon { color: #a855f7; }