/* ==========================================================================
   NAZ Imports design system
   Light grey canvas, white rounded cards, black primary actions, NAZ navy accent.
   Component classes live here; Tailwind utilities (loaded after this file) can
   still override any of them per element.
   ========================================================================== */

:root {
    --bg: #eceef2;
    --surface: #ffffff;
    --surface-2: #f5f6f8;
    --surface-3: #eceef1;
    --line: #e6e8ec;
    --line-strong: #d5d9e0;
    --ink: #111318;
    --ink-2: #474d5b;
    --muted: #8b91a0;

    --navy-50: #f1f4f9;
    --navy-100: #e2e8f1;
    --navy-200: #c6d1e2;
    --navy-300: #9fb1cc;
    --navy-400: #7089b0;
    --navy-500: #4f6b95;
    --navy-600: #3d567c;
    --navy-700: #2f4565;
    --navy-800: #203959;
    --navy-900: #172a43;
    --navy-950: #0e1a2b;
    --accent: var(--navy-800);

    --success: #15803d;
    --success-soft: #e7f6ed;
    --warning: #b45309;
    --warning-soft: #fdf3e1;
    --danger: #dc2626;
    --danger-soft: #fdeeee;

    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;

    --shadow-pop: 0 24px 64px -24px rgba(17, 19, 24, 0.38), 0 2px 6px rgba(17, 19, 24, 0.05);
    --shadow-hover: 0 10px 30px -18px rgba(17, 19, 24, 0.35);

    --rail-w: 64px;
    --topbar-h: 76px;
}

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

body {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

input[type='checkbox'],
input[type='radio'] {
    accent-color: var(--ink);
}

::selection {
    background: var(--navy-100);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cdd2da;
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: #aab1bd;
    border: 3px solid transparent;
    background-clip: padding-box;
}

html.ui-locked,
html.ui-locked body {
    overflow: hidden;
}

[x-cloak] {
    display: none !important;
}

/* Comfortable touch targets on phones and tablets only */
@media (pointer: coarse) {
    button,
    .btn {
        min-height: 40px;
    }
}

/* --------------------------------------------------------------------------
   App shell: top bar, section rail, content, mobile tab bar
   -------------------------------------------------------------------------- */
.app-shell {
    display: grid;
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: 24px;
    max-width: 1680px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 28px 28px 20px;
}

.app-topbar {
    grid-column: 1 / -1;
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: var(--topbar-h);
    padding: 14px 0;
    background: var(--bg);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-width: calc(var(--rail-w) + 24px);
    color: var(--ink);
}

.brand img {
    width: 40px;
    height: 40px;
    border-radius: 12px;
}

.brand-name {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: var(--surface);
    border-radius: 999px;
}

.icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    color: var(--ink-2);
    font-size: 15px;
    transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.icon-btn .dot {
    position: absolute;
    top: 9px;
    right: 10px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--danger);
    border: 2px solid var(--surface);
}

.profile-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 4px 14px 4px 4px;
    background: var(--surface);
    border-radius: 999px;
    text-align: left;
    transition: box-shadow 0.15s;
}

.profile-pill:hover {
    box-shadow: var(--shadow-hover);
}

.profile-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--ink);
}

.profile-role {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.2;
}

/* Section rail (desktop) */
.app-rail {
    grid-row: 2;
    grid-column: 1;
    position: sticky;
    top: var(--topbar-h);
    align-self: start;
    height: calc(100vh - var(--topbar-h) - 28px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding-top: 4px;
}

.rail-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px;
    background: var(--surface);
    border-radius: 999px;
}

.rail-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    color: var(--ink-2);
    font-size: 16px;
    transition: background 0.15s, color 0.15s;
}

.rail-btn:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.rail-btn.is-active {
    background: var(--ink);
    color: #fff;
}

.rail-btn.is-danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.rail-tip {
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
    z-index: 60;
}

.rail-btn:hover .rail-tip,
.rail-btn:focus-visible .rail-tip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.app-content {
    grid-row: 2;
    grid-column: 2;
    min-width: 0;
    padding-top: 4px;
}

/* Mobile tab bar (sections) */
.app-tabbar {
    display: none;
}

/* Top pill navigation (pages inside the current section) */
.pill-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px;
    background: var(--surface);
    border-radius: 999px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.pill-nav::-webkit-scrollbar {
    display: none;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-2);
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.pill:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.pill.is-active {
    background: var(--ink);
    color: #fff;
}

@media (max-width: 1100px) and (min-width: 768px) {
    .profile-meta {
        display: none;
    }

    .profile-pill {
        padding-right: 4px;
    }

    .profile-pill .fa-chevron-down {
        display: none;
    }
}

@media (max-width: 767px) {
    :root {
        --topbar-h: 64px;
    }

    .app-shell {
        grid-template-columns: minmax(0, 1fr);
        column-gap: 0;
        padding: 0 16px calc(96px + env(safe-area-inset-bottom));
    }

    .app-topbar {
        flex-wrap: wrap;
        gap: 10px;
        padding: max(10px, env(safe-area-inset-top)) 0 10px;
    }

    .brand {
        min-width: 0;
    }

    .brand img {
        width: 36px;
        height: 36px;
    }

    .app-topbar .pill-nav {
        order: 3;
        width: 100%;
    }

    .app-topbar .pill {
        flex: 1 0 auto;
        justify-content: center;
        height: 36px;
        padding: 0 12px;
        font-size: 13px;
    }

    .app-topbar .pill-nav:empty,
    .app-topbar .pill-nav-single {
        display: none;
    }

    .profile-meta,
    .profile-pill .fa-chevron-down {
        display: none;
    }

    .profile-pill {
        height: 44px;
        padding: 4px;
    }

    .app-rail {
        display: none;
    }

    .app-content {
        grid-column: 1;
    }

    .app-tabbar {
        position: fixed;
        z-index: 55;
        left: 16px;
        right: 16px;
        bottom: calc(12px + env(safe-area-inset-bottom));
        display: flex;
        justify-content: space-around;
        gap: 4px;
        padding: 6px;
        background: var(--surface);
        border-radius: 999px;
        box-shadow: 0 12px 40px -12px rgba(17, 19, 24, 0.35);
    }

    .tab-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        height: 54px;
        border-radius: 999px;
        font-size: 11px;
        font-weight: 500;
        color: var(--ink-2);
    }

    .tab-btn i {
        font-size: 16px;
    }

    .tab-btn.is-active {
        background: var(--ink);
        color: #fff;
    }

    /* Six or more sections: icons only, the active tab keeps its label */
    .app-tabbar.is-crowded {
        gap: 2px;
    }

    .app-tabbar.is-crowded .tab-btn:not(.is-active) span {
        display: none;
    }

    .app-tabbar.is-crowded .tab-btn.is-active {
        flex: 0 0 auto;
        padding: 0 14px;
    }
}

/* --------------------------------------------------------------------------
   Page header
   -------------------------------------------------------------------------- */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 6px 0 24px;
}

.page-title {
    font-size: clamp(26px, 2.6vw, 36px);
    font-weight: 500;
    letter-spacing: -0.03em;
    line-height: 1.12;
    color: var(--ink);
}

.page-sub {
    margin-top: 6px;
    font-size: 14px;
    color: var(--muted);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--ink);
}

/* --------------------------------------------------------------------------
   Cards, tiles, stats
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 20px;
    min-width: 0;
}

.card-lg {
    padding: 24px;
}

.card-flush {
    padding: 0;
    overflow: hidden;
}

.card-hover {
    transition: box-shadow 0.18s, transform 0.18s;
}

.card-hover:hover {
    box-shadow: var(--shadow-hover);
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.card-sub {
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
}

/* Grey inner panel inside a white card (like the reference's wallet strip) */
.tile {
    background: var(--surface-2);
    border-radius: var(--radius-lg);
    padding: 14px;
    min-width: 0;
}

/* White mini-card that sits on a .tile */
.tile-item {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 12px;
    min-width: 0;
}

/* Highlight card in brand navy (the reference's orange card) */
.card-accent {
    background:
        radial-gradient(120% 90% at 100% 0%, rgba(112, 137, 176, 0.35) 0%, transparent 55%),
        linear-gradient(160deg, #2c4a72 0%, var(--navy-800) 48%, var(--navy-950) 100%);
    color: #fff;
}

.card-dark {
    background: linear-gradient(160deg, #23262d 0%, #111318 100%);
    color: #fff;
}

.card-accent .stat-label,
.card-dark .stat-label,
.card-accent .stat-meta,
.card-dark .stat-meta,
.card-accent .card-sub,
.card-dark .card-sub {
    color: rgba(255, 255, 255, 0.72);
}

.card-accent .stat-value,
.card-dark .stat-value,
.card-accent .card-title,
.card-dark .card-title {
    color: #fff;
}

.stat-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-2);
}

.stat-value {
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.stat-value-lg {
    font-size: clamp(30px, 3vw, 38px);
}

.stat-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--muted);
}

.icon-chip {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    display: grid;
    place-items: center;
    color: var(--ink-2);
    font-size: 13px;
}

.icon-chip-lg {
    width: 44px;
    height: 44px;
    font-size: 16px;
}

.icon-chip-soft {
    border: 0;
    background: var(--surface-2);
}

.card-accent .icon-chip,
.card-dark .icon-chip {
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--ink-2);
}

.trend-up {
    background: var(--success-soft);
    color: var(--success);
}

.trend-down {
    background: var(--danger-soft);
    color: var(--danger);
}

.card-accent .trend,
.card-dark .trend {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

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

.btn:disabled,
.btn[aria-disabled='true'] {
    opacity: 0.5;
    pointer-events: none;
}

.btn i {
    font-size: 0.9em;
}

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

.btn-primary:hover {
    background: #000;
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--ink);
}

.btn-secondary:hover {
    background: var(--surface-3);
}

.btn-outline {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}

.btn-outline:hover {
    border-color: var(--line-strong);
    background: var(--surface-2);
}

.btn-accent {
    background: var(--navy-800);
    color: #fff;
}

.btn-accent:hover {
    background: var(--navy-900);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-danger-soft {
    background: var(--danger-soft);
    color: var(--danger);
}

.btn-danger-soft:hover {
    background: #fbdcdc;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #116632;
}

.btn-ghost {
    background: transparent;
    color: var(--ink-2);
}

.btn-ghost:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.btn-sm {
    height: 34px;
    padding: 0 14px;
    font-size: 13px;
}

.btn-lg {
    height: 46px;
    padding: 0 22px;
    font-size: 15px;
}

.btn-icon {
    width: 40px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 34px;
}

.btn-block {
    width: 100%;
}

.btn .count {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}

.btn-primary .count {
    background: #fff;
    color: var(--ink);
}

.btn .count.hidden,
.btn .count[hidden] {
    display: none;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
}

.field-hint {
    font-size: 12px;
    color: var(--muted);
}

.input,
.select,
.textarea {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.textarea {
    height: auto;
    min-height: 96px;
    padding: 10px 14px;
    resize: vertical;
    line-height: 1.5;
}

.select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%238b91a0'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--navy-400);
    box-shadow: 0 0 0 4px rgba(32, 57, 89, 0.1);
}

.input::placeholder,
.textarea::placeholder {
    color: #a8adb8;
}

.input-soft {
    background: var(--surface-2);
    border-color: transparent;
}

.input-soft:focus {
    background: var(--surface);
}

.search {
    position: relative;
    min-width: 0;
}

.search > i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 13px;
    pointer-events: none;
}

.search > input {
    width: 100%;
    height: 40px;
    padding: 0 16px 0 40px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search > input:focus {
    border-color: var(--navy-400);
    box-shadow: 0 0 0 4px rgba(32, 57, 89, 0.1);
}

.search > input::placeholder {
    color: #a8adb8;
}

/* Upload drop zone */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 18px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover {
    border-color: var(--navy-400);
    background: var(--navy-50);
}

/* Toggle switch: <label class="switch"><input type="checkbox"><span></span></label> */
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch span {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--line-strong);
    cursor: pointer;
    transition: background 0.15s;
}

.switch span::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s;
}

.switch input:checked + span {
    background: var(--ink);
}

.switch input:checked + span::after {
    transform: translateX(18px);
}

/* --------------------------------------------------------------------------
   Segmented control / in-page tabs
   -------------------------------------------------------------------------- */
.segmented {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: var(--surface);
    border-radius: 999px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.segmented::-webkit-scrollbar {
    display: none;
}

.card .segmented,
.modal-panel .segmented,
.drawer-panel .segmented {
    background: var(--surface-2);
}

.seg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.seg:hover {
    color: var(--ink);
}

.seg.is-active {
    background: var(--ink);
    color: #fff;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13.5px;
}

.table thead th {
    padding: 12px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
}

/* Zero-specificity alignment so Tailwind text-right / text-center on a header still win */
:where(.table thead) th {
    text-align: left;
}

.table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

/* Zero-specificity colour so Tailwind text-* classes on a cell still win */
:where(.table tbody) td {
    color: var(--ink);
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table tbody tr:hover td {
    background: #fafbfc;
}

.table tbody tr.is-selected td {
    background: var(--surface-2);
}

.table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.row-click {
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Badges, status dots, progress
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-soft);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-navy {
    background: var(--navy-50);
    color: var(--navy-800);
}

.badge-dark {
    background: var(--ink);
    color: #fff;
}

.badge-outline {
    background: transparent;
    border: 1px solid var(--line);
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--ink);
    white-space: nowrap;
}

.status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--muted);
    flex-shrink: 0;
}

.status-success::before {
    background: #22c55e;
}

.status-warning::before {
    background: #f59e0b;
}

.status-danger::before {
    background: #ef4444;
}

.status-navy::before {
    background: var(--navy-600);
}

.progress {
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: repeating-linear-gradient(-45deg, #e8eaee 0 5px, #f3f4f6 5px 10px);
}

.progress > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--navy-800);
}

/* --------------------------------------------------------------------------
   Lists, empty states, avatars, misc
   -------------------------------------------------------------------------- */
.list-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    min-width: 0;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.list-row.row-click:hover,
a.list-row:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-hover);
}

.empty {
    padding: 48px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.empty > i {
    display: block;
    margin-bottom: 12px;
    font-size: 28px;
    color: #c5cad3;
}

.empty-title {
    margin-bottom: 4px;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
}

.avatar {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--navy-800);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.divider {
    height: 1px;
    background: var(--line);
}

.kbd {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

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

.tnum {
    font-variant-numeric: tabular-nums;
}

/* Dropdown menu */
.menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 70;
    min-width: 230px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-pop);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--ink-2);
    font-size: 14px;
    text-align: left;
}

.menu-item:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.menu-item.is-danger {
    color: var(--danger);
}

.menu-item.is-danger:hover {
    background: var(--danger-soft);
}

/* --------------------------------------------------------------------------
   Modals and drawers
   Markup:
     <div id="x" class="modal hidden"><div class="modal-panel modal-md">
       <div class="modal-header">...<button class="modal-close" data-close>...</div>
       <div class="modal-body">...</div>
       <div class="modal-footer">...</div>
     </div></div>
   Open/close with UI.open('x') / UI.close('x'), data-open="x" / data-close,
   the Tailwind `hidden` class, the `hidden` attribute, or Alpine x-show.
   -------------------------------------------------------------------------- */
.modal,
.drawer {
    position: fixed;
    inset: 0;
    display: flex;
    background: rgba(17, 19, 24, 0.42);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal {
    z-index: 150;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.drawer {
    z-index: 140;
    justify-content: flex-end;
    background: rgba(17, 19, 24, 0.32);
}

.modal.hidden,
.modal[hidden],
.drawer.hidden,
.drawer[hidden] {
    display: none !important;
}

.modal-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-pop);
    animation: uiModalIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}

.modal-sm {
    max-width: 420px;
}

.modal-md {
    max-width: 560px;
}

.modal-lg {
    max-width: 760px;
}

.modal-xl {
    max-width: 1040px;
}

.drawer-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(460px, 100%);
    height: 100%;
    overflow: hidden;
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-pop);
    animation: uiDrawerIn 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.drawer-wide {
    width: min(680px, 100%);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 14px;
    flex-shrink: 0;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--ink);
}

.modal-sub {
    margin-top: 3px;
    font-size: 13px;
    color: var(--muted);
}

.modal-close {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
    background: var(--surface-3);
    color: var(--ink);
}

.modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 6px 24px 22px;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 24px;
    border-top: 1px solid var(--line);
    background: var(--surface);
    flex-shrink: 0;
}

@keyframes uiModalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes uiDrawerIn {
    from {
        transform: translateX(40px);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

@keyframes uiSheetIn {
    from {
        transform: translateY(40px);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

/* On phones, modals become bottom sheets and drawers go full width */
@media (max-width: 639px) {
    .modal {
        align-items: flex-end;
        padding: env(safe-area-inset-top) 0 0;
    }

    .modal-panel {
        max-width: 100% !important;
        max-height: 92vh;
        max-height: 92dvh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        padding-bottom: env(safe-area-inset-bottom);
        animation: uiSheetIn 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
    }

    .modal-header {
        padding: 18px 18px 12px;
    }

    .modal-body {
        padding: 4px 18px 18px;
    }

    .modal-footer {
        padding: 12px 18px;
    }

    .modal-footer > .btn {
        flex: 1;
    }

    .drawer-panel {
        width: 100%;
        border-radius: 0;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Toasts */
.toast-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 16px;
    border-radius: 14px;
    background: var(--ink);
    color: #fff;
    font-size: 14px;
    box-shadow: var(--shadow-pop);
    pointer-events: auto;
    animation: uiSheetIn 0.22s ease-out;
}

.toast-success i {
    color: #4ade80;
}

.toast-error i {
    color: #f87171;
}

@media (max-width: 767px) {
    .toast-stack {
        left: 16px;
        right: 16px;
        bottom: calc(96px + env(safe-area-inset-bottom));
        align-items: stretch;
    }
}

/* --------------------------------------------------------------------------
   Dashboard bar chart
   -------------------------------------------------------------------------- */
.chart {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    height: 220px;
}

.chart-axis {
    display: flex;
    flex-direction: column-reverse;
    justify-content: space-between;
    padding-bottom: 22px;
    font-size: 11px;
    color: var(--muted);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.chart-plot {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chart-grid {
    position: absolute;
    inset: 0 0 22px 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}

.chart-grid span {
    border-top: 1px dashed #e3e6eb;
}

.chart-bars {
    position: relative;
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 6px;
}

.chart-col {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.chart-pair {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
}

.chart-bar {
    width: min(14px, 42%);
    min-height: 3px;
    border-radius: 6px;
    transition: opacity 0.15s;
}

.chart-bar-income {
    background: repeating-linear-gradient(-45deg, var(--navy-800) 0 4px, var(--navy-600) 4px 8px);
}

.chart-bar-expense {
    background: var(--ink);
}

.chart-label {
    height: 22px;
    padding-top: 6px;
    font-size: 11px;
    color: var(--muted);
}

.chart-col .chart-tip {
    position: absolute;
    bottom: calc(100% - 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--ink);
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s;
}

.chart-col:hover .chart-tip {
    opacity: 1;
}

.chart-col:hover .chart-bar {
    opacity: 0.85;
}

.legend {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 12px;
    color: var(--ink-2);
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

/* --------------------------------------------------------------------------
   Shared overlays from base.html: loading, confirm
   -------------------------------------------------------------------------- */
.loading-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(17, 19, 24, 0.38);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.25s ease;
}

.loading-card {
    width: 90%;
    max-width: 320px;
    padding: 32px 28px;
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-pop);
    text-align: center;
}

.spinner-outer {
    position: relative;
    width: 52px;
    height: 52px;
    margin: 0 auto 18px;
}

.spinner-ring {
    position: absolute;
    inset: 0;
    border: 4px solid var(--surface-3);
    border-top-color: var(--navy-800);
    border-radius: 50%;
    animation: spin 0.9s cubic-bezier(0.55, 0.1, 0.15, 0.9) infinite;
}

.spinner-glow {
    display: none;
}

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

.no-transition {
    transition: none !important;
}

/* --------------------------------------------------------------------------
   Legacy helpers still used by page templates
   -------------------------------------------------------------------------- */
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

.modal-animate-in {
    animation: uiModalIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.no-scrollbar {
    scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

@supports (padding: env(safe-area-inset-top)) {
    .modal-safe-area {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Black pill tabs used by older page markup */
.supplier-tab-active,
.tab-active {
    background: var(--ink);
    color: #fff;
}

.supplier-tab-inactive,
.tab-inactive {
    color: var(--ink-2);
}

.supplier-tab-inactive:hover,
.tab-inactive:hover {
    background: var(--surface-2);
    color: var(--ink);
}

@media (max-width: 639px) {
    .mobile-compact-pad {
        padding: 1rem !important;
    }

    .filter-bar-responsive {
        flex-direction: column;
    }

    .filter-bar-responsive > * {
        width: 100% !important;
        min-width: unset !important;
    }
}

@media (max-height: 700px) {
    .modal-body-scroll {
        max-height: 50vh !important;
    }
}

/* Edit modal footer: wrap buttons on small screens */
@media (max-width: 639px) {
    .edit-modal-footer {
        flex-wrap: wrap;
    }

    .edit-modal-footer > * {
        flex: 1 1 100%;
    }

    .edit-modal-footer .edit-modal-actions {
        justify-content: stretch;
    }

    .edit-modal-footer .edit-modal-actions > * {
        flex: 1;
    }
}

/* Inventory table that switches to cards (inventory page) */
.responsive-table.force-card-view thead {
    display: none !important;
}

.responsive-table.force-card-view tbody {
    display: grid !important;
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    gap: 16px !important;
    padding: 4px 0 !important;
}

@media (min-width: 640px) {
    .responsive-table.force-card-view tbody {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 1400px) {
    .responsive-table.force-card-view tbody {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

.responsive-table.force-card-view tr.inventory-row {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    padding: 18px;
    border-radius: var(--radius-xl);
    background: var(--surface);
    transition: box-shadow 0.18s;
}

.responsive-table.force-card-view tr.inventory-row:hover {
    box-shadow: var(--shadow-hover);
}

.responsive-table.force-card-view .hidden-card {
    display: none !important;
}

.responsive-table.force-card-view tr.inventory-row > td {
    display: none !important;
}

.responsive-table.force-card-view tr.inventory-row > td:first-child {
    display: block !important;
}

@media (max-width: 1024px) {
    .responsive-table:not(.force-table-view) thead {
        display: none !important;
    }

    .responsive-table:not(.force-table-view) tr.inventory-row {
        display: block !important;
        margin-bottom: 12px;
        padding: 16px;
        border-radius: var(--radius-xl);
        background: var(--surface);
    }

    .responsive-table:not(.force-table-view) tr.inventory-row > td {
        display: none !important;
    }

    .responsive-table:not(.force-table-view) tr.inventory-row > td:first-child {
        display: block !important;
    }
}

@media (max-width: 767px) {
    .responsive-table.force-table-view {
        min-width: 800px;
    }
}

.responsive-table.force-table-view tr.inventory-row > td:first-child {
    display: none !important;
}

/* Printable invoice paper (Revenue Tracker) */
.invoice-paper {
    width: 100%;
    max-width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 10mm;
    background: #fff;
    box-shadow: 0 0 0 1px var(--line), 0 18px 40px -24px rgba(17, 19, 24, 0.3);
}

@media (max-width: 639px) {
    .invoice-paper {
        min-height: auto;
        padding: 4mm;
        font-size: 11px;
    }

    .invoice-paper h1 {
        font-size: 14px !important;
    }

    .invoice-paper h2 {
        font-size: 13px !important;
    }

    .invoice-info-grid {
        grid-template-columns: auto 1fr !important;
        gap: 2px 8px !important;
    }

    .invoice-info-grid .col-span-3 {
        grid-column: 2 / -1 !important;
    }

    .invoice-totals-wrap {
        width: 75% !important;
    }

    .invoice-signature-line {
        width: 5rem !important;
    }
}

@media (max-width: 400px) {
    .invoice-paper {
        padding: 3mm;
        font-size: 9px;
    }

    .invoice-paper table th,
    .invoice-paper table td {
        padding: 3px !important;
        font-size: 8px !important;
    }

    .invoice-totals-wrap {
        width: 85% !important;
    }

    .invoice-info-grid {
        font-size: 8px !important;
    }
}

@media (max-width: 1023px) {
    .invoice-preview-container {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: center !important;
        align-items: flex-start !important;
        padding: 0.5rem !important;
    }

    .invoice-preview-container .invoice-paper {
        flex-shrink: 0;
        transform-origin: top center;
        transform: scale(0.72);
        margin-bottom: -20%;
    }
}

@media (max-width: 639px) {
    .invoice-preview-container {
        padding: 0.25rem !important;
    }

    .invoice-preview-container .invoice-paper {
        transform: none;
        margin-bottom: 0;
        max-width: 100%;
        min-height: auto;
        padding: 4mm;
        font-size: 10px;
    }
}

@media (max-width: 400px) {
    .invoice-preview-container .invoice-paper {
        padding: 3mm;
        font-size: 9px;
    }
}

/* Revenue Tracker mobile tab switcher */
.mobile-tab-bar {
    display: none;
}

@media (max-width: 1023px) {
    .mobile-tab-bar {
        display: flex;
        gap: 4px;
        margin-bottom: 16px;
        padding: 4px;
        border-radius: 999px;
        background: var(--surface);
    }

    .mobile-tab-btn {
        flex: 1;
        height: 36px;
        border: 0;
        border-radius: 999px;
        background: transparent;
        color: var(--ink-2);
        font-size: 13px;
        font-weight: 500;
        cursor: pointer;
        transition: background 0.15s, color 0.15s;
    }

    .mobile-tab-btn.active {
        background: var(--ink);
        color: #fff;
    }
}
