/* Core Reset & Variables */
:root {
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent: #3b82f6;
    --bg-main: #f1f5f9;
    --bg-white: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --bg-form-gray: #e9e9e9;
    --sidebar-width: 256px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

.icon {
    width: 1.25rem;
    height: 1.25rem;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: inline-block;
    margin: 0;
    padding: 0;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout Utilities */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-1 {
    flex: 1 1 0%;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.justify-around {
    justify-content: space-around;
}

.justify-end {
    justify-content: flex-end !important;
}

.h-screen {
    height: 100vh;
}

.h-full {
    height: 100%;
}

.h-20 {
    height: 5rem;
}

.h-16 {
    height: 4rem;
}

.h-10 {
    height: 2.5rem;
}

.h-8 {
    height: 2rem;
}

.w-full {
    width: 100%;
}

.w-10 {
    width: 2.5rem;
}

.w-12 {
    width: 3rem;
}

.w-8 {
    width: 2rem;
}

.w-px {
    width: 1px;
}

.overflow-hidden {
    overflow: hidden;
}

.overflow-y-auto {
    overflow-y: auto;
}

.overflow-x-auto {
    overflow-x: auto;
}

.max-h-400 {
    max-height: 400px;
}

.max-h-500 {
    max-height: 500px;
}

.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

.fixed {
    position: fixed;
}

.inset-0 {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.inset-y-0 {
    top: 0;
    bottom: 0;
}

.left-0 {
    left: 0;
}

.right-0 {
    right: 0;
}

.bottom-0 {
    bottom: 0;
}

.top-0 {
    top: 0;
}

.z-50 {
    z-index: 50;
}

.z-10 {
    z-index: 10;
}

/* Spacing */
.p-1 {
    padding: 0.25rem;
}

.p-2 {
    padding: 0.5rem;
}

.p-2\.5 {
    padding: 0.625rem;
}

.p-3 {
    padding: 0.75rem;
}

.p-4 {
    padding: 1rem;
}

.p-6 {
    padding: 1.5rem;
}

.p-8 {
    padding: 2rem;
}

.p-10 {
    padding: 2.5rem;
}

.pl-4 {
    padding-left: 1rem !important;
}

.pl-10 {
    padding-left: 2.5rem;
}

.px-2 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
}

.px-6 {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.px-8 {
    padding-left: 2rem;
    padding-right: 2rem;
}

.py-1 {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.py-2 {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.py-3 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.pl-3 {
    padding-left: 0.75rem;
}

.pb-0 {
    padding-bottom: 0 !important;
}

.pb-10 {
    padding-bottom: 2.5rem !important;
}

.pb-20 {
    padding-bottom: 5rem !important;
}

.pb-24 {
    padding-bottom: 6rem !important;
}

.pb-32 {
    padding-bottom: 8rem !important;
}

.m-0 {
    margin: 0;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.max-w-md {
    max-width: 28rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-10 {
    margin-bottom: 2.5rem;
}

.mb-12 {
    margin-bottom: 3rem;
}

.mr-2 {
    margin-right: 0.5rem;
}

.mr-2\.5 {
    margin-right: 0.625rem;
}

.mr-3 {
    margin-right: 0.75rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-8 {
    margin-top: 2rem;
}

.ml-4 {
    margin-left: 1rem;
}

.space-x-3>*+* {
    margin-left: 0.75rem;
}

.space-x-4>*+* {
    margin-left: 1rem;
}

.space-x-6>*+* {
    margin-left: 1.5rem;
}

.space-y-1>*+* {
    margin-top: 0.25rem !important;
}

.space-y-2>*+* {
    margin-top: 0.5rem !important;
}

.space-y-3>*+* {
    margin-top: 0.75rem !important;
}

.space-y-4>*+* {
    margin-top: 1rem !important;
}

.space-y-6>*+* {
    margin-top: 1.5rem !important;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

.gap-8 {
    gap: 2rem;
}

.gap-10 {
    gap: 2.5rem;
}

.gap-x-8 {
    column-gap: 2rem;
}

.gap-y-4 {
    row-gap: 1rem;
}

/* Grid */
.grid {
    display: grid;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .lg\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Colors */
.bg-gray-50 {
    background-color: var(--bg-main) !important;
}

.bg-white {
    background-color: var(--bg-white) !important;
}

.bg-form-gray {
    background-color: var(--bg-form-gray) !important;
}

.bg-white\/90 {
    background-color: rgba(255, 255, 255, 0.9);
}

.bg-red-50 {
    background-color: #fef2f2;
}

.bg-red-500 {
    background-color: #ef4444;
}

.bg-slate-900 {
    background-color: var(--primary);
}

.bg-slate-900\/50 {
    background-color: rgba(15, 23, 42, 0.5);
}

.bg-slate-800 {
    background-color: var(--primary-light);
}

.bg-slate-700 {
    background-color: #334155;
}

.bg-gray-200 {
    background-color: var(--border);
}

.bg-blue-50 {
    background-color: #eff6ff;
}

.bg-blue-600 {
    background-color: #2563eb !important;
}

.bg-indigo-600 {
    background-color: #4f46e5 !important;
}

.bg-violet-600 {
    background-color: #7c3aed !important;
}

.bg-emerald-600 {
    background-color: #059669 !important;
}

.bg-green-50 {
    background-color: #f0fdf4;
}

.bg-green-900 {
    background-color: #14532d !important;
}

.text-white {
    color: white !important;
}

.text-slate-400 {
    color: #94a3b8;
}

.text-slate-500 {
    color: var(--text-muted);
}

.text-slate-900 {
    color: var(--primary);
}

.text-gray-400 {
    color: #9ca3af;
}

.text-gray-500 {
    color: #6b7280;
}

.text-gray-600 {
    color: #4b5563;
}

.text-gray-700 {
    color: #374151;
}

.text-gray-900 {
    color: var(--text-main);
}

.text-red-500 {
    color: #ef4444;
}

.text-red-600 {
    color: #dc2626;
}

.text-blue-600 {
    color: #2563eb;
}

/* Typography */
.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-base {
    font-size: 1rem;
}

.text-lg {
    font-size: 1.125rem;
}

.text-xl {
    font-size: 1.25rem;
}

.text-2xl {
    font-size: 1.5rem;
}

.text-3xl {
    font-size: 1.875rem;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.tracking-tight {
    letter-spacing: -0.025em;
}

.tracking-wider {
    letter-spacing: 0.05em;
}

.uppercase {
    text-transform: uppercase;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-center {
    text-align: center;
}

/* Components */
.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}

.btn-primary:hover {
    background-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3);
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.3);
}

.btn-secondary {
    background-color: #f3f4f6;
    color: #374151;
}

.btn-secondary:hover {
    background-color: #e5e7eb;
    transform: translateY(-1px);
}

.rounded-lg {
    border-radius: 0.5rem;
}

.rounded-xl {
    border-radius: 0.75rem;
}

.rounded-2xl {
    border-radius: 1rem;
}

.rounded-3xl {
    border-radius: 1.5rem;
}

.max-w-sm {
    max-width: 24rem;
}

.pb-2 {
    padding-bottom: 0.5rem;
}

.pt-0 {
    padding-top: 0;
}

.gap-3 {
    gap: 0.75rem;
}

.leading-relaxed {
    line-height: 1.625;
}

.rounded-full {
    border-radius: 9999px;
}

.shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.shadow-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.shadow-xl {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.shadow-inner {
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
}

/* Form Styles */
input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    transition: all 0.2s;
    background-color: white;
    appearance: none;
}

input[type="checkbox"], input[type="radio"] {
    width: auto;
    padding: 0;
    margin: 0;
    appearance: auto;
    -webkit-appearance: auto;
    border: none;
    border-radius: 0;
    background-color: transparent;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.required {
    color: #ef4444;
    margin-left: 0.125rem;
}

.optional {
    font-size: 0.75rem;
    font-weight: normal;
    color: #94a3b8;
}

/* Sidebar & Navigation */
#sidebar {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.collapsed {
    width: 0;
    transform: translateX(-100%);
}

@media (min-width: 768px) {
    #sidebar {
        position: static;
        transform: none !important;
    }
}

.backdrop-blur-md {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Sidebar flat navigation */
.sidebar-section-label {
    padding: 1.25rem 1rem 0.375rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    border-top: 1px solid rgba(100, 116, 139, 0.2);
    margin-top: 0.25rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: normal;
    color: #94a3b8;
    text-decoration: none !important;
    transition: background-color 0.15s, color 0.15s;
    cursor: pointer;
}

.sidebar-item:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
}

.sidebar-item-active {
    background-color: #3b82f6 !important;
    color: #ffffff !important;
    font-weight: 600;
}

.sidebar-item .icon {
    flex-shrink: 0;
}

nav a, nav button {
    text-decoration: none !important;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.opacity-100 {
    opacity: 1 !important;
}

.opacity-0 {
    opacity: 0 !important;
}

@media (min-width: 768px) {
    .md\:block {
        display: block;
    }

    .md\:hidden {
        display: none;
    }

    .md\:static {
        position: static;
    }

    .md\:translate-x-0 {
        transform: translateX(0) !important;
    }

    .md\:-translate-x-full {
        transform: translateX(-100%) !important;
    }

    .md\:pb-10 {
        padding-bottom: 2.5rem;
    }
}

/* Specific Sidebar Hiding Utilities */
.-translate-x-full {
    transform: translateX(-100%) !important;
}

.translate-x-0 {
    transform: translateX(0) !important;
}

@media (min-width: 1024px) {
    .lg\:p-10 {
        padding: 2.5rem;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover\:bg-gray-50:hover {
    background-color: #f9fafb;
}

.hover\:bg-red-50:hover {
    background-color: #fef2f2;
}

.hover\:text-gray-600:hover {
    color: #4b5563;
}

.hover\:text-red-600:hover {
    color: #dc2626;
}

.transition-all {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.transition-colors {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.transition-transform {
    transition-property: transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.group:hover .group-hover\:translate-x-0\.5 {
    transform: translateX(0.125rem);
}

/* Bottom Nav Scroll & Modal */
#bottom-nav {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
}

#bottom-nav::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.bottom-nav-item {
    flex: 0 0 auto;
    min-width: 90px;
    padding: 0 1rem;
}

/* Mobile Sub-menu Modal (Bottom Sheet) */
#mobile-submenu-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: white;
    border-top-left-radius: 1.5rem;
    border-top-right-radius: 1.5rem;
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    padding-bottom: 2.5rem;
}

#mobile-submenu-modal.show {
    transform: translateY(0);
}

.mobile-submenu-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-submenu-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mobile-submenu-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    text-decoration: none !important;
    background-color: #f8fafc;
    color: var(--text-main);
    font-weight: 600;
    transition: all 0.2s;
}

.mobile-submenu-item:active {
    background-color: #f1f5f9;
    transform: scale(0.98);
}

.mobile-submenu-item .icon {
    margin-right: 1.25rem;
    color: var(--accent);
}

#mobile-modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

#mobile-modal-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

/* Data Tables */
.table-container {
    background: white;
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    background-color: #f8fafc;
    padding: 1rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s;
}

.data-table th:hover {
    background-color: #f1f5f9;
}

.data-table th .sort-icon {
    margin-left: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.3;
}

.data-table th.sort-asc .sort-icon,
.data-table th.sort-desc .sort-icon {
    opacity: 1;
    color: var(--accent);
}

.data-table td {
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background-color: #f9fafb;
}

/* Compact parts table inside modals - spreadsheet-like */
.modal .data-table th {
    padding: 0.25rem 0.35rem;
    font-size: 0.7rem;
}

.modal .data-table td {
    padding: 0.15rem 0.35rem;
    border-bottom: none;
}

.modal .data-table tr:hover td {
    background-color: transparent;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background-color: #dcfce7;
    color: #166534;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Table Actions */
.table-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    border: none;
    background-color: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background-color: #f1f5f9;
    color: var(--accent);
}

.action-btn.delete {
    color: #dc2626 !important;
    background-color: #fef2f2 !important;
    border: none !important;
}

.action-btn.delete:hover {
    background-color: #fee2e2 !important;
    color: #b91c1c !important;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background-color: white;
    border-top: 1px solid var(--border);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.pagination-controls {
    display: flex;
    gap: 0.25rem;
}

.page-btn {
    min-width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background-color: white;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

.page-btn.active {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-ellipsis {
    min-width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.page-size-select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
    width: 4rem;
}

/* ActionBar */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-container {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-container .icon.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    width: 1.1rem;
    height: 1.1rem;
}

.search-container input {
    padding-left: 2.75rem;
    padding-right: 2.75rem;
}

.search-container .clear-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0.25rem;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    /* Controlled by JS */
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    transition: all 0.2s;
}

.search-container .clear-btn:hover {
    background-color: #f1f5f9;
    color: var(--text-main);
}

.search-container .clear-btn .icon {
    width: 1rem;
    height: 1rem;
}

/* Form Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background-color: white;
    border-radius: 1rem;
    width: 100%;
    max-width: 40rem;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
    transition: transform 0.3s;
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.lg-modal {
    max-width: 60rem;
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.modal-close {
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Diesel Data-Capture Modal Overlay */
.tx-details-portal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9000 !important;
    display: none;
    background: rgba(15, 23, 42, 0.7) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 1.5rem !important;
}

.tx-details-portal-overlay.show {
    display: flex !important;
}

.tx-details-modal-box {
    width: 95%;
    max-width: 850px;
    max-height: 90vh;
    background: white;
    border-radius: 2rem;
    box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Grid Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .form-grid.cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-grid.cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-group label span.required {
    color: #ef4444;
    margin-left: 0.25rem;
}

/* Toggle Switch - Reduced Size */
.switch {
    position: relative;
    display: inline-block;
    width: 2.5rem;
    height: 1.25rem;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 1.25rem;
}

.slider:before {
    position: absolute;
    content: "";
    height: 0.85rem;
    width: 0.85rem;
    left: 0.2rem;
    bottom: 0.2rem;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(1.25rem);
}

/* Field Helpers */
.read-only {
    background-color: #f8fafc;
    cursor: not-allowed;
}

.input-error {
    border-color: #ef4444 !important;
}

.error-message {
    font-size: 0.75rem;
    color: #ef4444;
}

/* Autocomplete/Search-as-you-type Styles */
.autocomplete-container {
    position: relative;
}

.autocomplete-item.selected {
    background: #f1f5f9;
}

/* Import Modal Steps */
.step-item {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.step-item.active {
    color: white;
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

.step-line {
    height: 2px;
    flex-grow: 1;
    max-width: 50px;
    background: var(--border);
}

.import-step {
    min-height: 300px;
}

.db-field-slot {
    background: white;
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.db-field-slot.mapped {
    border-color: #22c55e;
    background: #f0fdf4;
}

.file-col-tag {
    background: #f8fafc;
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
}

.file-col-tag:active {
    cursor: grabbing;
}

.file-col-tag.mapped {
    border-color: #22c55e;
    background: #f0fdf4;
    color: #166534;
}

.mapping-target {
    min-width: 120px;
    height: 32px;
    border: 2px dashed var(--border);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.mapping-target.drag-over {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

.preview-cell-error {
    background-color: #fef2f2 !important;
    color: #ef4444 !important;
    position: relative;
}

.preview-cell-error::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid #fee2e2;
    pointer-events: none;
}


.form-group-compact {
    margin-bottom: 1rem;
}

.form-group-compact label {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    display: block;
}

.form-group-compact input {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

#import-preview-table {
    min-width: 1500px;
    table-layout: auto !important;
}

#import-step-3 .table-container {
    overflow: auto !important;
    display: block;
    width: 100%;
}

#import-preview-table {
    table-layout: auto !important;
}

#import-preview-table th,
#import-preview-table td {
    white-space: nowrap !important;
}

.import-drop-zone {
    border: 3px dashed #cbd5e1;
    background-color: #f8fafc;
    border-radius: 1.5rem;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.import-drop-zone:hover, .import-drop-zone.border-blue-500 {
    border-color: #3b82f6;
    background-color: #eff6ff;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.import-drop-zone .icon {
    color: #94a3b8;
    transition: color 0.3s ease;
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
}

.import-drop-zone:hover .icon, .import-drop-zone.border-blue-500 .icon {
    color: #3b82f6;
}

.edit-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--accent);
    border-radius: 0.5rem;
    outline: none;
    font-size: 0.875rem;
    font-family: inherit;
    background-color: white;
}

.edit-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Supplemental Utilities for Inset Layout */
.shadow-2xl {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.m-2 {
    margin: 0.5rem;
}

@media (min-width: 768px) {
    .md\:m-3 {
        margin: 0.75rem;
    }

    .md\:rounded-\[2rem\] {
        border-radius: 2rem;
    }
}

/* Dynamic Table Resizing & Sticky Headers */
.page-flex-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 0.75rem;
}

.table-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Important for flex child overflow */
}

.table-wrapper {
    flex: 1;
    overflow-y: auto;
    position: relative;
    overflow-anchor: none;
}

.sticky-header th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: white !important;
    box-shadow: 0 1px 0 var(--border-color);
}


/* Modal & Overlay Utilities */
.z-100 {
    z-index: 100;
}

.bg-overlay {
    background-color: rgba(15, 23, 42, 0.4);
}

.backdrop-blur-sm {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.duration-200 {
    transition-duration: 200ms;
}

.scale-95 {
    transform: scale(0.95);
}

.scale-100 {
    transform: scale(1);
}

/* Validation Styles */
.pr-10 {
    padding-right: 2.5rem !important;
}

.validation-icon-container {
    position: absolute !important;
    right: 0.75rem !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 30 !important;
    cursor: help;
    height: 100%;
}

.validation-tooltip {
    position: absolute;
    bottom: 110%;
    right: -10px;
    width: 180px;
    padding: 8px 12px;
    background-color: #1e293b;
    color: #ffffff;
    font-size: 11px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    text-align: center;
    line-height: 1.4;
    font-weight: 500;
    z-index: 50;
}

.validation-icon-container:hover .validation-tooltip {
    opacity: 1;
    visibility: visible;
    bottom: 125%;
}

.validation-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    border-width: 6px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    background-color: #ffffff;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    min-width: 320px;
    border-left: 4px solid #10b981;
    transform: translateX(3rem);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success {
    border-left-color: #10b981;
}

.toast-error {
    border-left-color: #ef4444;
}

.toast-warning {
    border-left-color: #f59e0b;
}

.toast-icon-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 9999px;
    flex-shrink: 0;
}

.toast-success .toast-icon-dot {
    background-color: #10b981;
}

.toast-error .toast-icon-dot {
    background-color: #ef4444;
}

.toast-warning .toast-icon-dot {
    background-color: #f59e0b;
}

.toast-message {
    color: #334155;
    font-weight: 600;
    font-size: 0.875rem;
    flex: 1;
}

.toast-close {
    color: #cbd5e1;
    cursor: pointer;
    transition: color 0.2s;
    background: none;
    border: none;
    padding: 0.25rem;
    display: flex;
}

.toast-close:hover {
    color: #64748b;
}

/* Autocomplete Dropdowns */
.autocomplete-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    background: white;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 0.75rem 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    overflow-y: auto;
}

.autocomplete-results.show {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f1f5f9;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background-color: #f1f5f9;
}

/* Hide Spin Buttons */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}

/* Tab Styling */
.tabs-border-bottom {
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 0.25rem;
}

.tabs-flex {
    display: flex;
    gap: 2rem;
    padding: 0 1rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 1rem 0;
    font-weight: 700;
    font-size: 1.1rem;
    color: #64748b;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    box-shadow: none !important;
}

.tab-btn:hover {
    color: #2563eb;
}

.tab-btn.active {
    color: #2563eb;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #2563eb;
}

.tab-content.hidden {
    display: none;
}

/* Typeahead Dropdown */
.typeahead-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    margin-top: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 99999 !important;
}

.typeahead-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--border);
}

.typeahead-item:last-child {
    border-bottom: none;
}

.typeahead-item:hover {
    background-color: var(--bg-main);
}

/* Toggle Switch */
.toggle-checkbox {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-color: #64748b !important;
    width: 3rem !important;
    height: 1.5rem !important;
    border-radius: 9999px !important;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
    flex-shrink: 0 !important;
    box-sizing: border-box;
    border: 2px solid #475569 !important;
    display: inline-block !important;
    outline: none !important;
}

.toggle-checkbox:checked {
    background-color: var(--accent) !important;
    border-color: var(--accent) !important;
}

.toggle-checkbox::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: calc(1.5rem - 6px) !important;
    height: calc(1.5rem - 6px) !important;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.toggle-checkbox:checked::after {
    transform: translateX(1.5rem);
}

/* Toggle Switch (label + span pattern) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 3rem;
    height: 1.75rem;
}

.toggle-switch input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 9999px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 1.25rem;
    width: 1.25rem;
    left: 0.25rem;
    bottom: 0.25rem;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background-color: #3b82f6;
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(1.25rem);
}

.toggle-switch input:focus+.toggle-slider {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}


/* Column spanning utilities */
.col-span-3 {
    grid-column: 1 / -1;
}

/* Amber validation colors */
.bg-amber-50 {
    background-color: #fffbeb !important;
}

.bg-amber-600 {
    background-color: #d97706 !important;
}

.border-amber-500 {
    border-color: #f59e0b !important;
}

.text-amber-500 {
    color: #f59e0b;
}

/* Input validation styles with higher specificity */
input.border-amber-500 {
    border-color: #f59e0b !important;
}

input.bg-amber-50 {
    background-color: #fffbeb !important;
}

input.border-amber-500:focus {
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.1) !important;
}

.icon-fill {
    fill: currentColor !important;
    stroke: none !important;
}

#refresh-transactions {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    height: 44px !important;
}

/* Additional Utility Classes */
.whitespace-nowrap {
    white-space: nowrap;
}

.ml-2 {
    margin-left: 0.5rem;
}

.pr-3 {
    padding-right: 0.75rem;
}

.border-gray-200 {
    border-color: #e5e7eb;
}

.w-40 {
    width: 10rem;
}

.gap-2 {
    gap: 0.5rem;
}

.text-left {
    text-align: left;
}

.duration-150 {
    transition-duration: 150ms;
}

/* Avatar Dropdown Menu */
.avatar-btn {
    cursor: pointer;
    transition: opacity 0.2s, box-shadow 0.2s;
}

.avatar-btn:hover {
    opacity: 0.85;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.avatar-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 14rem;
    background-color: white;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 4px 10px -3px rgba(0, 0, 0, 0.08);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px) scale(0.97);
    transition: opacity 0.18s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.375rem;
}

.avatar-dropdown.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.avatar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: none;
    background: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s;
}

.avatar-dropdown-item:hover {
    background-color: #f1f5f9;
}

.avatar-dropdown-item--danger {
    color: #dc2626;
}

.avatar-dropdown-item--danger:hover {
    background-color: #fef2f2;
}

.avatar-dropdown-divider {
    height: 1px;
    background-color: var(--border);
    margin: 0.25rem 0;
}

/* Screen reader only - accessible text hidden visually */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Small button variant */
.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1.25rem;
}

/* Active navigation link */
.active-link {
    background-color: var(--primary);
    color: white;
}

/* Form utility classes */
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.form-input,
.form-control {
    width: 100%;
    padding: 0.3rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-main);
    color: var(--text-main);
    transition: border-color 0.15s ease;
}

.form-input:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-select {
    width: 100%;
    padding: 0.3rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-main);
    color: var(--text-main);
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Custom scrollbar */
.custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 3px;
}

/* Period selector buttons for report filters */
.period-btn {
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.period-btn:hover {
    background: var(--bg-hover);
}

.period-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Statistic cards for dashboards and reports */
.stat-card {
    background: var(--bg-main);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
}

/* ── Bulk Dispensing Spreadsheet Grid ── */
.bd-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.bd-th {
    background: #f8fafc;
    padding: 0.5rem 0.375rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
    border: 1px solid #e2e8f0;
    text-align: center;
    white-space: nowrap;
    user-select: none;
}

.bd-cell {
    padding: 0;
    border: 1px solid #e2e8f0;
    font-size: 0.8125rem;
    height: 32px;
    vertical-align: middle;
    position: relative;
}

.bd-cell-text {
    padding: 0.25rem 0.375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bd-cell-actions {
    text-align: center;
    white-space: nowrap;
    width: 50px;
}

.bd-row:hover .bd-cell {
    background: #f8fafc;
}

.bd-row-editing {
    outline: 2px solid #3b82f6;
    outline-offset: -1px;
    border-radius: 0.375rem;
    z-index: 1;
    position: relative;
}

/* Detail / Edit modal field layout (shared across query and capture pages) */
.ea-core-info {
    background: #f1f5f9;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.ea-core-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.ea-core-field {
    display: flex;
    flex-direction: column;
}

.ea-core-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ea-core-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e293b;
}

.ea-section-header {
    font-size: 0.8rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1rem 0 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #e2e8f0;
}

.ea-section-header:first-child {
    margin-top: 0;
}

.ea-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    align-items: start;
}

.ea-toggle-field {
    display: flex;
    flex-direction: column;
}

.ea-toggle-field .form-label {
    margin-bottom: 0.5rem;
}

.ea-toggle-label {
    display: flex;
    align-items: center;
    height: 2.75rem;
    cursor: pointer;
}

@media (max-width: 640px) {
    .ea-grid, .ea-core-row {
        grid-template-columns: 1fr;
    }
}

.bd-row-editing .bd-cell {
    background: #eff6ff;
}

.bd-row-new .bd-cell {
    background: #ecfdf5;
}

.bd-input {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    padding: 0.25rem 0.375rem;
    font-size: 0.8125rem;
    background: transparent;
    font-family: inherit;
    box-sizing: border-box;
}

.bd-input:focus {
    background: white;
    box-shadow: inset 0 0 0 2px #3b82f6;
}

.bd-input-readonly {
    background: #f8fafc;
    color: #64748b;
    cursor: not-allowed;
}

.bd-bold {
    font-weight: 700;
}

.bd-cell-warning {
    background: #fffbeb !important;
    box-shadow: inset 0 0 0 1px #f59e0b;
}

.bd-cell-warning .bd-input {
    background: #fffbeb;
    color: #92400e;
}

.bd-cell-warning .bd-input:focus {
    background: #fffbeb;
    box-shadow: inset 0 0 0 2px #f59e0b;
}

.bd-cell-error,
.bd-cell-danger {
    background: #fef2f2 !important;
    box-shadow: inset 0 0 0 1px #ef4444;
}

.bd-cell-danger .bd-input {
    background: #fef2f2;
    color: #991b1b;
}

/* ── Trip Sheet Route Pills ───────────────────────────────────────── */
.ts-route-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    min-height: 28px;
    padding: 2px;
}

.ts-route-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    max-width: 180px;
}

.ts-route-pill-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-route-pill-remove {
    background: none;
    border: none;
    color: #6366f1;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 2px;
    line-height: 1;
}

.ts-route-pill-remove:hover {
    color: #dc2626;
}

.ts-route-pill-error {
    background: #fef2f2;
    color: #991b1b;
    box-shadow: inset 0 0 0 1px #ef4444;
}

.ts-edit-row {
    background: #f8fafc;
}

.ts-edit-row .bd-cell {
    padding: 2px 4px;
}

.ts-route-input {
    border: none;
    outline: none;
    font-size: 0.75rem;
    min-width: 70px;
    flex: 1;
    background: transparent;
}

/* ── Query page tabs ──────────────────────────────────────────────── */
.qt-tab {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    transition: all 0.15s ease;
}

.qt-tab:hover {
    color: var(--text-main, #1e293b);
}

.qt-tab.active {
    color: var(--accent, #3b82f6);
    border-bottom-color: var(--accent, #3b82f6);
}

.bd-cell-error .bd-input {
    background: #fef2f2;
    color: #991b1b;
}

.bd-cell-error .bd-input:focus {
    background: #fef2f2;
    box-shadow: inset 0 0 0 2px #ef4444;
}

.bd-warning-tooltip {
    position: fixed;
    z-index: 9999;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid #fbbf24;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    white-space: nowrap;
    pointer-events: none;
    display: none;
}

.bd-warning-tooltip.show {
    display: block;
}

.bd-cell-view-warning {
    background: #fef3c7;
    color: #92400e;
    font-weight: 700;
}

.bd-cell-external {
    background: #fef3c7;
    color: #92400e;
    font-style: italic;
}

.bd-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 0.375rem;
    border: 1px solid #e2e8f0;
    background: white;
    cursor: pointer;
    color: #64748b;
    transition: all 0.15s;
    margin: 0 1px;
}

.bd-action-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.bd-action-btn.bd-save:hover {
    color: #16a34a;
    border-color: #16a34a;
}

.bd-action-btn.bd-cancel:hover {
    color: #dc2626;
    border-color: #dc2626;
}

.bd-action-btn.bd-comment-active {
    color: #1d4ed8;
    border-color: #1d4ed8;
    background: #eff6ff;
}

.bd-cell-zero-odo {
    background: #fee2e2 !important;
}

.bd-actions-trigger.has-comment {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

.bd-actions-trigger.has-comment:hover {
    background: #fecaca;
}

/* Actions dropdown menu */
.bd-actions-menu {
    position: relative;
    display: inline-block;
}

.bd-actions-trigger {
    font-size: 1rem;
}

.bd-actions-dropdown {
    display: none;
    position: fixed;
    min-width: 160px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 4px 0;
}

.bd-actions-dropdown.open {
    display: block;
}

.bd-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.8rem;
    color: #334155;
    white-space: nowrap;
    transition: background 0.1s;
}

.bd-dropdown-item:hover {
    background: #f1f5f9;
}

.bd-dropdown-item.bd-comment-active {
    color: #1d4ed8;
    font-weight: 600;
}

.bd-dropdown-danger {
    color: #dc2626;
}

.bd-dropdown-danger:hover {
    background: #fef2f2;
}

.bd-dropdown-divider {
    height: 1px;
    margin: 4px 0;
    background: #e2e8f0;
}

.bd-autocomplete {
    position: fixed;
    z-index: 9999;
    background: #fffbeb;
    border: 2px solid #f59e0b;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    display: none;
    min-width: 200px;
}

.bd-autocomplete.show {
    display: block;
}

.bd-autocomplete-item {
    padding: 0.5rem 0.625rem;
    cursor: pointer;
    border-bottom: 1px solid #fde68a;
    font-size: 0.8125rem;
}

.bd-autocomplete-item:hover {
    background: #fef3c7;
}

.bd-autocomplete-item:last-child {
    border-bottom: none;
}

/* ── Offline Status Indicator ── */
.offline-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
    user-select: none;
}

.offline-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.offline-status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.offline-status-dot.offline {
    background: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    animation: pulse-red 2s ease-in-out infinite;
}

@keyframes pulse-red {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.3);
    }
}

.offline-status-text {
    color: #475569;
}

.offline-pending-count {
    background: #fef3c7;
    color: #92400e;
    padding: 1px 8px;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 700;
}

.offline-pending-count.hidden {
    display: none;
}

/* Offline-queued row indicator */
.bd-row-offline .bd-cell {
    background: #fffbeb;
    border-left: 2px solid #f59e0b;
}

/* ─── Capture (fav-card) shared styles ─── */
.fav-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.fav-section-header .fav-section-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fav-section-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
}

.fav-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.fav-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 640px) {
    .fav-row, .fav-row-3 {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .fav-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

.fav-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem 1rem;
    background: white;
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    text-decoration: none;
    color: #1e293b;
    transition: all 0.15s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    text-align: center;
    cursor: pointer;
}

.fav-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: #93c5fd;
    transform: translateY(-2px);
}

.fav-card .fav-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fav-card .fav-label {
    font-size: 0.875rem;
    font-weight: 700;
}

.fav-card .fav-desc {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 0.125rem;
}