/* =============================================================================
   ProduceTrace Tenant Portal — "Ocean Professional" Theme
   Blazor WASM + Bootstrap 5.3.3 Override Layer
   ============================================================================= */

/* Wide-table top scrollbar — paired with the JS in index.html. Every
   .table-responsive that overflows horizontally gets a thin native
   scrollbar inserted above it that mirrors the bottom one. Sticks to
   the top edge of the table so it stays visible while the operator
   reads the column headers. */
.top-scrollbar-bar {
    overflow-x: auto;
    overflow-y: hidden;
    /* Slim by default; the operator sees the table headers right
       below, not 14px of empty space. */
    height: 12px;
    margin-bottom: 2px;
}
.top-scrollbar-inner {
    height: 1px; /* just enough so the bar renders a usable thumb */
}
/* Match the wider, trackpad-friendly scrollbar style we use elsewhere. */
.top-scrollbar-bar::-webkit-scrollbar { height: 12px; }
.top-scrollbar-bar::-webkit-scrollbar-thumb {
    background: rgba(13, 148, 136, 0.4);
    border-radius: 6px;
}
.top-scrollbar-bar::-webkit-scrollbar-thumb:hover {
    background: rgba(13, 148, 136, 0.6);
}
.top-scrollbar-bar::-webkit-scrollbar-track { background: transparent; }


/* ---------------------------------------------------------------------------
   1. Design Tokens (CSS Custom Properties)
   --------------------------------------------------------------------------- */
:root {
    /* Sidebar */
    --pt-sidebar-bg: #0f172a;
    --pt-sidebar-hover: rgba(255,255,255,0.06);
    --pt-sidebar-active: rgba(13,148,136,0.15);
    --pt-sidebar-accent: #0d9488;
    --pt-sidebar-text: rgba(255,255,255,0.65);
    --pt-sidebar-text-active: #ffffff;
    --pt-sidebar-section: rgba(255,255,255,0.35);

    /* Brand / Primary */
    --pt-primary: #0d9488;
    --pt-primary-hover: #0f766e;
    --pt-primary-light: rgba(13,148,136,0.1);

    /* Surfaces */
    --pt-bg: #f8fafc;
    --pt-card-bg: #ffffff;

    /* Text */
    --pt-text: #1e293b;
    --pt-text-muted: #64748b;

    /* Borders & Elevation */
    --pt-border: #e2e8f0;
    --pt-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --pt-shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.03);
    --pt-shadow-lg: 0 10px 25px rgba(0,0,0,0.08);

    /* Semantic */
    --pt-success: #10b981;
    --pt-warning: #f59e0b;
    --pt-danger: #ef4444;
    --pt-info: #3b82f6;

    /* Radii */
    --pt-radius: 12px;
    --pt-radius-sm: 8px;

    /* Motion */
    --pt-transition: 200ms ease;

    /* Layout Dimensions */
    --sidebar-width: 260px;
    --topbar-height: 60px;
}

/* ---------------------------------------------------------------------------
   2. Base / Reset
   --------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------------------------------------------------------------------------
   3. Typography
   --------------------------------------------------------------------------- */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    font-size: 0.9375rem;
    color: var(--pt-text);
    background: var(--pt-bg);
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--pt-text);
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }
h5 { font-size: 0.95rem; }
h6 { font-size: 0.85rem; }

.text-muted {
    color: var(--pt-text-muted) !important;
}

/* ---------------------------------------------------------------------------
   4. App Layout Shell
   --------------------------------------------------------------------------- */
.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
    background: var(--pt-bg);
    min-width: 0;
}

.page-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem 2rem;
}

/* ---------------------------------------------------------------------------
   5. Sidebar
   --------------------------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--pt-sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    /* Outer sidebar no longer scrolls — scope scroll to .sidebar-nav-area
       so the brand stays pinned at the top and the footer (Sign Out)
       stays pinned at the bottom regardless of how many nav items render. */
    overflow: hidden;
    z-index: 100;
}

/* Nav area is the scrollable region inside the sidebar. min-height:0 is
   required so it can shrink in the flex column; without it, the flex
   item refuses to give up space and the scroll never engages. */
.sidebar-nav-area {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--pt-sidebar-accent);
}

.sidebar-brand span {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #fff;
}

.sidebar-version {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 500;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
    padding: 0.1em 0.5em;
    border-radius: 4px;
    margin-left: 0.35rem;
    vertical-align: middle;
    letter-spacing: 0.03em;
}

.nav-section-header {
    text-transform: uppercase;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--pt-sidebar-section);
    padding: 0.5rem 1.25rem 0.35rem;
    margin-top: 1rem;
    user-select: none;
}

.sidebar .nav-link {
    color: var(--pt-sidebar-text);
    padding: 0.55rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    border-left: 3px solid transparent;
    transition: all var(--pt-transition);
    position: relative;
    white-space: nowrap;
}

.sidebar .nav-link:hover {
    color: rgba(255,255,255,0.9);
    background: var(--pt-sidebar-hover);
}

.sidebar .nav-link.active {
    color: var(--pt-sidebar-text-active);
    background: var(--pt-sidebar-active);
    border-left-color: var(--pt-sidebar-accent);
    font-weight: 600;
}

.sidebar .nav-link i {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.nav-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.45);
    padding: 0.15em 0.55em;
    border-radius: 4px;
    margin-left: auto;
}

.sidebar-footer {
    /* flex-shrink:0 keeps the footer at its natural height — without it
       the footer can collapse to zero when the nav area runs out of room. */
    flex-shrink: 0;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ---------------------------------------------------------------------------
   6. Topbar
   --------------------------------------------------------------------------- */
.topbar {
    height: var(--topbar-height);
    background: var(--pt-card-bg, #fff);
    border-bottom: 1px solid var(--pt-border, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    flex-shrink: 0;
    z-index: 1060;
    position: relative;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--pt-text);
}

.topbar-breadcrumb {
    font-size: 0.8rem;
    color: var(--pt-text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-notification {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--pt-text-muted);
    cursor: pointer;
    transition: background var(--pt-transition);
    font-size: 1.1rem;
}

.topbar-notification:hover {
    background: var(--pt-bg);
    color: var(--pt-text);
}

.topbar-notification .notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--pt-danger);
    border-radius: 50%;
    border: 2px solid #fff;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--pt-radius-sm);
    transition: background var(--pt-transition);
}

.topbar-user:hover {
    background: var(--pt-bg);
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.topbar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--pt-text);
}

.topbar-user-role {
    font-size: 0.7rem;
    color: var(--pt-text-muted);
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--pt-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
   7. Cards
   --------------------------------------------------------------------------- */
.card {
    background: var(--pt-card-bg);
    border: 1px solid var(--pt-border);
    border-radius: var(--pt-radius);
    box-shadow: var(--pt-shadow);
    transition: box-shadow var(--pt-transition);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--pt-border);
    font-weight: 600;
    padding: 1rem 1.25rem;
    font-size: 0.95rem;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: #fff;
    border-top: 1px solid var(--pt-border);
    padding: 0.75rem 1.25rem;
}

/* ---------------------------------------------------------------------------
   8. Stat Cards
   --------------------------------------------------------------------------- */
.stat-card {
    border-left: 4px solid var(--pt-border);
    border-radius: var(--pt-radius);
    background: var(--pt-card-bg);
    box-shadow: var(--pt-shadow);
    padding: 1.25rem;
    transition: box-shadow var(--pt-transition), transform var(--pt-transition);
}

.stat-card:hover {
    box-shadow: var(--pt-shadow-md);
    transform: translateY(-1px);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--pt-text);
    line-height: 1.2;
}

.stat-card-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pt-text-muted);
    font-weight: 500;
}

.stat-card-change {
    font-size: 0.75rem;
    font-weight: 600;
}

/* Stat Card Color Variants (left border style) */
.stat-card-teal  { border-left-color: var(--pt-primary); }
.stat-card-teal  .stat-card-icon { background: rgba(13,148,136,0.1);  color: #0d9488; }
.stat-card-emerald  { border-left-color: #10b981; }
.stat-card-emerald  .stat-card-icon { background: rgba(16,185,129,0.1); color: #10b981; }
.stat-card-amber  { border-left-color: #f59e0b; }
.stat-card-amber  .stat-card-icon { background: rgba(245,158,11,0.1); color: #f59e0b; }
.stat-card-rose  { border-left-color: #ef4444; }
.stat-card-rose  .stat-card-icon { background: rgba(239,68,68,0.1);  color: #ef4444; }
.stat-card-blue  { border-left-color: #3b82f6; }
.stat-card-blue  .stat-card-icon { background: rgba(59,130,246,0.1); color: #3b82f6; }
.stat-card-purple  { border-left-color: #8b5cf6; }
.stat-card-purple  .stat-card-icon { background: rgba(139,92,246,0.1); color: #8b5cf6; }

/* ── Premium Gradient Dashboard Cards ── */
.dash-card {
    border: none;
    border-radius: 16px;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.dash-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.12);
}
.dash-card::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    pointer-events: none;
}
.dash-card::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -15%;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    pointer-events: none;
}
.dash-card .card-body { position: relative; z-index: 1; }
.dash-card .dash-icon {
    width: 52px; height: 52px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.2);
    font-size: 1.3rem;
    backdrop-filter: blur(4px);
}
.dash-card .dash-value { font-size: 1.85rem; font-weight: 700; line-height: 1.1; }
.dash-card .dash-label { font-size: 0.78rem; font-weight: 500; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.04em; }
.dash-card .dash-sub { font-size: 0.72rem; opacity: 0.7; }

.dash-card-teal    { background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%); }
.dash-card-emerald { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.dash-card-blue    { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }
.dash-card-amber   { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.dash-card-purple  { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); }
.dash-card-rose    { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.dash-card-slate   { background: linear-gradient(135deg, #475569 0%, #334155 100%); }

/* Trend badge on dashboard cards */
.dash-trend {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(255,255,255,0.2);
}

.stat-card-change {
    font-size: 0.7rem;
    font-weight: 500;
}

/* ── Dashboard Chart Cards ── */
.chart-card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    overflow: hidden;
}
.chart-card .card-header {
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
    padding: 1rem 1.25rem;
}
.chart-card .card-header h6 {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1e293b;
}

/* ── Dashboard Quick Action Cards ── */
.quick-action-card {
    border: none;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    cursor: pointer;
}
.quick-action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}
.quick-action-icon {
    width: 52px; height: 52px; border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}

/* ── Activity Feed ── */
.activity-feed-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
}
.activity-feed-item:last-child {
    border-bottom: none;
}
.activity-feed-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
   9. Tables
   --------------------------------------------------------------------------- */
.table-wrapper {
    border-radius: var(--pt-radius);
    overflow: hidden;
    border: 1px solid var(--pt-border);
    background: var(--pt-card-bg);
}

.table-wrapper .table {
    margin: 0;
}

.table thead th {
    background: #f8fafc;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    color: var(--pt-text-muted);
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--pt-border);
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    font-size: 0.875rem;
    border-color: var(--pt-border);
    color: var(--pt-text);
}

.table-hover tbody tr:hover {
    background: rgba(13,148,136,0.03);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(248,250,252,0.5);
}

/* ---------------------------------------------------------------------------
   10. Modals
   --------------------------------------------------------------------------- */
/* Fix Blazor inline modals AND Bootstrap JS modals inside overflow:hidden layout */
/* z-index ladder: sidebar(100) < topbar(1060) < backdrop(1065) < modal(1070) */
.modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1065 !important;
}

.modal.show,
.modal.d-block {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1070 !important;
    overflow-x: hidden;
    overflow-y: auto;
}

.modal.show .modal-dialog,
.modal.d-block .modal-dialog {
    margin: 1.75rem auto !important;
    max-height: calc(100vh - 3.5rem);
}

.modal-content {
    border-radius: var(--pt-radius);
    border: none;
    box-shadow: var(--pt-shadow-lg);
    overflow: hidden;
}

.modal-header {
    border-bottom: 1px solid var(--pt-border);
    padding: 1rem 1.25rem;
    background: #fff;
}

.modal-title {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--pt-text);
}

.modal-body {
    padding: 1.25rem;
    /* Default modal bodies get a cap + always-visible scrollbar so a stiff
       trackpad has something to grab. Long forms can override max-height
       inline. Tall pages already scroll inside .modal-dialog itself, but
       this also covers Blazor inline modals that nest a tall body. */
    max-height: 75vh;
    overflow-y: auto;
}

.modal-footer {
    border-top: 1px solid var(--pt-border);
    padding: 0.75rem 1.25rem;
    background: #fff;
    /* Pin the footer outside the modal-body scroll so Save / Print / Close
       stay visible regardless of how far the body has scrolled. */
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 2;
}

.modal-backdrop {
    background: rgba(15,23,42,0.4);
}

.modal-backdrop.show {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ---------------------------------------------------------------------------
   11. Forms
   --------------------------------------------------------------------------- */
.form-control {
    border-radius: var(--pt-radius-sm);
    border-color: var(--pt-border);
    transition: border-color var(--pt-transition), box-shadow var(--pt-transition);
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
    color: var(--pt-text);
}

.form-control:focus {
    border-color: var(--pt-primary);
    box-shadow: 0 0 0 3px var(--pt-primary-light);
}

.form-control::placeholder {
    color: #94a3b8;
}

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--pt-text);
    margin-bottom: 0.35rem;
}

.form-select {
    border-radius: var(--pt-radius-sm);
    border-color: var(--pt-border);
    transition: border-color var(--pt-transition), box-shadow var(--pt-transition);
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
    color: var(--pt-text);
}

.form-select:focus {
    border-color: var(--pt-primary);
    box-shadow: 0 0 0 3px var(--pt-primary-light);
}

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

.input-group-text {
    background: #f8fafc;
    border-color: var(--pt-border);
    font-size: 0.875rem;
    color: var(--pt-text-muted);
}

.form-check-input:checked {
    background-color: var(--pt-primary);
    border-color: var(--pt-primary);
}

.form-check-input:focus {
    border-color: var(--pt-primary);
    box-shadow: 0 0 0 3px var(--pt-primary-light);
}

.form-switch .form-check-input:checked {
    background-color: var(--pt-primary);
    border-color: var(--pt-primary);
}

/* Validation States */
.valid.modified:not([type=checkbox]) {
    outline: none;
    border-color: var(--pt-success);
}

.invalid {
    outline: none;
    border-color: var(--pt-danger) !important;
}

.validation-message {
    color: var(--pt-danger);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* ---------------------------------------------------------------------------
   12. Buttons
   --------------------------------------------------------------------------- */
.btn {
    border-radius: var(--pt-radius-sm);
    font-weight: 500;
    transition: all var(--pt-transition);
    font-size: 0.875rem;
    padding: 0.45rem 1rem;
}

.btn-primary {
    background-color: var(--pt-primary) !important;
    border-color: var(--pt-primary) !important;
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--pt-primary-hover) !important;
    border-color: var(--pt-primary-hover) !important;
    box-shadow: 0 2px 8px rgba(13,148,136,0.3);
    color: #fff;
}

.btn-primary:active {
    background-color: var(--pt-primary-hover) !important;
    border-color: var(--pt-primary-hover) !important;
}

.btn-outline-primary {
    color: var(--pt-primary) !important;
    border-color: var(--pt-primary) !important;
    background: transparent;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background-color: var(--pt-primary) !important;
    border-color: var(--pt-primary) !important;
    color: #fff !important;
}

.btn-success {
    background-color: var(--pt-success) !important;
    border-color: var(--pt-success) !important;
}

.btn-success:hover {
    background-color: #059669 !important;
    border-color: #059669 !important;
    box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

.btn-danger {
    background-color: var(--pt-danger) !important;
    border-color: var(--pt-danger) !important;
}

.btn-danger:hover {
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
    box-shadow: 0 2px 8px rgba(239,68,68,0.3);
}

.btn-warning {
    background-color: var(--pt-warning) !important;
    border-color: var(--pt-warning) !important;
    color: #fff;
}

.btn-warning:hover {
    background-color: #d97706 !important;
    border-color: #d97706 !important;
    color: #fff;
}

.btn-outline-secondary {
    color: var(--pt-text-muted);
    border-color: var(--pt-border);
}

.btn-outline-secondary:hover {
    background: var(--pt-bg);
    border-color: var(--pt-border);
    color: var(--pt-text);
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.6rem 1.5rem;
    font-size: 1rem;
    border-radius: var(--pt-radius);
}

/* ---------------------------------------------------------------------------
   13. Badges
   --------------------------------------------------------------------------- */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    border-radius: 6px;
    padding: 0.3em 0.65em;
}

.badge-soft-success {
    background: rgba(16,185,129,0.1) !important;
    color: #059669 !important;
}

.badge-soft-warning {
    background: rgba(245,158,11,0.1) !important;
    color: #d97706 !important;
}

.badge-soft-danger {
    background: rgba(239,68,68,0.1) !important;
    color: #dc2626 !important;
}

.badge-soft-info {
    background: rgba(59,130,246,0.1) !important;
    color: #2563eb !important;
}

.badge-soft-primary {
    background: var(--pt-primary-light) !important;
    color: var(--pt-primary) !important;
}

.badge-soft-secondary {
    background: rgba(108,117,125,0.1) !important;
    color: #495057 !important;
}

.bg-success {
    background-color: var(--pt-success) !important;
}

.bg-warning {
    background-color: var(--pt-warning) !important;
}

.bg-danger {
    background-color: var(--pt-danger) !important;
}

.bg-info {
    background-color: var(--pt-info) !important;
}

/* ---------------------------------------------------------------------------
   14a. Settings Page — Compact Elegant
   --------------------------------------------------------------------------- */
.settings-page {
    max-width: 960px;
}

.settings-hero {
    padding: 1rem 1.25rem;
    background: var(--pt-card-bg);
    border-radius: var(--pt-radius-sm);
    box-shadow: var(--pt-shadow);
    border: 1px solid var(--pt-border);
}

.settings-hero-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--pt-primary-light);
    color: var(--pt-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

/* Section labels */
.settings-section {
    margin-bottom: 0.15rem;
}

.settings-section-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--pt-text-muted);
    margin-bottom: 0.5rem;
    padding-left: 2px;
}

.settings-section-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Setting cards — compact */
.settings-card {
    position: relative;
    background: var(--pt-card-bg);
    border: 1px solid var(--pt-border);
    border-radius: var(--pt-radius-sm);
    padding: 0.75rem 0.85rem;
    cursor: pointer;
    transition: all 0.18s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

.settings-card::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--pt-primary);
    border-radius: 2px;
    transition: width 0.2s ease;
}

.settings-card:hover {
    border-color: rgba(13,148,136,0.25);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    transform: translateY(-2px);
}

.settings-card:hover::before {
    width: 40%;
}

.settings-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    margin-bottom: 0.5rem;
}

.settings-card-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--pt-text);
    margin-bottom: 0.1rem;
    line-height: 1.3;
}

.settings-card-desc {
    font-size: 0.67rem;
    color: var(--pt-text-muted);
    line-height: 1.35;
}

/* Theme card */
.settings-card-theme {
    cursor: default;
}

.settings-card-theme:hover::before {
    background: var(--pt-warning);
}

.theme-switcher {
    display: flex;
    gap: 0.25rem;
}

.theme-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 0.78rem;
    border-radius: 6px;
    border: 1px solid var(--pt-border);
    background: transparent;
    color: var(--pt-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.theme-pill:hover {
    border-color: var(--pt-primary);
    color: var(--pt-primary);
}

.theme-pill.active {
    background: var(--pt-primary);
    border-color: var(--pt-primary);
    color: #fff;
}

/* ---------------------------------------------------------------------------
   14. Alerts
   --------------------------------------------------------------------------- */
.alert {
    border-radius: var(--pt-radius-sm);
    border: 1px solid transparent;
    border-left: 4px solid transparent;
    font-size: 0.875rem;
    padding: 0.85rem 1.1rem;
}

.alert-success {
    background: rgba(16,185,129,0.08);
    border-left-color: var(--pt-success);
    color: #065f46;
}

.alert-danger {
    background: rgba(239,68,68,0.08);
    border-left-color: var(--pt-danger);
    color: #991b1b;
}

.alert-warning {
    background: rgba(245,158,11,0.08);
    border-left-color: var(--pt-warning);
    color: #92400e;
}

.alert-info {
    background: rgba(59,130,246,0.08);
    border-left-color: var(--pt-info);
    color: #1e40af;
}

/* ---------------------------------------------------------------------------
   15. Tabs
   --------------------------------------------------------------------------- */
.nav-tabs {
    border-bottom: 2px solid var(--pt-border);
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.65rem 1.25rem;
    font-weight: 500;
    color: var(--pt-text-muted);
    margin-bottom: -2px;
    transition: color var(--pt-transition), border-color var(--pt-transition);
    font-size: 0.875rem;
}

.nav-tabs .nav-link.active {
    color: var(--pt-primary);
    border-bottom-color: var(--pt-primary);
    font-weight: 600;
    background: transparent;
}

.nav-tabs .nav-link:hover:not(.active) {
    color: var(--pt-text);
    border-bottom-color: var(--pt-border);
    background: transparent;
}

.tab-content {
    padding-top: 1.25rem;
}

/* ---------------------------------------------------------------------------
   16. Pagination
   --------------------------------------------------------------------------- */
.pagination {
    gap: 2px;
}

.page-link {
    border-radius: var(--pt-radius-sm);
    margin: 0 2px;
    border-color: var(--pt-border);
    color: var(--pt-text);
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
    transition: all var(--pt-transition);
}

.page-link:hover {
    background: var(--pt-bg);
    border-color: var(--pt-border);
    color: var(--pt-primary);
}

.page-item.active .page-link {
    background-color: var(--pt-primary);
    border-color: var(--pt-primary);
    color: #fff;
}

.page-item.disabled .page-link {
    color: #cbd5e1;
    background: transparent;
}

/* ---------------------------------------------------------------------------
   17. Loading & Skeleton States
   --------------------------------------------------------------------------- */
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--pt-radius-sm);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.spinner-border {
    color: var(--pt-primary);
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--pt-radius);
}

/* ---------------------------------------------------------------------------
   18. Login Page
   --------------------------------------------------------------------------- */
.login-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.login-brand-panel {
    flex: 0 0 55%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem;
    background: linear-gradient(135deg, #0f172a 0%, #134e4a 50%, #0d9488 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.login-brand-panel::before {
    content: '';
    position: absolute;
    top: -120px;
    right: -120px;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(255,255,255,0.03);
    pointer-events: none;
}

.login-brand-panel::after {
    content: '';
    position: absolute;
    bottom: -80px;
    left: -80px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    pointer-events: none;
}

.login-brand-panel h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
    position: relative;
    z-index: 1;
}

.login-brand-panel .tagline {
    font-size: 1.1rem;
    opacity: 0.85;
    margin-top: 0.5rem;
    position: relative;
    z-index: 1;
    font-weight: 400;
}

.login-features {
    list-style: none;
    padding: 0;
    margin-top: 2rem;
    position: relative;
    z-index: 1;
}

.login-features li {
    padding: 0.5rem 0;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    font-size: 0.95rem;
    opacity: 0.9;
}

.login-features li i {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.12);
    border-radius: 8px;
    font-size: 0.8rem;
    flex-shrink: 0;
    margin-top: 0.05rem;
}

.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    padding: 3rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.login-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.login-card .login-subtitle {
    color: var(--pt-text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.75rem;
}

.login-card .btn-primary {
    width: 100%;
    padding: 0.6rem;
    font-size: 0.95rem;
    font-weight: 600;
}

@media (max-width: 768px) {
    .login-brand-panel {
        display: none;
    }
    .login-form-panel {
        flex: 1;
        padding: 2rem 1.5rem;
    }
}

/* ---------------------------------------------------------------------------
   Tablet fix (Aug 2026): tables with Actions columns were getting clipped
   on Android tablets because .page-content is overflow-x:hidden. Wrap every
   table in the page area so it scrolls horizontally on tablet/phone widths,
   surfacing the right-side action buttons via a swipe.
   Also use dvh (dynamic viewport height) so the mobile browser chrome
   showing/hiding doesn't clip the bottom of the app.
   --------------------------------------------------------------------------- */
@media (max-width: 1440px) {
    .app-wrapper {
        height: 100dvh;
    }
    .page-content {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Every card body auto-scrolls horizontally so wide tables (Lanes,
       Cases, etc.) never chop their right-side Action columns off. Using
       card-body as the wrapper preserves table layout — display:block on
       <table> breaks row rendering in some browsers, but overflow on a
       block-level ancestor works everywhere. */
    .page-content .card-body {
        overflow-x: auto;
    }
    .page-content .table {
        min-width: max-content;
    }
}

/* ---------------------------------------------------------------------------
   19. Coming Soon Placeholder
   --------------------------------------------------------------------------- */
.coming-soon {
    text-align: center;
    padding: 4rem 2rem;
}

.coming-soon-icon {
    font-size: 4rem;
    color: var(--pt-text-muted);
    opacity: 0.3;
}

.coming-soon-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1rem;
    color: var(--pt-text);
}

.coming-soon-text {
    color: var(--pt-text-muted);
    max-width: 400px;
    margin: 0.5rem auto 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ---------------------------------------------------------------------------
   20. Custom Scrollbar
   --------------------------------------------------------------------------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Sidebar scrollbar override */
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.25);
}

/* ---------------------------------------------------------------------------
   21. Label Designer
   --------------------------------------------------------------------------- */
.label-designer {
    display: flex;
    gap: 1rem;
    height: calc(100vh - 170px);
    min-height: 500px;
}
.label-designer-left {
    width: 360px;
    min-width: 320px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    padding-right: 0.25rem;
}
.label-designer-left::-webkit-scrollbar { width: 5px; }
.label-designer-left::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.label-designer-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: repeating-conic-gradient(#f1f5f9 0% 25%, #fff 0% 50%) 50% / 20px 20px;
    border-radius: var(--pt-radius);
    border: 1px solid var(--pt-border);
    overflow: auto;
    position: relative;
}
.label-designer-right canvas {
    box-shadow: 0 6px 32px rgba(0,0,0,0.15);
    border-radius: 4px;
    max-width: 100%;
}
.label-preview-info {
    position: absolute;
    bottom: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(4px);
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    font-size: 0.72rem;
    color: var(--pt-text-muted);
    border: 1px solid var(--pt-border);
}
/* Palette */
.label-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.label-palette-chip {
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    border: 1px solid var(--pt-border);
    background: #fff;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}
.label-palette-chip:hover {
    background: var(--pt-primary);
    color: #fff;
    border-color: var(--pt-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(var(--pt-primary-rgb, 52,152,219), 0.3);
}
.label-palette-chip.disabled {
    opacity: 0.35;
    pointer-events: none;
    text-decoration: line-through;
}
/* Field List */
.label-field-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.label-field-item {
    background: #fff;
    border: 1px solid var(--pt-border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.label-field-item:hover {
    border-color: var(--pt-primary);
}
.label-field-item .field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    user-select: none;
    background: #fafbfc;
    border-bottom: 1px solid transparent;
}
.label-field-item.expanded .field-header {
    border-bottom-color: var(--pt-border);
}
.label-field-item .field-header .field-name {
    font-weight: 600;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.label-field-item .field-header .field-name .field-type-badge {
    font-size: 0.62rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: #e2e8f0;
    color: #64748b;
    font-weight: 500;
}
.label-field-item .field-body {
    display: none;
    padding: 0.5rem 0.6rem;
}
.label-field-item.expanded .field-body {
    display: block;
}
.label-field-item .field-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 0.35rem;
    align-items: end;
}
.label-field-item .field-controls .control-group {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.label-field-item .field-controls .control-group.span-2 {
    grid-column: span 2;
}
.label-field-item .field-controls .control-group.span-4 {
    grid-column: span 4;
}
.label-field-item .field-controls input[type="number"],
.label-field-item .field-controls input[type="text"] {
    width: 100%;
    padding: 0.2rem 0.35rem;
    font-size: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    text-align: center;
}
.label-field-item .field-controls input:focus {
    border-color: var(--pt-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--pt-primary-rgb, 52,152,219), 0.15);
}
.label-field-item .field-controls label {
    font-size: 0.62rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0;
    font-weight: 600;
}
.field-style-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid #f1f5f9;
}
.field-style-row .btn-style {
    padding: 0.15rem 0.5rem;
    font-size: 0.72rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.1s;
}
.field-style-row .btn-style.active {
    background: var(--pt-primary);
    color: #fff;
    border-color: var(--pt-primary);
}
.field-style-row .btn-style:hover:not(.active) {
    background: #f1f5f9;
}
.field-size-input {
    width: 48px !important;
    text-align: center;
}

/* ---------------------------------------------------------------------------
   22. Animations & Utilities
   --------------------------------------------------------------------------- */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Bootstrap Utility Overrides */
.text-primary {
    color: var(--pt-primary) !important;
}

.bg-primary {
    background-color: var(--pt-primary) !important;
}

.border-primary {
    border-color: var(--pt-primary) !important;
}

.link-primary {
    color: var(--pt-primary) !important;
}

.link-primary:hover {
    color: var(--pt-primary-hover) !important;
}

/* Dropdown overrides */
.dropdown-menu {
    border-radius: var(--pt-radius-sm);
    border-color: var(--pt-border);
    box-shadow: var(--pt-shadow-md);
    padding: 0.35rem;
    font-size: 0.875rem;
}

.dropdown-item {
    border-radius: 6px;
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    transition: background var(--pt-transition);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--pt-bg);
    color: var(--pt-text);
}

.dropdown-item.active,
.dropdown-item:active {
    background: var(--pt-primary-light);
    color: var(--pt-primary);
}

.dropdown-divider {
    border-color: var(--pt-border);
    margin: 0.25rem 0;
}

/* Tooltip override */
.tooltip-inner {
    background: var(--pt-text);
    border-radius: 6px;
    font-size: 0.8rem;
    padding: 0.35rem 0.65rem;
    font-family: 'Inter', sans-serif;
}

/* Progress bar overrides */
.progress {
    border-radius: var(--pt-radius-sm);
    background: var(--pt-bg);
    height: 6px;
}

.progress-bar {
    background-color: var(--pt-primary);
    border-radius: var(--pt-radius-sm);
}

/* Breadcrumb */
.breadcrumb {
    margin-bottom: 0;
    font-size: 0;
    background: none;
    padding: 0;
    flex-wrap: nowrap;
    align-items: center;
}

.breadcrumb-item {
    font-size: 0.8rem;
    letter-spacing: 0.01em;
}

.breadcrumb-item + .breadcrumb-item {
    padding-left: 0.5rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/" !important;
    font-family: inherit !important;
    font-size: 0.75rem;
    font-weight: 300;
    color: var(--pt-text-muted);
    opacity: 0.5;
    padding-right: 0.5rem;
    float: none;
}

.breadcrumb-item a {
    color: var(--pt-text-muted);
    text-decoration: none;
    transition: all 0.15s ease;
    padding: 0.2rem 0.45rem;
    border-radius: var(--pt-radius-sm, 4px);
    font-weight: 400;
}

.breadcrumb-item a:hover {
    color: var(--pt-primary);
    background: rgba(13,148,136,0.06);
}

.breadcrumb-item:first-child a {
    padding: 0.25rem 0.4rem;
    display: inline-flex;
    align-items: center;
}

.breadcrumb-item a i.bi-house-door {
    font-size: 0.85rem;
    line-height: 1;
}

.breadcrumb-item.active {
    color: var(--pt-text);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* List group */
.list-group-item {
    border-color: var(--pt-border);
    padding: 0.75rem 1.1rem;
    font-size: 0.875rem;
}

.list-group-item.active {
    background-color: var(--pt-primary);
    border-color: var(--pt-primary);
}

/* Offcanvas */
.offcanvas {
    border-color: var(--pt-border);
}

.offcanvas-header {
    border-bottom: 1px solid var(--pt-border);
    padding: 1rem 1.25rem;
}

.offcanvas-title {
    font-weight: 600;
    font-size: 1.05rem;
}

/* Popover */
.popover {
    border-radius: var(--pt-radius-sm);
    border-color: var(--pt-border);
    box-shadow: var(--pt-shadow-md);
}

/* ---------------------------------------------------------------------------
   22. Dark Theme
   --------------------------------------------------------------------------- */
[data-theme="dark"] {
    /* Surfaces */
    --pt-bg: #0f172a;
    --pt-card-bg: #1e293b;

    /* Text */
    --pt-text: #e2e8f0;
    --pt-text-muted: #94a3b8;

    /* Borders & Elevation */
    --pt-border: #334155;
    --pt-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --pt-shadow-md: 0 4px 6px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.15);
    --pt-shadow-lg: 0 10px 25px rgba(0,0,0,0.4);

    /* Primary adjustments for dark bg */
    --pt-primary-light: rgba(13,148,136,0.2);

    /* Sidebar — slightly darker than main bg */
    --pt-sidebar-bg: #0a0f1c;
}

/* Topbar */
[data-theme="dark"] .topbar {
    background: #1e293b;
    border-bottom-color: rgba(255,255,255,0.08);
}

[data-theme="dark"] .breadcrumb-item a:hover {
    background: rgba(13,148,136,0.12);
}

/* Card header/footer */
[data-theme="dark"] .card-header,
[data-theme="dark"] .card-footer {
    background: #1e293b;
}

/* Modal */
[data-theme="dark"] .modal-content {
    background: #1e293b;
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    background: #1e293b;
}

/* Tables */
[data-theme="dark"] .table thead th {
    background: #1a2332;
}

[data-theme="dark"] .table-hover tbody tr:hover {
    background: rgba(13,148,136,0.08);
}

[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(15,23,42,0.5);
}

/* Forms */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: #0f172a;
    color: #e2e8f0;
}

[data-theme="dark"] .form-control::placeholder {
    color: #64748b;
}

[data-theme="dark"] .input-group-text {
    background: #0f172a;
    color: #94a3b8;
}

/* Notification dot border */
[data-theme="dark"] .topbar-notification .notification-dot {
    border-color: #1e293b;
}

/* Loading overlay */
[data-theme="dark"] .loading-overlay {
    background: rgba(15,23,42,0.7);
}

/* Skeleton */
[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #334155 25%, #475569 50%, #334155 75%);
    background-size: 200% 100%;
}

/* Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #475569;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Alerts — darken backgrounds */
[data-theme="dark"] .alert-success {
    background: rgba(16,185,129,0.15);
    color: #6ee7b7;
}

[data-theme="dark"] .alert-danger {
    background: rgba(239,68,68,0.15);
    color: #fca5a5;
}

[data-theme="dark"] .alert-warning {
    background: rgba(245,158,11,0.15);
    color: #fcd34d;
}

[data-theme="dark"] .alert-info {
    background: rgba(59,130,246,0.15);
    color: #93c5fd;
}

/* Badges — soft variants in dark mode */
[data-theme="dark"] .badge-soft-success {
    background: rgba(16,185,129,0.2) !important;
    color: #6ee7b7 !important;
}

[data-theme="dark"] .badge-soft-warning {
    background: rgba(245,158,11,0.2) !important;
    color: #fcd34d !important;
}

[data-theme="dark"] .badge-soft-danger {
    background: rgba(239,68,68,0.2) !important;
    color: #fca5a5 !important;
}

[data-theme="dark"] .badge-soft-info {
    background: rgba(59,130,246,0.2) !important;
    color: #93c5fd !important;
}

[data-theme="dark"] .badge-soft-secondary {
    background: rgba(148,163,184,0.2) !important;
    color: #cbd5e1 !important;
}

/* Pagination disabled */
[data-theme="dark"] .page-item.disabled .page-link {
    color: #475569;
}

/* Dropdown */
[data-theme="dark"] .dropdown-menu {
    background: #1e293b;
}

[data-theme="dark"] .dropdown-item {
    color: #e2e8f0;
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background: #0f172a;
}

/* Offcanvas */
[data-theme="dark"] .offcanvas {
    background: #1e293b;
}

/* List group */
[data-theme="dark"] .list-group-item {
    background: #1e293b;
    color: #e2e8f0;
}

/* Popover */
[data-theme="dark"] .popover {
    background: #1e293b;
}

/* Login form panel */
[data-theme="dark"] .login-form-panel {
    background: #1e293b;
}

/* Settings page dark mode */
[data-theme="dark"] .settings-hero {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .settings-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .settings-card:hover {
    border-color: transparent;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2);
}

[data-theme="dark"] .settings-card-icon {
    background: rgba(255,255,255,0.06) !important;
}

[data-theme="dark"] .theme-pill {
    border-color: #475569;
    color: rgba(255,255,255,0.55);
}

[data-theme="dark"] .theme-pill:hover {
    border-color: var(--pt-primary);
    color: var(--pt-primary);
}

[data-theme="dark"] .theme-pill.active {
    background: var(--pt-primary);
    border-color: var(--pt-primary);
    color: #fff;
}

/* Accordion */
[data-theme="dark"] .accordion-item {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .accordion-button {
    background: #1e293b;
    color: #e2e8f0;
}

[data-theme="dark"] .accordion-button:not(.collapsed) {
    background: #0f172a;
    color: var(--pt-primary);
}

/* Button outline secondary in dark */
[data-theme="dark"] .btn-outline-secondary {
    color: #cbd5e1;
    border-color: #475569;
}

[data-theme="dark"] .btn-outline-secondary:hover {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}

/* Form check in dark */
[data-theme="dark"] .form-check-input {
    background-color: #0f172a;
    border-color: #475569;
}

/* (Theme toggle styles moved into settings-card section 14a) */

/* ---------------------------------------------------------------------------
   23. Blazor Infrastructure
   --------------------------------------------------------------------------- */
#blazor-error-ui {
    display: none;
}

/* Blazor reconnection UI */
#components-reconnect-modal {
    z-index: 10000;
}

/* ---------------------------------------------------------------------------
   24. Print Styles
   --------------------------------------------------------------------------- */
@media print {
    .sidebar,
    .topbar,
    .no-print {
        display: none !important;
    }
    .main-area {
        margin: 0;
    }
    .page-content {
        padding: 0;
    }
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ---------------------------------------------------------------------------
   25. Button Loading States — system-wide disabled/busy visual feedback
   --------------------------------------------------------------------------- */

/* Any button with disabled attribute shows reduced opacity and no-pointer */
button:disabled,
button[disabled] {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* Spinner sizing helpers for small icon buttons */
.spinner-btn-sm {
    width: 12px;
    height: 12px;
    border-width: 2px;
}

.spinner-btn-md {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

/* ---------------------------------------------------------------------------
   26. Searchable Select — Select2-style searchable dropdown component
   --------------------------------------------------------------------------- */

.ss-container {
    position: relative;
    width: 100%;
}

.ss-input {
    cursor: pointer;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    padding-right: 2rem !important;
}

.ss-container.ss-open .ss-input {
    cursor: text;
    border-color: var(--pt-primary, #0d9488);
    box-shadow: 0 0 0 0.2rem rgba(13, 148, 136, 0.15);
}

.ss-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1080;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    max-height: 220px;
    overflow-y: auto;
    margin-top: 2px;
    padding: 4px 0;
}

.ss-item {
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.8125rem;
    transition: background 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ss-item:hover,
.ss-item.ss-hl {
    background: rgba(13, 148, 136, 0.08);
}

.ss-item.ss-active {
    background: var(--pt-primary, #0d9488);
    color: #fff;
    font-weight: 500;
}

.ss-item.ss-active.ss-hl {
    background: var(--pt-primary-hover, #0f766e);
    color: #fff;
}

.ss-item.ss-none {
    color: #94a3b8;
    font-style: italic;
    cursor: default;
    text-align: center;
    padding: 12px;
}

.ss-item.ss-none:hover {
    background: transparent;
}

.ss-match {
    color: var(--pt-primary, #0d9488);
    font-weight: 600;
}

.ss-item.ss-active .ss-match {
    color: #fff;
}

/* Scrollbar styling for dropdown */
.ss-dropdown::-webkit-scrollbar {
    width: 6px;
}

.ss-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.ss-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.ss-dropdown::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Dark mode support */
[data-theme="dark"] .ss-dropdown {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .ss-item:hover,
[data-theme="dark"] .ss-item.ss-hl {
    background: rgba(13, 148, 136, 0.15);
}

[data-theme="dark"] .ss-item.ss-none {
    color: #64748b;
}

/* Ensure dropdown appears above modals */
.modal .ss-dropdown {
    z-index: 1090;
}

/* ---------------------------------------------------------------------------
   UI polish utilities (2026-04-22)
   Consistency helpers: page headers, action buttons, empty states.
   --------------------------------------------------------------------------- */

/* Page header block: icon + title + subtitle + (optional) primary action */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.page-header__main {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    min-width: 0;
}

.page-header__icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(13, 148, 136, 0.12);
    color: var(--pt-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex: 0 0 42px;
}

.page-header__title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    color: var(--pt-text);
}

.page-header__subtitle {
    font-size: 0.8rem;
    color: var(--pt-text-muted);
    margin-top: 0.15rem;
    display: block;
}

.page-header__actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

@media (max-width: 576px) {
    .page-header__icon { display: none; }
    .page-header__title { font-size: 1.15rem; }
}

/* Unified icon-only action button for table rows (edit/delete/print/etc.) */
.action-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    border: 1px solid transparent;
    background: #f1f5f9;
    color: var(--pt-text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

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

.action-btn + .action-btn {
    margin-left: 4px;
}

.action-btn--view    { background: #eff6ff; color: #2563eb; }
.action-btn--view:hover    { background: #dbeafe; }
.action-btn--edit    { background: #ecfdf5; color: #059669; }
.action-btn--edit:hover    { background: #d1fae5; }
.action-btn--print   { background: #fff7ed; color: #d97706; }
.action-btn--print:hover   { background: #ffedd5; }
.action-btn--danger  { background: #fef2f2; color: #dc2626; }
.action-btn--danger:hover  { background: #fee2e2; }
.action-btn--neutral { background: #f8fafc; color: #475569; border-color: var(--pt-border); }
.action-btn--neutral:hover { background: #e2e8f0; }

/* Empty state: centered icon + message + action in a card body */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state__icon {
    font-size: 3.25rem;
    color: #cbd5e1;
    line-height: 1;
    margin-bottom: 0.85rem;
    display: inline-block;
}

.empty-state__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--pt-text);
    margin: 0 0 0.25rem;
}

.empty-state__message {
    color: var(--pt-text-muted);
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
}

/* Loading state matching empty-state dimensions so they don't jump the layout */
.loading-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.loading-state__spinner {
    width: 2.25rem;
    height: 2.25rem;
    border-width: 3px;
}

.loading-state__message {
    color: var(--pt-text-muted);
    margin: 0.75rem 0 0;
    font-size: 0.9rem;
}

/* Dark mode tweaks */
[data-theme="dark"] .page-header__icon {
    background: rgba(13, 148, 136, 0.2);
}

[data-theme="dark"] .action-btn {
    background: #1e293b;
    color: #94a3b8;
}
[data-theme="dark"] .action-btn--view    { background: rgba(37, 99, 235, 0.15); color: #60a5fa; }
[data-theme="dark"] .action-btn--edit    { background: rgba(5, 150, 105, 0.15); color: #34d399; }
[data-theme="dark"] .action-btn--print   { background: rgba(217, 119, 6, 0.15); color: #fbbf24; }
[data-theme="dark"] .action-btn--danger  { background: rgba(220, 38, 38, 0.15); color: #f87171; }
[data-theme="dark"] .action-btn--neutral { background: #0f172a; color: #94a3b8; }

[data-theme="dark"] .empty-state__icon { color: #475569; }

/* ---------------------------------------------------------------------------
   N. Row-action toolbar — compact buttons that stay on a single row
   --------------------------------------------------------------------------- */
/* Wrap a list-row's action buttons in `<div class="row-actions">…</div>` to
   keep them on one horizontal line with reduced text size. Overflow scrolls
   horizontally on narrow screens instead of wrapping. */
.row-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: center;
    white-space: nowrap;
    overflow-x: auto;
    max-width: 100%;
}
.row-actions .btn,
.row-actions .btn-sm {
    font-size: 0.72rem;
    padding: 0.18rem 0.45rem;
    line-height: 1.2;
    border-radius: 6px;
    flex: 0 0 auto;
}
.row-actions .btn i.bi { font-size: 0.78rem; }
.row-actions .btn .bi + span,
.row-actions .btn span + .bi { margin-left: 2px; }
/* Tighten the auto-applied "me-1" spacing inside compact buttons */
.row-actions .btn .me-1 { margin-right: 2px !important; }

/* ---------------------------------------------------------------------------
   N. Always-visible, trackpad-friendly scrollbars
   Added 2026-05-28. Morgan's training laptops have stiff trackpads that
   make momentum-scroll hard to land. Force wider, always-visible
   scrollbars on modal bodies, page content, and key scroll regions so
   the user has a chunky thumb to grab with the mouse pointer.
   Scoped to elements that actually scroll — don't pollute every <div>.
   --------------------------------------------------------------------------- */

.modal-body,
.page-content,
.sidebar-nav-area,
.table-responsive {
    /* Firefox */
    scrollbar-width: auto;
    scrollbar-color: rgba(100, 116, 139, 0.55) rgba(15, 23, 42, 0.06);
}

/* WebKit / Chromium / Edge — explicit pixel width because Bootstrap's
   default ~6px thumb is too thin for trackpad grabbing. */
.modal-body::-webkit-scrollbar,
.page-content::-webkit-scrollbar,
.sidebar-nav-area::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

.modal-body::-webkit-scrollbar-track,
.page-content::-webkit-scrollbar-track,
.sidebar-nav-area::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.06);
    border-radius: 7px;
}

.modal-body::-webkit-scrollbar-thumb,
.page-content::-webkit-scrollbar-thumb,
.sidebar-nav-area::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.55);
    border-radius: 7px;
    border: 3px solid transparent;
    background-clip: content-box;
    min-height: 40px;
}

.modal-body::-webkit-scrollbar-thumb:hover,
.page-content::-webkit-scrollbar-thumb:hover,
.sidebar-nav-area::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: rgba(71, 85, 105, 0.85);
    background-clip: content-box;
    border: 3px solid transparent;
}

/* Sidebar nav inverts the palette (dark background) — give it a
   light-on-dark thumb for visibility. */
.sidebar-nav-area::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}
.sidebar-nav-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    background-clip: content-box;
}
.sidebar-nav-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
    background-clip: content-box;
}
