/* Shared iPad-friendly styling for trading portal pages */
:root {
    color-scheme: light;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-strong: rgba(255, 255, 255, 0.95);
    --border: rgba(15, 23, 42, 0.08);
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.12);
    --success: #16a34a;
    --warning: #f97316;
    --danger: #dc2626;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --radius-large: 26px;
    --radius-medium: 18px;
    --radius-small: 12px;
}

*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    overflow-y: scroll;
    scroll-padding-top: 80px;
}

body {
    margin: 0;
    font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(160deg, #eef2ff 0%, #f8fafc 34%, #ffffff 100%);
    color: var(--text-primary);
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    padding-bottom: 48px;
}

a {
    color: inherit;
}

/* Prevent page scroll when jQuery UI autocomplete menu opens (iPad/iOS) */
.ui-autocomplete {
    position: fixed !important;
}

/* Reduce jarring scroll when focused (iPad Safari centers/flushes field to top) */
input, select, textarea, button {
    scroll-margin-top: 60px;
}

.shell,
.app-shell {
    width: 100%;
    max-width: var(--shell-max-width, 1100px);
    padding: 42px 30px 56px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    isolation: isolate;
}

.app-version-footer {
    margin-top: auto;
    padding-top: 12px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.shell {
    display: grid;
    gap: var(--shell-gap, 26px);
}

.shell--compact {
    --shell-max-width: 860px;
}

.shell--narrow {
    --shell-max-width: 780px;
}

.shell--wide {
    --shell-max-width: 1120px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.title-stack {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.title-stack h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 660;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.page-title-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.95em;
}

.page-title-logo {
    height: 68px;
    width: auto;
    max-width: min(360px, 64vw);
    display: block;
}

.page-title-text {
    display: inline-block;
}

.nav-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.button,
.nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border-radius: 18px;
    border: 1px solid transparent;
    font-size: 1rem;
    font-weight: 540;
    text-decoration: none;
    color: var(--text-primary);
    background: var(--surface);
    box-shadow: 0 20px 28px -26px rgba(15, 23, 42, 0.32);
    backdrop-filter: blur(20px);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    cursor: pointer;
}

.button:hover,
.nav-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 34px -24px rgba(15, 23, 42, 0.36);
}

.button-primary {
    background: #1d4ed8;
    color: #fff;
}

.button-success {
    background: #16a34a;
    color: #fff;
}

.button-secondary {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text-primary);
}

.button-ghost {
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(15, 23, 42, 0.1);
}

.button-danger {
    background: rgba(220, 38, 38, 0.12);
    color: #dc2626;
    border: 1px solid rgba(220, 38, 38, 0.18);
}

.widget {
    background: var(--surface-strong);
    border-radius: var(--radius-large);
    border: 1px solid var(--border);
    padding: 28px;
    backdrop-filter: blur(24px);
    box-shadow: 0 30px 52px -30px rgba(15, 23, 42, 0.34);
}

.widget + .widget {
    margin-top: 20px;
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.widget-title {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.widget-title h2 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 640;
    letter-spacing: -0.015em;
}

.widget-title span,
.widget-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.widget-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 560;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.metric-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.metric-card {
    padding: 20px;
    border-radius: var(--radius-medium);
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric-label {
    font-size: 0.88rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 560;
}

.metric-value {
    font-size: 1.7rem;
    font-weight: 650;
    letter-spacing: -0.015em;
}

.metric-note {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.metric-delta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 560;
}

.metric-delta.positive {
    background: rgba(22, 163, 74, 0.12);
    color: var(--success);
}

.metric-delta.negative {
    background: rgba(220, 38, 38, 0.12);
    color: var(--danger);
}

.metric-delta.flat {
    background: rgba(15, 23, 42, 0.08);
    color: var(--text-secondary);
}

.list {
    display: grid;
    gap: 14px;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-medium);
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid rgba(15, 23, 42, 0.05);
}

.list-item .info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.list-item strong {
    font-size: 1rem;
}

.list-item span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.05);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.notification {
    padding: 14px 16px;
    border-radius: var(--radius-medium);
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.12);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.table-shell,
.table-wrapper {
    border-radius: var(--radius-large);
    border: 1px solid rgba(15, 23, 42, 0.06);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.98);
}

.table-scroll-x {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.scroll-area {
    max-height: 360px;
    overflow-y: auto;
}

.table-wrapper table,
.table-shell table,
table {
    width: 100%;
    border-collapse: collapse;
}

.table-wrapper thead,
.table-shell thead,
thead {
    background: rgba(37, 99, 235, 0.08);
}

thead th,
th,
td {
    padding: 16px 18px;
    text-align: left;
    font-size: 0.96rem;
}

thead th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.8rem;
}

tbody tr + tr {
    border-top: 1px solid rgba(15, 23, 42, 0.05);
}

.currency {
    text-align: right;
}

/* ── Generic pill badge ──────────────────────────────────────────────
   Used by admin_dashboard, users, portal pickups and portal invoices.
   Previously redeclared per-template, so several pages rendered these
   unstyled. */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(107, 114, 128, 0.12);
    color: var(--text-secondary);
}

.badge-success { background: rgba(22, 163, 74, 0.12); color: #166534; }
.badge-warning { background: rgba(217, 119, 6, 0.14); color: #b45309; }
.badge-danger { background: rgba(185, 28, 28, 0.10); color: #b91c1c; }

/* ── Invoice payment status ──────────────────────────────────────────
   Single source of truth for how a buy invoice's payment state looks.
   Anything still owed reads as a warning; void reads as inactive. */
.inv-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

.inv-status-draft {
    background: rgba(107, 114, 128, 0.10);
    color: #4b5563;
    border-color: rgba(107, 114, 128, 0.22);
}

.inv-status-unpaid {
    background: rgba(185, 28, 28, 0.10);
    color: #b91c1c;
    border-color: rgba(185, 28, 28, 0.28);
}

.inv-status-partial {
    background: rgba(217, 119, 6, 0.14);
    color: #b45309;
    border-color: rgba(217, 119, 6, 0.32);
}

.inv-status-paid {
    background: rgba(22, 163, 74, 0.12);
    color: #166534;
    border-color: rgba(22, 163, 74, 0.24);
}

.inv-status-void {
    background: rgba(71, 85, 105, 0.10);
    color: #475569;
    border-color: rgba(71, 85, 105, 0.22);
}

/* Row/card accent for "money still owed". border-collapse hides tr
   borders, so the bar goes on the first cell. */
tr.inv-owing > td {
    background: rgba(217, 119, 6, 0.055);
}

tr.inv-owing > td:first-child {
    box-shadow: inset 3px 0 0 var(--warning);
}

.inv-owing-card {
    border-left: 3px solid var(--warning);
    background: rgba(217, 119, 6, 0.05);
}

.inv-owing-amount {
    color: #b45309;
    font-weight: 700;
}

@media (prefers-contrast: more) {
    tr.inv-owing > td { background: rgba(217, 119, 6, 0.14); }
}

.list-panel {
    border-radius: var(--radius-medium);
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.96);
    padding: 18px;
    max-height: 360px;
    overflow: hidden;
}

.product-item {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 42, 0.05);
    background: rgba(15, 23, 42, 0.03);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-item + .product-item {
    margin-top: 12px;
}

.product-price {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--success);
}

.helper-text,
.status-message {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.status-message.error {
    color: var(--danger);
}

.actions,
.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.actions-row {
    justify-content: flex-end;
}

.logout-block {
    margin-top: 40px;
    text-align: center;
}

.page-intro {
    display: grid;
    gap: 12px;
}

.page-intro p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 1rem;
}

.grid {
    display: grid;
    gap: 20px;
}

.grid.quick-actions {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid.two-col {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    padding: 24px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 30px 48px -32px rgba(15, 23, 42, 0.35);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 32px 56px -30px rgba(15, 23, 42, 0.38);
}

.card h2,
.card h3,
.card h4 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 620;
}

.card p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

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

.toolbar .button {
    padding: 12px 18px;
}

.form-card {
    background: var(--surface-strong);
    border-radius: var(--radius-large);
    border: 1px solid var(--border);
    padding: 28px;
    display: grid;
    gap: 22px;
    box-shadow: 0 34px 58px -32px rgba(15, 23, 42, 0.3);
}

.form-section {
    display: grid;
    gap: 16px;
}

.form-grid {
    display: grid;
    gap: 18px;
}

.form-grid.two-col {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 560;
    color: var(--text-secondary);
    /* Prevent wrapping for the label text portion (text nodes and spans) */
    /* In flexbox, adjacent text and inline elements form an anonymous flex item */
    /* We prevent wrapping by ensuring the first flex item doesn't wrap */
    align-items: flex-start;
}

/* Keep required indicators inline with label text - prevent wrapping */
label span[style*="color"],
label .required,
label .required-indicator {
    white-space: nowrap;
    display: inline;
}

/* For labels containing spans, prevent the text portion from wrapping */
/* In flexbox, adjacent text nodes and inline elements form an anonymous flex item */
/* We prevent this item from wrapping by ensuring the label text doesn't wrap */
label:has(span) {
    /* Prevent wrapping for the label text (text node + span) */
    /* Use nowrap on the first line to keep text and span together */
    white-space: normal;
}

/* More aggressive: prevent wrapping for labels with required indicators */
/* This ensures "Label Text *" stays on one line */
label:has(span[style*="color"]),
label:has(.required),
label:has(.required-indicator) {
    /* The text and span form an anonymous flex item in flexbox */
    /* To prevent wrapping, we ensure the label has enough width */
    /* and use nowrap on spans (already done above) */
    min-width: fit-content;
}

/* Target spans in labels to ensure they stay inline with text */
label span[style*="color"]:first-child,
label .required:first-child,
label .required-indicator:first-child {
    white-space: nowrap;
    display: inline;
}

/* For labels, the text node and span form an anonymous flex item */
/* To prevent wrapping, we ensure the label has enough width via form-grid */
/* and use nowrap on the spans themselves (already done above) */

/* Prevent wrapping for currency displays */
.currency {
    white-space: nowrap;
}

/* Prevent wrapping for divs containing dollar signs (like price displays) */
.example-block div,
.metric-value,
.invoice-info-card .value {
    white-space: nowrap;
}

/* For table headers with required indicators */
th .required-indicator {
    white-space: nowrap;
    display: inline;
}

/* Ensure table headers with required indicators don't wrap */
th:has(.required-indicator) {
    white-space: nowrap;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-small);
    border: 1px solid rgba(15, 23, 42, 0.15);
    background: rgba(255, 255, 255, 0.88);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.4);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 560;
}

.pill-tabs {
    display: inline-flex;
    padding: 6px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.06);
    gap: 4px;
}

.pill-tabs a {
    padding: 8px 16px;
    border-radius: 999px;
    font-weight: 560;
    text-decoration: none;
    color: var(--text-secondary);
}

.pill-tabs a.active {
    background: white;
    color: var(--accent);
    box-shadow: 0 10px 18px -12px rgba(37, 99, 235, 0.35);
}

.dropdown-stack {
    display: grid;
    gap: 18px;
}

details.menu-card {
    background: var(--surface);
    border-radius: var(--radius-large);
    border: 1px solid var(--border);
    padding: 0 26px 10px;
    backdrop-filter: blur(18px);
    box-shadow: 0 28px 48px -30px rgba(15, 23, 42, 0.28);
}

details.menu-card summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

details.menu-card[open] {
    padding-bottom: 24px;
}

details.menu-card summary::-webkit-details-marker {
    display: none;
}

.chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.08);
    font-size: 1.1rem;
    transition: transform 0.2s ease;
}

details[open] .chevron {
    transform: rotate(180deg);
}

.menu-actions {
    display: grid;
    gap: 12px;
    padding-top: 10px;
}

.menu-actions a,
.menu-actions button {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    padding: 16px 18px;
    font-size: 1rem;
    font-weight: 550;
    color: var(--text-primary);
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.menu-actions a:hover,
.menu-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 26px -24px rgba(15, 23, 42, 0.22);
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state strong {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.flash-messages {
    display: grid;
    gap: 16px;
}

.flash {
    border-radius: var(--radius-medium);
    padding: 14px 18px;
    font-weight: 540;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.flash-success {
    background: rgba(22, 163, 74, 0.12);
    color: var(--success);
    border-color: rgba(22, 163, 74, 0.25);
}

.flash-info {
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent);
    border-color: rgba(37, 99, 235, 0.25);
}

.flash-error {
    background: rgba(220, 38, 38, 0.12);
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.25);
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    background-color: rgba(15, 23, 42, 0.55);
    padding: 24px;
    z-index: 400;
}

.modal.open {
    display: flex;
}

.modal-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    padding: 28px;
    max-width: 640px;
    width: 100%;
    display: grid;
    gap: 18px;
    box-shadow: 0 36px 68px -28px rgba(15, 23, 42, 0.38);
}

.modal-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-card header h3 {
    margin: 0;
    font-size: 1.3rem;
}

/* Shared Preview / Print / Email modal (templates/_share_modal.html) */
.share-modal-card {
    max-width: min(480px, 100%);
}

.share-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.share-option-button {
    flex: 1 1 8rem;
    min-height: 44px;
}

.share-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.share-toggle input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.share-toggle label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 8rem;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    background: rgba(15, 23, 42, 0.03);
    font-size: 0.9rem;
    cursor: pointer;
}

.share-toggle input[type="radio"]:checked + label {
    border-color: var(--accent, #2563eb);
    background: rgba(37, 99, 235, 0.12);
    font-weight: 600;
}

.share-toggle input[type="radio"]:focus-visible + label {
    outline: 2px solid var(--accent, #2563eb);
    outline-offset: 2px;
}

.share-note {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.share-status {
    margin: 0;
    min-height: 1.2em;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.share-status-ok { color: #15803d; }
.share-status-error { color: var(--danger, #dc2626); }

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, 0.08);
    font-size: 1.4rem;
    cursor: pointer;
}

/* --- Main Navigation Bar --- */
.main-nav {
    display: flex;
    gap: 6px;
    padding: 6px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.05);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

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

.main-nav .nav-link {
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 560;
    font-size: 0.92rem;
    text-decoration: none;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.main-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-primary);
}

.main-nav .nav-link.active {
    background: white;
    color: var(--accent);
    box-shadow: 0 8px 16px -10px rgba(37, 99, 235, 0.3);
}

/* --- Converter search row (portal price check, iPhone-friendly) --- */
.cat-search-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.cat-search-row input {
    flex: 1 1 140px;
    min-width: 0;
}

@media (max-width: 480px) {
    .cat-search-row {
        flex-direction: column;
    }
    .cat-search-row input {
        flex: 1 1 auto;
        width: 100%;
    }
    .cat-search-row .button {
        width: 100%;
        min-height: 44px;
    }
}

/* --- Section Dashboard Shared Styles --- */
.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.section-card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: var(--radius-medium);
    padding: 22px;
}

.section-card h3 {
    margin: 0 0 14px;
    font-size: 1.1rem;
    font-weight: 700;
}

.quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.quick-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 16px;
    border-radius: var(--radius-small);
    background: rgba(15, 23, 42, 0.04);
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 540;
    font-size: 0.88rem;
    transition: background 0.2s;
}

.quick-links a:hover {
    background: rgba(37, 99, 235, 0.1);
}

/* --- Metrics Row (shared for section dashboards) --- */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.metric-widget {
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: var(--radius-medium);
    padding: 18px 16px;
    text-align: center;
}

.metric-widget .metric-num {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.metric-widget .metric-lbl {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

.metric-widget.green .metric-num { color: #16a34a; }
.metric-widget.red .metric-num   { color: #dc2626; }
.metric-widget.amber .metric-num { color: #d97706; }
.metric-widget.blue .metric-num  { color: #2563eb; }

/* --- Customize Modal Toggle Switches --- */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

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

.toggle-label {
    font-weight: 560;
    font-size: 0.95rem;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.15);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.25s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.25s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

@media (max-width: 840px) {
    .shell,
    .app-shell {
        padding: 32px 18px 44px;
    }

    .top-bar {
        position: relative;
        flex-direction: row;
        align-items: flex-start;
    }

    .title-stack {
        width: 100%;
        padding-right: 132px;
    }

    .title-stack h1 {
        max-width: 100%;
    }

    .nav-buttons {
        position: absolute;
        top: 0;
        right: 0;
        width: auto;
        justify-content: flex-end;
    }

    .page-title-brand {
        max-width: 100%;
        align-items: flex-start;
    }

    .page-title-logo {
        height: 58px;
        max-width: 66vw;
    }

    .main-nav {
        margin: -12px 0;
    }

    .button,
    .nav-button {
        padding: 12px 18px;
    }

    .metric-row {
        flex-direction: column;
    }

    .metric-card {
        min-width: unset;
        width: 100%;
    }

    .table-wrapper thead th,
    .table-shell thead th,
    th,
    td {
        padding: 12px 14px;
    }

    .menu-actions {
        grid-template-columns: 1fr;
    }

    .button,
    .nav-button,
    .actions .button,
    .actions-row .button {
        width: 100%;
    }

    .nav-buttons .button,
    .nav-buttons .nav-button {
        width: auto;
        min-height: 44px;
        padding: 10px 14px;
    }

    .page-title-text {
        min-width: 0;
        max-width: 100%;
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
        overflow-wrap: anywhere;
        line-height: 1.15;
    }

    .list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .metrics-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .section-grid {
        grid-template-columns: 1fr;
    }

    @media (max-width: 420px) {
        .title-stack {
            padding-right: 120px;
        }

        .page-title-logo {
            height: 52px;
            max-width: 78vw;
        }
    }
}

/* ── Filter Bar (shared across table pages) ── */
.filter-bar-toggle {
    display: none;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 20px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
    margin-bottom: 16px;
    align-items: flex-end;
}

.filter-bar .filter-fields {
    display: contents;
}

.filter-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 140px;
    min-width: 0;
}

.filter-bar .filter-group label {
    font-size: 0.78rem;
    font-weight: 620;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.filter-bar .filter-group input,
.filter-bar .filter-group select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    font-size: 16px;
    background: white;
    color: var(--text-primary);
    width: 100%;
    min-height: 44px;
}

.filter-bar .filter-group input:focus,
.filter-bar .filter-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.filter-bar .filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.filter-bar .filter-actions .btn-filter {
    padding: 9px 18px;
    border-radius: var(--radius-small);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    min-height: 44px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
    text-align: center;
}

.filter-bar .filter-actions .btn-filter-apply {
    background: var(--accent);
    color: white;
}

.filter-bar .filter-actions .btn-filter-apply:hover {
    background: #1d4ed8;
}

.filter-bar .filter-actions .btn-filter-clear {
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-secondary);
    border-color: var(--border);
}

.filter-bar .filter-actions .btn-filter-clear:hover {
    background: rgba(15, 23, 42, 0.10);
}

.filter-active-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(37, 99, 235, 0.10);
    color: var(--accent);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .filter-bar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 12px 16px;
        margin-bottom: 12px;
        background: var(--surface-strong);
        border: 1px solid var(--border);
        border-radius: var(--radius-medium);
        font-weight: 600;
        font-size: 0.92rem;
        color: var(--accent);
        cursor: pointer;
        min-height: 48px;
    }

    .filter-bar-toggle .filter-badge {
        background: var(--accent);
        color: white;
        font-size: 0.72rem;
        padding: 2px 7px;
        border-radius: 999px;
        font-weight: 700;
    }

    .filter-bar {
        padding: 12px;
        gap: 8px;
        border-radius: var(--radius-small);
    }

    .filter-bar:not(.filter-bar--open) .filter-fields,
    .filter-bar:not(.filter-bar--open) .filter-actions {
        display: none;
    }

    .filter-bar .filter-fields {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .filter-bar .filter-group {
        flex: 1 1 100%;
    }

    .filter-bar .filter-actions {
        width: 100%;
    }

    .filter-bar .filter-actions .btn-filter {
        flex: 1;
    }
}

