/* ==========================================================================
   KR Motors — Admin Design System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --sidebar-width: 272px;
    --topbar-height: 68px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Brand palette */
    --primary: #0f2744;
    --primary-light: #1a3a5c;
    --primary-mid: #1e4976;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --accent-glow: rgba(245, 158, 11, 0.25);

    /* Surfaces */
    --bg: #f0f2f7;
    --bg-subtle: #e8ebf2;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --border: #e2e8f0;
    --border-light: #eef1f6;

    /* Text */
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15, 39, 68, 0.04);
    --shadow-sm: 0 2px 8px rgba(15, 39, 68, 0.06);
    --shadow-md: 0 4px 20px rgba(15, 39, 68, 0.08);
    --shadow-lg: 0 8px 40px rgba(15, 39, 68, 0.12);
    --shadow-card: 0 1px 3px rgba(15, 39, 68, 0.04), 0 4px 16px rgba(15, 39, 68, 0.06);

    /* Sidebar */
    --sidebar-bg: linear-gradient(180deg, #0f2744 0%, #0a1c32 100%);
    --sidebar-text: rgba(255, 255, 255, 0.72);
    --sidebar-text-active: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(245, 158, 11, 0.12);

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9375rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Login Page
   ========================================================================== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 80%, rgba(245, 158, 11, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 90% 20%, rgba(30, 73, 118, 0.4) 0%, transparent 50%);
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.login-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    padding: 1.5rem;
}

.login-card {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    overflow: hidden;
}

.login-brand {
    text-align: center;
    padding: 2.5rem 2rem 0;
}

.login-brand-icon {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    box-shadow: 0 8px 24px rgba(15, 39, 68, 0.25);
}

.login-brand-icon i {
    font-size: 2rem;
    color: var(--accent);
}

.login-brand h4 {
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.login-card .form-control {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    padding: 0.625rem 0.875rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.login-card .form-control:focus {
    border-color: var(--primary-mid);
    box-shadow: 0 0 0 3px rgba(30, 73, 118, 0.12);
}

.login-card .btn-primary {
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(15, 39, 68, 0.25);
    transition: transform var(--transition), box-shadow var(--transition);
}

.login-card .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(15, 39, 68, 0.3);
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-mid) 100%);
}

.login-card .card-footer {
    background: var(--bg);
    border-top: 1px solid var(--border-light);
}

.login-card .input-group-text {
    border-color: var(--border);
    color: var(--text-light);
}

.login-card .input-group .form-control {
    border-color: var(--border);
}

.login-card .input-group:focus-within .input-group-text,
.login-card .input-group:focus-within .form-control {
    border-color: var(--primary-mid);
}

.login-card .input-group:focus-within {
    box-shadow: 0 0 0 3px rgba(30, 73, 118, 0.12);
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Admin Layout
   ========================================================================== */

.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-sidebar::-webkit-scrollbar {
    width: 4px;
}

.admin-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

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

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: rgba(245, 158, 11, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.sidebar-brand-text {
    min-width: 0;
}

.sidebar-brand-text strong {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-brand-text small {
    display: block;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

.sidebar-nav {
    padding: 0.75rem 0 1rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.nav-section {
    padding: 1.25rem 1.25rem 0.4rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.35);
    font-weight: 600;
}

.nav-group + .nav-group {
    margin-top: 0.35rem;
    padding-top: 0.15rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-group .nav-section {
    padding-top: 0.85rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    margin: 2px 0.75rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    position: relative;
}

.nav-link i {
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
    opacity: 0.85;
}

.nav-link:hover {
    color: var(--sidebar-text-active);
    background: var(--sidebar-hover);
}

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

.nav-link.active::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-link.active i {
    color: var(--accent);
    opacity: 1;
}

.nav-link.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.nav-link-btn {
    cursor: pointer;
}

.sidebar-footer {
    padding: 1rem 0.75rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 0.5rem;
}

.sidebar-user .avatar-circle {
    width: 36px;
    height: 36px;
    font-size: 0.8rem;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: var(--primary);
    font-weight: 700;
}

.sidebar-user-info {
    min-width: 0;
    flex: 1;
}

.sidebar-user-info .name {
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sidebar-user-info .role {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
}

/* Main content area */
.admin-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.admin-topbar {
    height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 0 1.75rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.sidebar-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: all var(--transition);
    text-decoration: none;
    padding: 0;
}

.sidebar-toggle:hover {
    background: var(--bg);
    border-color: var(--border);
    color: var(--primary);
}

.topbar-search {
    position: relative;
    max-width: 480px;
    flex: 1;
    min-width: 0;
}

.topbar-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.9rem;
    pointer-events: none;
}

.topbar-search input {
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border-radius: var(--radius-md);
    background: var(--bg);
    border: 1px solid transparent;
    font-size: 0.875rem;
    transition: all var(--transition);
    width: 100%;
}

.topbar-search input:focus {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
    outline: none;
}

.topbar-search input::placeholder {
    color: var(--text-light);
}

.topbar-actions .dropdown-toggle {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    padding: 0.375rem 0.75rem 0.375rem 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
}

.topbar-actions .dropdown-toggle:hover {
    background: var(--bg);
    border-color: var(--border);
}

.topbar-actions .dropdown-menu {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.topbar-actions .dropdown-item {
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
}

.topbar-actions .dropdown-item:hover {
    background: var(--bg);
}

.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.admin-content {
    padding: 1.75rem;
    flex: 1;
}

/* ==========================================================================
   Page Header & Welcome Banner
   ========================================================================== */

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

.page-header h1 {
    font-size: 1.625rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.03em;
    color: var(--primary);
}

.page-header .page-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0.25rem 0 0;
}

.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    color: #fff;
    margin-bottom: 1.75rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.2) 0%, transparent 70%);
    pointer-events: none;
}

.welcome-banner::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: 30%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
    pointer-events: none;
}

.welcome-banner-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.welcome-banner h2 {
    font-size: 1.375rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    letter-spacing: -0.02em;
}

.welcome-banner p {
    margin: 0;
    opacity: 0.8;
    font-size: 0.9rem;
}

.welcome-banner .btn-light {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    color: var(--primary);
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.25rem;
    transition: all var(--transition);
}

.welcome-banner .btn-light:hover {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   Stat Cards
   ========================================================================== */

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.375rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
    height: 100%;
    transition: transform var(--transition), box-shadow var(--transition);
}

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

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text);
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    margin-top: 0.125rem;
}

/* ==========================================================================
   Cards & Panels
   ========================================================================== */

.card-panel {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.card-panel .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.375rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-panel .card-body {
    padding: 1.375rem;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table {
    --bs-table-hover-bg: rgba(15, 39, 68, 0.03);
    font-size: 0.875rem;
}

.table > thead {
    background: var(--bg);
}

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

.table > tbody td {
    padding: 0.875rem 1.25rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}

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

.table > tbody tr:hover {
    background: rgba(15, 39, 68, 0.02);
}

.table code {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary-mid);
    background: rgba(30, 73, 118, 0.08);
    padding: 0.2em 0.5em;
    border-radius: 4px;
}

.table-actions {
    white-space: nowrap;
}

.admin-content {
    animation: pageIn 0.22s ease;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .admin-content {
        animation: none;
    }
}

.page-header .text-muted {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0.25rem 0 0;
}

.live-search-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 1080;
    max-height: min(420px, 70vh);
    overflow-y: auto;
}

.live-search-item,
.live-search-more,
.live-search-empty {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    color: var(--text);
    text-decoration: none;
}

.live-search-item i {
    color: var(--accent-hover);
    margin-top: 0.15rem;
}

.live-search-item strong,
.live-search-item small {
    display: block;
}

.live-search-item small {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.1rem;
}

.live-search-item:hover,
.live-search-more:hover {
    background: var(--bg);
}

.live-search-more {
    justify-content: center;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--primary-mid);
    border-top: 1px solid var(--border-light);
}

.live-search-empty {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ==========================================================================
   Forms & Filters
   ========================================================================== */

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

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-mid);
    box-shadow: 0 0 0 3px rgba(30, 73, 118, 0.1);
}

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

.filter-bar {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    letter-spacing: 0.01em;
}

.btn-sm {
    font-size: 0.8125rem;
    padding: 0.35rem 0.75rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    border: none;
    box-shadow: 0 2px 8px rgba(15, 39, 68, 0.2);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-mid) 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(15, 39, 68, 0.25);
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--primary-mid);
    border-color: var(--border);
    background: var(--surface);
}

.btn-outline-primary:hover {
    background: rgba(30, 73, 118, 0.06);
    border-color: var(--primary-mid);
    color: var(--primary);
}

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

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

.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border: none;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-accent:hover {
    background: linear-gradient(135deg, #fbbf24 0%, var(--accent) 100%);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-light {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
}

.btn-light:hover {
    background: var(--bg-subtle);
    border-color: var(--border);
    color: var(--text);
}

/* ==========================================================================
   Badges & Status
   ========================================================================== */

.status-badge {
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.35em 0.7em;
    border-radius: 6px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.badge {
    font-weight: 500;
}

/* ==========================================================================
   Profile & Detail Pages
   ========================================================================== */

.profile-header {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
    margin-bottom: 1.5rem;
}

.profile-header h1,
.profile-header .h3 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--primary);
}

.profile-tabs {
    border-bottom: 2px solid var(--border-light);
    gap: 0.25rem;
}

.profile-tabs .nav-link {
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 0.75rem 1.125rem;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: -2px;
    transition: all var(--transition);
}

.profile-tabs .nav-link:hover {
    color: var(--primary);
    background: transparent;
}

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

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

.info-item label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-light);
    margin-bottom: 0.25rem;
    display: block;
    font-weight: 600;
}

.info-item span {
    font-weight: 500;
    color: var(--text);
}

/* Vehicle cards */
.vehicle-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.vehicle-card:hover {
    border-color: var(--primary-mid);
    box-shadow: var(--shadow-md);
    color: inherit;
    transform: translateY(-2px);
}

.vehicle-card .reg-number {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}

/* Quick actions panel */
.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
}

.quick-action-btn:hover {
    background: var(--bg);
    border-color: var(--primary-mid);
    color: var(--primary);
    transform: translateX(4px);
}

.quick-action-btn i {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: rgba(30, 73, 118, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-mid);
    font-size: 1rem;
    flex-shrink: 0;
    transition: all var(--transition);
}

.quick-action-btn:hover i {
    background: var(--primary);
    color: #fff;
}

.quick-action-btn.disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.875rem;
    box-shadow: var(--shadow-xs);
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
    --bs-pagination-border-radius: var(--radius-sm);
    gap: 0.25rem;
}

.page-link {
    border-radius: var(--radius-sm) !important;
    font-size: 0.875rem;
    color: var(--text-muted);
    border-color: var(--border-light);
}

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

/* ==========================================================================
   Empty States
   ========================================================================== */

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

.empty-state i {
    font-size: 2.5rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    display: block;
}

/* ==========================================================================
   Responsive & Utilities
   ========================================================================== */

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 39, 68, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1035;
}

.sidebar-backdrop.show {
    display: block;
}

body.sidebar-open {
    overflow: hidden;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 2000;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-sm);
    text-decoration: none;
}

.skip-link:focus {
    top: 1rem;
}

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

@media (max-width: 991.98px) {
    .admin-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .admin-sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

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

    .admin-content {
        padding: 1.25rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .page-header h1 {
        font-size: 1.375rem;
    }

    .welcome-banner {
        padding: 1.25rem 1.5rem;
    }

    .filter-bar .row > [class*="col-"] {
        margin-bottom: 0.25rem;
    }

    .topbar-search input {
        font-size: 0.8125rem;
    }

    .topbar-search input::placeholder {
        color: transparent;
    }

    .topbar-search input:focus::placeholder {
        color: var(--text-light);
    }

    .profile-header {
        padding: 1.25rem;
    }

    .profile-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .profile-tabs .nav-link {
        white-space: nowrap;
        font-size: 0.8125rem;
        padding: 0.5rem 0.875rem;
    }

    .table-responsive {
        font-size: 0.8125rem;
    }

    .stat-card .stat-value {
        font-size: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    .admin-topbar {
        padding: 0 1rem;
    }

    .topbar-search {
        max-width: none;
    }

    .btn-group-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .btn-group-actions .btn {
        width: 100%;
    }
}

@media print {
    .admin-sidebar,
    .admin-topbar,
    .no-print,
    .welcome-banner {
        display: none !important;
    }

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

    .admin-content {
        padding: 0;
    }
}

/* ==========================================================================
   Searchable Selects (Tom Select)
   ========================================================================== */

.ts-wrapper {
    width: 100%;
    display: block;
    position: relative;
}

.ts-wrapper.form-select,
.ts-wrapper.single {
    padding: 0 !important;
    margin: 0;
    background: transparent;
    box-shadow: none;
}

.ts-wrapper .ts-control {
    display: flex !important;
    align-items: center;
    width: 100%;
    min-height: calc(1.5em + 1rem + 2px);
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    font-size: 0.875rem;
    padding: 0.5rem 2.25rem 0.5rem 0.875rem !important;
    background-color: var(--surface) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 16px 12px !important;
    box-shadow: none;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.ts-wrapper.form-select-sm .ts-control,
.ts-wrapper.single.form-select-sm .ts-control {
    min-height: calc(1.5em + 0.5rem + 2px);
    padding: 0.35rem 2rem 0.35rem 0.75rem !important;
    font-size: 0.8125rem;
    background-position: right 0.5rem center !important;
}

.ts-wrapper.focus .ts-control,
.ts-wrapper .ts-control:focus,
.ts-wrapper .ts-control:focus-within {
    border-color: var(--primary-mid) !important;
    box-shadow: 0 0 0 3px rgba(30, 73, 118, 0.1) !important;
    outline: none;
}

.ts-wrapper .ts-control .item {
    color: var(--text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ts-wrapper .ts-control .item.placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.ts-wrapper.disabled .ts-control,
.ts-wrapper .ts-control.disabled {
    background-color: var(--bg) !important;
    opacity: 1;
    cursor: not-allowed;
}

.ts-wrapper.disabled .ts-control .item,
.ts-wrapper .ts-control.disabled .item {
    color: var(--text-muted);
}

/* Input group: vehicle select + button */
.input-group > .ts-wrapper {
    flex: 1 1 auto;
    width: 1% !important;
    min-width: 0;
}

.input-group > .ts-wrapper .ts-control {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-right: 0 !important;
}

.input-group > select.tomselected {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Validation states */
.was-validated .ts-wrapper:has(select:invalid) .ts-control,
.ts-wrapper:has(select.is-invalid) .ts-control {
    border-color: var(--bs-form-invalid-border-color, #dc3545) !important;
}

.was-validated .ts-wrapper:has(select:valid) .ts-control,
.ts-wrapper:has(select.is-valid) .ts-control {
    border-color: var(--bs-form-valid-border-color, #198754) !important;
}

.ts-wrapper .ts-dropdown {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: 0.875rem;
    z-index: 1060;
    margin-top: 4px;
    background: var(--surface);
}

.ts-wrapper .ts-dropdown .option {
    padding: 0.5rem 0.875rem;
}

.ts-wrapper .ts-dropdown .option.active {
    background: rgba(30, 73, 118, 0.08);
    color: var(--primary);
}

.ts-wrapper .ts-dropdown .option:hover,
.ts-wrapper .ts-dropdown .option[data-selectable]:hover {
    background: var(--bg);
    color: var(--text);
}

.ts-wrapper .ts-dropdown .dropdown-input-wrap {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--surface);
}

.ts-wrapper .ts-dropdown .dropdown-input {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    width: 100%;
}

.ts-wrapper .ts-dropdown .dropdown-input:focus {
    border-color: var(--primary-mid);
    box-shadow: 0 0 0 3px rgba(30, 73, 118, 0.1);
    outline: none;
}

.ts-wrapper .ts-dropdown .no-results {
    padding: 0.5rem 0.875rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.ts-wrapper .clear-button {
    color: var(--text-light);
    right: 1.75rem;
}

.ts-wrapper.plugin-dropdown_input .ts-control {
    cursor: pointer;
}

/* Line items + summary */
.line-items-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1.25rem;
    align-items: start;
}

.line-items-card .card-header {
    justify-content: space-between;
}

.btn-link-action {
    color: var(--primary-mid);
    font-weight: 600;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
}

.btn-link-action:hover {
    color: var(--primary);
    background: var(--bg);
}

.inventory-picker {
    padding: 0.875rem 1.25rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border-light);
}

.inventory-picker-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px 96px;
    gap: 0.5rem;
    align-items: stretch;
}

.inventory-picker-search .ts-wrapper,
.inventory-picker-search .ts-wrapper .ts-control {
    width: 100% !important;
}

.inventory-picker-qty {
    text-align: center;
    font-weight: 600;
}

.inventory-picker-add {
    white-space: nowrap;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.compact-items-table {
    margin-bottom: 0;
}

.compact-items-table thead th {
    background: #f8fafc;
    padding: 0.65rem 1.25rem;
}

.compact-items-table td {
    padding: 0.85rem 1.25rem;
    vertical-align: middle;
    border-color: var(--border-light);
}

.compact-items-table th:nth-child(2),
.compact-items-table td:nth-child(2) { width: 72px; }
.compact-items-table th:nth-child(3),
.compact-items-table td:nth-child(3) { width: 130px; }
.compact-items-table th:nth-child(4),
.compact-items-table td:nth-child(4) { width: 140px; }
.compact-items-table th:nth-child(5),
.compact-items-table td:nth-child(5) { width: 84px; }

.compact-items-table tbody tr:hover {
    background: rgba(15, 39, 68, 0.02);
}

.item-desc-text {
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
}

.item-meta-text {
    margin-top: 0.15rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.item-line-total {
    font-weight: 600;
    color: var(--primary);
}

.item-actions {
    display: inline-flex;
    gap: 0.15rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    transition: background var(--transition), color var(--transition);
}

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

.btn-icon-danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

.items-empty {
    text-align: center;
    padding: 2.25rem 1.25rem;
    color: var(--text-muted);
}

.items-empty i {
    font-size: 1.75rem;
    color: var(--text-light);
    display: block;
    margin-bottom: 0.5rem;
}

.items-empty p {
    margin: 0;
    font-size: 0.875rem;
}

.totals-card {
    position: sticky;
    top: calc(var(--topbar-height) + 1rem);
}

.totals-card-title,
.job-totals-bar {
    font-weight: 600;
}

.totals-card-title {
    padding: 1rem 1.25rem 0;
    font-size: 0.9375rem;
    color: var(--text);
}

.totals-body,
.job-totals-bar {
    padding: 1rem 1.25rem 1.25rem;
}

.job-totals-bar {
    margin-left: auto;
    max-width: 320px;
    width: 100%;
    border-top: 1px solid var(--border-light);
}

.totals-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 2rem;
    font-size: 0.875rem;
}

.totals-row + .totals-row {
    margin-top: 0.35rem;
}

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

.totals-row-input label {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text);
}

.totals-field {
    display: flex;
    align-items: center;
    width: 128px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.totals-field span {
    padding: 0 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.totals-field input {
    width: 100%;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 0.4rem 0.45rem;
    text-align: right;
    font-size: 0.875rem;
    font-weight: 600;
}

.totals-field input:focus {
    outline: none;
}

.totals-field input::-webkit-outer-spin-button,
.totals-field input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.totals-field input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.totals-field:focus-within {
    border-color: var(--primary-mid);
    box-shadow: 0 0 0 3px rgba(30, 73, 118, 0.1);
    background: #fff;
}

.totals-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0.85rem 0;
}

.totals-grand {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-top: 0.9rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border-light);
    font-weight: 700;
    color: var(--primary);
}

.totals-grand span:last-child {
    font-size: 1.15rem;
    color: var(--accent-hover);
}

.item-row-flash {
    animation: itemFlash 0.7s ease;
}

@keyframes itemFlash {
    0% { background: rgba(245, 158, 11, 0.25); }
    100% { background: transparent; }
}

@media (max-width: 991.98px) {
    .line-items-layout {
        grid-template-columns: 1fr;
    }

    .totals-card {
        position: static;
    }
}

@media (max-width: 767.98px) {
    .inventory-picker-row {
        grid-template-columns: 1fr 72px;
    }

    .inventory-picker-add {
        grid-column: 1 / -1;
    }

    .admin-topbar {
        padding: 0 0.85rem;
        gap: 0.5rem;
    }

    .card-panel .table-responsive:has(.table-stack) {
        overflow: visible;
    }

    .table-stack thead {
        display: none;
    }

    .table-stack tbody tr {
        display: block;
        padding: 0.9rem 1rem;
        border-bottom: 1px solid var(--border-light);
    }

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

    .table-stack tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        padding: 0.28rem 0;
        border: 0 !important;
        text-align: right !important;
        white-space: normal;
    }

    .table-stack tbody td::before {
        content: attr(data-label);
        font-size: 0.68rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--text-muted);
        text-align: left;
        flex: 0 0 38%;
    }

    .table-stack tbody td[data-label=""] {
        justify-content: flex-end;
        padding-top: 0.55rem;
    }

    .table-stack tbody td[data-label=""]::before {
        display: none;
    }

    .table-stack tbody td[colspan] {
        display: block;
        text-align: center !important;
    }

    .table-stack tbody td[colspan]::before {
        display: none;
    }

    .line-items-layout {
        grid-template-columns: 1fr;
    }
}

/* Line items table — keep columns wide enough to type */
.line-items-table {
    min-width: 1100px;
    table-layout: auto;
}

.line-items-table th,
.line-items-table td {
    vertical-align: middle;
    white-space: nowrap;
}

.line-items-table .form-control,
.line-items-table .form-select {
    min-width: 0;
    width: 100%;
}

.line-items-table .col-desc { min-width: 200px; }
.line-items-table .col-part { min-width: 120px; }
.line-items-table .col-category { min-width: 130px; }
.line-items-table .col-type { min-width: 120px; }
.line-items-table .col-qty { min-width: 90px; width: 90px; }
.line-items-table .col-unit { min-width: 80px; width: 80px; }
.line-items-table .col-price { min-width: 120px; width: 120px; }
.line-items-table .col-discount { min-width: 100px; width: 100px; }
.line-items-table .col-tax { min-width: 90px; width: 90px; }
.line-items-table .col-total { min-width: 120px; }
.line-items-table .col-action { width: 52px; }

.line-items-table input[type="number"]::-webkit-outer-spin-button,
.line-items-table input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.line-items-table input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.work-type-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    max-width: 520px;
}

.work-type-grid-4 {
    max-width: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 992px) {
    .work-type-grid-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

[x-cloak] {
    display: none !important;
}

.work-type-card {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin: 0;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.work-type-card i {
    font-size: 1.25rem;
    color: var(--primary-mid);
}

.work-type-card strong {
    font-size: 0.95rem;
}

.work-type-card span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.work-type-card:hover,
.work-type-card.is-selected {
    border-color: var(--primary-mid);
    box-shadow: 0 0 0 3px rgba(30, 73, 118, 0.1);
}

.work-type-card.is-selected {
    background: rgba(30, 73, 118, 0.05);
}

.work-type-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 575.98px) {
    .work-type-grid {
        grid-template-columns: 1fr;
        max-width: none;
    }
}


