/* =============================================
   FreshServe Stock Management - Main Stylesheet
   Modern, responsive, premium design
   ============================================= */

/* ---- CSS VARIABLES ---- */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-200: #c7d2fe;
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --accent-light: #22d3ee;

    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    --bg-body: #f4f6fb;
    --bg-card: #ffffff;
    --bg-sidebar: #1e1b4b;
    --bg-sidebar-hover: #312e81;
    --bg-sidebar-active: #4338ca;
    --bg-header: #ffffff;
    --bg-input: #f8fafc;
    --bg-subtle: #f8fafc;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-white: #ffffff;
    --text-sidebar: #c7d2fe;
    --text-sidebar-active: #ffffff;

    --border: #e5e9f0;
    --border-light: #eef1f6;
    /* Slate-tinted, layered shadows read more premium than flat black */
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
    --shadow: 0 1px 2px rgba(15,23,42,0.04), 0 2px 4px rgba(15,23,42,0.03);
    --shadow-md: 0 2px 4px rgba(15,23,42,0.04), 0 6px 12px rgba(15,23,42,0.06);
    --shadow-lg: 0 4px 8px rgba(15,23,42,0.05), 0 12px 24px rgba(15,23,42,0.08);
    --shadow-xl: 0 8px 16px rgba(15,23,42,0.06), 0 24px 48px rgba(15,23,42,0.12);

    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;

    --sidebar-width: 260px;
    --header-height: 64px;
    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ---- RESET & BASE ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    font-size: inherit;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

img {
    max-width: 100%;
    display: block;
}

/* ---- HEADER ---- */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.95);
}

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

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: all var(--transition);
}

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

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.header-role-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--primary-50);
    color: var(--primary-dark);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.role-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Profile Dropdown */
.header-profile {
    position: relative;
}

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px;
    border-radius: var(--radius-lg);
    transition: all var(--transition);
}

.profile-trigger:hover {
    background: var(--bg-body);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.profile-avatar-lg {
    width: 44px;
    height: 44px;
    font-size: 0.9rem;
}

.profile-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    text-align: left;
}

.profile-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.profile-role {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.profile-chevron {
    color: var(--text-muted);
    transition: transform var(--transition);
}

.header-profile.active .profile-chevron {
    transform: rotate(180deg);
}

.profile-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition);
    overflow: hidden;
    z-index: 1100;
}

.header-profile.active .profile-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-body);
}

.profile-menu-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.profile-menu-email {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.profile-menu-divider {
    height: 1px;
    background: var(--border);
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.profile-menu-item:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

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

.profile-menu-item-danger:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* ---- SIDEBAR ---- */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 900;
    transition: transform var(--transition-slow);
    overflow-y: auto;
    overflow-x: hidden;
}

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

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

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

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

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

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.3);
    padding: 8px 12px 8px;
    margin-bottom: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-sidebar);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
    position: relative;
}

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

.nav-item-active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

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

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-item-active .nav-icon,
.nav-item:hover .nav-icon {
    opacity: 1;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer-info {
    text-align: center;
}

.footer-version {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.3);
}

.footer-copyright {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.2);
}

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

/* ---- MAIN CONTENT ---- */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    padding: 24px;
    transition: margin-left var(--transition-slow);
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.page-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* ---- CARDS ---- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

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

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-body);
}

/* ---- STAT CARDS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--stat-color, var(--primary));
    opacity: 0;
    transition: opacity var(--transition);
}

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

.stat-card:hover::after {
    opacity: 1;
}

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

.stat-icon.blue { background: var(--info-light); color: var(--info); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-icon.indigo { background: var(--primary-100); color: var(--primary); }

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

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

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-top: 2px;
}

.stat-change {
    font-size: 0.75rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    cursor: pointer;
    line-height: 1.4;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 1px 3px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.35);
}

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

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

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

.btn-success:hover {
    background: #059669;
    border-color: #059669;
}

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

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

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

.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 0.95rem;
}

.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
}

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

.btn-outline-primary:hover {
    background: var(--primary-50);
}

/* ---- FORMS ---- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label-required::after {
    content: ' *';
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition);
    outline: none;
}

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

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

.form-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ---- TABLES ---- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    background: var(--bg-body);
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

.data-table tbody tr {
    transition: background var(--transition);
}

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

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

/* ---- BADGES ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-primary { background: var(--primary-100); color: var(--primary-dark); }
.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-info { background: var(--info-light); color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* ---- MODALS ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
}

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

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ---- ALERTS/TOASTS ---- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 16px;
    border: 1px solid;
    animation: slideDown 0.3s ease;
}

.alert-success { background: var(--success-light); border-color: #a7f3d0; color: #065f46; }
.alert-warning { background: var(--warning-light); border-color: #fde68a; color: #92400e; }
.alert-danger { background: var(--danger-light); border-color: #fecaca; color: #991b1b; }
.alert-info { background: var(--info-light); border-color: #bfdbfe; color: #1e40af; }

.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 16px);
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    min-width: 280px;
    max-width: 400px;
    border-left: 4px solid var(--primary);
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }

/* ---- SEARCH & FILTERS ---- */
.search-bar {
    position: relative;
    max-width: 320px;
}

.search-bar input {
    width: 100%;
    padding: 9px 14px 9px 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    font-size: 0.85rem;
    transition: all var(--transition);
    outline: none;
}

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100);
    background: white;
}

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

/* ---- PAGINATION ---- */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    margin-top: 16px;
}

.pagination-btn {
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    background: var(--bg-card);
    transition: all var(--transition);
}

.pagination-btn:hover {
    background: var(--bg-body);
    border-color: var(--primary-200);
}

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

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

.pagination-btn:disabled:hover {
    background: var(--bg-card);
    border-color: var(--border);
}

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state svg {
    margin: 0 auto 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 0.85rem;
}

/* ---- UTILITY ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

/* ---- ANIMATIONS ---- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 0 auto;
}

/* ---- LOGIN PAGE ---- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 35%, #4338ca 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(99, 102, 241, 0.12), transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(139, 92, 246, 0.08), transparent 50%);
    animation: float 20s linear infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(2%, -1%) rotate(1deg); }
    50% { transform: translate(-1%, 2%) rotate(-1deg); }
    75% { transform: translate(1%, 1%) rotate(0.5deg); }
}

.login-container {
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: rgba(255, 255, 255, 0.97);
    border-radius: var(--radius-2xl);
    padding: 40px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
    backdrop-filter: blur(20px);
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand .brand-icon {
    margin: 0 auto 12px;
    width: 56px;
    height: 56px;
}

.login-brand .brand-icon svg {
    width: 56px;
    height: 56px;
}

.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.login-brand p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

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

.login-form .form-control {
    padding: 12px 14px;
    font-size: 0.9rem;
}

.login-form .btn {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
}

.login-error {
    background: var(--danger-light);
    color: #991b1b;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    margin-bottom: 16px;
    text-align: center;
    border: 1px solid #fecaca;
    animation: slideDown 0.3s ease;
}

/* ---- DASHBOARD GRID ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
}

.dashboard-grid .card {
    height: fit-content;
}

/* ---- LOW STOCK ALERTS ---- */
.alert-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: var(--danger-light);
    border: 1px solid #fecaca;
    font-size: 0.82rem;
}

.alert-item-warning {
    background: var(--warning-light);
    border-color: #fde68a;
}

.alert-item-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    flex-shrink: 0;
}

.alert-item-warning .alert-item-icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.alert-item-text {
    flex: 1;
    min-width: 0;
}

.alert-item-name {
    font-weight: 600;
    color: var(--text-primary);
}

.alert-item-qty {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ---- CHECKBOX GRID (for privileges) ---- */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all var(--transition);
    cursor: pointer;
    font-size: 0.82rem;
}

.checkbox-item:hover {
    background: var(--primary-50);
    border-color: var(--primary-200);
}

.checkbox-item input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

/* ---- HEADER OVERLAY ---- */
.header-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
}

body.sidebar-open {
    overflow: hidden;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

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

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

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

    .header-role-badge {
        display: none;
    }

    .profile-info {
        display: none;
    }

    .profile-trigger {
        gap: 0;
    }

    .profile-menu {
        position: fixed;
        top: calc(var(--header-height) + 8px);
        right: 12px;
        width: min(260px, calc(100vw - 24px));
    }

    .page-title {
        font-size: 1.25rem;
    }

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

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

    .login-card {
        padding: 28px 24px;
    }

    .modal {
        max-width: 100%;
        margin: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 85vh;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

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

    .data-table {
        font-size: 0.78rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.82rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .brand-text {
        display: none;
    }

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

    .page-actions {
        flex-direction: column;
    }

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

    .card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar {
        max-width: 100%;
    }
}

/* =============================================
   PAGE HEADER (title row + actions)
   ============================================= */
.content-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---- OUTLINE / GHOST BUTTONS ---- */
.btn-outline {
    background: var(--bg-card);
    color: var(--text-secondary);
    border-color: var(--border);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

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

/* =============================================
   POINT-OF-SALE / ORDER SCREEN
   ============================================= */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    align-items: start;
}

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

.pos-toolbar .search-bar {
    max-width: 240px;
    flex: 1;
    min-width: 160px;
}

.pos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
    gap: 12px;
    max-height: 66vh;
    overflow-y: auto;
    padding: 4px;
}

.pos-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
    text-align: left;
    width: 100%;
}

.pos-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.pos-item:active {
    transform: translateY(0) scale(0.98);
}

.pos-item-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.pos-item-cat {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.pos-item-price {
    margin-top: auto;
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--primary);
}

/* Order summary panel */
.order-panel {
    position: sticky;
    top: calc(var(--header-height) + 20px);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--header-height) - 40px);
}

.order-panel .card-body {
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.order-meta {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: grid;
    gap: 12px;
}

.order-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.order-lines {
    flex: 1;
    overflow-y: auto;
    padding: 6px 16px;
    min-height: 120px;
}

.order-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.order-line:last-child { border-bottom: none; }

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

.order-line-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.order-line-price {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.order-line-ext {
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 74px;
    text-align: right;
    color: var(--text-primary);
}

.order-line-remove {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition);
    flex-shrink: 0;
}

.order-line-remove:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* Quantity stepper */
.qty-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
}

.qty-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1rem;
    transition: all var(--transition);
}

.qty-btn:hover {
    background: var(--primary-50);
    color: var(--primary);
}

.qty-value {
    min-width: 30px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Totals + actions */
.order-totals {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-subtle);
    display: grid;
    gap: 6px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.total-row.grand {
    padding-top: 10px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.total-row.grand .total-amount { color: var(--primary); }

.order-actions {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 10px;
}

/* Colourful order summary panel */
.order-panel .card-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-bottom: none;
}
.order-panel .card-header .card-title { color: #fff; }

.order-totals {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border-top: none;
}
.order-totals .total-row { color: rgba(255, 255, 255, 0.9); }
.order-totals #subtotalDisplay { color: #fff; }
.order-totals .total-row.grand {
    color: #fff;
    border-top-color: rgba(255, 255, 255, 0.3);
}
.order-totals .total-row.grand .total-amount { color: #fff; }

/* Empty state inside order panel */
.order-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 32px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.order-empty svg { opacity: 0.35; }

@media (max-width: 900px) {
    .pos-layout {
        grid-template-columns: 1fr;
    }
    .order-panel {
        position: static;
        max-height: none;
    }
    .pos-grid {
        max-height: none;
    }
}

/* =============================================
   DASHBOARD POLISH
   ============================================= */

/* Card-header titles can carry a small colored icon chip */
.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius);
    background: var(--primary-50);
    color: var(--primary);
    flex-shrink: 0;
}

.card-title-ic svg { width: 16px; height: 16px; }
.card-title-ic.green  { background: var(--success-light); color: var(--success); }
.card-title-ic.amber  { background: var(--warning-light); color: var(--warning); }
.card-title-ic.red    { background: var(--danger-light);  color: var(--danger); }
.card-title-ic.cyan   { background: var(--info-light);    color: var(--info); }
.card-title-ic.purple { background: #f3e8ff;              color: #9333ea; }

/* Stat cards: refine, and support both markup variants (.stat-details / .stat-info) */
.stat-info { flex: 1; min-width: 0; }

/* Vibrant gradient stat cards — bold, colourful, borderless, white text.
   Colour is driven by position so it works across every dashboard's markup. */
.stats-grid .stat-card {
    border: none;
    border-radius: var(--radius-lg);
    color: #fff;
    box-shadow: var(--shadow-md);
    background: var(--sc-grad, linear-gradient(135deg, var(--primary), var(--secondary)));
}
.stats-grid .stat-card::after { display: none; }
.stats-grid .stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }

.stats-grid .stat-card:nth-child(6n+1) { --sc-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); }
.stats-grid .stat-card:nth-child(6n+2) { --sc-grad: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%); }
.stats-grid .stat-card:nth-child(6n+3) { --sc-grad: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.stats-grid .stat-card:nth-child(6n+4) { --sc-grad: linear-gradient(135deg, #f59e0b 0%, #f97316 100%); }
.stats-grid .stat-card:nth-child(6n+5) { --sc-grad: linear-gradient(135deg, #ec4899 0%, #db2777 100%); }
.stats-grid .stat-card:nth-child(6n+6) { --sc-grad: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%); }

/* White text + translucent icon chip on the coloured cards */
.stats-grid .stat-card .stat-value  { color: #fff; }
.stats-grid .stat-card .stat-label  { color: rgba(255, 255, 255, 0.92); }
.stats-grid .stat-card .stat-change { color: rgba(255, 255, 255, 0.88); }
.stats-grid .stat-card .stat-icon {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #fff !important;
}

/* Action button clusters in table rows */
.btn-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-group .btn.btn-icon,
.btn-group .btn.btn-sm {
    width: auto;
}

/* Icon-only action button used in tables */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    transition: all var(--transition);
}

.btn-action:hover {
    border-color: var(--primary-200);
    background: var(--primary-50);
    color: var(--primary);
}

.btn-action.success:hover { border-color: #a7f3d0; background: var(--success-light); color: var(--success); }
.btn-action.warning:hover { border-color: #fde68a; background: var(--warning-light); color: var(--warning); }
.btn-action.danger:hover  { border-color: #fecaca; background: var(--danger-light);  color: var(--danger); }

.btn-action svg { width: 16px; height: 16px; }

/* Horizontal-scroll wrapper alias used by several pages */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
/* Sales scenarios are visually distinct from official production data. */
.simulation-warning,.global-simulation-banner{background:#7f1d1d;color:#fff;border:3px solid #fca5a5;padding:14px 18px;display:flex;gap:12px;align-items:center;justify-content:space-between;position:relative;z-index:20}
.simulation-warning{border-radius:10px;margin-bottom:20px}.global-simulation-banner{position:sticky;top:0;z-index:1000;text-align:center;flex-direction:column;gap:3px}
.scenario-meta{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:18px}.scenario-report{position:relative}.simulation-watermark{display:none}.simulation-print-footer{margin-top:20px;font-weight:700;color:#7f1d1d;text-align:center}
@media print{.sidebar,.main-header,.global-simulation-banner,.no-print{display:none!important}.main-content{margin:0!important;padding:12px!important}.simulation-watermark{display:block;position:fixed;inset:35% 0 auto;transform:rotate(-25deg);font-size:90px;font-weight:800;text-align:center;color:rgba(127,29,29,.12);z-index:999;pointer-events:none}.simulation-warning{display:flex!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}.scenario-report .card{break-inside:avoid}}

/* Print: render table footers once at the end, not repeated on every page */
@media print {
    .data-table tfoot { display: table-row-group; }
}

/* ---- DATABASE SWITCHER ---- */
.header-dbswitch { position: relative; }

.dbswitch-trigger {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--bg-card);
    color: var(--text-primary); font-size: 0.8rem; font-weight: 600;
    cursor: pointer; transition: all var(--transition); max-width: 260px;
}
.dbswitch-trigger:hover { background: var(--bg-body); }
.dbswitch-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbswitch-chevron { color: var(--text-muted); transition: transform var(--transition); flex-shrink: 0; }
.header-dbswitch.active .dbswitch-chevron { transform: rotate(180deg); }

/* A non-primary database is tinted amber everywhere it appears, so nobody
   mistakes a secondary dataset for the live one. */
.header-dbswitch.is-secondary .dbswitch-trigger {
    border-color: #f59e0b; background: #fffbeb; color: #92400e;
}

.dbswitch-menu {
    position: absolute; top: calc(100% + 8px); right: 0; width: 300px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: all var(--transition); z-index: 1100; overflow: hidden;
}
.header-dbswitch.active .dbswitch-menu { opacity: 1; visibility: visible; transform: translateY(0); }

.dbswitch-menu-title {
    padding: 12px 14px 8px; font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
}
.dbswitch-menu form { margin: 0; }
.dbswitch-item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; padding: 10px 14px; border: 0; background: none; cursor: pointer;
    text-align: left; color: var(--text-primary); transition: background var(--transition);
}
.dbswitch-item:hover { background: var(--bg-body); }
.dbswitch-item.is-active { background: rgba(72,69,201,.07); color: var(--primary); }
.dbswitch-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dbswitch-item-label { font-size: 0.83rem; font-weight: 600; }
.dbswitch-item-sub { font-size: 0.7rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbswitch-manage {
    display: block; padding: 10px 14px; border-top: 1px solid var(--border);
    font-size: 0.78rem; font-weight: 600; color: var(--primary); background: var(--bg-body);
}

/* ---- DATABASE / STATUS BANNERS ---- */
.db-banner {
    padding: 10px 18px; font-size: 0.82rem; text-align: center;
    border-bottom: 1px solid transparent;
}
.db-banner-warn  { background: #fef3c7; color: #92400e; border-bottom-color: #fcd34d; }
.db-banner-error { background: #fee2e2; color: #991b1b; border-bottom-color: #fca5a5; }
.db-banner-ok    { background: #dcfce7; color: #166534; border-bottom-color: #86efac; }

@media (max-width: 768px) {
    .dbswitch-label { display: none; }
    .dbswitch-trigger { max-width: none; }
    .dbswitch-menu { width: 260px; }
}

/* ---- ACCOUNTING / BOOKS ---- */
.books-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.books-tab {
    padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--bg-card); font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
}
.books-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.acc-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.acc-table th, .acc-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.acc-table th { text-align: left; font-size: 0.72rem; text-transform: uppercase;
                letter-spacing: .04em; color: var(--text-muted); background: var(--bg-body); }
.acc-table td.num, .acc-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.acc-table tr.acc-header-row td { font-weight: 700; background: var(--bg-body); }
.acc-table tr.acc-total td { font-weight: 700; border-top: 2px solid var(--text-primary); }
.acc-code { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.acc-void { opacity: .55; text-decoration: line-through; }

.acc-pill { display: inline-block; padding: 2px 8px; border-radius: 999px;
            font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.acc-pill-asset     { background:#e0f2fe; color:#075985; }
.acc-pill-liability { background:#fee2e2; color:#991b1b; }
.acc-pill-equity    { background:#ede9fe; color:#5b21b6; }
.acc-pill-income    { background:#dcfce7; color:#166534; }
.acc-pill-expense   { background:#ffedd5; color:#9a3412; }
.acc-pill-posted    { background:#dcfce7; color:#166534; }
.acc-pill-void      { background:#e5e7eb; color:#374151; }

.acc-balanced   { color:#166534; font-weight:700; }
.acc-unbalanced { color:#991b1b; font-weight:700; }

/* ---- BOOKS: FILTER BARS ---- */
/* The date/account pickers that sit in a card header. They need to size to
   their content rather than the .form-control default of 100%, and they need
   to wrap rather than overflow once a card gets narrow. */
.books-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.books-filter .form-control {
    width: auto;
    min-width: 0;
    padding: 7px 12px;
    font-size: 0.8125rem;
}
.books-filter select.form-control { padding-right: 32px; min-width: 220px; }
.books-filter .books-filter-sep { color: var(--text-muted); font-size: 0.8125rem; }
.books-filter .form-label { margin: 0; white-space: nowrap; }

/* Card headers carrying a filter bar need to wrap on narrow screens instead of
   squeezing the title into nothing. */
.card-header.has-filter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .books-filter { width: 100%; }
    .books-filter .form-control { flex: 1 1 140px; }
}

/* ---- BOOKS: CHART OF ACCOUNTS LAYOUT ---- */
/* The account list carries five columns and is the reason for the page, so it
   gets the room; the add/edit form is a sidebar next to it rather than an equal
   half. Collapses to a single column before the table starts to crush. */
.books-split {
    display: grid;
    grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}
@media (max-width: 1180px) {
    .books-split { grid-template-columns: minmax(0, 1fr); }
}

/* Wide tables scroll inside their own card rather than pushing the page out. */
.acc-table-wrap { overflow-x: auto; }
.acc-table-wrap .acc-table { min-width: 560px; }

/* Small muted text that is allowed to wrap. Distinct from .dbswitch-item-sub,
   which is deliberately clipped to one line for the database switcher and was
   truncating the explanatory notes under these forms. */
.books-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.6;
    white-space: normal;
}
.books-hint strong { color: var(--text-secondary); }
