/* ============================================================
   SERVICE CRM PRO - ENTERPRISE DESIGN SYSTEM
   Glassmorphism | Premium UI | Responsive
   ============================================================ */

/* --- CSS Variables / Design Tokens --- */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --primary-bg: rgba(37, 99, 235, 0.08);
    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.08);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.08);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.08);
    --info: #0284c7;
    --info-bg: rgba(2, 132, 199, 0.08);
    --purple: #7c3aed;
    --purple-bg: rgba(124, 58, 237, 0.08);
    --orange: #ea580c;
    --orange-bg: rgba(234, 88, 12, 0.08);
    --emerald: #10b981;
    --emerald-bg: rgba(16, 185, 129, 0.08);

    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 40px -5px rgba(0,0,0,0.1);
    --glass-bg: rgba(255,255,255,0.7);
    --glass-border: rgba(255,255,255,0.2);
    --glass-shadow: 0 8px 32px rgba(0,0,0,0.06);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --sidebar-width: 260px;
    --header-height: 64px;
}

/* --- Dark Theme --- */
.dark-theme, [data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #1e293b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
    --glass-bg: rgba(30,41,59,0.7);
    --glass-border: rgba(255,255,255,0.05);
    --glass-shadow: 0 8px 32px rgba(0,0,0,0.3);
    --primary-bg: rgba(59,130,246,0.12);
}

/* --- Base / Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a { text-decoration: none; color: var(--primary); transition: color 0.2s; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }
ul { list-style: none; }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }

/* --- Glass Card --- */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius-lg);
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 24px;
}

.card-body.p-0 { padding: 0; }

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.brand-text {
    flex: 1;
}

.brand-name {
    display: block;
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    line-height: 1.2;
}

.brand-version {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.user-name {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: capitalize;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 12px;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 8px 12px 6px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    color: var(--text-muted);
    transition: color 0.2s;
}

.nav-item:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.nav-item:hover i {
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active i {
    color: var(--primary);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.logout-form {
    margin: 0;
}

.logout-btn {
    width: 100%;
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
}

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

.logout-btn:hover i {
    color: var(--danger);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
    backdrop-filter: blur(2px);
}

/* --- Top Header --- */
.top-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
}

.hamburger:hover {
    background: var(--bg-tertiary);
}

.header-search {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

.header-search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
    background: var(--bg-secondary);
}

.search-results {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.theme-toggle .fa-sun { display: none; }
.dark-theme .theme-toggle .fa-moon { display: none; }
.dark-theme .theme-toggle .fa-sun { display: inline; }

.notification-dropdown, .user-dropdown {
    position: relative;
}

.notif-btn, .user-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    position: relative;
}

.notif-btn:hover, .user-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-btn {
    width: auto;
    gap: 8px;
    padding: 0 12px 0 8px;
    border-radius: var(--radius-md);
}

.user-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    overflow: hidden;
}

.user-avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.notif-menu, .user-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 200;
    min-width: 320px;
}

.user-menu {
    min-width: 220px;
}

.notif-menu.active, .user-menu.active {
    display: block;
}

.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
}

.notif-header h4 {
    font-size: 14px;
    font-weight: 600;
}

.notif-mark-read {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

.notif-list {
    max-height: 300px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 18px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-light);
}

.notif-item:hover {
    background: var(--bg-tertiary);
}

.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

.notif-content {
    flex: 1;
    min-width: 0;
}

.notif-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.notif-message {
    font-size: 12px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

.notif-empty {
    text-align: center;
    padding: 30px 18px;
    color: var(--text-muted);
}

.notif-empty i {
    font-size: 32px;
    margin-bottom: 8px;
    color: var(--success);
}

.user-menu-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color);
}

.user-menu-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.user-menu-email {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.user-menu-body {
    padding: 8px;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.user-menu-item i {
    width: 18px;
    color: var(--text-muted);
}

.user-menu-item:hover {
    background: var(--bg-tertiary);
}

.user-menu-item.text-danger {
    color: var(--danger);
}

.user-menu-item.text-danger i {
    color: var(--danger);
}

.user-menu-body hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 6px 0;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    padding: 28px 32px 40px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Page Container --- */
.page-container {
    max-width: 1400px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 400;
}

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

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

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

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

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-success:hover {
    background: #047857;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #b91c1c;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    padding: 8px 12px;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

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

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

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

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
    margin-top: 28px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

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

.stat-icon-blue { background: var(--primary-bg); color: var(--primary); }
.stat-icon-purple { background: var(--purple-bg); color: var(--purple); }
.stat-icon-orange { background: var(--orange-bg); color: var(--orange); }
.stat-icon-green { background: var(--success-bg); color: var(--success); }
.stat-icon-red { background: var(--danger-bg); color: var(--danger); }
.stat-icon-emerald { background: var(--emerald-bg); color: var(--emerald); }

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

.stat-value {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.stat-trend {
    font-size: 12px;
    font-weight: 600;
}

.stat-trend-up { color: var(--success); }
.stat-trend-down { color: var(--danger); }

/* Grid Variants */
.stats-grid.mini .stat-card { padding: 16px; }

/* --- Charts --- */
.charts-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.chart-card .card-body {
    padding: 0 20px 20px;
}

.chart-card canvas {
    height: 280px !important;
}

/* --- Tables --- */
.tables-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

.table th:first-child {
    padding-left: 24px;
}

.table th:last-child {
    padding-right: 24px;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}

.table td:first-child {
    padding-left: 24px;
}

.table td:last-child {
    padding-right: 24px;
}

.table tbody tr {
    transition: background 0.15s;
}

.table tbody tr:hover {
    background: var(--bg-tertiary);
}

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

.table .link {
    font-weight: 500;
    color: var(--primary);
}

.table .link:hover {
    text-decoration: underline;
}

/* --- Action Buttons --- */
.action-btns {
    display: flex;
    gap: 6px;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: capitalize;
}

.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-secondary { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }

/* --- Forms --- */
.form { max-width: 100%; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.form-grid .full-width { grid-column: 1 / -1; }

.form-group {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    margin:7px;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-input:disabled, .form-input[readonly] {
    background: var(--bg-tertiary);
    cursor: not-allowed;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-input-sm {
    width: auto;
    padding: 6px 10px;
    font-size: 13px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.form-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.form-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.form-section-header h3 {
    font-size: 15px;
    font-weight: 600;
}

/* Floating Labels - Input Groups */
.input-group {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    z-index: 1;
    pointer-events: none;
}

.input-group .form-input {
    padding-left: 44px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
}

/* Checkbox */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    position: relative;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    border-radius: 4px;
    cursor: pointer;
}

/* Filters Bar */
.filters-bar {
    padding: 16px 20px;
    margin-bottom: 20px;
}

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

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 9px 14px 9px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.filter-select {
    min-width: 160px;
}

/* --- Search Results --- */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 14px;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-light);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-tertiary);
}

.search-result-item i {
    width: 32px;
    height: 32px;
    background: var(--primary-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 14px;
    flex-shrink: 0;
}

.search-result-item strong {
    display: block;
    font-weight: 600;
}

.search-result-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
}

/* --- Priority Row Colors --- */
.priority-urgent td { border-left: 3px solid var(--danger); }
.priority-high td { border-left: 3px solid var(--warning); }
.priority-medium td { border-left: 3px solid var(--primary); }
.priority-low td { border-left: 3px solid var(--success); }

/* --- Pagination --- */
.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

.pagination {
    display: flex;
    gap: 4px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    background: var(--bg-secondary);
    transition: all 0.2s;
}

.page-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* --- Auth --- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 20px;
}

.auth-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 1000px;
    width: 100%;
    min-height: 600px;
    border-radius: var(--radius-xl);
    background: var(--bg-secondary);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.auth-left {
    background: linear-gradient(135deg, var(--primary), #1e40af);
    padding: 48px;
    display: flex;
    flex-direction: column;
    color: white;
    position: relative;
    overflow: hidden;
}

.auth-left::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
    pointer-events: none;
}

.auth-brand {
    margin-bottom: 40px;
}

.auth-brand-icon {
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
    backdrop-filter: blur(10px);
}

.auth-brand h1 {
    font-size: 28px;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
}

.auth-brand p {
    font-size: 14px;
    opacity: 0.8;
}

.auth-illustration {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-quote {
    margin-bottom: 32px;
}

.auth-quote i {
    font-size: 24px;
    opacity: 0.6;
    margin-bottom: 12px;
    display: block;
}

.auth-quote p {
    font-size: 15px;
    line-height: 1.7;
    opacity: 0.9;
}

.auth-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    opacity: 0.85;
}

.auth-feature i {
    color: #34d399;
    font-size: 16px;
}

.auth-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.auth-form-container {
    width: 100%;
    max-width: 380px;
}

.auth-form-header {
    margin-bottom: 28px;
}

.auth-form-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.auth-form-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.forgot-link {
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
}

.auth-footer-text {
    text-align: center;
    margin-top: 24px;
}

.auth-footer-text a {
    font-size: 14px;
    color: var(--text-muted);
}

.auth-footer-text a:hover {
    color: var(--primary);
}

/* --- Flash Messages --- */
.flash-container {
    position: fixed;
    top: 80px;
    right: 28px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 400px;
}

.flash-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.flash-success { border-left: 3px solid var(--success); }
.flash-success i { color: var(--success); }
.flash-error { border-left: 3px solid var(--danger); }
.flash-error i { color: var(--danger); }
.flash-warning { border-left: 3px solid var(--warning); }
.flash-warning i { color: var(--warning); }
.flash-info { border-left: 3px solid var(--info); }
.flash-info i { color: var(--info); }

.flash-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
}

/* --- Detail / Info Grids --- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.detail-grid.two-col .card:first-child {
    grid-column: 1;
}

.detail-grid.two-col .card:last-child {
    grid-column: 2;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.info-item.full-width {
    grid-column: 1 / -1;
}

.info-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.info-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.customer-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

/* --- Timeline --- */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg-secondary);
}

.timeline-content {
    padding-left: 12px;
}

.timeline-status {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.timeline-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.timeline-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

/* --- Error Pages --- */
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--bg-primary);
}

.error-content {
    text-align: center;
    max-width: 500px;
}

.error-code {
    font-size: 120px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin: 0 0 10px;
}

.error-content h2 {
    font-size: 28px;
    color: var(--text-primary);
    margin: 0 0 10px;
}

.error-content p {
    color: var(--text-secondary);
    margin: 0 0 30px;
    font-size: 16px;
}

/* --- Settings --- */
.settings-grid {
    display: grid;
    gap: 20px;
}

/* --- Responsive --- */
@media (max-width: 1200px) {
    .charts-grid { grid-template-columns: 1fr; }
    .tables-grid { grid-template-columns: 1fr; }
}

@media (max-width: 992px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .top-header {
        left: 0;
    }

    .hamburger {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 20px 16px 32px;
    }

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

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
    }

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

    .auth-container {
        grid-template-columns: 1fr;
    }

    .auth-left {
        display: none;
    }

    .auth-right {
        padding: 32px 24px;
    }

    .header-search {
        display: none;
    }

    .notif-menu {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        border-radius: 0;
        min-width: auto;
    }

    .flash-container {
        right: 16px;
        left: 16px;
        max-width: none;
    }

    .pagination-wrapper {
        flex-direction: column;
        align-items: center;
    }

    .table { font-size: 13px; }
    .table th, .table td { padding: 10px 12px; }
    .table th:first-child, .table td:first-child { padding-left: 14px; }
    .table th:last-child, .table td:last-child { padding-right: 14px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .filters-form { flex-direction: column; align-items: stretch; }
    .search-box { min-width: auto; }
    .filter-select { min-width: auto; }
}

/* ============================================================
   MODERN ACTION TOOLBAR — Pill-style action buttons for show views
   ============================================================ */

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.page-actions .btn {
    padding: 7px 16px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 500;
    gap: 7px;
    border: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.page-actions .btn i,
.page-actions .btn .fas,
.page-actions .btn .fab {
    font-size: 14px;
}

.page-actions .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.page-actions .btn:active {
    transform: translateY(0) scale(0.97);
}

.page-actions .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Ripple effect on click */
.page-actions .btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.2);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s;
}
.page-actions .btn:active::after {
    opacity: 1;
    transition: 0s;
}

/* Color by icon — auto-detect action type */

/* View (eye icon) — Light blue */
.page-actions .btn i.fa-eye,
.page-actions .btn .fas.fa-eye {
    color: var(--primary);
}
.page-actions .btn:has(i.fa-eye):not(.btn-success):not(.btn-danger) {
    background: var(--primary-bg);
    color: var(--primary);
}
.page-actions .btn:has(i.fa-eye):not(.btn-success):not(.btn-danger):hover {
    background: var(--primary);
    color: white;
}
.page-actions .btn:has(i.fa-eye):not(.btn-success):not(.btn-danger):hover i.fa-eye {
    color: white;
}

/* Edit (pencil icon) — Purple/Indigo */
.page-actions .btn i.fa-edit,
.page-actions .btn .fas.fa-edit {
    color: var(--purple);
}
.page-actions .btn:has(i.fa-edit):not(.btn-success):not(.btn-danger):not(.btn-primary) {
    background: var(--purple-bg);
    color: var(--purple);
}
.page-actions .btn:has(i.fa-edit):not(.btn-success):not(.btn-danger):not(.btn-primary):hover {
    background: var(--purple);
    color: white;
}
.page-actions .btn:has(i.fa-edit):not(.btn-success):not(.btn-danger):not(.btn-primary):hover i.fa-edit {
    color: white;
}

/* PDF (file-pdf icon) — Red */
.page-actions .btn i.fa-file-pdf,
.page-actions .btn .fas.fa-file-pdf {
    color: var(--danger);
}
.page-actions .btn:has(i.fa-file-pdf):not(.btn-success):not(.btn-danger) {
    background: var(--danger-bg);
    color: var(--danger);
}
.page-actions .btn:has(i.fa-file-pdf):not(.btn-success):not(.btn-danger):hover {
    background: var(--danger);
    color: white;
}
.page-actions .btn:has(i.fa-file-pdf):not(.btn-success):not(.btn-danger):hover i.fa-file-pdf {
    color: white;
}

/* Print (print icon) — Slate */
.page-actions .btn i.fa-print,
.page-actions .btn .fas.fa-print {
    color: var(--text-secondary);
}
.page-actions .btn:has(i.fa-print):not(.btn-success):not(.btn-danger):not(.btn-primary) {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.page-actions .btn:has(i.fa-print):not(.btn-success):not(.btn-danger):not(.btn-primary):hover {
    background: var(--text-secondary);
    color: white;
    border-color: var(--text-secondary);
}
.page-actions .btn:has(i.fa-print):not(.btn-success):not(.btn-danger):not(.btn-primary):hover i.fa-print {
    color: white;
}

/* WhatsApp — Premium green gradient */
.page-actions .btn:has(.fa-whatsapp) {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.25);
}
.page-actions .btn:has(.fa-whatsapp) i,
.page-actions .btn:has(.fa-whatsapp) .fab {
    color: white;
}
.page-actions .btn:has(.fa-whatsapp):hover {
    background: linear-gradient(135deg, #20bd5a, #0e7a6e);
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4);
    transform: translateY(-1px);
}

/* Payment / Dollar — Emerald green */
.page-actions .btn:has(.fa-dollar-sign) {
    background: var(--emerald);
    color: white;
}
.page-actions .btn:has(.fa-dollar-sign) i {
    color: white;
}
.page-actions .btn:has(.fa-dollar-sign):hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

/* Delete (trash icon) — Soft danger red */
.page-actions .btn:has(.fa-trash) {
    background: var(--danger-bg);
    color: var(--danger);
}
.page-actions .btn:has(.fa-trash) i {
    color: var(--danger);
}
.page-actions .btn:has(.fa-trash):hover {
    background: var(--danger);
    color: white;
}
.page-actions .btn:has(.fa-trash):hover i {
    color: white;
}

/* Convert to Invoice (file-invoice) — Primary */
.page-actions .btn:has(.fa-file-invoice) {
    background: var(--primary);
    color: white;
}
.page-actions .btn:has(.fa-file-invoice) i {
    color: white;
}
.page-actions .btn:has(.fa-file-invoice):hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Check / Mark Delivered — Success green */
.page-actions .btn:has(.fa-check) {
    background: var(--success);
    color: white;
}
.page-actions .btn:has(.fa-check) i {
    color: white;
}
.page-actions .btn:has(.fa-check):hover {
    background: #047857;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
}

/* ============================================================
   ACTION DROPDOWN — For index table action columns
   Uses Bootstrap 5 Dropdown + Popper.js with custom styling
   ============================================================ */

/* Wrapper — must allow the menu to overflow */
.dropdown {
    position: relative;
    display: inline-block;
}

/* Table action cell — prevent overflow clipping */
table td:has(.dropdown),
.table td:has(.dropdown) {
    overflow: visible;
    position: relative;
}

/* The three-dot toggle button */
.dropdown-toggle.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.dropdown-toggle.btn-icon:hover,
.dropdown-toggle.btn-icon:focus-visible {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--primary);
    outline: none;
}

.dropdown-toggle.btn-icon:active,
.dropdown-toggle.btn-icon.show {
    background: var(--primary-bg);
    color: var(--primary);
    border-color: var(--primary);
}

/* Dropdown menu — Bootstrap 5 compatible */
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12);
    z-index: 99999;
    padding: 6px;
    margin: 4px 0 0;
    animation: dropdownFadeIn 0.15s ease;
    /* Bootstrap 5 resets */
    list-style: none;
    text-align: left;
    font-size: inherit;
    background-clip: padding-box;
}

.dark-theme .dropdown-menu {
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.dropdown-menu.show {
    display: block;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-menu-end {
    right: 0;
    left: auto;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    line-height: 1.4;
    clear: both;
    white-space: nowrap;
    text-decoration: none;
}

.dropdown-item i,
.dropdown-item .fas,
.dropdown-item .fab {
    width: 18px;
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
    transition: color 0.15s;
    flex-shrink: 0;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
}

.dropdown-item:hover i,
.dropdown-item:hover .fas,
.dropdown-item:hover .fab,
.dropdown-item:focus i,
.dropdown-item:focus .fas,
.dropdown-item:focus .fab {
    color: var(--text-primary);
}

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

.dropdown-item .text-success {
    color: var(--success);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
    overflow: hidden;
    border: none;
}

/* Responsive: On mobile, reduce toolbar button padding */
@media (max-width: 768px) {
    .page-actions .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    .page-actions .btn i,
    .page-actions .btn .fas,
    .page-actions .btn .fab {
        font-size: 12px;
    }
    .page-actions {
        gap: 6px;
    }
}

/* Smallest screens — inline minimal buttons */
@media (max-width: 480px) {
    .page-actions .btn span {
        display: none;
    }
    .page-actions .btn {
        padding: 7px;
        border-radius: 50%;
        min-width: 34px;
        min-height: 34px;
        justify-content: center;
    }
    .page-actions .btn i {
        margin: 0;
    }
}

/* ============================================================
   FLOATING DROPDOWN SYSTEM
   Uses position:fixed to escape overflow clipping from parent
   containers (table-responsive, cards, modals, etc.)
   ============================================================ */

.dropdown-menu.dropdown-fixed {
    position: fixed !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    margin: 0 !important;
    animation: dropdownFadeIn 0.15s ease;
}

/* Backdrop for click-outside closing when using fixed dropdowns */
.dropdown-fixed-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: transparent;
}

/* ============================================================
   DASHBOARD STATS MODAL
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.modal-container {
    background: var(--bg-primary, #fff);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 960px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #111827);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--text-muted, #9ca3af);
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s;
}

.modal-close:hover {
    color: var(--text-primary, #111827);
}

.modal-body {
    padding: 16px 24px 20px;
    overflow: auto;
    flex: 1;
}

.modal-search {
    margin-bottom: 16px;
}

.modal-table-wrap {
    min-height: 200px;
}

.modal-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted, #9ca3af);
    font-size: 14px;
}

.modal-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted, #9ca3af);
    font-size: 14px;
}

.modal-footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, #e5e7eb);
    flex-wrap: wrap;
    gap: 8px;
}

.modal-info {
    font-size: 13px;
    color: var(--text-muted, #9ca3af);
}

.modal-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.modal-pagination .btn-text {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    font-size: 14px;
}

.modal-pagination .page-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #111827);
}

.modal-container .table {
    margin-bottom: 0;
}

.modal-container .table td,
.modal-container .table th {
    white-space: nowrap;
    padding: 10px 12px;
}

.modal-container .table td:last-child,
.modal-container .table th:last-child {
    text-align: center;
    width: 80px;
}

.modal-container .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
}

@media (max-width: 768px) {
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .modal-container {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
    }
    .modal-footer-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .modal-pagination {
        justify-content: center;
    }
}

/* ============================================================
   MOBILE: INVOICE ITEMS CARD LAYOUT
   ============================================================ */
@media (max-width: 768px) {
    #itemsTable,
    #itemsTable thead,
    #itemsTable tbody,
    #itemsTable tfoot,
    #itemsTable tr,
    #itemsTable th,
    #itemsTable td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    #itemsTable thead {
        display: none;
    }

    #itemsTable .item-row {
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        padding: 14px;
        margin-bottom: 14px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }

    #itemsTable .item-row td {
        padding: 6px 0;
        border: none;
        vertical-align: middle;
    }

    #itemsTable .item-row td:first-child {
        padding-top: 0;
    }

    #itemsTable .item-row td:last-child {
        padding-bottom: 0;
        text-align: right;
    }

    #itemsTable .item-row td:nth-child(2)::before {
        content: "HSN: ";
        font-weight: 600;
        font-size: 12px;
        color: #475569;
        display: inline-block;
        margin-right: 6px;
    }

    #itemsTable .item-row td:nth-child(3)::before {
        content: "Qty: ";
        font-weight: 600;
        font-size: 12px;
        color: #475569;
        display: block;
        margin-bottom: 4px;
    }

    #itemsTable .item-row td:nth-child(4)::before {
        content: "Price: ";
        font-weight: 600;
        font-size: 12px;
        color: #475569;
        display: block;
        margin-bottom: 4px;
    }

    #itemsTable .item-row td:nth-child(5) {
        font-weight: 700;
        font-size: 15px;
        padding-top: 8px;
        border-top: 1px solid #e2e8f0;
        margin-top: 6px;
    }

    #itemsTable .item-row td:nth-child(5)::before {
        content: "Total: ";
        font-weight: 600;
        font-size: 13px;
        color: #475569;
    }

    #itemsTable .item-row .item-desc {
        font-size: 14px;
        min-height: 44px;
        width: 100%;
        box-sizing: border-box;
    }

    #itemsTable .item-row .item-details {
        width: 100%;
        min-height: 80px;
        resize: vertical;
        box-sizing: border-box;
        font-size: 13px;
    }

    #itemsTable .item-row .item-qty,
    #itemsTable .item-row .item-price {
        width: 100%;
        min-height: 44px;
        box-sizing: border-box;
        font-size: 14px;
    }

    #itemsTable .item-row .item-hsn {
        font-weight: 600;
        font-size: 14px;
    }

    #itemsTable .item-row .remove-item {
        min-height: 44px;
        min-width: 44px;
        font-size: 16px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
    }

    #itemsTable .item-row .product-suggestions {
        position: fixed !important;
        left: 16px !important;
        right: 16px !important;
        width: auto !important;
        max-height: 240px;
        z-index: 9999 !important;
    }

    /* ─── TOTALS SECTION ─── */
    #itemsTable tfoot,
    #itemsTable tfoot tr,
    #itemsTable tfoot td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    #itemsTable tfoot {
        margin-top: 8px;
    }

    #itemsTable tfoot tr {
        padding: 10px 0;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
    }

    #itemsTable tfoot tr:first-child {
        padding-top: 0;
    }

    #itemsTable tfoot tr:last-child {
        padding-bottom: 0;
    }

    #itemsTable tfoot td {
        padding: 0;
        border: none;
        width: auto;
    }

    /* Hide spacer columns: first td (colspan=3) and 4th td (empty, only in 4-td rows) */
    #itemsTable tfoot td:first-child,
    #itemsTable tfoot td:nth-child(4) {
        display: none;
    }

    /* Label/input column (2nd td) */
    #itemsTable tfoot td:nth-child(2) {
        font-weight: 600;
        font-size: 13px;
        color: #1e293b;
        flex: 1 1 auto;
        min-width: 80px;
    }

    /* Value column (3rd td) */
    #itemsTable tfoot td:nth-child(3) {
        font-weight: 700;
        font-size: 14px;
        color: #0f172a;
        text-align: right;
        flex: 0 0 auto;
    }

    /* Input fields inside tfoot (discount %, tax %) */
    #itemsTable tfoot .form-input-sm {
        width: 100%;
        min-height: 44px;
        font-size: 14px;
        box-sizing: border-box;
        display: block;
        margin-top: 4px;
    }

    #itemsTable tfoot tr.grand-total-row td:nth-child(2) {
        font-size: 15px;
        font-weight: 700;
    }

    #itemsTable tfoot tr.grand-total-row td:nth-child(3) {
        font-size: 17px;
    }

    /* GST Type row: radio buttons in a colspan=2 td (3rd td) */
    #itemsTable tfoot tr:has(td:nth-child(3) .radio-inline) {
        flex-direction: column;
        align-items: flex-start;
    }

    #itemsTable tfoot tr:has(td:nth-child(3) .radio-inline) td:nth-child(2),
    #itemsTable tfoot tr:has(td:nth-child(3) .radio-inline) td:nth-child(3) {
        width: 100%;
        text-align: left;
    }

    #itemsTable tfoot tr:has(td:nth-child(3) .radio-inline) td:nth-child(3) .radio-inline {
        display: block;
        margin: 6px 0;
        font-size: 14px;
    }

    /* Add Item button */
    .form-section-header .btn {
        min-height: 44px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    #itemsTable .item-row {
        padding: 12px;
    }

    #itemsTable tfoot tr {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    #itemsTable tfoot td:nth-child(2) {
        width: 100%;
    }

    #itemsTable tfoot td:nth-child(3) {
        width: 100%;
        text-align: left;
        padding-left: 0;
    }

    #itemsTable .item-row td:nth-child(5) {
        text-align: left;
    }
}
