/* ==== theme ==== */
/* The apps' shared theme: paste this block unchanged as the first section of static_extend/<app>/css/<app>.css (no separate file, so no extra request).
   One navy accent (#1a396f; dark mode a brighter #24508f fill and #9db9ea text) on neutral greys (shadcn-style: soft borders, 8px radius, clear focus ring). Dialog headers are filled --brand with white text; table and column headers use --brand-tint. Every colour in the app uses these tokens; status colours keep their meaning. */
:root {
  --brand: #1a396f;
  --brand-hover: #142c57;
  --brand-soft: #edf2fa;
  --brand-line: #b7c8e3;
  --brand-tint: #dce6f5;
  --brand-ink: #1a396f; /* the brand as text and icons; --brand is the fill under white text */
  --on-brand-soft: #dce6f5; /* a subtitle on a --brand header */
  --on-brand: #fff;
  --on-brand-line: rgba(255, 255, 255, .35);
  --on-brand-hover: rgba(255, 255, 255, .16);
  --bg: #f7f8fa;
  --surface: #fff;
  --surface-2: #f2f4f7;
  --ink: #1f2933;
  --muted: #5f6b7a;
  --faint: #8a94a3;
  --line: #e3e7ed;
  --line-strong: #cfd5de;
  --ring: 0 0 0 3px rgba(26, 57, 111, .22);
  --success: #2e7d4f;
  --success-soft: #e8f4ec;
  --warning: #9a6200;
  --warning-soft: #fdf3e1;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --info: #2f6bad;
  --info-soft: #eaf1f9;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --backdrop: rgba(16, 24, 40, .45);
  --toast-bg: #1f2933;
  --font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* sizes: every app takes its sizes from here (heights, paddings, type), so all pages line up */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs: 13px;
  --fs-lg: 17px;
  --topbar-h: 64px;
  --topbar-pad: 24px;
  --mark: 32px;
  --avatar: 36px;
  --control-h: 36px;
  --control-pad: 0 10px;
  --btn-h: 36px;
  --btn-pad: 0 14px;
  --btn-sm-h: 30px;
  --cell-pad: 10px 12px;
  --dialog-head-pad: 14px 20px;
  --dialog-pad: 18px 20px;
  --dialog-actions-pad: 12px 20px;
  color-scheme: light;
}
/* dark: <html data-theme="dark"> (js/settings.js sets it from Settings > Theme; Light is the default, System follows the computer); the same names, darker surfaces, lighter text */
:root[data-theme="dark"] {
  --brand: #24508f;
  --brand-hover: #2c5aa0;
  --brand-ink: #9db9ea;
  --brand-soft: #1b293d;
  --brand-line: #2f4a73;
  --brand-tint: #1d2e47;
  --on-brand-soft: #d6e0f2;
  --bg: #0e1216;
  --surface: #161b21;
  --surface-2: #1d232a;
  --ink: #e4e9ee;
  --muted: #9aa6b2;
  --faint: #6e7a86;
  --line: #283039;
  --line-strong: #38424d;
  --ring: 0 0 0 3px rgba(157, 185, 234, .3);
  --success: #5ec48d;
  --success-soft: #14301f;
  --warning: #e3a640;
  --warning-soft: #33270f;
  --danger: #f07470;
  --danger-soft: #3a1a1b;
  --info: #6ea9ea;
  --info-soft: #152639;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  --backdrop: rgba(0, 0, 0, .6);
  --toast-bg: #2b343e;
  color-scheme: dark;
}
/* compact: <html data-density="compact"> (js/settings.js, Settings > Density); smaller rows, fields, buttons and bars, the same layout */
:root[data-density="compact"] {
  --topbar-h: 52px;
  --mark: 28px;
  --avatar: 30px;
  --control-h: 30px;
  --btn-h: 30px;
  --btn-pad: 0 12px;
  --btn-sm-h: 26px;
  --cell-pad: 6px 10px;
  --dialog-head-pad: 10px 16px;
  --dialog-pad: 14px 16px;
  --dialog-actions-pad: 10px 16px;
}
/* ==== Base ==== */

/* TradeLane's own names, kept so the screens need no renaming: each one is a Pulse theme token above, so light, dark and compact follow the theme */
:root {
    --bg-main: var(--bg);
    --bg-surface: var(--surface);
    --panel-head-bg: var(--brand);
    --primary: var(--brand);
    --primary-hover: var(--brand-hover);
    --text-dark: var(--ink);
    --text-muted: var(--muted);
    --border: var(--line);
    --status-green: var(--success-soft);
    --status-green-text: var(--success);
    --status-blue: var(--info-soft);
    --status-blue-text: var(--info);
    /* The export/import split chart (Country Overview and the Customer Dashboard): data colours, kept as they are. */
    --co-export: #ED7D31;
    --co-import: #5B9BD5;
    --co-heading: #1F3864;
}

* {
    box-sizing: border-box;
}

/* Base for every rem size in the app — lower this to scale all text down together. */
html {
    font-size: 15px;
}

body {
    margin: 0;
    font: var(--font);
    background-color: var(--bg-main);
    color: var(--text-dark);
}

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

.sidebar {
    width: 232px !important;
    max-width: 232px !important;
    min-width: 232px !important;
    flex-shrink: 0;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.logo {
    height: 42px;
    padding: 0 0.6rem;
    display: flex;
    align-items: center;
    color: var(--sidebar-text-active);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo h2 {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.nav-menu {
    padding: 0.45rem 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    overflow-y: auto;
}

/* ==== Sidebar current filters ==== */

/* Sidebar Current Filters Card */
.sidebar-current-filters {
    display: flex !important;
    flex-direction: column !important;
    width: calc(100% - 0.5rem) !important;
    max-width: calc(100% - 0.5rem) !important;
    margin: auto 0.25rem 0.4rem 0.25rem !important;
    padding: 0.38rem 0.4rem !important;
    background: var(--sidebar-deep) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 5px !important;
    color: var(--sidebar-text-active) !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    max-height: 180px !important;
}

.scf-header {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.25rem !important;
    font-weight: 600 !important;
    font-size: 0.60rem !important;
    color: var(--sidebar-text-active) !important;
    width: 100% !important;
}

.scf-icon {
    font-size: 0.65rem !important;
}

.scf-divider {
    width: 100% !important;
    margin: 0.3rem 0 !important;
    border: 0 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.scf-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.2rem !important;
    width: 100% !important;
    max-height: 140px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: thin !important;
}

.scf-item {
    display: flex !important;
    align-items: flex-start !important;
    gap: 0.2rem !important;
    font-size: 0.55rem !important;
    line-height: 1.25 !important;
    color: var(--sidebar-text) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
}

.scf-bullet {
    color: var(--sidebar-text-active) !important;
    flex-shrink: 0 !important;
    font-weight: 700 !important;
}

.scf-label {
    color: var(--sidebar-text) !important;
    font-weight: 400 !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
}

.scf-value {
    color: var(--sidebar-text-active) !important;
    font-weight: 600 !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    flex: 1 1 0 !important;
    min-width: 0 !important;
    line-height: 1.2 !important;
}

.sidebar-collapsed .sidebar-current-filters {
    display: none !important;
}

.nav-item {
    padding: 0.5rem 0.7rem;
    color: var(--sidebar-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    font-weight: 500;
    font-size: 0.85rem;
    line-height: 1.3;
    white-space: nowrap;
    border-radius: 6px;
    transition: all 0.18s ease;
}

.nav-item i {
    width: 20px;
    flex: 0 0 20px;
    text-align: center;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Labels must never wrap in the rail; ellipsis instead. */
.nav-label {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex: 1;
}

.nav-item:hover {
    color: var(--sidebar-text-active);
    background-color: color-mix(in srgb, var(--sidebar-text-active) 7%, transparent);
}

.nav-item.active {
    color: var(--sidebar-text-active);
    background-color: var(--sidebar-active-bg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 56px;
    min-height: 56px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
}

.user-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ==== Auth ==== */

/* Auth component: header controls, account menu, modals, and shared auth styling */
.profile-actions {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.user-profile {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.25rem;
    background: transparent;
}

.user-profile:hover {
    border-color: var(--border);
    background: var(--bg-main);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--on-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.72rem;
    line-height: 1;
    overflow: hidden;
    white-space: nowrap;
}

.profile-menu {
    position: absolute;
    top: calc(100% + 0.65rem);
    right: 0;
    min-width: 200px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 18px 35px rgba(17, 24, 39, 0.14);
    padding: 0.35rem;
    display: none;
    z-index: 200;
}

.profile-menu.open {
    display: block;
}

.profile-menu button {
    width: 100%;
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-align: left;
    padding: 0.65rem 0.75rem;
    border-radius: 6px;
    color: var(--text-dark);
    font: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.profile-menu button:hover {
    background: var(--bg-main);
}

.profile-menu button.danger {
    color: var(--danger);
}

.profile-menu button i {
    width: 16px;
    text-align: center;
    font-size: 0.85rem;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.22s ease;
}

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

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

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.1rem;
}

.section-header h1 {
    margin: 0;
    font-size: 1.2rem;
}

.section-header p {
    margin: 0.3rem 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.schema-kpi-row {
    display: flex;
}

.panel {
    background: var(--bg-surface);
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 1.15rem;
    margin-bottom: 1.15rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-header h3 {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.2;
}

.schema-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.schema-tab-table-wrap {
    max-height: calc(100vh - 235px);
    overflow: auto;
}

.query-builder-field select,
.query-builder-field select,
.query-builder-filter-row select,
.schema-index-filter,
.schema-table-filter {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.15rem;
    background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23111827' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 16px 16px;
}

.schema-result-count {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.schema-panel-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 0;
}

.query-builder-reset,
.query-runner-reset,
.query-ai-reset {
    width: auto;
    min-width: 62px;
    padding: 0.42rem 0.7rem;
    flex: 0 0 auto;
    border-color: var(--brand-line);
    background: var(--brand-soft);
    color: var(--brand-ink);
    font-size: 0.78rem;
    font-weight: 700;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--brand) 16%, transparent);
}

.nav-item[hidden],
.query-builder-reset[hidden],
.query-runner-reset[hidden],
.query-ai-reset[hidden] {
    display: none !important;
}

.query-builder-reset:hover,
.query-runner-reset:hover,
.query-ai-reset:hover {
    border-color: var(--brand-line);
    background: var(--brand-tint);
    color: var(--brand-ink);
}

.schema-index-filter,
.schema-table-filter {
    min-height: 34px;
    min-width: 120px;
    max-width: 200px;
    padding: 0.4rem 2.15rem 0.4rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background-color: var(--surface);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.8rem;
    outline: none;
}

.schema-index-filter:focus,
.schema-table-filter:focus {
    border-color: var(--brand-line);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent);
}

#schema-cols-modal .modal-content {
    width: min(650px, calc(100vw - 2.5rem));
}

.kpi-card-clickable {
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card-clickable:hover {
    border-color: var(--brand-line);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 12%, transparent);
    transform: translateY(-2px);
}

.kpi-card-clickable:active {
    transform: translateY(0);
}

.table-download-icon {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
}

.schema-table {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
}

.schema-table th,
.schema-table td {
    padding: 0.65rem 0.55rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-dark);
    font-size: 0.78rem;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}

.schema-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.schema-table th:nth-child(1),
.schema-table td:nth-child(1) {
    width: 56px;
    min-width: 56px;
    text-align: center;
}

.schema-table th:nth-child(5),
.schema-table td:nth-child(5) {
    width: 110px;
    min-width: 110px;
    text-align: center;
}

.schema-table th:nth-child(6),
.schema-table th:nth-child(7),
.schema-table td:nth-child(6),
.schema-table td:nth-child(7) {
    width: 96px;
    min-width: 96px;
    text-align: center;
}

.schema-table th:nth-child(2),
.schema-table td:nth-child(2),
.schema-table th:nth-child(3),
.schema-table td:nth-child(3) {
    width: max-content;
}

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

.schema-table tbody tr:hover td,
.query-table tbody tr:hover td {
    background: var(--brand-soft);
}

.schema-cell-main {
    color: var(--text-dark);
    font-weight: 500;
    overflow-wrap: normal;
    word-break: normal;
    white-space: nowrap;
}

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

.query-form {
    display: grid;
    gap: 1rem;
}

#query-runner {
    position: relative;
}

.query-runner-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(243, 244, 246, 0.66);
    backdrop-filter: blur(2px);
}

.query-runner-overlay[hidden] {
    display: none;
}

.query-runner-loader {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 14px 34px rgba(17, 24, 39, 0.16);
    color: var(--text-dark);
    font-size: 0.86rem;
    font-weight: 700;
}

.query-runner-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid color-mix(in srgb, var(--success) 35%, var(--surface));
    border-top-color: var(--success);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.busy-cancel-btn {
    min-height: 32px;
    padding: 0.38rem 0.65rem;
}

.busy-cancel-btn[hidden] {
    display: none;
}

.query-builder-panel,
.query-ai-panel {
    margin: 0;
    min-height: 195px;
}

.query-editor-panel {
    margin-top: 1rem;
}

.query-preview-panel {
    margin-top: 1rem;
}

.query-preview-editor {
    min-height: 150px;
}

.query-builder-actions,
.query-result-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.query-result-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.query-result-search-icon {
    position: absolute;
    left: 0.65rem;
    color: var(--faint);
    font-size: 0.75rem;
    pointer-events: none;
}

.query-result-search-input {
    width: 220px;
    height: 34px;
    padding: 0 0.65rem 0 1.9rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.81rem;
    outline: none;
    transition: all 0.15s ease;
}

.query-result-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent);
}

@media (max-width: 640px) {
    .query-result-search-input {
        width: 130px;
    }
}

.query-builder-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.query-builder-grid .query-builder-field:first-child {
    flex: 0 1 320px;
    max-width: 340px;
    min-width: 200px;
}

.query-builder-grid .query-builder-field:nth-child(2) {
    flex: 0 0 110px;
    max-width: 120px;
}

.query-builder-field {
    min-width: 0;
    display: grid;
    gap: 0.4rem;
}

.query-builder-field label {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: none;
}

.query-builder-field input,
.query-builder-field select,
.query-ai-question,
.query-builder-filter-row input,
.query-builder-filter-row select {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background-color: var(--surface);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.84rem;
}

.query-builder-filter-row input:disabled,
.query-builder-filter-row select:disabled {
    background-color: var(--surface-2);
    color: var(--faint);
    border-color: var(--line);
    cursor: not-allowed;
}

.query-ai-form {
    display: grid;
    gap: 0.65rem;
}

.query-ai-question {
    min-height: 84px;
    resize: vertical;
}

#query-builder-limit {
    max-width: none;
}

#query-builder-add-filter-btn {
    min-height: 38px;
    background-color: var(--brand-soft);
    border-color: var(--brand-line);
    color: var(--brand-ink);
    font-weight: 800;
}

#query-builder-add-filter-btn:hover {
    background-color: var(--brand-soft);
    border-color: var(--brand-line);
}

.query-builder-filter-list {
    display: grid;
    gap: 0.55rem;
}

.query-builder-filter-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(130px, 0.7fr) minmax(160px, 1fr) 36px;
    gap: 0.55rem;
    align-items: center;
}

.query-builder-column-wrap,
.query-builder-value-wrap {
    position: relative;
    min-width: 0;
}

.query-builder-value-wrap .ms-select {
    width: 100%;
    min-width: 0;
    height: 100%;
}

.query-builder-value-wrap .ms-trigger {
    width: 100%;
    max-width: 100%;
    min-height: 38px;
}

.query-builder-remove {
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    background-color: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 35%, var(--surface));
    color: var(--danger);
}

.query-builder-remove:hover {
    background-color: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 35%, var(--surface));
}

.query-builder-reset,
.query-runner-reset,
.query-ai-reset {
    height: 36px;
    min-height: 36px;
}

.query-builder-message {
    min-height: 1.1rem;
    margin: 0.75rem 0 0;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.query-editor {
    min-height: 190px;
    width: 100%;
    resize: vertical;
    padding: 1rem;
    border: 1px solid var(--ink);
    border-radius: 10px;
    background: var(--toast-bg);
    color: var(--success);
    font: 0.86rem/1.6 "SF Mono", Menlo, Monaco, Consolas, monospace;
    outline: none;
}

.query-editor:focus {
    border-color: var(--brand-line);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

.query-editor-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0;
}

.query-message {
    min-height: 1.2rem;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.query-result-panel {
    margin-top: 1.5rem;
}

.query-result-panel[hidden] {
    display: none;
}

.query-result-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.query-table-wrap {
    overflow: auto;
    max-height: 520px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.query-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.query-table th,
.query-table td {
    max-width: 360px;
    padding: 0.65rem 0.55rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-dark);
    font-size: 0.78rem;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

.query-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: none;
}

.query-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.42rem 0.85rem;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.2s;
}

.btn i,
.close-modal i,
.password-toggle i {
    display: block;
    line-height: 1;
}

.btn>i:not(:only-child) {
    width: 1em;
    min-width: 1em;
    text-align: center;
    font-size: 0.9em;
}

.query-builder-remove,
.query-builder-reset,
.query-runner-reset,
.query-ai-reset,
.table-download-icon,
.close-modal,
.password-toggle {
    display: inline-grid;
    place-items: center;
}

.btn-primary {
    background: var(--primary);
    color: var(--on-brand);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:active {
    background: var(--brand);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

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

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

.btn-danger:active {
    background: var(--danger);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-dark);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--brand-line);
    background: var(--brand-soft);
    color: var(--brand-ink);
}

.btn-secondary:active {
    background: var(--brand-soft);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Sortable column header */

.nav-item {
    position: relative;
}

/* Panel search */
.panel-search {
    min-height: 34px;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.82rem;
    width: 180px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.panel-search:focus {
    border-color: var(--brand-line);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent);
}

.panel-search::placeholder {
    color: var(--faint);
}

.auth-only {
    display: none;
}

body.logged-in .auth-only {
    display: flex;
}

body.logged-out .sidebar,
body.logged-out .auth-only {
    display: none !important;
}

body.logged-out .main-content {
    width: 100%;
}

/* signed in (a refresh with a saved login included), the login page never shows */
body.logged-in .home-section {
    display: none !important;
}

body.logged-out .top-bar {
    display: none !important;
}

body.logged-out .content-wrapper {
    padding: 0;
    overflow-y: auto;
    min-height: 100vh;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1.25rem;
    box-sizing: border-box;
    background: rgba(17, 24, 39, 0.62);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    width: 650px;
    max-width: 100%;
    max-height: calc(100vh - 2.5rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(17, 24, 39, 0.24);
}

.modal-header {
    min-height: 76px;
    box-sizing: border-box;
    padding: 1rem 1.25rem 1rem 1.5rem;
    border-bottom: 1px solid var(--brand-line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, var(--brand-soft) 0%, var(--brand-soft) 100%);
}

.modal-heading {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.modal-heading-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--brand-line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--primary);
}

.modal-header h3 {
    margin: 0;
    color: var(--brand-ink);
    font-size: 1.05rem;
    line-height: 1.3;
}

.modal-subtitle {
    margin: 0.18rem 0 0;
    color: var(--brand-ink);
    font-size: 0.8rem;
    line-height: 1.35;
}

.close-modal {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--brand-ink);
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.close-modal:hover {
    border-color: var(--brand-line);
    background: rgba(255, 255, 255, 0.78);
    color: var(--brand-ink);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

#profile-modal .modal-content {
    width: min(var(--login-details-width, 420px), calc(100vw - 2.5rem));
    min-width: min(420px, calc(100vw - 2.5rem));
}

#user-profile-modal .modal-content {
    width: min(var(--user-profile-width, 420px), calc(100vw - 2.5rem));
    min-width: min(420px, calc(100vw - 2.5rem));
}

#logout-modal .modal-content {
    width: 420px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.form-field label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.form-field input {
    width: 100%;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    outline: none;
}

.form-field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent);
}

.password-toggle {
    position: absolute;
    right: 0.45rem;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.password-toggle:hover {
    background: var(--bg-main);
    color: var(--text-dark);
}

.auth-message {
    min-height: 1.2rem;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.profile-grid {
    display: grid;
    gap: 0.8rem;
}

.profile-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 1rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}

.profile-row:last-child {
    border-bottom: none;
}

.profile-row span {
    color: var(--text-muted);
}

.profile-row strong {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: normal;
}

.logout-confirmation {
    color: var(--muted);
    line-height: 1.55;
}

.logout-confirmation p {
    margin: 0;
}

/* ==== Account blocked dialog ==== */
/* js/account.js (the same file in every Atom app) builds dialog.atom-account.modal > .modal-header + .atom-account-body.
   The page's .modal is a div overlay (display:flex, dimmed background), so a <dialog class="modal"> keeps the browser's
   own open/closed display, and its header and button take this page's modal look. */
dialog.modal {
    display: block;
    backdrop-filter: none;
}

dialog.modal:not([open]) {
    display: none;
}

dialog.atom-account .modal-header {
    min-height: 0;
}

dialog.atom-account .modal-header h2 {
    margin: 0;
    color: var(--brand-ink);
    font-size: 1.05rem;
    line-height: 1.3;
}

dialog.atom-account .atom-account-body {
    color: var(--muted);
}

@media (max-width: 1440px) {
    .logo {
        height: 58px;
        padding: 0 1.15rem;
    }

    .logo h2 {
        font-size: 1.12rem;
    }

    .nav-menu {
        padding: 0.75rem 0;
        gap: 0.15rem;
    }

    .nav-item {
        gap: 0.75rem;
        padding: 0.72rem 1.1rem;
        font-size: 0.88rem;
    }

    .top-bar {
        height: 58px;
        min-height: 58px;
        padding: 0 1.25rem;
    }

    .content-wrapper {
        padding: 1.25rem 1.35rem;
    }

    .section-header {
        align-items: center;
        margin-bottom: 1rem;
    }

    .section-header h1 {
        font-size: 1.3rem;
    }

    .section-header p {
        font-size: 0.84rem;
    }

    .panel {
        padding: 1.1rem;
        margin-bottom: 1rem;
        border-radius: 10px;
    }

    .panel-header {
        margin-bottom: 0.85rem;
    }

    .panel-header h3 {
        font-size: 1rem;
    }

    .schema-table th,
    .schema-table td {
        padding: 0.55rem 0.45rem;
        font-size: 0.74rem;
    }

    .schema-table th {
        font-size: 0.68rem;
    }

    .query-builder-panel,
    .query-ai-panel {
        min-height: 172px;
    }

    .query-builder-grid {
        grid-template-columns: minmax(180px, 1fr) 104px minmax(145px, 170px);
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    #query-builder-limit {
        max-width: none;
    }

    .query-builder-filter-row {
        grid-template-columns: minmax(130px, 1.05fr) minmax(100px, 0.7fr) minmax(125px, 1fr) 34px;
        gap: 0.45rem;
    }

    .query-builder-field {
        gap: 0.32rem;
    }

    .query-builder-field input,
    .query-builder-field select,
    .query-ai-question,
    .query-builder-filter-row input,
    .query-builder-filter-row select {
        min-height: 36px;
        padding: 0.46rem 0.55rem;
        font-size: 0.8rem;
    }

    .query-ai-question {
        min-height: 72px;
    }

    .query-editor {
        min-height: 150px;
        padding: 0.85rem;
    }

    .query-table-wrap {
        max-height: 390px;
    }

    .query-table th,
    .query-table td {
        padding: 0.55rem 0.65rem;
        font-size: 0.76rem;
    }

    .btn {
        gap: 0.35rem;
        padding: 0.46rem 0.75rem;
        font-size: 0.88rem;
    }

    .query-builder-remove {
        width: 34px;
        height: 34px;
        min-height: 34px;
    }
}

@media (max-height: 820px) and (min-width: 901px) {
    .content-wrapper {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .section-header {
        margin-bottom: 0.85rem;
    }

    .panel {
        padding: 1rem;
        margin-bottom: 0.85rem;
    }

    .query-builder-panel,
    .query-ai-panel {
        min-height: 160px;
    }

    .query-ai-question {
        min-height: 64px;
    }

    .query-editor {
        min-height: 130px;
    }

    .query-table-wrap {
        max-height: 300px;
    }
}

@media (max-width: 900px) {

    .top-bar {
        padding: 0 1rem;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .query-builder-grid,
    .query-builder-filter-row {
        grid-template-columns: 1fr;
    }

    .query-builder-remove {
        width: 100%;
    }
}

@media (max-width: 700px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
    }

    .nav-menu {
        flex-direction: row;
        overflow-x: auto;
        padding: 0.65rem;
    }

    .nav-item {
        white-space: nowrap;
        border-radius: 8px;
        padding: 0.7rem 0.85rem;
    }

    .nav-item.active {
        border-left: 0;
    }

}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* ==== Dashboard hero ==== */

/* Dashboard Centered Hero Card */
.dashboard-hero-container {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2.5rem 1rem;
    width: 100%;
}

.dashboard-hero-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.06), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
    max-width: 680px;
    width: 100%;
    padding: 3rem 2.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dashboard-hero-card:hover {
    box-shadow: 0 16px 36px -5px rgba(0, 0, 0, 0.09), 0 6px 16px -2px rgba(0, 0, 0, 0.04);
}

.dashboard-hero-icon-wrapper {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 12%, transparent) 0%, color-mix(in srgb, var(--brand) 20%, transparent) 100%);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    margin-bottom: 1.5rem;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 15%, transparent);
}

.dashboard-hero-title {
    margin: 0 0 0.75rem 0;
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: -0.02em;
}

.dashboard-hero-subtitle {
    margin: 0 0 1.75rem 0;
    font-size: 0.98rem;
    line-height: 1.6;
    color: var(--text-muted);
    max-width: 520px;
}

.dashboard-hero-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 2rem;
}

.hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: color-mix(in srgb, var(--brand) 6%, transparent);
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.4rem 0.85rem;
    border-radius: 9999px;
    border: 1px solid color-mix(in srgb, var(--brand) 10%, transparent);
}

.hero-tag i {
    font-size: 0.8em;
}

.dashboard-hero-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 0.85rem 2.25rem;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 10px;
    background: var(--primary);
    color: var(--on-brand);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 35%, transparent);
    transition: all 0.2s ease;
}

.dashboard-hero-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--brand) 45%, transparent);
    color: var(--on-brand);
}

.dashboard-hero-btn:active {
    transform: translateY(0);
}

.dashboard-hero-footer {
    margin-top: 2.25rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border);
    font-size: 0.84rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    max-width: 520px;
    width: 100%;
}

.dashboard-hero-footer i {
    color: var(--primary);
    font-size: 1rem;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .dashboard-hero-card {
        padding: 2rem 1.5rem;
    }

    .dashboard-hero-btn {
        width: 100%;
    }
}

/* ==== Country Overview ==== */

.co-icon {
    width: 1em;
    height: 1em;
    display: block;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

/* Filter bar */
.co-filter-bar {
    position: relative;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    margin-bottom: 0.55rem;
    border: 1px solid var(--border-color, var(--line));
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: visible !important;
}

.co-filter-grid {
    position: relative;
    z-index: 40;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.4rem;
    overflow: visible !important;
}

.co-filter {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    display: flex;
    flex-direction: column;
    gap: 0;
    height: auto;
    padding: 0;
    border: none;
    background: transparent;
    overflow: visible !important;
}

.co-filter.co-filter-date {
    flex: 1.15 1 0;
    min-width: 0;
    max-width: none;
}

.co-filter:focus-within,
.co-filter:hover,
.co-filter.is-open,
.co-filter:has(.is-open) {
    z-index: 1000 !important;
}

.co-filter .ms-select {
    position: relative;
    width: 100%;
    max-width: none;
    height: 26px;
    overflow: visible !important;
}

.ms-select.is-open,
.ms-select:focus-within {
    z-index: 10000 !important;
}

.co-filter .ms-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: none;
    height: 26px;
    line-height: 24px;
    border-radius: 5px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    font-size: 0.74rem;
    color: var(--ink);
    padding: 0 0.45rem;
    box-sizing: border-box;
}

.co-filter .co-filter-label,
.co-advanced-label {
    display: none !important;
}

.co-filter .co-advanced-date {
    height: 26px;
    border-radius: 5px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    padding: 0 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
    box-sizing: border-box;
}

.co-filter .co-advanced-date-input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.74rem;
    color: var(--ink) !important;
    -webkit-text-fill-color: var(--ink) !important;
    opacity: 1 !important;
    font-weight: 500;
    width: 100%;
}

.co-filter .co-advanced-date-input::placeholder,
.co-filter .co-advanced-date-input::-webkit-input-placeholder,
.co-filter .co-advanced-date-input::-moz-placeholder,
.co-filter .co-advanced-date-input:-ms-input-placeholder {
    color: var(--ink) !important;
    -webkit-text-fill-color: var(--ink) !important;
    opacity: 1 !important;
    font-weight: 500;
}

.co-filter-actions {
    position: relative;
    z-index: 50;
    margin-left: 0.25rem;
    flex-shrink: 0;
}

.co-action-btn.is-apply {
    height: 26px;
    padding: 0 0.75rem;
    font-weight: 600;
    border-radius: 5px;
    border: none;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.74rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.co-action-btn.is-apply.is-visible {
    display: inline-flex !important;
}

.co-action-btn {
    justify-content: center;
}

.co-action-btn[id*="-clear-filters"] {
    display: none;
}

.co-action-btn[id*="-clear-filters"].is-visible {
    display: inline-flex !important;
}

.co-filters-btn {
    align-items: center;
    justify-content: center;
}

.co-filter-label {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
}

.co-advanced-label {
    display: none;
}

/* An ellipsised label breaks out of its card on hover so the full name is readable.
   It stays a single line at its natural width, so the row height never shifts. */
.co-filter:hover .co-filter-label,
.co-advanced-field:hover .co-advanced-label {
    position: relative;
    z-index: 20;
    width: max-content;
    max-width: 340px;
    overflow: visible;
    background: var(--bg-surface);
    border-radius: 4px;
    padding-right: 0.3rem;
    box-shadow: 6px 0 6px -4px rgba(17, 24, 39, 0.14);
}

.co-filter-control,
.co-advanced-select,
.co-advanced-date-input {
    width: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-dark);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    outline: none;
}

select.co-filter-control,
.co-advanced-select {
    cursor: pointer;
}

/* Type-to-filter dropdown: an input plus a menu layered over a hidden native select. */

/* Only the options scroll; the pager stays pinned to the bottom of the menu. */

/* Apply / Clear / advance-filters icon, inline at the end of the filter row. */
.co-filter-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.co-action-btn {
    height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.co-action-btn .co-icon {
    width: 12px;
    height: 12px;
    stroke-width: 2.4;
}

.co-action-btn:hover {
    background: var(--bg-main);
    border-color: var(--line-strong);
}

.co-action-btn.is-apply {
    border-color: var(--brand);
    background: var(--brand);
    color: var(--on-brand);
}

.co-action-btn.is-apply:hover {
    background: var(--brand);
    border-color: var(--brand);
}

.co-filters-btn {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--brand);
    border-radius: 5px;
    background: var(--brand);
    color: var(--on-brand);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.co-filters-btn:hover {
    background: var(--brand);
    border-color: var(--brand);
}

.co-filters-btn:active {
    background: var(--brand);
}

.co-filters-btn.is-open {
    background: var(--brand);
    border-color: var(--brand);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.co-filters-btn .co-icon,
.co-filters-btn .co-chevron-icon {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: var(--on-brand);
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

.co-filters-btn.is-open .co-icon,
.co-filters-btn.is-open .co-chevron-icon,
.co-filters-btn[aria-expanded="true"] .co-icon,
.co-filters-btn[aria-expanded="true"] .co-chevron-icon {
    transform: rotate(180deg);
}

/* Advance filters panel */
.co-advanced {
    position: relative;
    padding: 1.25rem 1.75rem 1.5rem;
    margin: 0.75rem 0 1.25rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.06), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    animation: fadeIn 0.18s ease;
}

.co-advanced[hidden] {
    display: none;
}

.co-advanced-groups {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.75rem;
}

.co-advanced-group {
    min-width: 0;
}

.co-advanced-group+.co-advanced-group {
    padding-left: 1.75rem;
    border-left: 1px solid var(--line);
}

.co-advanced-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 0.85rem;
    color: var(--ink);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.co-advanced-title .co-icon {
    width: 16px;
    height: 16px;
    color: var(--brand-ink);
    stroke-width: 2.2;
    flex-shrink: 0;
}

.co-advanced-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem 0.75rem;
    align-items: center;
}

.co-advanced-field {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.co-advanced-field .ms-select {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 26px !important;
    position: relative !important;
}

.co-advanced-field .ms-trigger {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 26px !important;
    line-height: 24px !important;
    padding: 0 0.45rem !important;
    border: 1px solid var(--line-strong) !important;
    border-radius: 5px !important;
    background: var(--surface) !important;
    color: var(--ink) !important;
    font-size: 0.74rem !important;
    font-weight: 500 !important;
    box-sizing: border-box !important;
    transition: all 0.15s ease !important;
}

.co-advanced-field .ms-trigger:hover {
    border-color: var(--line-strong) !important;
    background: var(--surface-2) !important;
}

.co-advanced-field .ms-trigger.is-active {
    border-color: var(--primary) !important;
    background: var(--brand-soft) !important;
    color: var(--primary) !important;
    font-weight: 600 !important;
}

.co-advanced-field .ms-trigger-text {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    text-align: left !important;
}

.co-advanced-date {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
    min-width: 0;
    height: 26px;
    padding: 0 0.4rem;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    background: var(--surface);
    box-sizing: border-box;
}

.co-advanced-date .co-icon {
    width: 15px;
    height: 15px;
    color: var(--brand-ink);
    flex: 0 0 auto;
}

.co-advanced-date .co-icon.date-picker-icon {
    stroke: none;
}

.co-advanced-date-input {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 0.76rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.co-advanced-date-input::placeholder {
    color: var(--faint);
    font-weight: 400;
}

@media (max-width: 1180px) {
    .co-advanced-groups {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .co-advanced-group:nth-child(3) {
        padding-left: 0;
        border-left: 0;
    }
}

@media (max-width: 860px) {
    .co-advanced {
        padding: 1.25rem;
    }

    .co-advanced-groups {
        grid-template-columns: minmax(0, 1fr);
    }

    .co-advanced-group+.co-advanced-group {
        padding-left: 0;
        padding-top: 1.25rem;
        border-left: 0;
        border-top: 1px solid var(--line);
    }
}

@media (max-width: 560px) {
    .co-advanced-fields {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Date range picker */
.drp {
    position: fixed;
    z-index: 120;
    width: max-content;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-surface);
    box-shadow: 0 18px 40px rgba(17, 24, 39, 0.18);
    font-size: 0.8rem;
    color: var(--text-dark);
}

.drp[hidden] {
    display: none;
}

.drp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.drp-range {
    color: var(--co-heading, var(--brand-ink));
    font-size: 0.78rem;
    font-weight: 700;
}

.drp-nav {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-dark);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.drp-nav:hover {
    background: var(--surface-2);
}

.drp-months {
    display: flex;
    gap: 1rem;
}

.drp-month-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-bottom: 0.45rem;
    color: var(--co-heading, var(--brand-ink));
    font-size: 0.78rem;
    font-weight: 700;
}

.drp-select {
    min-width: 0;
    padding: 0.2rem 0.3rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--co-heading, var(--brand-ink));
    font: inherit;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.drp-select:focus {
    border-color: var(--brand-line);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent);
}

.drp-dow,
.drp-days {
    display: grid;
    grid-template-columns: repeat(7, 30px);
}

.drp-dow span {
    height: 22px;
    display: grid;
    place-items: center;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
}

.drp-day {
    height: 28px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-dark);
    font: inherit;
    font-size: 0.76rem;
    line-height: 28px;
    cursor: pointer;
}

.drp-day.is-blank {
    cursor: default;
}

.drp-day:hover:not(.is-blank) {
    background: var(--brand-soft);
}

.drp-day.in-range {
    background: var(--brand-soft);
}

.drp-day.is-today {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.drp-day.is-start,
.drp-day.is-end {
    background: var(--brand);
    color: var(--on-brand);
    font-weight: 700;
}

.drp-day.is-start {
    border-radius: 6px 0 0 6px;
}

.drp-day.is-end {
    border-radius: 0 6px 6px 0;
}

.drp-day.is-single {
    border-radius: 6px;
}

.drp-foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.7rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
}

.drp-btn {
    padding: 0.35rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.drp-btn:hover {
    background: var(--surface-2);
}

.drp-btn.is-primary {
    border-color: var(--brand);
    background: var(--brand);
    color: var(--on-brand);
}

.drp-btn.is-primary:hover {
    background: var(--brand);
}

.co-advanced-date {
    cursor: pointer;
}

@media (max-width: 620px) {
    .drp-months {
        flex-direction: column;
        gap: 0.6rem;
    }
}

/* Top / All records switch */
.co-record-toggle {
    display: flex;
    justify-content: flex-end;
    margin: 0.5rem 0;
}

.co-record-btn {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.co-record-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.co-record-btn:last-child {
    border-radius: 0 6px 6px 0;
}

.co-record-btn+.co-record-btn {
    border-left-width: 0;
}

.co-record-btn:hover:not(.is-active) {
    background: var(--surface-2);
}

.co-record-btn.is-active {
    border-color: var(--warning);
    background: var(--warning);
    color: var(--on-brand);
    font-weight: 600;
}

.co-record-btn.is-active+.co-record-btn {
    border-left-width: 1px;
}

/* Chart panels */
.co-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

/* Chart cards carry a banded header so the title reads as the card's header rather than floating above the chart. */
.co-chart-panel {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    padding: 0;
    overflow: hidden;
}

/* Panel headers are shared by the Country Overview cards and the Trend Analysis panels. */
.co-chart-panel .panel-header,
.ta-panel-head {
    margin-bottom: 0;
    padding: 0.22rem 1.25rem;
    border-bottom: 1px solid var(--panel-head-bg);
    background: var(--panel-head-bg);
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
}

.co-chart-mount {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1rem 0.75rem;
}

.co-chart-panel .panel-header h3,
.ta-panel-head,
.ta-panel-head h3,
.ta-panel-head h4 {
    color: var(--on-brand);
    font-size: 0.81rem;
    font-weight: 700;
    text-align: left !important;
    width: 100% !important;
}

/* Chart */
.co-legend {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    width: 100%;
}

.co-legend-title {
    color: var(--co-heading);
    font-weight: 700;
}

.co-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.co-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.co-dot.is-export {
    background: var(--co-export);
}

.co-dot.is-import {
    background: var(--co-import);
}

.co-chart {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.co-chart-main {
    flex: 1 1 auto;
    display: flex;
    align-items: stretch;
    gap: 0.4rem;
    min-height: 0;
}

.co-axis-y-title {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    color: var(--faint) !important;
    font-size: 0.72rem;
    font-weight: 400 !important;
}

.co-plot {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding-right: 1.5rem;
}

.co-rows-wrap {
    position: relative;
    max-height: 420px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.25rem 0.5rem 0.25rem 0;
}

.co-rows-wrap::-webkit-scrollbar {
    width: 6px;
}

.co-rows-wrap::-webkit-scrollbar-track {
    background: var(--surface-2);
    border-radius: 3px;
}

.co-rows-wrap::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 3px;
}

.co-rows-wrap::-webkit-scrollbar-thumb:hover {
    background: var(--faint);
}

.co-grid {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--co-label-w);
    pointer-events: none;
}

.co-grid span {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dashed var(--line);
}

.co-rows {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: var(--co-row-gap);
}

.co-row {
    display: grid;
    grid-template-columns: var(--co-label-w) minmax(0, 1fr);
    align-items: center;
}

.co-row-label {
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
}

.co-bar {
    display: flex;
    height: var(--co-bar-h);
    min-width: 0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.co-bar:hover {
    z-index: 100 !important;
    overflow: visible !important;
    min-width: max-content !important;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25) !important;
}

.co-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    color: var(--on-brand);
    font-size: var(--co-value-size, 0.48rem);
    font-weight: 700;
    white-space: nowrap;
    text-overflow: clip !important;
    padding: 0 3px;
    box-sizing: border-box;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.co-seg .co-seg-val {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip !important;
}

.co-seg.is-small .co-seg-val {
    display: none;
}

.co-bar:hover .co-seg {
    min-width: max-content !important;
    overflow: visible !important;
    padding: 0 6px !important;
    font-size: 0.68rem !important;
}

.co-bar:hover .co-seg.is-small .co-seg-val,
.co-seg:hover .co-seg-val {
    display: inline-block !important;
    font-weight: 750 !important;
    font-size: 0.68rem !important;
}

.co-seg.is-export {
    background: var(--co-export);
}

.co-seg.is-import {
    background: var(--co-import);
}

.co-ticks {
    display: grid;
    grid-template-columns: var(--co-label-w) minmax(0, 1fr);
    margin-top: 0.35rem;
}

.co-ticks-track {
    position: relative;
    grid-column: 2;
    height: 16px;
}

.co-ticks-track span {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    color: var(--ink) !important;
    white-space: nowrap;
}

.co-axis-x-title {
    padding-left: calc(var(--co-label-w) + 1rem);
    text-align: center;
    color: var(--faint) !important;
    font-size: 0.72rem;
    font-weight: 400 !important;
}

/* Keep the filters on one row for as long as they fit, then step down. */
@media (max-width: 1240px) {
    .co-filter-bar {
        gap: 0.4rem;
        padding: 0.45rem 0.6rem;
    }

    .co-action-btn {
        padding: 0 0.55rem;
        font-size: 0.69rem;
    }
}

/* Country Overview card alignment & tick styling */
.co-ticks-track span {
    font-size: 0.65rem !important;
}

#country-overview .co-chart-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 1.25rem !important;
    align-items: stretch !important;
}

#country-overview .co-chart-panel {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
    border-radius: 12px !important;
    border: 1px solid var(--line) !important;
    background: var(--surface) !important;
    overflow: hidden !important;
}

#country-overview .co-chart-mount {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0.65rem 0.85rem 0.6rem 0.85rem !important;
    min-height: 0 !important;
}

#country-overview .co-chart {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
}

#country-overview .co-legend {
    display: flex !important;
    justify-content: flex-start !important;
    width: 100% !important;
    margin-bottom: 0.5rem !important;
    flex: 0 0 auto !important;
}

#country-overview .co-chart-main {
    flex: 1 1 auto !important;
    display: flex !important;
    align-items: stretch !important;
    min-height: 0 !important;
}

#country-overview .co-plot {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-height: 0 !important;
}

#country-overview .co-rows-wrap {
    flex: 1 1 auto !important;
    min-height: 0 !important;
}

#country-overview.scope-top .co-rows-wrap {
    max-height: none !important;
    overflow-y: hidden !important;
    overflow: hidden !important;
}

#country-overview.scope-all .co-rows-wrap {
    max-height: 380px !important;
    overflow-y: auto !important;
}

#country-overview .co-ticks {
    margin-top: 0.35rem !important;
    flex: 0 0 auto !important;
}

#country-overview .co-axis-x-title {
    margin-top: 0.35rem !important;
    line-height: 1.2 !important;
    padding-bottom: 0.1rem !important;
    flex: 0 0 auto !important;
}

@media (max-width: 1100px) {
    .co-chart-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 1000px) {
    .co-filter-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .co-filter-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.45rem;
        width: 100%;
    }

    .co-filter,
    .co-filter.co-filter-date {
        min-width: 0;
        max-width: none;
    }

    .co-filter-actions {
        margin-left: auto;
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 720px) {
    .co-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .co-filter-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .co-action-btn {
        flex: 1 1 auto;
    }
}

/* ==== Trend Analysis ==== */

.ta-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    margin: 0.5rem 0;
}

.ta-header .co-record-toggle {
    margin: 0;
    flex: 0 0 auto;
}

/* KPI cards */
.ta-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.1rem;
}

.ta-kpi-card {
    display: flex;
    flex-direction: column;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.ta-kpi-card:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.07);
}

.ta-kpi-head {
    display: flex;
    align-items: center;
    justify-content: center !important;
    text-align: center !important;
    padding: 0.45rem 0.85rem;
    background: var(--panel-head-bg, var(--toast-bg)) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    width: 100%;
}

.ta-kpi-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 0.85rem;
    min-width: 0;
    text-align: center;
}

.ta-kpi-label {
    padding: 0 !important;
    background: transparent !important;
    color: var(--on-brand) !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    line-height: 1.2;
    text-align: center !important;
    display: block !important;
    width: 100% !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ta-kpi-value {
    color: var(--ink) !important;
    font-size: 1.05rem !important;
    font-weight: 400 !important;
    line-height: 1.15 !important;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

/* Panels */
.ta-chart-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr);
    gap: 1.1rem;
    align-items: start;
}

.ta-side {
    min-width: 0;
    display: grid;
    align-content: start;
    gap: 1.1rem;
}

.ta-panel {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.ta-panel:hover {
    transform: translateY(-2px) scale(1.006);
    box-shadow: 0 10px 24px -4px rgba(15, 23, 42, 0.08), 0 4px 8px -2px rgba(15, 23, 42, 0.04);
}

.ta-panel-head {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 0.4rem 0.75rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
    background: var(--panel-head-bg, var(--toast-bg)) !important;
    color: var(--on-brand) !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    margin-bottom: 0.65rem !important;
}

.ta-panel-body {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.85rem 1rem 1rem 1rem !important;
}

/* Vertical bar chart */
.ta-bars {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    column-gap: 0.5rem;
}

/* Horizontal bar chart layout for "All Records" scope */
.ta-hbar-chart {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 0.5rem;
}

.ta-hbar-ytitle {
    grid-column: 1;
    align-self: center;
    justify-self: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    color: var(--faint) !important;
    font-size: 0.57rem !important;
    font-weight: 400 !important;
}

.ta-hbar-body {
    grid-column: 2;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
}

.ta-hbar-rows-wrap {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden !important;
    padding-right: 0.4rem;
}

.ta-hbar-rows-wrap::-webkit-scrollbar {
    width: 5px;
    height: 0px;
}

.ta-hbar-rows-wrap::-webkit-scrollbar-track {
    background: var(--surface-2);
    border-radius: 3px;
}

.ta-hbar-rows-wrap::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 3px;
}

.ta-hbar-rows-wrap::-webkit-scrollbar-thumb:hover {
    background: var(--faint);
}

.ta-hbar-grid {
    position: absolute;
    top: 0;
    right: 0.8rem;
    bottom: 0;
    left: 110px;
    pointer-events: none;
}

.ta-hbar-grid span {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dashed var(--line);
}

.ta-hbar-grid span:first-child {
    border-left: 1.5px solid var(--line-strong);
}

.ta-hbar-rows {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

.ta-hbar-row {
    display: grid;
    grid-template-columns: minmax(80px, 110px) minmax(0, 1fr);
    align-items: center;
    gap: 0.4rem;
    padding-right: 0.5rem;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.ta-hbar-row:hover {
    z-index: 10;
    overflow: visible;
}

.ta-hbar-row:hover .ta-hbar-value {
    color: var(--ink) !important;
    font-weight: 400 !important;
    font-size: 0.75rem !important;
    z-index: 100 !important;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.9);
}

.ta-hbar-row:hover .ta-hbar-label {
    color: var(--ink) !important;
    font-weight: 400 !important;
}

.ta-hbar-label {
    padding-right: 0.35rem;
    color: var(--muted) !important;
    font-size: 0.57rem !important;
    font-weight: 400 !important;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ta-hbar-track {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    height: 17px;
    min-width: 135px;
    padding-right: 1.15rem;
}

.ta-hbar-fill {
    height: 100%;
    border-radius: 3px;
    flex: 0 0 auto;
    transition: width 0.3s ease;
}

.ta-hbar-value {
    color: var(--ink) !important;
    font-size: 0.57rem !important;
    font-weight: 400 !important;
    white-space: nowrap;
    flex: 0 0 auto;
    padding: 0 2px;
    margin-left: 0.25rem;
}

.ta-hbar-ticks {
    flex: 0 0 auto;
    position: relative;
    margin-left: 110px;
    margin-right: 0.5rem;
    height: 16px;
    margin-top: 0.2rem;
}

.ta-hbar-ticks span {
    position: absolute;
    transform: translateX(-50%);
    color: var(--ink) !important;
    font-size: 0.57rem !important;
    font-weight: 400 !important;
    white-space: nowrap;
}

.ta-hbar-xtitle {
    flex: 0 0 auto;
    margin-left: 0 !important;
    margin-top: 0.15rem !important;
    text-align: center !important;
    width: 100% !important;
    color: var(--faint) !important;
    font-size: 0.57rem !important;
    font-weight: 400 !important;
    min-height: 16px;
    line-height: 16px;
}

.ta-bars-ytitle {
    grid-row: 1;
    grid-column: 1;
    align-self: center;
    justify-self: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    color: var(--faint) !important;
    font-size: 0.57rem !important;
    font-weight: 400 !important;
}

.ta-bars-plot {
    grid-row: 1;
    grid-column: 2;
    position: relative;
    height: 340px;
    display: flex;
    align-items: flex-end;
    gap: 6%;
    padding-left: 2.6rem;
}

.ta-bars-grid {
    position: absolute;
    inset: 0 0 0 2.6rem;
    pointer-events: none;
}

.ta-bars-grid span {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    border-top: 1px dashed var(--line);
}

.ta-bars-grid span::after {
    content: attr(data-label);
    position: absolute;
    right: 100%;
    top: -0.55em;
    padding-right: 0.5rem;
    color: var(--ink) !important;
    font-size: 0.57rem !important;
    white-space: nowrap;
}

.ta-bar-col {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
}

.co-row-label {
    padding-right: 0.7rem;
    color: var(--ink) !important;
    font-size: 0.7rem;
    font-weight: 400 !important;
    white-space: nowrap;
}

.ta-bar-value {
    margin-bottom: 0.25rem;
    color: var(--ink) !important;
    font-size: 0.72rem;
    font-weight: 400 !important;
    white-space: nowrap;
}

.ta-bar-col {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom center;
    cursor: pointer;
}

.ta-bar-col:hover {
    transform: scaleY(1.04);
}

.ta-bar {
    width: 100%;
    border-radius: 2px 2px 0 0;
    transition: filter 0.2s ease;
}

.ta-bar:hover {
    filter: brightness(0.92) drop-shadow(0 4px 10px color-mix(in srgb, var(--brand) 30%, transparent));
}

.ta-bars-xlabels {
    grid-row: 2;
    grid-column: 2;
    display: flex;
    gap: 4%;
    margin-top: 0.35rem;
    padding-left: 2.2rem;
}

.ta-bar-label {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    color: var(--ink) !important;
    font-size: 0.66rem;
    font-weight: 400 !important;
    line-height: 1.18;
}

.ta-bars-xtitle {
    grid-row: 3;
    grid-column: 1 / -1;
    margin-top: 0.35rem;
    padding-left: 0;
    text-align: center;
    color: var(--faint) !important;
    font-size: 0.57rem;
    font-weight: 400 !important;
    width: 100%;
}

.ta-hbar-row {
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease;
    transform-origin: left center;
}

.ta-hbar-row:hover {
    transform: scale(1.02) translateX(4px);
}

/* Donut Chart Styling & Hover Interactivity */
.ta-donut {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.ta-donut-slice {
    cursor: pointer;
    transition: opacity 0.2s ease, filter 0.2s ease, stroke-width 0.2s ease;
}

.ta-donut-slice:hover {
    opacity: 1 !important;
    stroke-width: 92px !important;
    filter: drop-shadow(0 6px 16px rgba(15, 23, 42, 0.28));
}

.ta-donut:has(.ta-donut-slice:hover) .ta-donut-slice:not(:hover) {
    opacity: 0.45;
}

.ta-donut-label-group {
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.ta-donut-leader {
    fill: none;
    stroke: var(--faint);
    stroke-width: 1.2px;
    transition: stroke 0.15s ease, stroke-width 0.15s ease;
}

.ta-donut-label-group:hover .ta-donut-leader {
    stroke: var(--muted);
    stroke-width: 1.8px;
}

.ta-donut-label {
    font-family: inherit;
}

.ta-donut-label tspan {
    fill: var(--ink) !important;
    color: var(--ink) !important;
}

.ta-donut-center-title {
    font-size: 19.2px;
    font-weight: 400 !important;
    fill: var(--ink) !important;
    color: var(--ink) !important;
    letter-spacing: 0.06em;
}

.ta-donut-center-val {
    font-size: 26px;
    font-weight: 400 !important;
    fill: var(--ink) !important;
    color: var(--ink) !important;
    font-variant-numeric: tabular-nums;
}

.ta-donut-center-sub {
    font-size: 19.2px;
    font-weight: 400 !important;
    fill: var(--brand-ink) !important;
    color: var(--brand-ink) !important;
}

@media (max-width: 1180px) {
    .ta-chart-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .ta-kpi-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .ta-kpi-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .ta-bars-plot {
        height: 260px;
    }
}

/* Full screen 100% height stretch for Trend Analysis (Top Records scope: strictly zero scrollbars) */
/* Full screen 100% height stretch for Trend Analysis (STRICTLY zero page scrollbars for both Top & All Records) */
.content-wrapper:has(#trend-analysis.active) {
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    height: calc(100vh - 56px) !important;
    padding: 0.6rem 1.25rem 0.8rem 1.25rem !important;
}

#trend-analysis.active {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important;
}

#trend-analysis .co-filter-bar {
    flex: 0 0 auto !important;
    margin-bottom: 0.35rem !important;
    padding: 0.4rem 0.6rem !important;
}

#trend-analysis .ta-header {
    flex: 0 0 auto !important;
    margin: 0.1rem 0 0.3rem 0 !important;
}

#trend-analysis .ta-kpi-row {
    flex: 0 0 auto !important;
    gap: 0.6rem !important;
    margin-bottom: 0.5rem !important;
}

#trend-analysis .ta-kpi-card {
    border-radius: 8px !important;
}

#trend-analysis .ta-kpi-head {
    padding: 0.25rem 0.5rem !important;
    background: var(--panel-head-bg, var(--toast-bg)) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
}

#trend-analysis .ta-kpi-label {
    padding: 0 !important;
    color: var(--on-brand) !important;
    font-size: 0.76rem !important;
    font-weight: 700 !important;
}

#trend-analysis .ta-kpi-main {
    padding: 0.35rem 0.5rem !important;
    gap: 0.5rem !important;
}

#trend-analysis .ta-kpi-value {
    font-size: 0.88rem !important;
    font-weight: 400 !important;
}

#trend-analysis.active .ta-chart-grid {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1.03fr) minmax(0, 1fr) !important;
    gap: 0.6rem !important;
    align-items: stretch !important;
}

#trend-analysis.active .ta-panel {
    height: 100% !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    background: var(--surface) !important;
    border: 1px solid var(--line) !important;
}

#trend-analysis .ta-panel-head {
    flex: 0 0 auto !important;
    padding: 0.28rem 0.65rem !important;
    font-size: 0.74rem !important;
}

#trend-analysis.active .ta-panel-body {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0.85rem 0.75rem 0.65rem 0.75rem !important;
    overflow: hidden !important;
}

#trend-analysis.active .ta-bars {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
    grid-template-rows: 1fr auto auto !important;
    height: 100% !important;
}

#trend-analysis.active .ta-bars-plot {
    flex: 1 1 0 !important;
    height: 100% !important;
    min-height: 100px !important;
}

#trend-analysis .ta-bars-ytitle {
    font-size: 0.76rem !important;
    font-weight: 400 !important;
    color: var(--faint) !important;
}

#trend-analysis .ta-bars-grid span {
    border-top: 1px dotted var(--line-strong) !important;
}

#trend-analysis .ta-bars-grid span::after {
    font-size: 0.72rem !important;
    font-weight: 400 !important;
    color: var(--ink) !important;
}

#trend-analysis .ta-bar-value {
    font-size: 0.72rem !important;
    font-weight: 400 !important;
    color: var(--ink) !important;
    margin-bottom: 0.35rem !important;
}

#trend-analysis .ta-bars-xlabels {
    margin-top: 0.4rem !important;
}

#trend-analysis .ta-bar-label,
#trend-analysis .ta-hbar-label {
    font-size: 0.76rem !important;
    font-weight: 400 !important;
    color: var(--ink) !important;
    line-height: 1.25 !important;
}

#trend-analysis .ta-bars-xtitle {
    margin-top: 0.45rem !important;
    font-size: 0.8rem !important;
    font-weight: 400 !important;
    color: var(--faint) !important;
}

#trend-analysis .ta-donut-label tspan:nth-child(1) {
    font-size: 30px !important;
    font-weight: 700 !important;
}

#trend-analysis .ta-donut-label tspan:nth-child(2) {
    font-size: 25.3px !important;
    font-weight: 500 !important;
    fill: var(--ink) !important;
    color: var(--ink) !important;
}

#trend-analysis .ta-donut-center-title {
    font-size: 26.9px !important;
    fill: var(--ink) !important;
    color: var(--ink) !important;
}

#trend-analysis .ta-donut-center-val {
    font-size: 28.8px !important;
    fill: var(--ink) !important;
    color: var(--ink) !important;
}

#trend-analysis .ta-donut-center-sub {
    font-size: 26.9px !important;
    fill: var(--brand-ink) !important;
    color: var(--brand-ink) !important;
}

#trend-analysis.active .ta-side {
    height: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.6rem !important;
}

#trend-analysis.active .ta-side .ta-panel {
    flex: 1 1 0 !important;
    min-height: 0 !important;
}

#trend-analysis .ta-side .ta-panel-body {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    width: 100% !important;
    height: 100% !important;
}

#trend-analysis .ta-side .ta-panel-body:has(.ta-donut) {
    align-items: center !important;
    justify-content: center !important;
    padding: 0.2rem 0.2rem 0.6rem 0.2rem !important;
    overflow: visible !important;
}

#trend-analysis.active .ta-donut {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
}

/* Horizontal bar chart inside cards when All Records is selected */
#trend-analysis.active .ta-hbar-chart {
    height: 100% !important;
    width: 100% !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
    column-gap: 0.35rem !important;
    flex: 1 1 0 !important;
}

#trend-analysis.active .ta-hbar-body {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

#trend-analysis.active .ta-hbar-rows-wrap {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow-y: auto !important;
    padding-right: 0.5rem !important;
}

/* ==== Company Analysis layout ==== */
/* No page scrollbar: the 4 cards share a 2x2 grid that fits the screen. */
.content-wrapper:has(#company-analysis.active) {
    overflow: hidden !important;
    height: calc(100vh - 56px) !important;
}

#company-analysis.active {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important;
    padding-bottom: 0.5rem !important;
}

#company-analysis.active .co-record-toggle {
    margin: 0.2rem 0 0.4rem 0 !important;
    flex: 0 0 auto !important;
}

#company-analysis.active .ca-chart-grid {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
    align-items: stretch !important;
}

#company-analysis.active .ta-panel {
    height: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: 8px !important;
    overflow: hidden !important;
}

#company-analysis.active .ta-panel-head {
    flex: 0 0 auto !important;
    padding: 0.35rem 0.75rem !important;
    font-size: 0.76rem !important;
}

#company-analysis.active .ta-panel-body {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0.4rem 0.65rem !important;
    overflow: hidden !important;
}

#company-analysis.active .ta-bars {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
    grid-template-rows: 1fr auto auto !important;
    height: 100% !important;
}

#company-analysis.active .ta-bars-plot {
    flex: 1 1 0 !important;
    height: 100% !important;
    min-height: 80px !important;
}

#company-analysis.active .ta-donut {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
}

#company-analysis.active .ta-hbar-chart {
    height: 100% !important;
    width: 100% !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
    column-gap: 0.35rem !important;
    flex: 1 1 0 !important;
}

#company-analysis.active .ta-hbar-body {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    overflow: hidden !important;
}

#company-analysis.active .ta-hbar-rows-wrap {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow-y: auto !important;
    padding-right: 0.5rem !important;
}

/* ==== Port & Trade Insights layout ==== */
/* No page scrollbar: 3-column card arrangement. */
.content-wrapper:has(#port-trade-insights.active) {
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    height: calc(100vh - 56px) !important;
    padding: 0.6rem 1.25rem 0.8rem 1.25rem !important;
}

#port-trade-insights.active {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important;
    padding-bottom: 0.4rem !important;
}

#port-trade-insights.active .co-record-toggle {
    margin: 0.2rem 0 0.4rem 0 !important;
    flex: 0 0 auto !important;
}

#port-trade-insights.active .pt-chart-grid {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 1.1rem !important;
    align-items: stretch !important;
}

#port-trade-insights.active .pt-col {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.1rem !important;
    height: 100% !important;
    min-height: 0 !important;
}

#port-trade-insights.active .pt-col-left .ta-panel,
#port-trade-insights.active .pt-col-right .ta-panel {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: calc(50% - 0.55rem) !important;
}

#port-trade-insights.active .pt-col-middle .ta-panel {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: 100% !important;
}

#port-trade-insights.active .ta-panel {
    display: flex !important;
    flex-direction: column !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    background: var(--surface) !important;
    border: 1px solid var(--line) !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04) !important;
}

#port-trade-insights.active .ta-panel-head {
    flex: 0 0 auto !important;
    padding: 0.35rem 0.8rem !important;
    font-size: 0.78rem !important;
    background: var(--panel-head-bg, var(--brand-hover)) !important;
    color: var(--on-brand) !important;
    font-weight: 700 !important;
}

#port-trade-insights.active .ta-panel-body {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0.45rem 0.75rem 0.6rem 0.75rem !important;
    overflow: hidden !important;
}

#port-trade-insights.active .ta-bar-value {
    font-size: 0.56rem !important;
    font-weight: 400 !important;
    margin-bottom: 0.2rem !important;
}

#port-trade-insights.active .ta-bars-xlabels {
    margin-top: 0.3rem !important;
    gap: 4% !important;
    padding-left: 2rem !important;
}

#port-trade-insights.active .ta-bar-label {
    font-size: 0.54rem !important;
    font-weight: 400 !important;
    color: var(--ink) !important;
    line-height: 1.15 !important;
}

#port-trade-insights.active .ta-bars-xtitle {
    margin-top: 0.3rem !important;
    font-size: 0.57rem !important;
    padding-left: 0 !important;
    grid-column: 1 / -1 !important;
    text-align: center !important;
    width: 100% !important;
}

#port-trade-insights.active .ta-bars {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
    grid-template-rows: 1fr auto auto !important;
    height: 100% !important;
}

#port-trade-insights.active .ta-bars-plot {
    flex: 1 1 0 !important;
    height: 100% !important;
    min-height: 60px !important;
}

/* Horizontal bar chart inside cards when All Records or Tradelanes is rendered */
#port-trade-insights.active .ta-hbar-chart {
    height: 100% !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
    column-gap: 0.45rem !important;
    flex: 1 1 0 !important;
}

#port-trade-insights.active .ta-hbar-body {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

#port-trade-insights.active .ta-hbar-rows-wrap {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow-y: auto !important;
    padding-right: 0.45rem !important;
}

/* Vertical distribution & bar sizing for horizontal bar charts */
#port-trade-insights.active:not(.scope-all) .ta-hbar-rows,
#trend-analysis.active:not(.scope-all) .ta-hbar-rows,
.scope-top .ta-hbar-rows {
    height: 100% !important;
    min-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    padding-top: clamp(0.7rem, 2vh, 1.3rem) !important;
    gap: clamp(0.75rem, 2.2vh, 1.45rem) !important;
}

#port-trade-insights.active:not(.scope-all) .ta-hbar-track,
#trend-analysis.active:not(.scope-all) .ta-hbar-track,
.scope-top .ta-hbar-track {
    height: clamp(30px, 4.8vh, 42px) !important;
}

#port-trade-insights.active:not(.scope-all) .ta-hbar-fill,
#trend-analysis.active:not(.scope-all) .ta-hbar-fill,
.scope-top .ta-hbar-fill {
    border-radius: 6px !important;
}

#port-trade-insights.active .ta-hbar-label,
#trend-analysis.active .ta-hbar-label,
.ta-hbar-label {
    font-size: 0.57rem !important;
    font-weight: 400 !important;
    color: var(--ink) !important;
    padding-right: 0.35rem !important;
}

#port-trade-insights.active .ta-hbar-value,
#trend-analysis.active .ta-hbar-value,
.ta-hbar-value {
    font-size: 0.57rem !important;
    font-weight: 400 !important;
    color: var(--ink) !important;
    margin-left: 0.25rem !important;
}

#port-trade-insights.active .ta-hbar-ticks span,
#trend-analysis.active .ta-hbar-ticks span,
.ta-hbar-ticks span,
#port-trade-insights.active .ta-bars-grid span::after,
#trend-analysis.active .ta-bars-grid span::after,
.ta-bars-grid span::after {
    font-size: 0.57rem !important;
    font-weight: 400 !important;
    color: var(--ink) !important;
}

#port-trade-insights.active .ta-hbar-xtitle,
#trend-analysis.active .ta-hbar-xtitle,
.ta-hbar-xtitle {
    font-size: 0.57rem !important;
    font-weight: 400 !important;
    color: var(--faint) !important;
    margin-left: 0 !important;
    text-align: center !important;
    width: 100% !important;
}

#port-trade-insights.active .ta-bars-ytitle,
#trend-analysis.active .ta-bars-ytitle,
.ta-bars-ytitle,
#port-trade-insights.active .ta-hbar-ytitle,
#trend-analysis.active .ta-hbar-ytitle,
.ta-hbar-ytitle {
    font-size: 0.57rem !important;
    font-weight: 400 !important;
    color: var(--faint) !important;
}

#port-trade-insights.active.scope-all .ta-hbar-rows,
#trend-analysis.active.scope-all .ta-hbar-rows {
    height: auto !important;
    min-height: 0 !important;
    justify-content: flex-start !important;
    gap: 0.3rem !important;
}

#port-trade-insights.active.scope-all .ta-hbar-track,
#trend-analysis.active.scope-all .ta-hbar-track {
    height: 15px !important;
}

/* ==== Collapsible sidebar ==== */

.sidebar {
    transition: width 0.18s ease;
}

.logo {
    justify-content: space-between;
    gap: 0.6rem;
}

.logo-short {
    display: none;
}

.sidebar-toggle {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--sidebar-text-active);
    cursor: pointer;
    transition: background 0.15s;
}

.sidebar-toggle:hover {
    background: color-mix(in srgb, var(--sidebar-text-active) 10%, transparent);
}

.sidebar-toggle-bars {
    display: grid;
    gap: 3px;
    width: 16px;
}

.sidebar-toggle-bars i {
    display: block;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
}

/* Reserve the active accent on every row so icons stay aligned when collapsed. */
.nav-item {
    border-left: 3px solid transparent;
    padding-left: calc(0.45rem - 3px);
}

.nav-item.active {
    border-left-color: var(--sidebar-accent);
}

body.sidebar-collapsed .sidebar {
    width: 64px !important;
    max-width: 64px !important;
    min-width: 64px !important;
}

body.sidebar-collapsed .logo {
    height: auto;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.7rem 0;
    justify-content: center;
}

body.sidebar-collapsed .logo-full {
    display: none;
}

body.sidebar-collapsed .logo-short {
    display: inline;
}

body.sidebar-collapsed .nav-label {
    display: none;
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    gap: 0;
    padding-right: 0;
    padding-left: 0;
}

body.sidebar-collapsed .nav-item i {
    font-size: 1.15rem;
}

/* ==== Company Analysis (reuses the Trend Analysis panel + chart styles) ==== */

#company-analysis .ca-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.1rem;
    align-items: start;
}

#company-analysis .ta-panel {
    display: flex;
    flex-direction: column;
    min-height: 320px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

#company-analysis .ta-panel-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: 0.8rem 0.9rem;
}

#company-analysis .ta-bars {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 1fr auto auto;
    column-gap: 0.5rem;
    height: 100%;
}

#company-analysis .ta-bars-plot {
    height: 220px !important;
    min-height: 220px !important;
}

#company-analysis .ta-bars-xlabels {
    margin-top: 0.35rem;
}

#company-analysis .ta-bars-ytitle {
    font-size: 0.76rem !important;
    font-weight: 400 !important;
    color: var(--faint) !important;
}

#company-analysis .ta-bars-grid span::after {
    font-size: 0.72rem !important;
    font-weight: 400 !important;
    color: var(--ink) !important;
}

#company-analysis .ta-bar-value {
    margin-bottom: 0.2rem;
    font-size: 0.68rem;
    font-weight: 400 !important;
    color: var(--ink) !important;
}

#company-analysis .ta-donut {
    max-height: 280px !important;
    height: 280px !important;
    width: 100%;
    margin: 0 auto;
    display: block;
    object-fit: contain;
}

#company-analysis .ta-donut-center-title {
    font-size: 22.4px !important;
    font-weight: 400 !important;
    fill: var(--ink) !important;
    color: var(--ink) !important;
    letter-spacing: 0.04em;
}

#company-analysis .ta-donut-center-val {
    font-size: 24px !important;
    font-weight: 400 !important;
    fill: var(--ink) !important;
    color: var(--ink) !important;
    font-variant-numeric: tabular-nums;
}

#company-analysis .ta-donut-label tspan {
    font-size: 20px !important;
    font-weight: 400 !important;
    fill: var(--ink) !important;
    color: var(--ink) !important;
}

#company-analysis .ta-donut-center-sub {
    font-size: 20.8px !important;
    font-weight: 400 !important;
    fill: var(--brand-ink) !important;
}

#company-analysis .ta-bar-label {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.68rem;
    font-weight: 400 !important;
    color: var(--ink) !important;
    line-height: 1.2;
}

#company-analysis .ta-hbar-label {
    color: var(--ink) !important;
    font-weight: 400 !important;
}

#company-analysis .ta-hbar-value {
    color: var(--ink) !important;
    font-weight: 400 !important;
}

#company-analysis .ta-hbar-ytitle {
    color: var(--faint) !important;
    font-weight: 400 !important;
}

#company-analysis .ta-hbar-xtitle {
    color: var(--faint) !important;
    font-weight: 400 !important;
}

#company-analysis .ta-hbar-ticks span {
    color: var(--ink) !important;
    font-weight: 400 !important;
}

#company-analysis .ta-bars-xtitle {
    margin-top: 0.45rem !important;
    font-size: 0.8rem !important;
    font-weight: 400 !important;
    color: var(--faint) !important;
}

@media (max-width: 860px) {
    #company-analysis .ca-chart-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ==== Customer-Centric Dashboard ==== */

.cd-header-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.35rem 0 0.65rem 0;
    flex-wrap: wrap;
}

.cd-direction-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cd-direction-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-dark);
}

.cd-kpi-row {
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 0.6rem !important;
    margin-bottom: 0.85rem !important;
}

.cd-kpi-card {
    border-radius: 8px !important;
}

.cd-kpi-card .ta-kpi-head {
    padding: 0.35rem 0.5rem !important;
}

.cd-kpi-card .ta-kpi-label {
    font-size: 0.75rem !important;
    white-space: normal !important;
    text-align: center !important;
}

.cd-kpi-card .ta-kpi-main {
    padding: 0.5rem 0.6rem !important;
}

.cd-kpi-card .ta-kpi-value {
    font-size: 1.05rem !important;
    font-weight: 600 !important;
}

.cd-kpi-card .cd-val-import {
    color: var(--brand-ink) !important;
}

.cd-kpi-card .cd-val-export {
    color: var(--warning) !important;
}

.cd-chart-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    align-items: stretch;
    margin-bottom: 1.5rem;
}

.cd-panel {
    min-height: 290px;
    display: flex;
    flex-direction: column;
}

.cd-panel .ta-bars-plot {
    height: 200px;
}

.cd-panel .ta-bar-label {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.68rem;
}

.cd-panel .ta-hbar-chart {
    min-height: 200px;
}

/* These cards are a third of the page wide: the split chart gets a tighter legend and plot. */
.cd-panel .co-legend {
    margin-bottom: 0.6rem;
    font-size: 0.7rem;
    gap: 0.7rem;
}

.cd-panel .co-plot {
    padding-right: 0.75rem;
}

.cd-panel .co-rows-wrap {
    max-height: 260px;
}

@media (max-width: 1280px) {
    .cd-chart-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .cd-chart-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ==== Port & Trade Insights (reuses the Trend Analysis panel + chart styles) ==== */

.pt-chart-grid {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.pt-chart-grid .ta-bars-plot {
    height: 235px;
}

.pt-chart-grid .ta-bar-label {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.7rem;
}

/* Horizontal bars (Top Tradelanes) */

/* ==== Company & Data Explorer ==== */

/* Full screen 100% height stretch for Data Explorer (STRICTLY zero page scrollbars, table fills remaining space) */
.content-wrapper:has(#data-explorer.active) {
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    height: calc(100vh - 56px) !important;
    padding: 0.6rem 1.25rem 1.35rem 1.25rem !important;
}

#data-explorer.active {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important;
}

#data-explorer .co-filter-bar {
    flex: 0 0 auto !important;
    margin-bottom: 0.4rem !important;
    padding: 0.4rem 0.6rem !important;
}

#data-explorer .de-top-row {
    flex: 0 0 auto !important;
    margin-bottom: 0.4rem !important;
}

#data-explorer .de-table-panel {
    flex: 0 1 auto !important;
    max-height: calc(100vh - 195px) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    margin-bottom: 0.5rem !important;
}

#data-explorer .de-table-wrap {
    flex: 0 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(100vh - 245px) !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

#data-explorer .de-pager {
    flex: 0 0 auto !important;
}

/* Same head/body split as the Trend Analysis KPI cards. */
.de-total-card {
    flex: 0 0 auto;
    min-width: 190px;
    margin-left: auto;
    display: grid;
    align-content: start;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-surface);
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
    overflow: hidden;
}

.de-export-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    height: 26px;
    line-height: 24px;
    padding: 0 0.6rem;
    flex: 0 0 auto;
    border: 1px solid var(--success);
    border-radius: 5px;
    background: var(--success);
    color: var(--on-brand);
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--success) 15%, transparent);
    transition: all 0.15s ease;
    white-space: nowrap;
    box-sizing: border-box;
}

.de-export-btn:hover:not(:disabled) {
    background: var(--success);
    border-color: var(--success);
    box-shadow: 0 2px 6px color-mix(in srgb, var(--success) 25%, transparent);
}

.de-export-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.de-export-btn .de-excel-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.de-export-btn .co-icon {
    width: 15px;
    height: 15px;
    stroke-width: 2.2;
}

.de-total-head {
    padding: 0.35rem 0.6rem;
    background: var(--panel-head-bg);
    color: var(--on-brand);
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
}

.de-total-value {
    padding: 0.5rem 0.6rem;
    color: var(--text-dark);
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* Table */
.de-table-panel {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.de-table-wrap {
    max-height: 460px;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.de-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.de-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.65rem 0.8rem;
    background: var(--panel-head-bg);
    color: var(--on-brand);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}

.de-table th+th {
    border-left: 1px solid rgba(255, 255, 255, 0.18);
}

.de-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
    font-size: 0.78rem;
    line-height: 1.4;
}

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

.de-table tbody tr:nth-child(even) td {
    background: var(--surface-2);
}

.de-table tbody tr:hover td {
    background: var(--brand-soft);
}

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

/* Pagination */
.de-pager {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.85rem;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.74rem;
}

.de-page-size-select {
    height: 32px;
    min-width: 86px;
    padding: 0 1.5rem 0 0.65rem;
    margin-left: 0.35rem;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background-color: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23334155' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 11px 11px;
    appearance: none;
    -webkit-appearance: none;
    color: var(--ink);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    line-height: 30px;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.de-page-size-select:hover,
.de-page-size-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.12);
}

.de-pager-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.de-pager-pages {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.de-page-label {
    padding: 0 0.5rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    user-select: none;
}

.de-page-btn {
    font: inherit;
}

@media (max-width: 860px) {
    .de-top-row {
        flex-wrap: wrap;
    }

    .de-total-card {
        flex: 1 1 100%;
        margin-left: 0;
    }

    .de-pager {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ==== Multi-select filter dropdowns ==== */

.ms-select {
    position: relative;
    width: max-content;
    min-width: 0;
    height: 100%;
    display: inline-flex;
    align-items: center;
}

.ms-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
    width: auto;
    max-width: 260px;
    height: 100%;
    padding: 0 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.81rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    outline: none;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.15s ease;
}

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

.ms-trigger.is-active {
    border-color: var(--primary);
    background: var(--brand-soft);
    color: var(--primary);
    font-weight: 600;
}

.ms-trigger::after {
    content: '';
    position: relative;
    right: auto;
    top: auto;
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    margin-left: auto;
    margin-top: -2px;
    border-right: 1.8px solid var(--muted);
    border-bottom: 1.8px solid var(--muted);
    transform: rotate(45deg);
    pointer-events: none;
    transition: border-color 0.15s ease;
}

.ms-trigger.is-active::after {
    border-color: var(--primary);
}

.ms-trigger:focus-visible {
    outline: 2px solid var(--brand-line);
    outline-offset: 2px;
}

.ms-trigger-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: left;
}

.ms-trigger-text.is-placeholder {
    color: var(--muted);
    font-weight: 500;
}

.ms-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 99999 !important;
    display: flex;
    flex-direction: column;
    min-width: 240px;
    width: max-content;
    max-width: 340px;
    max-height: 300px;
    padding: 0.6rem;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 14px 30px rgba(17, 24, 39, 0.2);
}

.ms-panel[hidden] {
    display: none;
}

.ms-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.55rem;
}

.ms-title {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ms-clear {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
}

.ms-clear:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.ms-search {
    flex: 0 0 auto;
    margin-bottom: 0.5rem;
}

.ms-search-input {
    width: 100%;
    min-width: 0;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.74rem;
    outline: none;
}

.ms-search-input::placeholder {
    color: var(--faint);
}

.ms-search-input:focus {
    border-color: var(--brand-line);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent);
}

.ms-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    align-content: start;
    gap: 0.1rem;
}

.ms-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.32rem 0.35rem;
    border-radius: 6px;
    color: var(--text-dark);
    font-size: 0.75rem;
    cursor: pointer;
}

.ms-option:hover {
    background: var(--bg-main);
}

.ms-option input {
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
    cursor: pointer;
}

.ms-option-single.is-selected {
    background: var(--brand-soft);
    color: var(--brand-ink);
    font-weight: 600;
}

.ms-option-text {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ms-empty,
.ms-note {
    flex: 0 0 auto;
    padding: 0.4rem 0.35rem 0;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.ms-note[hidden] {
    display: none;
}

/* Custom Data Source Dropdown Component */
.data-source-wrapper {
    position: relative;
    display: none;
    align-items: center;
    height: 38px;
    padding: 0 30px 0 34px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    margin-right: 0.75rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

body.logged-in .data-source-wrapper {
    display: inline-flex;
}

.data-source-wrapper:hover {
    border-color: var(--line-strong);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.data-source-wrapper.is-open {
    border-color: var(--brand-hover);
    box-shadow: 0 0 0 2px rgba(14, 30, 70, 0.1);
}

.data-source-icon {
    position: absolute;
    left: 10px;
    width: 17px;
    height: 17px;
    color: var(--brand-ink);
    pointer-events: none;
}

.data-source-trigger {
    display: flex;
    align-items: center;
}

.data-source-text {
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--brand-ink);
    white-space: nowrap;
    line-height: 1;
}

.data-source-arrow {
    position: absolute;
    right: 10px;
    width: 12px;
    height: 12px;
    color: var(--muted);
    pointer-events: none;
    transition: transform 0.2s ease;
}

.data-source-wrapper.is-open .data-source-arrow {
    transform: rotate(180deg);
}

.data-source-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    min-width: 100%;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 4px 10px -2px rgba(15, 23, 42, 0.05);
    padding: 4px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-sizing: border-box;
    animation: dataSourceFadeIn 0.15s ease-out;
}

.data-source-menu[hidden] {
    display: none !important;
}

@keyframes dataSourceFadeIn {
    from {
        opacity: 0;
        transform: translateY(-3px);
    }

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

.data-source-item {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

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

.data-source-item.is-selected {
    background: var(--surface-2);
    color: var(--brand-ink);
    font-weight: 700;
}

.data-source-item-check {
    width: 14px;
    height: 14px;
    color: var(--brand-ink);
}

/* Header Sync button: opens the shared Sync dialog (js/sync.js). */
.header-sync-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 36px;
    padding: 0 1rem;
    border: 1px solid var(--line-strong);
    border-radius: 20px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.header-sync-btn:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 3px 8px color-mix(in srgb, var(--brand) 15%, transparent);
}

.header-sync-btn .co-icon {
    width: 14px;
    height: 14px;
    stroke-width: 2.2;
    transition: transform 0.2s ease;
}

.header-sync-btn:hover:not(:disabled) .co-icon {
    transform: rotate(45deg);
}

body.logged-in .header-sync-btn {
    display: inline-flex;
}

/* ==== Company & Data Explorer Slicer Cards & Top Row ==== */
.de-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

/* ==== Chart Loading Overlay & Circle ==== */
.chart-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 240px;
    min-height: 220px;
    width: 100%;
    gap: 0.85rem;
    animation: fadeIn 0.2s ease-out;
}

.chart-spinner {
    width: 38px;
    height: 38px;
    border: 3.5px solid color-mix(in srgb, var(--brand) 15%, transparent);
    border-top-color: var(--brand);
    border-right-color: var(--brand-line);
    border-radius: 50%;
    animation: chartSpin 0.7s cubic-bezier(0.6, 0.2, 0.4, 0.8) infinite;
    box-shadow: 0 0 12px color-mix(in srgb, var(--brand) 12%, transparent);
}

.chart-loading-text {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.01em;
    animation: chartPulse 1.2s ease-in-out infinite alternate;
}

/* Modal Table Loading Cell — Pinned to left-center of visible viewport */
.modal-table-loading-cell {
    text-align: left !important;
    vertical-align: middle !important;
    padding: 5rem 1.5rem !important;
}

.modal-table-loading-cell .chart-loading-state {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    height: auto !important;
    min-height: 100px !important;
    width: auto !important;
    position: sticky !important;
    left: 180px !important;
    gap: 0.85rem !important;
    z-index: 20 !important;
}

@keyframes chartSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes chartPulse {
    0% {
        opacity: 0.55;
    }

    100% {
        opacity: 1;
    }
}

/* ==== Shipment details modal ==== */

/* Reporter Modal Styles */
.co-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.65) !important;
    backdrop-filter: blur(4px) !important;
    z-index: 999999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1.5rem !important;
    box-sizing: border-box !important;
    animation: coModalFadeIn 0.2s ease-out;
}

.co-modal-overlay[hidden] {
    display: none !important;
}

@keyframes coModalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.co-modal-container {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    width: 92vw;
    max-width: 1240px;
    height: auto !important;
    max-height: 88vh !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: coModalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes coModalSlideUp {
    from {
        transform: translateY(16px) scale(0.98);
    }

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

.co-modal-header {
    flex-shrink: 0;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.75rem 1.25rem !important;
    background: var(--panel-head-bg, var(--brand-hover)) !important;
    color: var(--on-brand) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.co-modal-title-group {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.co-modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--on-brand);
    letter-spacing: -0.01em;
}

.co-modal-subtitle {
    font-size: 0.72rem;
    color: var(--brand-ink);
    font-weight: 400;
}

.co-modal-close {
    background: transparent;
    border: none;
    color: var(--on-brand);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

.co-modal-close:hover {
    background: rgba(255, 255, 255, 0.18);
    color: var(--faint);
}

.co-modal-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.25rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    gap: 0.75rem;
    flex-wrap: wrap;
}

.co-modal-body {
    flex: 0 1 auto !important;
    min-height: 0 !important;
    max-height: calc(88vh - 165px) !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
}

.co-modal-body .de-table-wrap {
    flex: 0 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: calc(88vh - 185px) !important;
    margin-top: 0;
    border-radius: 8px;
    border: 1px solid var(--line);
    overflow: auto;
    position: relative;
}

.co-modal-body .de-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    font-size: 0.72rem !important;
    padding: 0.55rem 0.65rem !important;
    white-space: nowrap !important;
    font-weight: 650 !important;
    background: var(--brand-hover) !important;
    color: var(--on-brand) !important;
    box-shadow: 0 1px 0 var(--brand-hover);
}

.co-modal-body .de-table td {
    font-size: 0.72rem !important;
    padding: 0.5rem 0.65rem !important;
    white-space: nowrap !important;
}

/* Data Explorer & Modal Table Footer & Pagination */
.de-table-footer {
    flex-shrink: 0;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.75rem 1.25rem !important;
    background: var(--surface-2) !important;
    border-top: 1px solid var(--line) !important;
    gap: 1rem !important;
    flex-wrap: wrap !important;
}

.de-record-info {
    font-size: 0.78rem !important;
    color: var(--muted) !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
}

.de-pagination {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.35rem !important;
}

.de-page-btn {
    height: 32px !important;
    min-width: 32px !important;
    padding: 0 0.65rem !important;
    border: 1px solid var(--line-strong) !important;
    background: var(--surface) !important;
    color: var(--ink) !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.15s ease-in-out !important;
    outline: none !important;
    user-select: none !important;
    margin: 0 !important;
}

.de-page-btn:hover:not(:disabled) {
    background: var(--surface-2) !important;
    border-color: var(--line-strong) !important;
    color: var(--ink) !important;
}

.de-page-btn:disabled {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
    background: var(--surface-2) !important;
    border-color: var(--line) !important;
    color: var(--faint) !important;
}

/* Global Table Missing Permanent Error Banner */
.global-table-error-banner {
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
    padding: 0.75rem 1.25rem !important;
    margin: 0.75rem 1.5rem 0 1.5rem !important;
    background: var(--danger-soft) !important;
    border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--surface)) !important;
    border-left: 4px solid var(--danger) !important;
    border-radius: 8px !important;
    color: var(--danger) !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.08) !important;
    z-index: 100 !important;
}

.global-table-error-banner i {
    font-size: 1.1rem !important;
    color: var(--danger) !important;
}

.global-table-error-banner[hidden] {
    display: none !important;
}

/* ==== Authentication and landing page ==== */

.home-section {
    position: relative;
    min-height: 100vh;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 5.5rem 1.5rem 2.5rem;
    background: var(--bg-main);
    box-sizing: border-box;
}

.home-section.active {
    display: flex;
}

.tl-auth-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 2.8rem;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

/* Left Side Styling */
.tl-auth-left {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.tl-auth-brand {
    position: absolute;
    top: 2rem;
    left: max(1.5rem, calc((100vw - 1200px) / 2));
    display: flex;
    align-items: center;
    gap: 0.7rem;
    z-index: 10;
}

.tl-brand-logo-img {
    height: 40px;
    width: auto;
    object-fit: contain;
    display: block;
}

.tl-brand-name {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--brand-ink);
    letter-spacing: -0.03em;
    line-height: 1;
}

.tl-hero-header {
    margin-bottom: 1.5rem;
}

.tl-pill-tag {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: var(--brand-soft);
    border: 1px solid var(--brand-line);
    color: var(--brand-ink);
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 0.85rem;
}

.tl-hero-header h1 {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 2.75rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.12;
    letter-spacing: -0.01em;
    margin: 0 0 0.85rem;
}

.tl-hero-header p {
    font-size: 1.02rem;
    line-height: 1.6;
    color: var(--muted);
    margin: 0;
    max-width: 640px;
}

/* 2x2 Feature Cards Grid */
.tl-features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.15rem;
}

.tl-feature-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.1rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

.tl-feature-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -6px color-mix(in srgb, var(--brand) 12%, transparent);
    border-color: var(--brand-line);
}

.tl-feature-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.tl-feature-content h3 {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 0.25rem;
    line-height: 1.25;
}

.tl-feature-content p {
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--muted);
    margin: 0;
}

/* Right Side: Floating Sign In Card */
.tl-auth-right {
    display: flex;
    justify-content: center;
}

.tl-login-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 2rem 1.75rem;
    box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.08);
    width: 100%;
}

.tl-login-card-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--ink);
    margin: 0 0 0.35rem;
    letter-spacing: -0.02em;
}

.tl-login-card-header p {
    font-size: 0.84rem;
    color: var(--muted);
    margin: 0 0 1.35rem;
}

.tl-login-card .form-field label {
    color: var(--ink);
    font-size: 0.88rem;
    font-weight: 700;
}

/* Inputs & Wrappers */
.auth-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.auth-input-icon {
    position: absolute;
    left: 0.95rem;
    color: var(--faint);
    font-size: 0.95rem;
    pointer-events: none;
    z-index: 2;
    transition: color 0.15s ease;
}

.auth-input-wrap:focus-within .auth-input-icon {
    color: var(--brand-ink);
}

.auth-input-wrap input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.75rem 0.9rem 0.75rem 2.7rem;
    font-size: 0.92rem;
    color: var(--ink);
    transition: all 0.15s ease;
}

.auth-input-wrap input:focus {
    background: var(--surface);
    border-color: var(--brand);
    box-shadow: 0 0 0 3.5px rgba(30, 58, 138, 0.15);
    outline: none;
}

.auth-input-wrap .password-toggle {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--faint);
    padding: 0.3rem;
    cursor: pointer;
    font-size: 0.95rem;
    z-index: 2;
}

.auth-input-wrap .password-toggle:hover {
    color: var(--muted);
}

.tl-login-submit-btn {
    width: 100%;
    margin-top: 0.6rem;
    background: var(--brand) !important;
    color: var(--on-brand) !important;
    border: none !important;
    border-radius: 10px !important;
    padding: 0.82rem !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    cursor: pointer;
    transition: all 0.2s ease !important;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 25%, transparent) !important;
}

.tl-login-submit-btn:hover {
    background: var(--primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 35%, transparent) !important;
}

.tl-login-card-footer {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    text-align: center;
    font-size: 0.78rem;
    color: var(--faint);
    line-height: 1.4;
}

/* Responsive Layout */
@media (max-width: 980px) {
    .home-section {
        align-items: flex-start;
        padding: 5.5rem 1rem 2rem;
    }

    .tl-auth-brand {
        top: 1.5rem;
        left: 1.25rem;
    }

    .tl-auth-container {
        grid-template-columns: 1fr;
        gap: 2.25rem;
    }

    .tl-auth-right {
        max-width: 440px;
        margin: 0 auto;
        width: 100%;
    }
}

@media (max-width: 640px) {
    .tl-features-grid {
        grid-template-columns: 1fr;
    }

    .tl-hero-header h1 {
        font-size: 1.85rem;
    }

    .tl-login-card {
        padding: 1.5rem 1.25rem;
    }
}

/* Developer Column Inspector UI Popup Card */
.dev-column-popover {
    position: fixed;
    z-index: 999999;
    background: var(--toast-bg);
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid color-mix(in srgb, var(--info) 35%, transparent);
    box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.5), 0 0 18px color-mix(in srgb, var(--info) 20%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: 10px;
    padding: 8px 12px;
    color: var(--faint);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.78rem;
    line-height: 1.45;
    pointer-events: auto;
    transition: opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    transform: translateY(6px);
    max-width: 300px;
    min-width: 220px;
}

.dev-column-popover.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.dev-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dev-popover-title {
    font-weight: 700;
    font-size: 0.68rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--faint);
}

.dev-popover-badge {
    display: inline-block;
    background: color-mix(in srgb, var(--info) 15%, transparent);
    color: var(--info);
    border: 1px solid color-mix(in srgb, var(--info) 30%, transparent);
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
}

.dev-popover-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.dev-popover-code {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid color-mix(in srgb, var(--info) 30%, transparent);
    color: var(--info);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.dev-popover-code:hover {
    background: color-mix(in srgb, var(--info) 12%, transparent);
    border-color: var(--info);
}

.dev-popover-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--brand);
    color: var(--on-brand);
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.dev-popover-copy-btn:hover {
    background: var(--brand);
    transform: scale(1.03);
}

.dev-copy-icon {
    flex-shrink: 0;
}

/* Floating Toast notification for Alt+Click Copy */
.dev-copy-toast {
    position: fixed;
    z-index: 999999;
    background: var(--success);
    color: var(--on-brand);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.76rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 8px;
    box-shadow: 0 10px 25px -4px rgba(16, 185, 129, 0.4);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    opacity: 0;
    transform: translateY(4px);
}

.dev-copy-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ==== Export dialog ==== */
/* The Export dialog of every Atom app (Pulse's export dialog section), in this page's modal look and
   export green. Markup: #export-confirm-modal.modal > .modal-content.export-dialog > form#export-form >
   .modal-header (title, subtitle "CSV · one row per <thing> · up to 1,000,000 rows", ×) > .modal-body.export-body:
   label.export-scope (checkbox, "Use the filters applied on the main page", hint, ul.export-filter-list chips)
   > .export-options (Rows: .export-rows box + chevron menu; Order) > p.export-note (only a failed download's
   message) > .modal-footer: Cancel, Download CSV. Short enough never to scroll, so nothing clips the Rows menu. */
#export-confirm-modal {
    z-index: 10000005 !important;
}

#export-confirm-modal .modal-content.export-dialog {
    width: min(520px, calc(100vw - 2.5rem));
    overflow: visible;
    border-radius: 12px;
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.2);
}

.export-dialog .modal-header {
    border-radius: 12px 12px 0 0;
}

.export-dialog .modal-footer {
    border-radius: 0 0 12px 12px;
}

.export-modal-icon {
    background: var(--line) !important;
    color: var(--success) !important;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
}

.export-dialog .modal-body.export-body {
    display: grid;
    gap: 14px;
    overflow: visible;
}

.export-body .field {
    display: grid;
    gap: 6px;
    min-width: 0;
    margin: 0;
}

.export-scope {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    cursor: pointer;
}

.export-scope[hidden] {
    display: none;
}

.export-scope.disabled {
    opacity: 0.6;
    cursor: default;
}

.export-scope input {
    flex: none;
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    accent-color: var(--success);
}

.export-scope span {
    display: grid;
    gap: 2px;
    min-width: 0;
    color: var(--text-dark);
    font-size: 0.88rem;
}

.export-scope small {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.export-filter-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
}

.export-filter-list:empty,
.export-filter-list.hidden {
    display: none;
}

.export-filter-list li {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 22px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--line);
    color: var(--success);
    font-size: 0.72rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.export-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 12px;
}

.export-options.is-single {
    grid-template-columns: 1fr;
}

.export-options .field[hidden] {
    display: none;
}

.export-limit-label {
    color: var(--text-dark);
    font-size: 0.82rem;
    font-weight: 700;
}

.export-limit-input {
    width: 100%;
    height: 40px;
    padding: 0 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-dark);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
}

.export-limit-input:focus {
    outline: none;
    border-color: var(--success);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 15%, transparent);
}

.export-rows {
    position: relative;
}

.export-rows input {
    padding-right: 34px;
    appearance: textfield;
    -moz-appearance: textfield;
}

.export-rows input::-webkit-inner-spin-button,
.export-rows input::-webkit-outer-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.export-rows input:invalid {
    border-color: var(--danger);
}

.export-rows-toggle {
    position: absolute;
    top: 1px;
    right: 1px;
    bottom: 1px;
    display: grid;
    place-items: center;
    width: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.export-rows-toggle svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.export-rows-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    z-index: 5;
    margin: 0;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.18);
    list-style: none;
    max-height: 248px;
    overflow-y: auto;
}

.export-rows-menu.hidden {
    display: none;
}

.export-rows-menu button {
    display: block;
    width: 100%;
    height: 30px;
    margin: 0;
    padding: 0 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-dark);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
}

.export-rows-menu button:hover,
.export-rows-menu button.active {
    background: var(--surface-2);
}

.export-note:empty {
    display: none;
}

.export-note {
    margin: 0;
    color: var(--danger);
    font-size: 0.8rem;
}

.export-confirm-btn {
    background: var(--success) !important;
    border-color: var(--success) !important;
    color: var(--on-brand) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.45rem !important;
    padding: 0.45rem 1rem !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
}

.export-confirm-btn:hover:not(:disabled) {
    background: var(--success) !important;
    border-color: var(--success) !important;
    box-shadow: 0 3px 8px color-mix(in srgb, var(--success) 28%, transparent) !important;
}

.export-confirm-btn:disabled {
    opacity: 0.65;
    cursor: default !important;
}

.export-toast {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 10000006;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    background: var(--brand-hover);
    color: var(--on-brand);
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.24);
}

.export-toast[hidden] {
    display: none;
}

@media (max-width: 520px) {
    .export-options {
        grid-template-columns: 1fr;
    }
}

/* ==== Sync progress ==== */
/* The dialog that locks the page while a sync downloads data (js/ui/syncProgress.js). */

dialog.sync-progress {
    /* showModal() focuses the dialog itself, and a focus ring around the whole card is noise. */
    outline: none;
    width: min(460px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 1.4rem 1.4rem 1.1rem;
    border: 0;
    border-radius: 14px;
    background: var(--bg-surface);
    color: var(--text-dark);
    box-shadow: 0 24px 60px rgba(8, 19, 32, 0.35);
    font: inherit;
}

dialog.sync-progress::backdrop {
    background: rgba(8, 19, 32, 0.55);
    backdrop-filter: blur(3px);
}

body.sync-progress-locked {
    overflow: hidden;
}

/* `showModal()` already makes everything outside the dialog inert, which stops clicks, focus and
   keys but not a wheel over a scrolling panel: taking the rest of the page out of hit testing
   sends that wheel to the body, which does not scroll while it is locked. */
body.sync-progress-locked>*:not(dialog.sync-progress) {
    pointer-events: none;
    user-select: none;
}

.sync-progress .sp-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.sync-progress .sp-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--primary);
}

.sync-progress .sp-icon i {
    animation: sp-spin 1.1s linear infinite;
}

.sync-progress.is-done .sp-icon {
    background: var(--status-green);
    color: var(--status-green-text);
}

.sync-progress.is-failed .sp-icon {
    background: var(--danger-soft);
    color: var(--danger);
}

.sync-progress.is-done .sp-icon i,
.sync-progress.is-failed .sp-icon i {
    animation: none;
}

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

.sync-progress .sp-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.sync-progress .sp-reason {
    margin: 0.15rem 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.sync-progress .sp-meter {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.sync-progress .sp-percent {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    color: var(--primary);
}

.sync-progress .sp-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.sync-progress .sp-bar {
    height: 8px;
    margin-bottom: 0.9rem;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.sync-progress .sp-bar i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand-line), var(--primary));
    transition: width 0.35s ease;
}

.sync-progress.is-done .sp-bar i {
    background: var(--status-green-text);
}

.sync-progress .sp-steps {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.sync-progress .sp-steps li {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.65rem;
    margin: 0;
    padding: 0.55rem 0.75rem;
    font-size: 0.84rem;
}

.sync-progress .sp-steps li+li {
    border-top: 1px solid var(--line);
}

.sync-progress .sp-label {
    min-width: 0;
    font-weight: 600;
}

.sync-progress .sp-label small {
    display: block;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-muted);
}

.sync-progress .sp-time {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--faint);
    white-space: nowrap;
}

.sync-progress .sp-state {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--line-strong);
}

.sync-progress li.is-running .sp-state {
    border-color: var(--primary);
    border-top-color: transparent;
    animation: sp-spin 0.8s linear infinite;
}

.sync-progress li.is-running .sp-time {
    color: var(--primary);
}

.sync-progress li.is-done .sp-state {
    border: 0;
    background: var(--status-green-text) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.2l2.6 2.6L12 5.4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat;
}

.sync-progress li.is-done .sp-time {
    color: var(--status-green-text);
}

.sync-progress li.is-failed .sp-state {
    border: 0;
    background: var(--danger) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5 5l6 6M11 5l-6 6' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center/100% no-repeat;
}

.sync-progress li.is-failed .sp-time {
    color: var(--danger);
}

.sync-progress .sp-note {
    margin: 0;
    font-size: 0.76rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.sync-progress .sp-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.9rem;
}

.sync-progress .sp-actions[hidden] {
    display: none;
}

/* ==== Pulse shell ==== */
/* The shared look of the apps (Pulse's page standard, docs page.md): wordmark and login card with the --brand head, avatar and account menu,
   the dialog frame (--brand head, 17px title, 32px square ×, actions on --bg), table heads and pager. Last in the file, so it wins over the older rules above. */
.brand-wordmark {
    display: inline-flex;
    align-items: center;
    color: var(--brand-ink);
    font-family: Arial, sans-serif;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -2px;
}
.brand-wordmark::before {
    content: "";
    width: 18px;
    height: 25px;
    margin-right: 3px;
    background: repeating-linear-gradient(to bottom, transparent 0 5px, var(--brand-line) 5px 7px);
}
/* login card: 370px, --radius-lg, 27px inside, a --brand head like a dialog's, labels over 45px fields, the full-width Login button 22px below */
.tl-login-card {
    max-width: 370px;
    padding: 27px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.tl-login-card-header {
    display: grid;
    align-content: center;
    gap: 2px;
    min-height: 75px;
    margin: -27px -27px 11px;
    padding: var(--dialog-head-pad);
    border-bottom: 1px solid var(--brand-hover);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--brand);
}
.tl-login-card-header h2 {
    margin: 0;
    color: var(--on-brand);
    font-size: var(--fs-lg);
    font-weight: 600;
    letter-spacing: normal;
}
.tl-login-card-header p {
    margin: 0;
    color: var(--on-brand-soft);
    font-size: 12px;
}
.tl-login-card .auth-form {
    gap: 16px;
}
.tl-login-card .form-field {
    gap: 8px;
}
.tl-login-card .form-field label {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
}
.tl-login-card .auth-message:empty {
    display: none;
}
.tl-login-card .auth-input-wrap input {
    height: 45px;
    border-color: var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
}
.tl-login-card .auth-input-wrap input:focus {
    border-color: var(--brand);
    box-shadow: var(--ring);
}
.tl-login-card .tl-login-submit-btn {
    width: 100%;
    height: 45px;
    margin-top: 6px; /* with the form's 16px gap: 22px under the last field */
    border-radius: var(--radius);
    background: var(--brand) !important;
    color: var(--on-brand);
    font-size: 14px;
    font-weight: 600;
    box-shadow: none !important;
    transform: none !important;
}
.tl-login-card .tl-login-submit-btn:hover {
    background: var(--brand-hover) !important;
}
/* avatar and account menu: My profile, Login details, User management, Sync, Settings, then Logout in red; no divider */
.avatar {
    width: var(--avatar);
    height: var(--avatar);
    background: var(--brand);
    color: var(--on-brand);
    font-size: 14px;
    font-weight: 700;
}
.profile-menu.account-menu {
    min-width: 180px;
    width: max-content;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}
.profile-menu .account-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    height: 36px;
    padding: 0 18px 0 11px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink);
    font-size: var(--fs);
    font-weight: 400;
}
.profile-menu .account-menu-item:hover {
    background: var(--surface-2);
    color: var(--ink);
}
.profile-menu .account-menu-item svg {
    flex: none;
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.profile-menu .account-menu-logout,
.profile-menu .account-menu-logout:hover {
    color: var(--danger);
}
.profile-menu .account-menu-logout:hover {
    background: var(--danger-soft);
}
/* dialogs: --radius-lg frame, a --brand head (17px title, 12px subtitle, a 32px square ×), the actions on --bg at the right */
.modal-content {
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.modal-header {
    min-height: 0;
    padding: var(--dialog-head-pad);
    border-bottom: 1px solid var(--brand-hover);
    background: var(--brand);
}
.modal-heading-icon {
    display: none;
}
.modal-header h3,
.modal-header h2 {
    margin: 0;
    color: var(--on-brand);
    font-size: var(--fs-lg);
    font-weight: 600;
}
.modal-subtitle,
.modal-header > div:first-child > p {
    margin: 0;
    color: var(--on-brand-soft);
    font-size: 12px;
}
.close-modal,
.modal-close {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border: 1px solid var(--on-brand-line);
    border-radius: var(--radius);
    background: transparent;
    color: var(--on-brand);
}
.close-modal:hover,
.modal-close:hover {
    border-color: var(--on-brand-line);
    background: var(--on-brand-hover);
    color: var(--on-brand);
}
.modal-footer {
    gap: 8px;
    padding: var(--dialog-actions-pad);
    border-top: 1px solid var(--line);
    background: var(--bg);
}

/* ==== side navigation (Pulse theme, dark navy) ==== */
/* The sidebar is a dark shade of the theme's navy (--brand), with light text; the item on screen is the navy itself, marked in light blue.
   Every sidebar colour is one of these tokens, derived from --brand, so dark mode follows. */
:root {
    --sidebar-bg: color-mix(in srgb, var(--brand) 38%, #000); /* #0a162a in light mode */
    --sidebar-deep: color-mix(in srgb, var(--brand) 28%, #000);
    --sidebar-hover-bg: color-mix(in srgb, var(--brand) 60%, #000);
    --sidebar-active-bg: var(--brand);
    --sidebar-text: color-mix(in srgb, var(--on-brand) 72%, var(--brand));
    --sidebar-text-active: var(--on-brand);
    --sidebar-accent: color-mix(in srgb, var(--brand) 30%, #fff);
    --sidebar-line: rgba(255, 255, 255, .1);
}
