:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-foreground: #ffffff;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --foreground: #0f172a;
    --muted: #64748b;
    --muted-bg: #f1f5f9;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --error: #dc2626;
    --error-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --info: #2563eb;
    --info-bg: #dbeafe;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--foreground);
    line-height: 1.5;
    font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.site-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 62px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--foreground);
}
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 1.4rem; }
.main-nav {
    display: flex;
    align-items: center;
    gap: 18px;
}
.nav-link {
    color: var(--muted);
    font-weight: 500;
}
.nav-link:hover { color: var(--foreground); text-decoration: none; }
.nav-user {
    color: var(--muted);
    font-size: 0.85rem;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main */
.site-main { flex: 1; padding: 32px 0; }

/* Footer */
.site-footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 20px 0;
    margin-top: 40px;
}
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 0.85rem; }
.muted { color: var(--muted); }

/* Typography helpers */
h1 { font-size: 1.9rem; font-weight: 700; margin: 0 0 6px; }
h2 { font-size: 1.4rem; font-weight: 700; margin: 0 0 6px; }
.page-header { margin-bottom: 28px; }
.page-header .subtitle { color: var(--muted); margin: 0; }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.card-header {
    padding: 20px 22px 0;
}
.card-title { font-size: 1.15rem; font-weight: 600; margin: 0; }
.card-description { color: var(--muted); font-size: 0.9rem; margin: 4px 0 0; }
.card-body { padding: 20px 22px; }

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
}
.stat-label { color: var(--muted); font-size: 0.85rem; display: flex; justify-content: space-between; align-items: center; }
.stat-value { font-size: 2rem; font-weight: 700; margin-top: 6px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    background: var(--muted-bg);
    color: var(--foreground);
    text-decoration: none;
    line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--foreground); }
.btn-outline:hover { background: var(--muted-bg); }
.btn-ghost { background: transparent; color: var(--muted); padding: 7px 10px; }
.btn-ghost:hover { background: var(--muted-bg); color: var(--foreground); }
.btn-danger { background: transparent; color: var(--error); padding: 7px 10px; }
.btn-danger:hover { background: var(--error-bg); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-row { display: flex; gap: 12px; align-items: center; }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-weight: 500; font-size: 0.9rem; margin-bottom: 6px; }
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    color: var(--foreground);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.form-hint { color: var(--muted); font-size: 0.8rem; margin-top: 5px; }
.input-search { position: relative; }
.input-search .form-control { padding-left: 36px; }
.input-search::before {
    content: "🔍";
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    opacity: 0.5;
}

/* Alerts */
.alert {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 0.9rem;
    display: flex;
    gap: 8px;
    align-items: center;
}
.alert-success { background: var(--success-bg); color: #166534; }
.alert-error { background: var(--error-bg); color: #991b1b; }
.alert-info { background: var(--info-bg); color: #1e40af; }

/* Tables */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
    text-align: left;
    padding: 11px 14px;
    background: var(--muted-bg);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
tbody td { padding: 11px 14px; border-top: 1px solid var(--border); }
tbody tr:hover { background: #fafbfc; }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.status-pending { background: var(--warning-bg); color: var(--warning); }
.status-processing { background: var(--info-bg); color: var(--info); }
.status-completed { background: var(--success-bg); color: var(--success); }
.status-error { background: var(--error-bg); color: var(--error); }

/* Progress */
.progress {
    height: 10px;
    background: var(--muted-bg);
    border-radius: 999px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}
.dropzone.drag-active { border-color: var(--primary); background: rgba(37, 99, 235, 0.04); }
.dropzone-icon { font-size: 2.4rem; }
.dropzone p { margin: 10px 0; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state .empty-icon { font-size: 2.6rem; }
.empty-state h3 { margin: 12px 0 6px; }

/* Auth pages */
.auth-wrap {
    min-height: calc(100vh - 200px);
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-card {
    width: 100%;
    max-width: 420px;
}
.auth-icon {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    background: rgba(37, 99, 235, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    margin: 0 auto 14px;
}

/* Home / hero */
.hero { text-align: center; padding: 40px 0 20px; }
.hero h1 { font-size: 2.6rem; margin-bottom: 14px; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 640px; margin: 0 auto 26px; }
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 44px;
}
.feature { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.feature .feature-icon { font-size: 1.8rem; margin-bottom: 10px; }
.feature h3 { margin: 0 0 6px; font-size: 1.05rem; }
.feature p { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* Tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab {
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.92rem;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Flex utils */
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.mb-3 { margin-bottom: 16px; }
.actions-cell { display: flex; gap: 4px; justify-content: flex-end; }
.inline-form { display: inline; }

@media (max-width: 640px) {
    .nav-user { display: none; }
    .main-nav { gap: 12px; }
    .hero h1 { font-size: 2rem; }
}
