/* ═══════════════════════════════════════════════════════════════════
   Axe CRM — Glass Morphism Design System
   Frosted glass surfaces, subtle gradients, bold data-viz accents.
   Base: Plus Jakarta Sans font, custom layout (no framework).
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ────────────────────────────────────────────────── */

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

:root {
    --color-bg: rgba(255, 255, 255, 0.72);
    --color-bg-solid: #ffffff;
    --color-bg-subtle: rgba(247, 248, 252, 0.65);
    --color-bg-hover: rgba(0, 0, 0, 0.04);
    --color-bg-toolbar: rgba(255, 255, 255, 0.55);
    --color-text: #1a1a2e;
    --color-text-secondary: #5a607a;
    --color-text-muted: #8b90a8;
    --color-border: rgba(0, 0, 0, 0.08);
    --color-border-subtle: rgba(0, 0, 0, 0.04);

    /* McCandless accent palette — bold, vibrant data-viz colours */
    --color-coral: #ff6b6b;
    --color-teal: #18b5a4;
    --color-gold: #f0a500;
    --color-orange: #ff8c42;
    --color-blue: #4a90d9;
    --color-purple: #9b59b6;

    --color-primary: var(--color-teal);
    --color-primary-hover: #14a090;

    /* Glass properties */
    --glass-blur: 20px;
    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-bg-strong: rgba(255, 255, 255, 0.78);
    --glass-border: rgba(255, 255, 255, 0.35);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.10), 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 40px rgba(24, 181, 164, 0.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --sidebar-width: 240px;

    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background: #eef0f6;
    background-image:
        radial-gradient(ellipse at 15% 10%, rgba(24, 181, 164, 0.10) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 80%, rgba(74, 144, 217, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 107, 107, 0.04) 0%, transparent 60%);
    background-attachment: fixed;
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    line-height: 1.3;
    font-weight: 600;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Login Screen ────────────────────────────────────────────────── */

.gsection-login-logo img {
    max-width: 320px;
    height: auto;
}

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    padding: 3rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-title {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: var(--color-text-secondary);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* ── App Layout ──────────────────────────────────────────────────── */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */

.sidebar {
    background: rgba(22, 25, 38, 0.88);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 10;
}

.sidebar-brand {
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
}

.brand-logo {
    display: block;
    filter: brightness(1.1);
}

.sidebar-nav {
    list-style: none;
    padding: 0.75rem 0.75rem;
    flex: 1;
}

.sidebar-nav li {
    margin-bottom: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.55);
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 2px 12px rgba(24, 181, 164, 0.35);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 0.75rem 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-settings-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    font: inherit;
    font-weight: 500;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    margin-bottom: 0.5rem;
}

.sidebar-settings-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
}

.sidebar-settings-link.active {
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 2px 12px rgba(24, 181, 164, 0.35);
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-label {
    display: block;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 500;
    padding: 0 0.75rem;
}

.logout-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 0.375rem;
    color: rgba(255, 255, 255, 0.35);
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}

.logout-button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
}

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

.main-content {
    flex: 1;
    /* min-width:0 (overriding the flex default of auto) is load-bearing: without it this flex item refuses to
       shrink below its content's intrinsic width, so a list page with a very wide DataGrid balloons the whole
       content column past the viewport and the toolbar (headers/filters) scrolls off to the right across the
       fixed sidebar. With it, the column stays viewport-width and the grid scrolls inside its own .dg-container
       (overflow:hidden) / .dg-scroll-container (overflow:auto) instead. */
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-content {
    flex: 1;
    /* Same reasoning as .main-content — keep this column-flex child from being widened by an over-wide grid. */
    min-width: 0;
    /* min-height:0 completes the flex chain so a child with Height="100%" (a DataGrid) resolves to a definite
       height and scrolls inside its own container. Without it the flex item's default min-height:auto lets a
       tall/wide grid grow to full content size and the browser window scrollbars take over (see #60; the Loans
       split panes already carry min-height:0 for exactly this reason, which is why that grid always worked). */
    min-height: 0;
    padding: 2rem 2.5rem;
}

.page-header {
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ── Toolbar ──────────────────────────────────────────────────────── */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    /* backdrop-filter makes the toolbar its own stacking context; raise it so an open dropdown
       (a descendant) paints above the page content/grid below. Stays under modals (z-index 1000). */
    position: relative;
    z-index: 100;
}

.toolbar-tabs {
    display: flex;
    gap: 0.25rem;
}

.toolbar-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.filter-select {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--color-text-secondary);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(24, 181, 164, 0.12);
}

/* Checkbox filter sitting alongside .filter-select in a toolbar. */
.filter-check {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.filter-check input {
    cursor: pointer;
    margin: 0;
}

/* Realtime free-text filter box in toolbars. */
.invoice-search {
    min-width: 220px;
    color: var(--color-text);
}

.invoice-search::placeholder {
    color: var(--color-text-secondary);
}

/* Toolbar "More" dropdown menu. */
.toolbar-dropdown {
    position: relative;
    display: inline-flex;
}

.toolbar-dropdown-backdrop {
    position: fixed;
    inset: 0;
    /* Above the page content (so outside clicks are caught) but below the toolbar (z-index 100),
       so the menu — a child of the toolbar — still paints on top of this backdrop. */
    z-index: 90;
}

.toolbar-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;
    z-index: 50;
    min-width: 210px;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.35rem;
    background: var(--glass-bg-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.toolbar-dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.7rem;
    font-family: var(--font-sans);
    font-size: 0.83rem;
    color: var(--color-text);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.toolbar-dropdown-item:hover {
    background: var(--color-bg-hover);
}

.toolbar-dropdown-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Tabs ─────────────────────────────────────────────────────────── */

.tab {
    background: none;
    border: none;
    padding: 0.75rem 1.25rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
    color: var(--color-text);
}

.tab-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-count {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-left: 0.35rem;
}

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

.card {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem;
    transition: box-shadow 0.2s, transform 0.15s;
}

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

.card-with-logo {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

.card-with-logo .card-body {
    flex: 1;
    min-width: 0;
}

.card-logo {
    width: 48px;
    height: 48px;
    max-width: 48px;
    max-height: 48px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    align-self: center;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

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

.card-detail {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

.card-detail-subtle {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

/* ── Badges ───────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2em 0.6em;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text-secondary);
}

.badge-enduser {
    background: #e0f7f5;
    color: #0d7d74;
}

.badge-dealer {
    background: #fff3e0;
    color: #c77800;
}

.badge-distributor {
    background: #ede7f6;
    color: #7b1fa2;
}

.badge-manufacturer {
    background: #fce4ec;
    color: #c62828;
}

.badge-local {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-remote {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-signalr {
    background: #fff3e0;
    color: #e65100;
}

.badge-online {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-offline {
    background: #fef2f2;
    color: #dc2626;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), #14a090);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(24, 181, 164, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--color-primary-hover), #0f8a7c);
    box-shadow: 0 4px 16px rgba(24, 181, 164, 0.35);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.85);
}

.btn-danger {
    background: linear-gradient(135deg, var(--color-coral), #e55a5a);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.25);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #e55a5a, #d04545);
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.35);
}

.danger-card {
    border-color: var(--color-coral);
}

/* ── Diagnostic Panel ─────────────────────────────────────────────── */

.diagnostic-panel {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.diagnostic-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--color-border-subtle);
}

.diagnostic-count {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.diagnostic-log {
    max-height: 600px;
    overflow-y: auto;
}

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.log-table thead {
    position: sticky;
    top: 0;
    background: var(--color-bg-subtle);
}

.log-table th {
    text-align: left;
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

.log-table td {
    padding: 0.4rem 1rem;
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: top;
}

.log-time {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    white-space: nowrap;
    color: var(--color-text-muted);
}

.log-detail {
    color: var(--color-text-secondary);
    max-width: 500px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Service Tiles (Diagnostics) ──────────────────────────────────── */

.service-tile {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.75rem;
    border-left: 3px solid var(--color-border);
    overflow: hidden;
}

.service-tile--healthy {
    border-left-color: #2e7d32;
}

.service-tile--degraded {
    border-left-color: #f57f17;
}

.service-tile--disconnected {
    border-left-color: #dc2626;
}

.service-tile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.service-tile-header:hover {
    background: var(--color-bg-subtle);
}

.service-tile-identity {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.service-tile-name {
    font-weight: 600;
    font-size: 0.92rem;
}

.service-tile-key {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    background: var(--color-bg-subtle);
    padding: 0.1em 0.4em;
    border-radius: 3px;
}

.service-tile-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.service-tile-protocol {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.service-tile-detail {
    padding: 0 1.25rem 1rem;
    border-top: 1px solid var(--color-border-subtle);
}

.service-tile-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding-top: 0.75rem;
}

.service-tile-detail .detail-list {
    font-size: 0.82rem;
}

.tile-chevron {
    transition: transform 0.2s ease;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.tile-chevron--open {
    transform: rotate(180deg);
}

.badge-degraded {
    background: #fff8e1;
    color: #f57f17;
}

/* ── Status Icons (connection & source) ──────────────────────────── */

.status-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    vertical-align: middle;
}

.badge-source {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
}

.badge-source .status-icon {
    width: 12px;
    height: 12px;
}

.error-timestamp {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-left: 0.5rem;
}

.section-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
}

/* ── About ────────────────────────────────────────────────────────── */

.about-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(560px, 1fr));
    gap: 1rem;
}

.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1.5rem;
    font-size: 0.9rem;
}

.detail-list dt {
    font-weight: 600;
    color: var(--color-text);
}

.detail-list dd {
    color: var(--color-text-secondary);
}

/* ── States ───────────────────────────────────────────────────────── */

.loading-indicator {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
}

.error-banner {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.error-banner p {
    color: #dc2626;
    font-size: 0.9rem;
}

.not-found {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--color-text-muted);
    font-size: 1.1rem;
}

.text-error {
    color: #dc2626;
}

/* ── Brand Badges ────────────────────────────────────────────────── */

.badge-belcanto {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-ygacoustics {
    background: #e3f2fd;
    color: #1565c0;
}

/* ── Sale/Invoice Status Badges ──────────────────────────────────── */

.badge-draft {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-confirmed {
    background: #e0f7f5;
    color: #0d7d74;
}

.badge-invoiced {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-issued {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-paid {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-awaitingdispatch {
    background: #fff8e1;
    color: #f57f17;
}

.badge-stock {
    background: #ede9fe;
    color: #5b21b6;
}

.badge-dispatched {
    background: #e0f2f1;
    color: #00695c;
}

.badge-overdue {
    background: #fef2f2;
    color: #dc2626;
}

.badge-received {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-disputed {
    background: #fff3e0;
    color: #e65100;
}

.badge-cancelled {
    background: #f3f4f6;
    color: #9ca3af;
}

.badge-pendingsale {
    background: rgba(234, 179, 8, 0.18);
    color: #a16207;
}

.badge-sold {
    background: rgba(16, 185, 129, 0.18);
    color: #065f46;
}

/* ── Repair / RMA Status Badges ──────────────────────────────────── */

.badge-awaitingreceipt {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-receivedunprocessed {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-underreview {
    background: #fff3e0;
    color: #e65100;
}

.badge-awaitingparts {
    background: #fef2f2;
    color: #dc2626;
}

.badge-underrepair {
    background: #fff8e1;
    color: #f57f17;
}

.badge-repaircomplete {
    background: #e0f7f5;
    color: #0d7d74;
}

.badge-awaitingshipment {
    background: #ede7f6;
    color: #4527a0;
}

.badge-shipped {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-onhold {
    background: #fce4ec;
    color: #880e4f;
}

.badge-active {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-delivered {
    background: #eef1f6;
    color: #5a607a;
}

.badge-superseded {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-archived {
    background: #f3f4f6;
    color: #9ca3af;
}

.badge-discontinued {
    background: #f3f4f6;
    color: #9ca3af;
}

/* Not carried — the brand makes it, we don't stock it. Warmer than discontinued so the two
   are distinguishable at a glance when both are revealed on the Products grid. */
.badge-not-carried {
    background: #fef3e2;
    color: #b26a1f;
}

/* Cable family parent — the one visible row per cable model; shows how many lengths sit behind it. */
.badge-cable-family {
    background: #e0f2f1;
    color: #00695c;
}

/* ── Condition Badges ────────────────────────────────────────────── */

.badge-new {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-used {
    background: #fff3e0;
    color: #c77800;
}

.badge-demo {
    background: #e3f2fd;
    color: #1565c0;
}

/* ── Loan Status Badges ──────────────────────────────────────────── */

.badge-out {
    background: #fff8e1;
    color: #f57c00;
}

.badge-returned {
    background: #e8f5e9;
    color: #2e7d32;
}

.card-detail-muted {
    color: #999;
    font-size: 0.85em;
}

/* ── Inline Forms ────────────────────────────────────────────────── */

.form-panel {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 180px;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.6);
    color: var(--color-text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(24, 181, 164, 0.12);
}

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

.settings-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* ── Pricing Table ───────────────────────────────────────────────── */

.pricing-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: var(--glass-bg-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.pricing-table thead {
    background: var(--color-bg-subtle);
}

.pricing-table th {
    text-align: left;
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

.pricing-table td {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--color-border-subtle);
}

.pricing-table tr:last-child td {
    border-bottom: none;
}

.pricing-table .currency {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    margin-right: 0.15rem;
}

/* Sales line-item table — more spacious rows */
.pricing-table.pricing-table-sales td {
    padding: 0.65rem 1rem;
    vertical-align: middle;
}

.pricing-table .col-price { min-width: 110px; }

.pricing-table .col-discount {
    text-align: right;
    white-space: nowrap;
    width: 72px;
    color: var(--color-coral);
    font-weight: 500;
}

.pricing-table .col-total { font-weight: 600; white-space: nowrap; }

/* Strikethrough original price when a discount is active */
.pricing-table .price-was {
    display: block;
    text-decoration: line-through;
    color: var(--color-text-muted);
    font-size: 0.78em;
    line-height: 1.2;
}

.pricing-table .price-now {
    display: block;
    font-weight: 600;
    line-height: 1.4;
}

/* Inputs and selects inside pricing-table (e.g. supplier line item editor) */
.pricing-table td input,
.pricing-table td select {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.6);
    color: var(--color-text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.pricing-table td input:focus,
.pricing-table td select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(24, 181, 164, 0.12);
}

/* ── Pricing Tree View ──────────────────────────────────────────── */

.pricing-tree-brand {
    margin-top: 0.5rem;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
}

.pricing-tree-brand > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    user-select: none;
}

.pricing-tree-brand > summary::-webkit-details-marker {
    display: none;
}

.pricing-tree-brand > summary::before {
    content: "\25B6";
    font-size: 0.65rem;
    transition: transform 0.15s ease;
    color: var(--color-text-muted);
}

.pricing-tree-brand[open] > summary::before {
    transform: rotate(90deg);
}

.pricing-tree-brand-name {
    font-size: 0.95rem;
}

.pricing-tree-tier {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 1rem;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border-subtle);
}

.pricing-tree-tier-label {
    font-weight: 500;
    color: var(--color-text);
    min-width: 100px;
}

.pricing-tree-pct {
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.78rem;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
}

.pricing-tree-pct-override {
    background: rgba(32, 178, 170, 0.12);
    color: var(--color-primary);
    font-weight: 600;
}

.pricing-tree-pct-override-text {
    font-weight: 600;
    color: var(--color-text);
}

.pricing-tree-pct-inherited-text {
    color: var(--color-text-muted);
    font-style: italic;
}

.pricing-tree-series {
    margin: 0.25rem 0;
}

.pricing-tree-series > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.4rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    border-top: 1px solid var(--color-border-subtle);
    user-select: none;
}

.pricing-tree-series > summary::-webkit-details-marker {
    display: none;
}

.pricing-tree-series > summary::before {
    content: "\25B6";
    font-size: 0.55rem;
    transition: transform 0.15s ease;
    color: var(--color-text-muted);
}

.pricing-tree-series[open] > summary::before {
    transform: rotate(90deg);
}

.pricing-tree-series-name {
    font-weight: 500;
}

.pricing-tree-editable {
    cursor: pointer;
    transition: background 0.15s;
}

.pricing-tree-editable:hover {
    background: rgba(255, 255, 255, 0.08);
    text-decoration: underline;
    text-decoration-style: dotted;
}

.pricing-tree-edit-input {
    width: 70px;
    padding: 2px 4px;
    font-size: 0.8rem;
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    background: var(--glass-bg-strong);
    border: 1px solid var(--color-primary);
    border-radius: 3px;
    color: var(--color-text);
    outline: none;
}

.pricing-tree-clear-btn {
    display: inline-block;
    margin-left: 2px;
    padding: 0 3px;
    font-size: 0.65rem;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
    opacity: 0.5;
    vertical-align: middle;
}

.pricing-tree-clear-btn:hover {
    opacity: 1;
    color: var(--color-danger, #e74c3c);
}

/* ── Import Panel ───────────────────────────────────────────────── */

.import-textarea {
    width: 100%;
    min-height: 160px;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    resize: vertical;
}

.import-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(32, 178, 170, 0.15);
}

/* ── Card Actions (Edit / Delete) ────────────────────────────────── */

.card-actions {
    display: flex;
    gap: 0.35rem;
    margin-left: auto;
}

.card-actions .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.card-actions .btn-icon:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.card-actions .btn-icon-danger:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.card-actions .btn-icon-sell {
    color: #14b8a6;
}

.card-actions .btn-icon-sell:hover {
    background: rgba(20, 184, 166, 0.12);
    color: #0d9488;
}

/* ── Map Pin Button (address book → map navigation) ──────────── */

.map-pin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.map-pin-btn:hover {
    color: #2dd4bf;
    background: rgba(45, 212, 191, 0.12);
}

/* ── Modal Dialog ─────────────────────────────────────────────────
   Modal styles ship with GSection.Blazor.DataGrid (datagrid.css); the
   fade keyframes stay here because .mobile-nav-overlay animates with them. */

@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Highlight the table row currently being edited */
.row-editing td {
    background: #fffbeb;
}

.row-selected td {
    background: rgba(24, 181, 164, 0.10);
}

.delete-confirm {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: #dc2626;
}

.delete-confirm .btn {
    font-size: 0.78rem;
    padding: 0.3rem 0.75rem;
}

.import-message {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
}

.import-success {
    color: #15803d;
    background: #f0fdf4;
}

.import-error {
    color: #b91c1c;
    background: #fef2f2;
}

/* ── Import Page Banners ─────────────────────────────────────────── */

.import-banner {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.import-banner-success {
    color: #15803d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.import-banner-error {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.import-error-text {
    color: #b91c1c;
    font-weight: 500;
}

/* ── Import Diagnostic Log ───────────────────────────────────────── */

.import-log {
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.85rem;
    font-family: var(--font-sans);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
}

.import-log-entry {
    padding: 0.35rem 0.75rem;
    border-bottom: 1px solid var(--color-border-subtle);
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.import-log-entry:last-child {
    border-bottom: none;
}

.import-log-level {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    flex-shrink: 0;
    width: 3rem;
}

.import-log-info .import-log-level {
    color: var(--color-blue);
}

.import-log-warn .import-log-level {
    color: var(--color-gold);
}

.import-log-error {
    background: #fef2f2;
}

.import-log-error .import-log-level {
    color: #b91c1c;
}

/* ── Map Page ────────────────────────────────────────────────────── */

/* Map tab wrapper — a definite-height flex column (100% of .page-content's flex height, the same
   mechanism the DataGrid's Height="100%" relies on). Without this the map's flex:1 has no flex parent
   to resolve against (the map is a tab inside a plain-block .page-content now) and collapses to 0 height,
   rendering blank — the #45 regression from folding the standalone Map page into a Contacts tab. */
.map-tab {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.map-page-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.map-container {
    flex: 1;
    min-height: 0;
    width: 100%;
}

.map-toolbar-count {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    padding: 0.35rem 0.75rem;
    background: var(--glass-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
}

/* MapLibre popup styling — glass morphism. */
.maplibregl-popup-content {
    background: var(--glass-bg-strong) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-md) !important;
    font-family: var(--font-sans) !important;
    padding: 0.75rem 1rem !important;
    color: var(--color-text);
}

.maplibregl-popup-close-button {
    color: var(--color-text-muted);
    font-size: 1.2rem;
    padding: 4px 8px !important;
}

.map-popup-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-teal);
    margin-bottom: 0.15rem;
}

.map-popup-type {
    margin-bottom: 0.35rem;
}

.map-popup-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.map-popup-address {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.map-popup-contact {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

/* ── Mini Map (Address Book editor) ──────────────────────────────── */

.mini-map-container {
    width: 100%;
    height: 300px;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    overflow: hidden;
}

.location-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.location-panel h3 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
}

.location-coords {
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin: 0.5rem 0;
}

.location-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    align-items: center;
}

.location-message {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-left: 0.5rem;
}

/* ── Geocode Log (modal) ─────────────────────────────────────────── */

.geocode-log {
    background: #0d1117;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    max-height: 400px;
    min-height: 200px;
    overflow-y: auto;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    color: #c9d1d9;
}

.geocode-log-line {
    white-space: pre-wrap;
    word-break: break-word;
}

.geocode-log-success {
    color: #3fb950;
}

.geocode-log-error {
    color: #f85149;
}

.geocode-log-warn {
    color: #d29922;
}

/* ── Mobile / Touch Layout ───────────────────────────────────────── */

/* Hidden by default — media query reveals them on mobile */

.mobile-header {
    display: none;
}

.mobile-nav-overlay {
    display: none;
}

.hamburger-btn {
    display: none;
}

@keyframes slide-up-sheet {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {

    /* ── Sidebar: off-screen by default, slides in on toggle */

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 200;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 6px 0 40px rgba(0, 0, 0, 0.4);
    }

    /* ── Overlay behind the open sidebar */

    .mobile-nav-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 190;
        animation: modal-fade-in 0.2s ease-out;
    }

    /* ── Main content fills the full viewport width */

    .main-content {
        margin-left: 0;
    }

    /* ── Mobile top header bar */

    .mobile-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.6rem 1rem;
        background: var(--glass-bg);
        backdrop-filter: blur(var(--glass-blur));
        -webkit-backdrop-filter: blur(var(--glass-blur));
        border-bottom: 1px solid var(--color-border);
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .hamburger-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0.4rem;
        color: var(--color-text);
        flex-shrink: 0;
        border-radius: var(--radius-sm);
        transition: background 0.15s;
    }

    .hamburger-btn:hover,
    .hamburger-btn:active {
        background: var(--color-bg-hover);
    }

    /* ── Modals: full-width bottom sheet */

    .modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .modal-dialog {
        min-width: 0 !important;
        max-width: 100% !important;
        width: 100%;
        max-height: 92dvh;
        overflow-y: auto;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 1.5rem 1rem 1.25rem;
        animation: slide-up-sheet 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Sheet drag handle */
    .modal-dialog::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--color-border);
        border-radius: 2px;
        margin: -0.5rem auto 1.25rem;
    }

    /* ── Toolbar: stacks vertically */

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }

    .toolbar-filters {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .filter-select {
        flex: 1 1 130px;
    }

    /* ── Page content: tighter padding */

    .page-content {
        padding: 0.75rem;
    }

}

/* ──────────────────────────────────────────────────────────────────────
   Price Import Wizard
   ────────────────────────────────────────────────────────────────────── */

.btn-small {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    margin-right: 0.25rem;
}

.wizard-steps {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    background: transparent;
    border: 1px solid transparent;
}

.wizard-step.active {
    background: var(--glass-bg-strong);
    border-color: var(--color-teal);
    color: var(--color-text-primary);
}

.wizard-step.done {
    color: var(--color-teal);
}

.wizard-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--glass-bg);
    font-size: 0.75rem;
    font-weight: 600;
}

.wizard-step.active .wizard-step-num {
    background: var(--color-teal);
    color: white;
}

.wizard-step.done .wizard-step-num {
    background: var(--color-teal);
    color: white;
}

.price-match-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-teal);
    background: rgba(64, 192, 175, 0.15);
    border: 1px solid rgba(64, 192, 175, 0.4);
    border-radius: var(--radius-sm);
    vertical-align: middle;
}

/* ── Global Search ───────────────────────────────────────────────── */

.nav-search-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.7);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 0.25rem;
}

.nav-search-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.nav-search-btn .nav-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.nav-search-btn:hover .nav-icon { opacity: 1; }

.nav-search-kbd {
    margin-left: auto;
    font-size: 0.68rem;
    font-family: var(--font-sans);
    color: rgba(255,255,255,0.35);
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    letter-spacing: 0.02em;
}

.gs-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(10, 10, 30, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8vh;
}

.gs-modal {
    width: 100%;
    max-width: 660px;
    background: rgba(255,255,255,0.97);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 75vh;
}

.gs-input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--color-border);
}

.gs-search-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
}

.gs-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.4;
}

.gs-input::placeholder { color: var(--color-text-muted); font-weight: 400; }

.gs-esc {
    font-size: 0.72rem;
    font-family: var(--font-sans);
    color: var(--color-text-muted);
    background: var(--color-bg-subtle);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    flex-shrink: 0;
}

.gs-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-teal);
    border-radius: 50%;
    animation: gs-spin 0.6s linear infinite;
    flex-shrink: 0;
}

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

.gs-body {
    overflow-y: auto;
    padding: 0.5rem 0 0.75rem;
}

.gs-hint {
    padding: 1.25rem 1.25rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    text-align: center;
}

.gs-hint strong { color: var(--color-text-secondary); }

.gs-group { margin-bottom: 0.25rem; }

.gs-group-header {
    padding: 0.5rem 1.1rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

.gs-result {
    display: block;
    width: 100%;
    padding: 0.55rem 1.1rem;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s;
    font-family: var(--font-sans);
}

.gs-result:hover { background: var(--color-bg-hover); }

.gs-result-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.15rem;
}

.gs-result-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.gs-result-tag {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-teal);
    background: rgba(24, 181, 164, 0.1);
    border: 1px solid rgba(24, 181, 164, 0.3);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    white-space: nowrap;
}

.gs-result-sub {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gs-group-overflow {
    padding: 0.25rem 1.1rem 0.35rem;
    font-size: 0.775rem;
    color: var(--color-text-muted);
    font-style: italic;
}

/* ── Sale / Supplier Invoice link badge ──────────────────────── */

.badge-link-count {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--color-teal);
    background: rgba(24, 181, 164, 0.12);
    border: 1px solid rgba(24, 181, 164, 0.35);
    border-radius: 10px;
    padding: 0.1rem 0.5rem;
    white-space: nowrap;
}

/* ── Graphs page ─────────────────────────────────────────────── */

.graphs-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Reports page: summary bar above the brand-sales grid. */
.report-summary {
    display: flex;
    align-items: baseline;
    gap: 1.5rem;
    margin-bottom: 0.85rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.report-summary .report-summary-label {
    font-weight: 600;
    color: var(--color-text);
    font-size: 1rem;
}

.chart-card {
    padding: 1.5rem 1.75rem 1rem;
}

/* Sales Over Time stretches to fill the viewport height below the toolbar.
   ApexCharts only honours a number or "100%" for height, and for "100%" it reads the chart
   element's PARENT height — so .chart-fill must carry a real, definite height. It must NOT be a
   flex item with flex:1 (that sets flex-basis:0 and collapses the explicit height). */
.chart-card-fill .chart-fill {
    height: calc(100vh - 240px);
    min-height: 360px;
}

.chart-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 1.25rem;
}

/* ApexCharts: transparent SVG background + force visible label colours. */
.apexcharts-canvas svg {
    background: transparent !important;
}

.apexcharts-xaxis text,
.apexcharts-yaxis text,
.apexcharts-xaxis-texts-g text,
.apexcharts-yaxis-texts-g text,
.apexcharts-datalabel,
.apexcharts-legend-text {
    fill: #5a607a !important;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.apexcharts-gridline {
    stroke: rgba(0, 0, 0, 0.08) !important;
}

.apexcharts-xaxis-tick,
.apexcharts-yaxis-tick {
    stroke: #8b90a8 !important;
}

/* Receivables detail table */
.receivables-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.receivables-table th {
    padding: 0.45rem 0.75rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.receivables-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    vertical-align: middle;
}

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

.receivables-table .text-muted {
    color: var(--color-text-muted);
}

.receivables-table .invoice-num {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* Outstanding-invoice rows deep-link to the invoice's detail modal. */
.receivables-table tbody tr.clickable-row {
    cursor: pointer;
    transition: background 0.12s;
}

.receivables-table tbody tr.clickable-row:hover {
    background: var(--glass-bg);
}

.receivables-table tbody tr.clickable-row:hover .invoice-num {
    color: var(--color-primary);
}

.outstanding-amount {
    font-weight: 600;
}

.receivables-total-row td {
    font-weight: 700;
    border-top: 2px solid rgba(0, 0, 0, 0.1);
    border-bottom: none;
    padding-top: 0.65rem;
}

.age-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.age-future { background: rgba(24, 181, 164, 0.12); color: #0e8a7d; }
.age-overdue-30 { background: rgba(240, 165, 0, 0.15); color: #966500; }
.age-overdue-60 { background: rgba(255, 107, 107, 0.2); color: #c0282b; }
.age-overdue-90 { background: rgba(200, 30, 30, 0.2); color: #a01010; }
.age-overdue-90plus { background: rgba(150, 0, 0, 0.2); color: #780000; }

/* ── Loans split layout + Notes panel ─────────────────────────────── */

.loans-split {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.loans-split-pane {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.loans-split-pane--notes {
    border-top: 1px solid var(--color-border);
}

/* Body below each pane's toolbar. The grid manages its own scroll; the notes body scrolls itself. */
.loans-split-body {
    flex: 1;
    min-height: 0;
    padding: 1rem 1.25rem;
}

.loans-split-body.notes-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notes-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.25rem;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    color: var(--color-text);
}

.notes-show-done {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    cursor: pointer;
}

.notes-empty {
    padding: 1rem 0.25rem;
    color: var(--color-text-secondary);
    font-style: italic;
    font-size: 0.875rem;
}

.note-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.6rem 0.7rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    transition: border-color 0.15s;
}

.note-row:hover {
    border-color: var(--color-primary);
}

.note-check {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 0.15rem;
    cursor: pointer;
}

.note-main {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.note-text {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--color-text);
    white-space: pre-wrap;
    word-break: break-word;
}

.note-meta {
    margin-top: 0.25rem;
    font-size: 0.72rem;
    color: var(--color-text-secondary);
}

.note-row--done .note-text {
    text-decoration: line-through;
    color: var(--color-text-secondary);
}

.note-del {
    flex-shrink: 0;
    padding: 0 0.25rem;
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.note-row:hover .note-del {
    opacity: 1;
}

.note-del:hover {
    color: var(--color-danger, #e5484d);
}

.notes-done-header {
    margin: 0.75rem 0 0.1rem;
    padding-left: 0.25rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
}

/* ── Right-click context menu ─────────────────────────────────────── */

.ctx-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
}

.ctx-menu {
    position: fixed;
    z-index: 1201;
    min-width: 190px;
    padding: 0.3rem;
    background: var(--glass-bg-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ctx-menu-title {
    padding: 0.4rem 0.55rem 0.45rem;
    margin-bottom: 0.2rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--glass-border);
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ctx-menu-item {
    text-align: left;
    background: transparent;
    border: none;
    color: var(--color-text);
    padding: 0.5rem 0.55rem;
    border-radius: 6px;
    font-size: 0.88rem;
    cursor: pointer;
    white-space: nowrap;
}

.ctx-menu-item:hover {
    background: var(--color-primary);
    color: #fff;
}

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

.ctx-menu-item-danger:hover {
    background: var(--color-coral);
    color: #fff;
}

