/* ============================================
   SAFARI SEEDS - COMPLETE DESIGN SYSTEM
   Based on Figma Design Specification v1.0
   ============================================ */

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

/* ============================================
   SECTION 1: DESIGN TOKENS
   ============================================ */

:root {
    /* PRIMARY COLORS - Safari Green */
    --primary-900: #0a2710;
    --primary-800: #0e3b17;
    --primary-700: #124f1e;
    --primary-600: #166325;
    --primary-500: #1a5f2a;
    /* Main Brand Green ★ */
    --primary-400: #2d8a3e;
    --primary-300: #4caf50;
    --primary-200: #81c784;
    --primary-100: #c8e6c9;
    --primary-50: #e8f5e9;

    /* SECONDARY COLORS - Gold */
    --secondary-900: #ff6f00;
    --secondary-800: #ff8f00;
    --secondary-700: #ffa000;
    --secondary-600: #ffb300;
    --secondary-500: #f4a020;
    /* Main Gold ★ */
    --secondary-400: #ffca28;
    --secondary-300: #ffd54f;
    --secondary-200: #ffe082;
    --secondary-100: #ffecb3;
    --secondary-50: #fff8e1;

    /* NEUTRAL COLORS */
    --gray-900: #212121;
    --gray-800: #424242;
    --gray-700: #616161;
    --gray-600: #757575;
    --gray-500: #9e9e9e;
    --gray-400: #bdbdbd;
    --gray-300: #e0e0e0;
    --gray-200: #eeeeee;
    --gray-100: #f5f5f5;
    --gray-50: #fafafa;
    --white: #ffffff;

    /* SEMANTIC COLORS */
    --success: #28a745;
    --success-light: #d4edda;
    --warning: #ffc107;
    --warning-light: #fff3cd;
    --danger: #dc3545;
    --danger-light: #f8d7da;
    --info: #17a2b8;
    --info-light: #d1ecf1;

    /* DARK THEME (Sidebar) */
    --dark-primary: #1a1a2e;
    --dark-secondary: #16213e;
    --dark-tertiary: #0f3460;
    --dark-text: rgba(255, 255, 255, 0.87);
    --dark-text-muted: rgba(255, 255, 255, 0.6);
    --dark-border: rgba(255, 255, 255, 0.1);

    /* TYPOGRAPHY */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* SPACING (8px base grid) */
    --space-0: 0px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    --space-20: 80px;
    --space-24: 96px;

    /* BORDER RADIUS */
    --radius-none: 0px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-2xl: 16px;
    --radius-3xl: 24px;
    --radius-full: 9999px;

    /* SHADOWS */
    --shadow-none: none;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.25);
    --focus-ring: 0 0 0 3px rgba(26, 95, 42, 0.2);

    /* Custom Scrollbar - High Visibility Green */
    ::-webkit-scrollbar {
        width: 12px;
        height: 12px;
    }

    ::-webkit-scrollbar-track {
        background: var(--gray-100);
        border-radius: 10px;
    }

    ::-webkit-scrollbar-thumb {
        background: var(--primary-500);
        border-radius: 10px;
        border: 3px solid var(--gray-100);
    }

    ::-webkit-scrollbar-thumb:hover {
        background: var(--primary-600);
    }

    /* For Firefox */
    * {
        scrollbar-width: auto;
        scrollbar-color: var(--primary-500) var(--gray-100);
    }

    --sidebar-width: 280px;
    --sidebar-collapsed: 80px;
    --header-height: 64px;
}

/* ============================================
   SECTION 2: BASE STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary) !important;
    font-size: 14px;
    line-height: 22px;
    color: var(--gray-900);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   SECTION 3: TYPOGRAPHY
   ============================================ */

.display-xl {
    font-size: 48px;
    line-height: 56px;
    letter-spacing: -0.5px;
    font-weight: 700;
}

.display-lg {
    font-size: 36px;
    line-height: 44px;
    letter-spacing: -0.25px;
    font-weight: 700;
}

.heading-1 {
    font-size: 30px;
    line-height: 38px;
    font-weight: 600;
}

.heading-2 {
    font-size: 24px;
    line-height: 32px;
    font-weight: 600;
}

.heading-3 {
    font-size: 20px;
    line-height: 28px;
    font-weight: 600;
}

.heading-4 {
    font-size: 18px;
    line-height: 26px;
    font-weight: 500;
}

.body-lg {
    font-size: 16px;
    line-height: 24px;
    font-weight: 400;
}

.body-md {
    font-size: 14px;
    line-height: 22px;
    font-weight: 400;
}

.body-sm {
    font-size: 13px;
    line-height: 20px;
    font-weight: 400;
}

.caption {
    font-size: 12px;
    line-height: 18px;
    letter-spacing: 0.2px;
    font-weight: 400;
}

.overline {
    font-size: 11px;
    line-height: 16px;
    letter-spacing: 0.5px;
    font-weight: 500;
    text-transform: uppercase;
}

/* ============================================
   SECTION 4: BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 20px;
    height: 40px;
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal) ease;
    text-decoration: none;
}

.btn:focus {
    outline: none;
    box-shadow: var(--focus-ring);
}

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

/* Primary Button */
.btn-primary {
    background: var(--primary-500);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
    background: var(--primary-700);
    transform: translateY(0);
}

/* Secondary Button */
.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-800);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-200);
    border-color: var(--gray-400);
}

/* Success Button */
.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Outline Buttons */
.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary-500);
    color: var(--primary-500);
}

.btn-outline-primary:hover:not(:disabled) {
    background: var(--primary-50);
    border-color: var(--primary-600);
    color: var(--primary-600);
}

.btn-outline-secondary {
    background: transparent;
    border: 1px solid var(--gray-400);
    color: var(--gray-600);
}

.btn-outline-secondary:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-600);
    color: var(--gray-800);
}

.btn-outline-success {
    background: transparent;
    border: 1px solid var(--success);
    color: var(--success);
}

.btn-outline-success:hover:not(:disabled) {
    background: var(--success-light);
}

.btn-outline-warning {
    background: transparent;
    border: 1px solid var(--warning);
    color: #856404;
}

.btn-outline-warning:hover:not(:disabled) {
    background: var(--warning-light);
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-outline-danger:hover:not(:disabled) {
    background: var(--danger-light);
}

/* Danger Button */
.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Ghost Button */
.btn-ghost {
    background: transparent;
    color: var(--primary-500);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--primary-50);
}

/* Button Sizes */
.btn-sm {
    height: 32px;
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    height: 48px;
    padding: 12px 24px;
    font-size: 16px;
}

/* Icon Button */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: var(--space-2);
    border-radius: var(--radius-lg);
}

/* Full Width */
.btn-block {
    width: 100%;
}

/* ============================================
   SECTION 5: FORM INPUTS
   ============================================ */

.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-700);
    margin-bottom: var(--space-2);
    white-space: normal;
    /* Fix: Allow long labels to wrap */
    word-wrap: break-word;
}

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    height: 44px;
    padding: 10px 16px;
    border: 1px solid #E0E0E0;
    border-radius: var(--radius-lg);
    background: var(--white);
    font-family: var(--font-primary);
    font-size: 14px;
    color: var(--gray-900);
    box-shadow: none;
    transition: all 0.2s ease;
}

.form-control::placeholder {
    color: var(--gray-400);
}

/* Hover state - darker border */
.form-control:hover:not(:focus):not(:disabled) {
    border-color: #1A1A1A;
    background: var(--white);
}

/* Active/Focus state - cyan/teal border with focus ring */
.form-control:focus {
    outline: none;
    border-color: #0EA5E9;
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

/* Disabled state - gray background, muted text */
.form-control:disabled,
.form-control[readonly] {
    background: #F5F5F5;
    border-color: #E0E0E0;
    color: var(--gray-500);
    cursor: not-allowed;
    box-shadow: none;
}

/* Readonly fields should look slightly different */
.form-control[readonly]:not(:disabled) {
    background: #FAFAFA;
    cursor: default;
}

.form-control.is-invalid {
    border-color: var(--danger);
    background: #fff5f5;
    box-shadow: 0 0 0 4px var(--danger-light);
}

.form-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: var(--space-2);
}

.form-error {
    font-size: 12px;
    font-weight: 500;
    color: var(--danger);
    margin-top: var(--space-1);
}

/* Input with Icon */
.input-group {
    position: relative;
}

.input-group .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
    width: 18px;
    height: 18px;
    pointer-events: none;
}

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

.input-group .input-icon-right {
    position: absolute;
    left: auto;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    pointer-events: auto;
    color: var(--gray-500);
}

.input-group .form-control.has-icon-right {
    padding-right: 42px;
}

/* Input with Addon */
.input-addon {
    display: flex;
}

.input-addon .addon {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
    font-size: 14px;
}

.input-addon .addon-left {
    border-right: none;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.input-addon .addon-right {
    border-left: none;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.input-addon .form-control {
    border-radius: 0;
}

.input-addon .form-control:first-child {
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.input-addon .form-control:last-child {
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

/* Textarea */
textarea.form-control {
    height: auto;
    min-height: 100px;
    resize: vertical;
}

/* Select & Datalist Inputs */
select.form-control,
input[list].form-control {
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    padding-right: 40px !important;
}

/* Make the dropdown behavior feel more natural */
input[list].form-control {
    cursor: pointer;
}

input[list].form-control:focus {
    cursor: text;
}

/* Hide default datalist arrow in WebKit to use our unified SVG arrow */
input[list].form-control::-webkit-calendar-picker-indicator {
    opacity: 0 !important;
    cursor: pointer !important;
    padding: 10px;
    /* Increase click area */
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-500);
    cursor: pointer;
}

.form-check-label {
    font-size: 14px;
    color: var(--gray-700);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    transition: var(--transition-normal);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background: var(--white);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--primary-500);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(20px);
}

/* ============================================
   SECTION 6: CARDS
   ============================================ */

.card {
    background: var(--white);
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: visible;
    /* Fix: Ensure shadows and borders aren't clipped */
    max-width: 100%;
    /* Fix: Prevent width overflow */
    position: relative;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--gray-100);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.card-body {
    padding: var(--space-6);
}

.card-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

/* Stat Card */
.stat-card {
    background: var(--white);
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 16px;
    display: flex;
    flex-direction: column !important;
    /* Vertical stack */
    align-items: flex-start !important;
    gap: 8px !important;
    overflow: visible;
}

.stat-card .stat-icon {
    width: 32px !important;
    height: 32px !important;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card .stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-card .stat-icon.success {
    background: var(--success-light);
    color: var(--success);
}

.stat-card .stat-icon.warning {
    background: var(--warning-light);
    color: #856404;
}

.stat-card .stat-icon.danger {
    background: var(--danger-light);
    color: var(--danger);
}

.stat-card .stat-icon.info {
    background: var(--info-light);
    color: var(--info);
}

.stat-card .stat-icon.primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.stat-card .stat-content {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.stat-card .stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-1);
}

.stat-card .stat-value {
    font-size: 1.2rem !important;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.1;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    word-break: normal !important;
    max-width: 100%;
    display: block;
}

.stat-card .stat-change {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    margin-top: var(--space-2);
}

.stat-card .stat-change.positive {
    color: var(--success);
}

.stat-card .stat-change.negative {
    color: var(--danger);
}

/* ============================================
   SECTION 7: DATA TABLES
   ============================================ */

.table-container {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    /* Keep vertical hidden for border-radius */
    overflow-x: auto;
    /* Allow horizontal scroll */
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
    /* Reduced from 8px */
}

.table thead {
    background: var(--gray-100);
}

.table thead th {
    padding: 8px 10px;
    /* Reduced padding */
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border-bottom: none;
    vertical-align: middle;
    /* Ensure alignment */
}

.table tbody tr {
    background: var(--white);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--white);
    transform: translateY(-1px);
    /* Subtle hover lift */
    box-shadow: var(--shadow-md);
}

.table tbody td {
    padding: 8px 10px;
    /* Reduced padding */
    font-size: 14px;
    color: var(--gray-900);
    vertical-align: middle;
    border-top: 1px solid var(--gray-50);
    border-bottom: 1px solid var(--gray-50);
}

.table tbody td:first-child {
    border-left: 1px solid var(--gray-50);
    border-top-left-radius: var(--radius-md);
    border-bottom-left-radius: var(--radius-md);
}

.table tbody td:last-child {
    border-right: 1px solid var(--gray-50);
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

/* Table Pagination */
.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--gray-100);
}

.table-pagination .info {
    font-size: 14px;
    color: var(--gray-600);
}

.table-pagination .pages {
    display: flex;
    gap: var(--space-1);
}

.table-pagination .page-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--gray-700);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.table-pagination .page-btn:hover {
    background: var(--gray-100);
}

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

/* Empty State */
.table-empty {
    padding: var(--space-12);
    text-align: center;
}

.table-empty .icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-4);
    color: var(--gray-300);
}

.table-empty .message {
    font-size: 14px;
    color: var(--gray-500);
}

/* ============================================
   SECTION 8: BADGES
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 500;
    text-transform: capitalize;
    white-space: nowrap !important;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: #856404;
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-info {
    background: var(--info-light);
    color: var(--info);
}

.badge-primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

/* Status Dot */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot.active {
    background: var(--success);
}

.status-dot.inactive {
    background: var(--gray-400);
}

.status-dot.pending {
    background: var(--warning);
}

.status-dot.error {
    background: var(--danger);
}

/* ============================================
   SECTION 9: AVATARS
   ============================================ */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary-500);
    color: var(--white);
    font-weight: 700;
    overflow: hidden;
}

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

.avatar-xs {
    width: 24px;
    height: 24px;
    font-size: 10px;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 13px;
}

.avatar-md {
    width: 40px;
    height: 40px;
    font-size: 16px;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 19px;
}

.avatar-xl {
    width: 64px;
    height: 64px;
    font-size: 26px;
}

.avatar-2xl {
    width: 96px;
    height: 96px;
    font-size: 38px;
}

/* ============================================
   SECTION 10: MODALS
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn var(--transition-normal) ease;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: scaleIn var(--transition-slow) ease;
    width: 100%;
    max-width: 500px;
    /* Default width */
    overflow-y: auto;
}

.modal-sm {
    width: 400px;
}

.modal-md {
    width: 560px;
}

.modal-lg {
    width: 800px;
}

.modal-xl {
    width: 1000px;
}

.modal-full {
    width: 95vw;
    max-width: 1400px;
}

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

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    border: none;
    background: transparent;
    color: var(--gray-500);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-body {
    padding: var(--space-6);
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding-top: var(--space-4);
    margin-top: auto;
    /* Push to bottom if flex container */
    border-top: 1px solid var(--gray-100);
}

/* --- Compact Modal (No Page Scroll) --- */
.modal-no-scroll .modal-content {
    height: 90vh;
    /* Fixed height */
    max-height: 90vh;
    overflow: hidden;
    /* Prevent body scroll */
    display: flex;
    flex-direction: column;
}

.modal-no-scroll .modal-body {
    flex: 1;
    overflow-y: auto;
    /* Only body scrolls */
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
}

.form-row-compact {
    display: flex;
    gap: 8px;
    align-items: center;
}

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

.form-row-compact .form-control {
    height: 36px;
    font-size: 13px;
    padding: 4px 8px;
}



/* ============================================
   SECTION 11: TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    width: 360px;
    padding: var(--space-4);
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid;
    display: flex;
    gap: var(--space-3);
    animation: slideInRight var(--transition-slow) ease;
}

.toast.success {
    border-left-color: var(--primary-500);
}

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

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

.toast.info {
    border-left-color: var(--info);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: var(--gray-600);
}

.toast-close {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    flex-shrink: 0;
}

/* ============================================
   SECTION 12: ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.animate-fade-in {
    animation: fadeIn var(--transition-normal) ease;
}

.animate-scale-in {
    animation: scaleIn var(--transition-slow) ease;
}

.animate-slide-up {
    animation: slideInUp var(--transition-slow) ease;
}

.animate-spin {
    animation: spin 0.8s linear infinite;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--gray-200) 0%, var(--gray-100) 50%, var(--gray-200) 100%);
    background-size: 1000px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

/* ============================================
   SECTION 13: UTILITIES
   ============================================ */

/* Display */
.d-none {
    display: none !important;
}

.d-block {
    display: block !important;
}

.d-flex {
    display: flex !important;
}

.d-inline-flex {
    display: inline-flex !important;
}

.d-grid {
    display: grid !important;
}

/* Flexbox */
.flex-row {
    flex-direction: row !important;
}

.flex-column {
    flex-direction: column !important;
}

.justify-start {
    justify-content: flex-start !important;
}

.justify-center {
    justify-content: center !important;
}

.justify-end {
    justify-content: flex-end !important;
}

.justify-between {
    justify-content: space-between !important;
}

.align-start {
    align-items: flex-start !important;
}

.align-center {
    align-items: center !important;
}

.align-end {
    align-items: flex-end !important;
}

.flex-wrap {
    flex-wrap: wrap !important;
}

.flex-1 {
    flex: 1 !important;
}

.gap-1 {
    gap: var(--space-1) !important;
}

.gap-2 {
    gap: var(--space-2) !important;
}

.gap-3 {
    gap: var(--space-3) !important;
}

.gap-4 {
    gap: var(--space-4) !important;
}

.gap-6 {
    gap: var(--space-6) !important;
}

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

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

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

/* Spacing */
.m-0 {
    margin: 0 !important;
}

.m-1 {
    margin: var(--space-1) !important;
}

.m-2 {
    margin: var(--space-2) !important;
}

.m-3 {
    margin: var(--space-3) !important;
}

.m-4 {
    margin: var(--space-4) !important;
}

.m-6 {
    margin: var(--space-6) !important;
}

.mt-0 {
    margin-top: 0 !important;
}

.mt-1 {
    margin-top: var(--space-1) !important;
}

.mt-2 {
    margin-top: var(--space-2) !important;
}

.mt-3 {
    margin-top: var(--space-3) !important;
}

.mt-4 {
    margin-top: var(--space-4) !important;
}

.mt-6 {
    margin-top: var(--space-6) !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: var(--space-1) !important;
}

.mb-2 {
    margin-bottom: var(--space-2) !important;
}

.mb-3 {
    margin-bottom: var(--space-3) !important;
}

.mb-4 {
    margin-bottom: var(--space-4) !important;
}

.mb-6 {
    margin-bottom: var(--space-6) !important;
}

.ml-0 {
    margin-left: 0 !important;
}

.ml-1 {
    margin-left: var(--space-1) !important;
}

.ml-2 {
    margin-left: var(--space-2) !important;
}

.ml-3 {
    margin-left: var(--space-3) !important;
}

.ml-4 {
    margin-left: var(--space-4) !important;
}

.mr-0 {
    margin-right: 0 !important;
}

.mr-1 {
    margin-right: var(--space-1) !important;
}

.mr-2 {
    margin-right: var(--space-2) !important;
}

.mr-3 {
    margin-right: var(--space-3) !important;
}

.mr-4 {
    margin-right: var(--space-4) !important;
}

.p-0 {
    padding: 0 !important;
}

.p-1 {
    padding: var(--space-1) !important;
}

.p-2 {
    padding: var(--space-2) !important;
}

.p-3 {
    padding: var(--space-3) !important;
}

.p-4 {
    padding: var(--space-4) !important;
}

.p-6 {
    padding: var(--space-6) !important;
}

/* Text */
.text-left {
    text-align: left !important;
}

.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

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

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

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

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

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

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

.font-bold {
    font-weight: 700 !important;
}

.font-semibold {
    font-weight: 600 !important;
}

.font-medium {
    font-weight: 500 !important;
}

/* Background */
.bg-white {
    background: var(--white) !important;
}

.bg-gray-50 {
    background: var(--gray-50) !important;
}

.bg-gray-100 {
    background: var(--gray-100) !important;
}

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

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

/* Border */
.border {
    border: 1px solid var(--gray-200) !important;
}

.border-top {
    border-top: 1px solid var(--gray-200) !important;
}

.border-bottom {
    border-bottom: 1px solid var(--gray-200) !important;
}

.rounded {
    border-radius: var(--radius-lg) !important;
}

.rounded-xl {
    border-radius: var(--radius-xl) !important;
}

.rounded-full {
    border-radius: var(--radius-full) !important;
}

/* Width/Height */
.w-full {
    width: 100% !important;
}

.h-full {
    height: 100% !important;
}

/* Position */
.relative {
    position: relative !important;
}

.absolute {
    position: absolute !important;
}

.fixed {
    position: fixed !important;
}

/* Overflow */
.overflow-hidden {
    overflow: hidden !important;
}

.overflow-auto {
    overflow: auto !important;
}

/* Cursor */
.cursor-pointer {
    cursor: pointer !important;
}

.cursor-not-allowed {
    cursor: not-allowed !important;
}

/* ============================================
   SECTION 14: TABS
   ============================================ */

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
    padding: 4px;
    /* Space for focus rings/shadows */
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-full);
    color: var(--gray-600);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.tab-btn:hover {
    background: var(--gray-50);
    color: var(--primary-600);
    border-color: var(--primary-200);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tab-btn:active {
    transform: translateY(0);
}

.tab-btn.active {
    background: var(--primary-500);
    color: var(--white);
    border-color: var(--primary-500);
    box-shadow: var(--shadow-md);
    font-weight: 600;
}

/* Optional: Add an icon support if they add icons to tabs later */
.tab-btn i,
.tab-btn svg {
    margin-right: 8px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ============================================
   SECTION 8: UTILITIES (ADDED)
   ============================================ */

.grid {
    display: grid;
    gap: 16px;
}

.grid-cols-12 {
    grid-template-columns: repeat(12, minmax(0, 1fr));
}

.col-span-1 {
    grid-column: span 1 / span 1;
}

.col-span-2 {
    grid-column: span 2 / span 2;
}

.col-span-3 {
    grid-column: span 3 / span 3;
}

.col-span-4 {
    grid-column: span 4 / span 4;
}

.col-span-5 {
    grid-column: span 5 / span 5;
}

.col-span-6 {
    grid-column: span 6 / span 6;
}

.col-span-7 {
    grid-column: span 7 / span 7;
}

.col-span-8 {
    grid-column: span 8 / span 8;
}

.col-span-9 {
    grid-column: span 9 / span 9;
}

.col-span-10 {
    grid-column: span 10 / span 10;
}

.col-span-11 {
    grid-column: span 11 / span 11;
}

.col-span-12 {
    grid-column: span 12 / span 12;
}

.items-end {
    align-items: flex-end !important;
}


.gap-4 {
    gap: 16px;
}

.mb-4 {
    margin-bottom: 16px;
}

.mb-6 {
    margin-bottom: 24px;
}

.bg-gray-50 {
    background-color: var(--gray-50);
}

.p-3 {
    padding: 12px;
}

.rounded {
    border-radius: 8px;
}

.border {
    border: 1px solid var(--gray-200);
}

/* ============================================
   SECTION 15: PREMIUM MODAL HEADERS
   ============================================ */

/* --- Premium Gradient Modal Headers --- */
.modal-header-green {
    background: linear-gradient(135deg, #166325 0%, #1a5f2a 50%, #2d8a3e 100%) !important;
    color: #fff !important;
    border-radius: 16px 16px 0 0;
    padding: 14px 20px !important;
    border-bottom: none !important;
}

.modal-header-blue {
    background: linear-gradient(135deg, #1565c0 0%, #0d47a1 50%, #1976d2 100%) !important;
    color: #fff !important;
    border-radius: 16px 16px 0 0;
    padding: 14px 20px !important;
    border-bottom: none !important;
}

.modal-header-teal {
    background: linear-gradient(135deg, #0f766e 0%, #115e59 50%, #14b8a6 100%) !important;
    color: #fff !important;
    border-radius: 16px 16px 0 0;
    padding: 14px 20px !important;
    border-bottom: none !important;
}

.modal-header-neutral {
    background: linear-gradient(135deg, #374151 0%, #1f2937 50%, #4b5563 100%) !important;
    color: #fff !important;
    border-radius: 16px 16px 0 0;
    padding: 14px 20px !important;
    border-bottom: none !important;
}

.modal-header-green .modal-title,
.modal-header-blue .modal-title,
.modal-header-teal .modal-title,
.modal-header-neutral .modal-title {
    color: #fff !important;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header-green .close-modal,
.modal-header-blue .close-modal,
.modal-header-teal .close-modal,
.modal-header-neutral .close-modal,
.modal-header-green .qa-close,
.modal-header-blue .qa-close,
.modal-header-teal .qa-close,
.modal-header-neutral .qa-close {
    color: rgba(255, 255, 255, 0.85) !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: none !important;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 20px;
}

.modal-header-green .close-modal:hover,
.modal-header-blue .close-modal:hover,
.modal-header-teal .close-modal:hover,
.modal-header-neutral .close-modal:hover,
.modal-header-green .qa-close:hover,
.modal-header-blue .qa-close:hover,
.modal-header-teal .qa-close:hover,
.modal-header-neutral .qa-close:hover {
    background: rgba(255, 255, 255, 0.25) !important;
}

/* --- Keyboard Shortcut Badges --- */
.kbd-badge {
    font-size: 11px;
    background: rgba(255, 255, 255, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* --- Compact Form Utilities --- */
.form-label-xs {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
    margin-bottom: 2px;
}

.form-control-compact {
    height: 34px !important;
    font-size: 13px !important;
    padding: 4px 10px !important;
    border-radius: 6px !important;
}

/* --- Section Divider --- */
.form-section {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
}

.form-section-blue {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
}

.form-section-green {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
}

/* --- Item Entry Row --- */
.item-entry-header {
    display: flex;
    gap: 6px;
    align-items: center;
    background: #f1f5f9;
    padding: 6px 8px;
    border-radius: 6px 6px 0 0;
    border: 1px solid #e2e8f0;
    border-bottom: none;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
}

.item-entry-row {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    background: #fff;
    padding: 8px;
    border-radius: 0 0 6px 6px;
    border: 1px solid #e2e8f0;
}

/* --- Premium Footer --- */
.modal-footer-premium {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    border-radius: 0 0 16px 16px;
    gap: 12px;
}

/* --- Highlight Input Variants --- */
.form-control-highlight-blue {
    border: 2px solid #3b82f6 !important;
    background: #eff6ff !important;
}

.form-control-highlight-green {
    border: 2px solid #22c55e !important;
    background: #f0fdf4 !important;
}

.form-control-highlight-amber {
    border: 2px solid #f59e0b !important;
    background: #fffbeb !important;
}

/* ============================================
   SECTION 20: LAYOUT UTILITIES & PROTECTION
   ============================================ */

.grid {
    display: grid;
    min-width: 0;
}

.grid>div {
    min-width: 0;
    /* Critical: Prevent children from expanding grid */
}

/* Ensure all cards are contained and borders are visible */
.card {
    max-width: 100%;
    width: 100%;
    margin-bottom: var(--space-6);
    box-sizing: border-box;
    overflow: visible;
    /* Ensure shadows/borders aren't clipped */
}

.mx-auto {
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Base box-sizing reset for safety */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ============================================
   SECTION 21: LEDGER TABLE HOVER STYLES
   ============================================ */

.ledger-row {
    transition: background-color 0.15s ease;
}

.ledger-row:hover {
    background-color: #dbeafe !important;
    /* clear blue highlight */
}

.ledger-row:hover td {
    background-color: #dbeafe !important;
}

/* ============================================
   SECTION 22: CUSTOM ACCOUNT AUTOCOMPLETE
   ============================================ */

.account-autocomplete-wrapper {
    position: relative;
}

.account-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #fff;
    border: 1.5px solid #2563eb;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.15);
    max-height: 260px;
    overflow-y: auto;
    margin-top: -1px;
}

.account-autocomplete-item {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    transition: background-color 0.1s ease;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.account-autocomplete-item:last-child {
    border-bottom: none;
}

.account-autocomplete-item:hover,
.account-autocomplete-item.active {
    background-color: #2563eb;
    color: #fff;
}

.account-autocomplete-item:hover .account-sub,
.account-autocomplete-item.active .account-sub {
    color: #bfdbfe;
}

.account-autocomplete-item .account-name {
    font-weight: 600;
}

.account-autocomplete-item .account-sub {
    font-size: 11px;
    color: #64748b;
}

.account-autocomplete-empty {
    padding: 10px 12px;
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
    font-style: italic;
}