/* ═══════════════════════════════════════════════════════════════
   Invoice Matcher — Design C (Light Clean)
   Palette: white cards / #f0f4ff bg / #6366f1→#0ea5e9 accent
═══════════════════════════════════════════════════════════════ */

:root {
    --im-bg:           #f0f4ff;
    --im-surface:      #ffffff;
    --im-border:       #e2e8f0;
    --im-border-light: #f1f5f9;
    --im-accent:       #6366f1;
    --im-accent2:      #0ea5e9;
    --im-accent-bg:    #eef2ff;
    --im-text:         #1e293b;
    --im-text-muted:   #64748b;
    --im-text-faint:   #94a3b8;
    --im-shadow-sm:    0 1px 3px rgba(0,0,0,0.06);
    --im-shadow-md:    0 4px 16px rgba(99,102,241,0.10);
    --im-radius:       14px;
    --im-radius-sm:    9px;
    --im-sidebar-w:    248px;
    --im-topbar-h:     60px;
}

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

html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', Inter, system-ui, sans-serif;
    font-size: 14px;
    color: var(--im-text);
    background: var(--im-bg);
}

/* ── Layout ──────────────────────────────────────────────────── */
.im-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.im-sidebar {
    width: var(--im-sidebar-w);
    min-height: 100vh;
    background: var(--im-surface);
    border-right: 1px solid var(--im-border);
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 2px 0 12px rgba(99,102,241,0.06);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.im-sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 18px;
    border-bottom: 1px solid var(--im-border-light);
    margin-bottom: 12px;
}

.im-logo-icon {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--im-accent), var(--im-accent2));
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.im-logo-icon i { color: #fff; font-size: 16px; }
.im-logo-text { color: var(--im-text); font-weight: 800; font-size: 14px; white-space: nowrap; }

/* Nav */
.im-nav-section {
    font-size: 10px; font-weight: 700;
    color: var(--im-text-faint);
    letter-spacing: 1px; text-transform: uppercase;
    padding: 0 8px; margin: 12px 0 4px;
}

.im-nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px;
    border-radius: var(--im-radius-sm);
    color: var(--im-text-muted);
    font-size: 13px; font-weight: 500;
    cursor: pointer; text-decoration: none;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 1px;
}
.im-nav-item:hover { background: #f8fafc; color: var(--im-text); text-decoration: none; }
.im-nav-item.active { background: var(--im-accent-bg); color: var(--im-accent); font-weight: 600; }
.im-nav-item i { font-size: 15px; width: 16px; flex-shrink: 0; }
.im-nav-sub .im-nav-item { padding-left: 30px; font-size: 12.5px; }

/* Sidebar footer */
.im-sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--im-border-light); }

.im-user-row {
    display: flex; align-items: center; gap: 9px;
    padding: 8px; border-radius: var(--im-radius-sm);
    transition: background 0.15s;
}
.im-user-row:hover { background: #f8fafc; }

.im-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--im-accent), var(--im-accent2));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 12px; font-weight: 700;
    flex-shrink: 0; text-transform: uppercase;
}

.im-user-name { display: block; color: var(--im-text); font-size: 12px; font-weight: 600; }
.im-user-role { display: block; color: var(--im-text-faint); font-size: 11px; }

.im-logout-btn {
    color: var(--im-text-faint); font-size: 16px;
    text-decoration: none; padding: 4px; border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.im-logout-btn:hover { color: #ef4444; background: #fee2e2; }

/* ── Main area ───────────────────────────────────────────────── */
.im-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.im-topbar {
    display: flex; align-items: center; gap: 14px;
    padding: 0 24px; height: var(--im-topbar-h);
    background: var(--im-surface);
    border-bottom: 1px solid var(--im-border);
    box-shadow: var(--im-shadow-sm);
    position: sticky; top: 0; z-index: 100;
}

.im-page-title { font-size: 17px; font-weight: 800; color: var(--im-text); margin: 0; flex: 1; }
.im-topbar-right { display: flex; align-items: center; gap: 10px; }

.im-hamburger {
    background: none; border: none;
    color: var(--im-text-muted); font-size: 22px;
    padding: 4px; cursor: pointer; border-radius: 6px;
}

.im-lang-btn {
    background: #f8fafc; border: 1.5px solid var(--im-border);
    border-radius: 8px; padding: 5px 10px;
    color: var(--im-text-muted); font-size: 12px; font-weight: 600;
    cursor: pointer; display: flex; align-items: center; gap: 5px;
    transition: border-color 0.15s;
}
.im-lang-btn:hover { border-color: var(--im-accent); color: var(--im-accent); }

/* Content */
.im-content { flex: 1; padding: 24px; overflow-y: auto; }

/* ── Cards ───────────────────────────────────────────────────── */
.im-card {
    background: var(--im-surface);
    border: 1px solid var(--im-border);
    border-radius: var(--im-radius);
    box-shadow: var(--im-shadow-sm);
    padding: 20px 22px;
}

/* ── Stat cards ──────────────────────────────────────────────── */
.im-stats-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 22px; }
.im-stat-card {
    background: var(--im-surface); border: 1px solid var(--im-border);
    border-radius: var(--im-radius); padding: 18px 20px; box-shadow: var(--im-shadow-sm);
}
.im-stat-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.im-stat-label { color: var(--im-text-muted); font-size: 12px; font-weight: 500; }
.im-stat-icon { width: 34px; height: 34px; border-radius: var(--im-radius-sm); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.im-stat-value { font-size: 28px; font-weight: 800; color: var(--im-text); margin-bottom: 4px; }
.im-stat-sub { font-size: 12px; font-weight: 500; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-im-primary {
    padding: 8px 18px;
    background: linear-gradient(135deg, var(--im-accent), var(--im-accent2));
    color: #fff; border: none; border-radius: var(--im-radius-sm);
    font-size: 13px; font-weight: 600; cursor: pointer;
    box-shadow: 0 2px 8px rgba(99,102,241,0.25);
    transition: opacity 0.15s, transform 0.12s;
    text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn-im-primary:hover { opacity: 0.9; transform: translateY(-1px); color: #fff; }

.btn-im-ghost {
    padding: 5px 12px; background: #f8fafc;
    color: var(--im-text-muted); border: 1.5px solid var(--im-border);
    border-radius: 7px; font-size: 12px; font-weight: 500; cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-im-ghost:hover { border-color: var(--im-accent); color: var(--im-accent); background: var(--im-accent-bg); }

/* ── Badges ──────────────────────────────────────────────────── */
.im-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600; white-space: nowrap;
}
.im-badge-auto     { background: #dcfce7; color: #16a34a; }
.im-badge-manual   { background: #fef9c3; color: #ca8a04; }
.im-badge-ai       { background: #ede9fe; color: #7c3aed; }
.im-badge-notfound { background: #fee2e2; color: #dc2626; }

/* ── Score bar ───────────────────────────────────────────────── */
.im-score-bar { display: flex; align-items: center; gap: 8px; }
.im-score-track { flex: 1; height: 5px; background: #f1f5f9; border-radius: 3px; overflow: hidden; }
.im-score-fill { height: 100%; border-radius: 3px; }
.im-score-fill.high { background: linear-gradient(90deg, #10b981, #34d399); }
.im-score-fill.mid  { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.im-score-fill.low  { background: linear-gradient(90deg, #ef4444, #f87171); }
.im-score-val { font-size: 12px; color: var(--im-text-faint); width: 32px; font-weight: 600; }

/* ── Table ───────────────────────────────────────────────────── */
.im-table-card {
    background: var(--im-surface); border: 1px solid var(--im-border);
    border-radius: var(--im-radius); overflow: hidden; box-shadow: var(--im-shadow-sm);
}
.im-table { width: 100%; border-collapse: collapse; }
.im-table th {
    color: var(--im-text-faint); font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .5px;
    padding: 11px 16px; text-align: left;
    border-bottom: 1px solid var(--im-border-light);
    background: #fafbff; white-space: nowrap;
}
.im-table td {
    padding: 12px 16px; color: var(--im-text); font-size: 13px;
    border-bottom: 1px solid var(--im-border-light);
}
.im-table tr:last-child td { border-bottom: none; }
.im-table tbody tr:hover td { background: #fafbff; }

/* ── Upload zone ─────────────────────────────────────────────── */
.im-upload-zone {
    border: 2px dashed #c7d2fe; border-radius: var(--im-radius);
    padding: 32px; text-align: center; background: #fafbff;
    cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
.im-upload-zone:hover { border-color: var(--im-accent); background: var(--im-accent-bg); }
.im-upload-zone i { font-size: 32px; color: #a5b4fc; margin-bottom: 10px; display: block; }
.im-upload-zone p { color: var(--im-text-muted); font-size: 14px; margin: 0; }
.im-upload-zone span { color: var(--im-accent); font-weight: 600; }

/* ── Forms ───────────────────────────────────────────────────── */
.im-form-label { color: var(--im-text-muted); font-size: 13px; font-weight: 600; margin-bottom: 6px; display: block; }
.im-form-control {
    width: 100%; padding: 10px 14px;
    background: #f8fafc; border: 1.5px solid var(--im-border);
    border-radius: var(--im-radius-sm);
    color: var(--im-text); font-size: 14px; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.im-form-control::placeholder { color: #cbd5e1; }
.im-form-control:focus {
    border-color: var(--im-accent); background: #fff;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* ── Alerts ──────────────────────────────────────────────────── */
.im-alert {
    padding: 12px 16px; border-radius: var(--im-radius-sm);
    font-size: 13px; margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}
.im-alert-success { background: #dcfce7; color: #16a34a; border: 1px solid #bbf7d0; }
.im-alert-error   { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.im-alert-warning { background: #fef9c3; color: #ca8a04; border: 1px solid #fef08a; }
.im-alert-info    { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }

/* ── Form labels & validation ────────────────────────────────── */
.im-label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--im-text-muted); margin-bottom: 5px; letter-spacing: .02em;
}
.im-field-error {
    display: block; font-size: 11px; color: #dc2626; margin-top: 4px;
}
.field-validation-error { display: block; font-size: 11px; color: #dc2626; margin-top: 4px; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.validation-summary-errors    { font-size: 13px; }

/* ── Misc utilities ──────────────────────────────────────────── */
.text-accent  { color: var(--im-accent); }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title  { font-size: 15px; font-weight: 700; color: var(--im-text); margin: 0; }
.section-sub    { font-size: 12px; color: var(--im-text-faint); margin-top: 2px; }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes imFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0);   }
}
@keyframes imPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .5; }
}
@keyframes imSlideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0);    }
}

.im-content { animation: imFadeIn 0.22s ease both; }

/* Alert entrance */
.im-alert { animation: imFadeIn 0.18s ease both; }

/* Stat card hover lift */
.im-stat-card--hover {
    transition: box-shadow 0.18s, transform 0.18s;
    cursor: default;
}
.im-stat-card--hover:hover {
    box-shadow: var(--im-shadow-md);
    transform: translateY(-2px);
}

/* Table row entrance stagger (applied via JS) */
.im-table tbody tr {
    animation: imFadeIn 0.18s ease both;
}

/* Button active press */
.btn-im-primary:active { transform: translateY(0) scale(0.98); }
.btn-im-ghost:active   { transform: scale(0.97); }

/* Skeleton shimmer for loading states */
@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}
.im-skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 600px 100%;
    animation: shimmer 1.4s infinite linear;
    border-radius: 6px;
    display: inline-block;
}

/* ── Mobile sidebar overlay ──────────────────────────────────── */
.im-sidebar-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 1049;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    transition: opacity 0.25s;
}
.im-sidebar-overlay.show { display: block; animation: imFadeIn 0.2s ease; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1100px) { .im-stats-row { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 600px)  { .im-stats-row { grid-template-columns: 1fr; } }

/* Responsive table scroll */
.im-table-card { overflow-x: auto; }

@media (max-width: 991px) {
    .im-sidebar {
        position: fixed; left: -100%; top: 0; z-index: 1050;
        transition: left 0.28s cubic-bezier(.4,0,.2,1); height: 100vh;
        box-shadow: none;
    }
    .im-sidebar.show {
        left: 0;
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }
    .im-page-title { font-size: 15px; }
    .im-content { padding: 16px; }
}

/* Upload grid: collapse to single column on tablet */
@media (max-width: 820px) {
    .im-upload-grid { grid-template-columns: 1fr !important; }
}

/* Dashboard quick-actions grid: single column on mobile */
@media (max-width: 640px) {
    .im-dash-grid { grid-template-columns: 1fr !important; }
}

/* Section header wraps on small screens */
@media (max-width: 560px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}
