/* ============================================================
   HiDocument — Main Stylesheet
   Design system: Navy #1E3A5F | Blue #2E6DA4 | Highlight #00B4D8
   Background #F8FAFC | Font: Inter
   ============================================================ */

/* --- CSS Variables --- */
:root {
    --primary:      #1E3A5F;
    --accent:       #2E6DA4;
    --highlight:    #00B4D8;
    --bg:           #F8FAFC;
    --surface:      #FFFFFF;
    --text:         #1A202C;
    --text-muted:   #64748B;
    --border:       #E2E8F0;
    --success:      #10B981;
    --warning:      #F59E0B;
    --danger:       #EF4444;
    --danger-dark:  #B91C1C;
    --radius:       8px;
    --radius-lg:    16px;
    --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
    --shadow:       0 4px 16px rgba(0,0,0,.10);
    --shadow-lg:    0 10px 40px rgba(0,0,0,.14);
    --transition:   0.2s ease;
    --sidebar-w:    256px;
    --header-h:     64px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--highlight); }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
h1,h2,h3,h4,h5,h6 { line-height: 1.25; font-weight: 700; color: var(--primary); }

/* --- Container --- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 640px; margin: 0 auto; padding: 0 24px; }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 22px; border-radius: var(--radius); font-size: 15px; font-weight: 600;
    border: 2px solid transparent; transition: all var(--transition); white-space: nowrap;
    line-height: 1;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-dark); border-color: var(--danger-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 30px; font-size: 17px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* --- Forms --- */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius);
    font-size: 15px; color: var(--text); background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,109,164,.15); }
.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-valid { border-color: var(--success); }
.form-error { font-size: 13px; color: var(--danger); margin-top: 4px; }
.form-hint { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.input-group { position: relative; }
.input-group .form-control { padding-right: 44px; }
.input-group-append {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-muted); padding: 0;
}
.form-check { display: flex; align-items: flex-start; gap: 10px; }
.form-check input[type="checkbox"] { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.form-check label { font-size: 14px; color: var(--text-muted); cursor: pointer; }

/* --- Password Strength --- */
.password-strength { margin-top: 6px; }
.strength-bar { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.strength-fill { height: 100%; border-radius: 2px; transition: width 0.3s ease, background 0.3s ease; width: 0%; }
.strength-fill.strength-1 { width: 25%; background: var(--danger); }
.strength-fill.strength-2 { width: 50%; background: var(--warning); }
.strength-fill.strength-3 { width: 75%; background: #3B82F6; }
.strength-fill.strength-4 { width: 100%; background: var(--success); }
.strength-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* --- Flash Messages --- */
.flash {
    padding: 12px 18px; border-radius: var(--radius); margin-bottom: 20px;
    font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px;
    animation: fadeIn 0.3s ease;
}
.flash-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.flash-error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.flash-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.flash-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* --- Badge / Status --- */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 50px;
    font-size: 12px; font-weight: 600; line-height: 1;
}
.badge-user      { background: #EFF6FF; color: var(--accent); }
.badge-admin     { background: #F0FDF4; color: #15803D; }
.badge-pending   { background: #FFFBEB; color: #92400E; }
.badge-analyzed  { background: #ECFDF5; color: #065F46; }
.badge-failed    { background: #FEF2F2; color: #991B1B; }
.badge-active    { background: #ECFDF5; color: #065F46; }
.badge-suspended { background: #FEF2F2; color: #991B1B; }

/* ============================================================
   LANDING PAGE — PUBLIC NAV
   ============================================================ */
.public-header {
    position: sticky; top: 0; z-index: 1000; background: var(--surface);
    box-shadow: var(--shadow-sm); height: var(--header-h);
    transition: box-shadow var(--transition);
}
.public-header.scrolled { box-shadow: var(--shadow); }
.public-nav {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--header-h); padding: 0 24px; max-width: 1200px; margin: 0 auto;
}
.nav-brand {
    display: flex; align-items: center; gap: 10px;
    font-size: 20px; font-weight: 800; color: var(--primary); text-decoration: none;
}
.nav-brand:hover { color: var(--primary); }
.nav-links { display: flex; align-items: center; gap: 32px; }
.nav-links a { font-size: 15px; font-weight: 500; color: var(--text-muted); transition: color var(--transition); }
.nav-links a:hover { color: var(--primary); }
.nav-actions { display: flex; align-items: center; gap: 12px; }
.hamburger {
    display: none; flex-direction: column; gap: 5px; background: none; border: none;
    padding: 8px; cursor: pointer; min-width: 44px; min-height: 44px;
    align-items: center; justify-content: center;
}
.hamburger span { display: block; width: 24px; height: 2px; background: var(--primary); border-radius: 2px; transition: all 0.3s; }
/* Hamburger → X animation */
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.mobile-nav {
    display: none; position: fixed; top: var(--header-h); left: 0; right: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 20px 24px; z-index: 999; box-shadow: var(--shadow);
    max-height: calc(100vh - var(--header-h)); overflow-y: auto;
}
.mobile-nav.open { display: block; }
.mobile-nav a { display: flex; align-items: center; min-height: 44px; padding: 10px 0; font-size: 16px; font-weight: 500; color: var(--text); border-bottom: 1px solid var(--border); }
.mobile-nav .nav-actions-mobile { padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.mobile-nav .nav-actions-mobile .btn { width: 100%; justify-content: center; }

/* ============================================================
   HERO
   ============================================================ */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #2a4f7c 60%, #1a3256 100%);
    color: #fff; padding: 80px 0 60px;
    overflow: hidden; position: relative;
}
.hero-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center;
    max-width: 1200px; margin: 0 auto; padding: 0 24px;
}
.hero-content h1 { font-size: clamp(32px, 5vw, 52px); color: #fff; line-height: 1.15; margin-bottom: 20px; }
.hero-content h1 span { color: var(--highlight); }
.hero-content p { font-size: 18px; color: rgba(255,255,255,0.85); margin-bottom: 32px; line-height: 1.7; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 32px; }
.hero-actions .btn-primary { background: var(--highlight); border-color: var(--highlight); color: #fff; font-size: 16px; padding: 14px 28px; }
.hero-actions .btn-primary:hover { background: #00a3c7; border-color: #00a3c7; }
.hero-actions .btn-outline { border-color: rgba(255,255,255,0.5); color: #fff; font-size: 16px; padding: 14px 28px; }
.hero-actions .btn-outline:hover { background: rgba(255,255,255,0.1); }
.trust-badges { display: flex; gap: 20px; flex-wrap: wrap; }
.trust-badge { display: flex; align-items: center; gap: 6px; font-size: 13px; color: rgba(255,255,255,0.75); }
.trust-badge svg { color: var(--highlight); }

/* --- Document Illustration with Scanning Line --- */
.hero-visual { display: flex; justify-content: center; align-items: center; position: relative; }
.doc-illustration {
    position: relative; width: 280px; height: 360px;
    background: rgba(255,255,255,0.08); border-radius: 12px;
    border: 1.5px solid rgba(255,255,255,0.2); overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.doc-illustration::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, transparent, var(--highlight), transparent);
    animation: scanLine 2.5s ease-in-out infinite;
}
@keyframes scanLine {
    0%   { top: 0; opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { top: calc(100% - 3px); opacity: 0; }
}
.doc-lines { padding: 24px 20px; display: flex; flex-direction: column; gap: 12px; }
.doc-line {
    height: 10px; border-radius: 5px; background: rgba(255,255,255,0.15);
    animation: lineGlow 2.5s ease-in-out infinite;
}
.doc-line:nth-child(1) { width: 60%; animation-delay: 0s; }
.doc-line:nth-child(2) { width: 90%; animation-delay: 0.1s; }
.doc-line:nth-child(3) { width: 80%; animation-delay: 0.2s; }
.doc-line:nth-child(4) { width: 95%; animation-delay: 0.3s; }
.doc-line:nth-child(5) { width: 70%; animation-delay: 0.4s; }
.doc-line:nth-child(6) { width: 85%; animation-delay: 0.5s; }
.doc-line:nth-child(7) { width: 55%; animation-delay: 0.6s; }
.doc-line:nth-child(8) { width: 90%; animation-delay: 0.7s; }
.doc-line:nth-child(9) { width: 75%; animation-delay: 0.8s; }
.doc-line:nth-child(10){ width: 65%; animation-delay: 0.9s; }
@keyframes lineGlow {
    0%, 100% { background: rgba(255,255,255,0.10); }
    50%       { background: rgba(0,180,216,0.35); }
}
.doc-ai-badge {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: var(--highlight); color: #fff; font-size: 13px; font-weight: 700;
    padding: 6px 16px; border-radius: 50px; white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0,180,216,0.5); animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{transform:translateX(-50%) scale(1)} 50%{transform:translateX(-50%) scale(1.04)} }

/* ============================================================
   SECTIONS — FEATURES
   ============================================================ */
.section { padding: 80px 0; }
.section-title { text-align: center; font-size: clamp(26px, 4vw, 38px); margin-bottom: 14px; }
.section-subtitle { text-align: center; font-size: 17px; color: var(--text-muted); margin-bottom: 56px; max-width: 560px; margin-left: auto; margin-right: auto; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.feature-card {
    background: var(--surface); border-radius: var(--radius-lg); padding: 32px 28px;
    border: 1px solid var(--border); transition: transform var(--transition), box-shadow var(--transition);
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.feature-icon {
    width: 52px; height: 52px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--highlight));
    display: flex; align-items: center; justify-content: center; color: #fff; margin-bottom: 18px;
}
.feature-card h3 { font-size: 18px; margin-bottom: 10px; }
.feature-card p { font-size: 14px; color: var(--text-muted); line-height: 1.7; }

/* ============================================================
   HOW IT WORKS
   ============================================================ */
.how-section { background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%); color: #fff; }
.how-section .section-title, .how-section .section-subtitle { color: #fff; }
.how-section .section-subtitle { color: rgba(255,255,255,0.8); }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 40px; position: relative; }
.step-card { text-align: center; position: relative; }
.step-number {
    width: 56px; height: 56px; border-radius: 50%; background: var(--highlight);
    color: #fff; font-size: 22px; font-weight: 800; display: flex; align-items: center;
    justify-content: center; margin: 0 auto 18px;
}
.step-card h3 { font-size: 18px; color: #fff; margin-bottom: 10px; }
.step-card p  { font-size: 14px; color: rgba(255,255,255,0.8); line-height: 1.7; }

/* ============================================================
   INLINE AUTH — LANDING PAGE
   ============================================================ */
.auth-section { background: var(--bg); padding: 80px 0; }
.auth-section .section-title { color: var(--primary); }
.auth-inline-wrapper { max-width: 520px; margin: 0 auto; }
.auth-tabs { display: flex; gap: 0; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; border: 1px solid var(--border); border-bottom: none; }
.auth-tab-btn {
    flex: 1; padding: 14px; font-size: 15px; font-weight: 600; background: var(--bg);
    border: none; color: var(--text-muted); transition: all var(--transition);
}
.auth-tab-btn.active { background: var(--surface); color: var(--accent); }
.auth-tab-panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 32px; display: none;
}
.auth-tab-panel.active { display: block; }
.social-proof { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.social-proof strong { color: var(--primary); }

/* ============================================================
   PRICING SECTION
   ============================================================ */
.pricing-section { background: var(--surface); }
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; max-width: 900px; margin: 0 auto; }
.pricing-card {
    border: 2px solid var(--border); border-radius: var(--radius-lg); padding: 36px 28px;
    transition: transform var(--transition), box-shadow var(--transition);
}
.pricing-card.featured { border-color: var(--accent); background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%); color: #fff; }
.pricing-card.featured h3, .pricing-card.featured .price, .pricing-card.featured .price-period { color: #fff; }
.pricing-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.pricing-card h3 { font-size: 20px; margin-bottom: 8px; }
.price { font-size: 42px; font-weight: 800; color: var(--primary); }
.price-period { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }
.pricing-features { margin-bottom: 28px; }
.pricing-features li { padding: 8px 0; font-size: 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.pricing-card.featured .pricing-features li { border-color: rgba(255,255,255,0.2); color: rgba(255,255,255,0.9); }
.check-icon { color: var(--success); flex-shrink: 0; }
.pricing-card.featured .check-icon { color: var(--highlight); }

/* ============================================================
   SITE FOOTER
   ============================================================ */
.site-footer { background: var(--primary); color: rgba(255,255,255,0.75); padding: 40px 0; }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.footer-brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 800; color: #fff; }
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
.footer-links a { font-size: 14px; color: rgba(255,255,255,0.65); }
.footer-links a:hover { color: #fff; }
.footer-copy { font-size: 13px; color: rgba(255,255,255,0.45); }

/* ============================================================
   AUTH PAGES — SPLIT SCREEN
   ============================================================ */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-panel-left {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: 60px 40px; color: #fff; position: relative; overflow: hidden;
}
.auth-panel-left::after {
    content: ''; position: absolute; bottom: -80px; right: -80px;
    width: 300px; height: 300px; border-radius: 50%;
    background: rgba(255,255,255,0.05); pointer-events: none;
}
.auth-left-brand { font-size: 28px; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 12px; }
.auth-left-tagline { font-size: 16px; color: rgba(255,255,255,0.8); text-align: center; max-width: 320px; line-height: 1.7; margin-bottom: 40px; }
.auth-left-bullets { display: flex; flex-direction: column; gap: 16px; }
.auth-left-bullet { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.auth-left-bullet svg { color: var(--highlight); flex-shrink: 0; }
.auth-panel-right {
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: 60px 40px; background: var(--bg);
}
.auth-form-box { width: 100%; max-width: 420px; }
.auth-form-box h2 { font-size: 26px; margin-bottom: 6px; }
.auth-form-box .auth-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 28px; }
.auth-divider { text-align: center; font-size: 13px; color: var(--text-muted); margin: 20px 0; position: relative; }
.auth-divider::before, .auth-divider::after {
    content: ''; position: absolute; top: 50%; height: 1px; width: 40%; background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.app-layout { display: flex; min-height: 100vh; }
.app-main {
    flex: 1; margin-left: var(--sidebar-w);
    padding: 32px; background: var(--bg); min-width: 0;
    transition: margin-left var(--transition);
}
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 24px; margin-bottom: 4px; }
.page-header p  { font-size: 14px; color: var(--text-muted); }

/* Welcome Banner */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: var(--radius-lg); padding: 28px 32px; color: #fff; margin-bottom: 28px;
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
}
.welcome-banner h2 { font-size: 22px; color: #fff; margin-bottom: 4px; }
.welcome-banner p  { font-size: 14px; color: rgba(255,255,255,0.8); }
.welcome-banner .btn { background: var(--highlight); border-color: var(--highlight); color: #fff; }
.welcome-banner .btn:hover { background: #00a3c7; border-color: #00a3c7; }

/* Stats Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card {
    background: var(--surface); border-radius: var(--radius-lg); padding: 24px;
    border: 1px solid var(--border); transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--highlight)); display: flex; align-items: center; justify-content: center; color: #fff; margin-bottom: 14px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Documents Table */
.card {
    background: var(--surface); border-radius: var(--radius-lg);
    border: 1px solid var(--border); overflow: visible;
}
/* Clip only the first and last child to preserve rounded corners */
.card > :first-child { border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0; overflow: hidden; }
.card > :last-child  { border-radius: 0 0 calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px); overflow: hidden; }
.card > :only-child  { border-radius: calc(var(--radius-lg) - 1px); overflow: hidden; }
.card-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.card-header h3 { font-size: 16px; }
.card-body { padding: 24px; }
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { background: var(--bg); font-weight: 600; color: var(--text-muted); padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }
.action-btns { display: flex; gap: 6px; flex-wrap: nowrap; }

/* Pagination */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
    display: flex; align-items: center; justify-content: center; min-width: 36px; height: 36px;
    border-radius: var(--radius); font-size: 14px; font-weight: 500;
    border: 1.5px solid var(--border); color: var(--text-muted); background: var(--surface);
    transition: all var(--transition);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Empty State */
.empty-state { text-align: center; padding: 60px 24px; }
.empty-state svg { margin: 0 auto 16px; color: var(--border); }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }

/* ============================================================
   UPLOAD ZONE
   ============================================================ */
.upload-zone {
    border: 2.5px dashed var(--border); border-radius: var(--radius-lg); padding: 60px 30px;
    text-align: center; cursor: pointer; transition: all var(--transition);
    background: var(--bg);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent); background: rgba(46,109,164,0.04);
}
.upload-zone-icon { color: var(--accent); margin: 0 auto 16px; }
.upload-zone h3 { font-size: 18px; margin-bottom: 8px; }
.upload-zone p { font-size: 14px; color: var(--text-muted); }
.upload-zone .upload-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.file-preview {
    display: flex; align-items: center; gap: 14px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-top: 16px;
}
.file-preview-icon { color: var(--accent); flex-shrink: 0; }
.file-preview-info h4 { font-size: 14px; font-weight: 600; }
.file-preview-info p  { font-size: 12px; color: var(--text-muted); }
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 12px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--highlight)); border-radius: 3px; transition: width 0.3s ease; width: 0%; }

/* Analysis Options */
.analysis-options { margin-top: 24px; }
.analysis-options h4 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.options-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.option-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer;
    transition: all var(--transition); font-size: 14px; font-weight: 500;
}
.option-item:hover { border-color: var(--accent); background: rgba(46,109,164,0.04); }
.option-item input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.option-item.checked { border-color: var(--accent); background: rgba(46,109,164,0.07); }

/* Analysis Tabs */
.analysis-tabs { border-bottom: 2px solid var(--border); display: flex; gap: 0; overflow-x: auto; }
.analysis-tab {
    padding: 12px 20px; font-size: 14px; font-weight: 600; color: var(--text-muted);
    border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; white-space: nowrap; transition: all var(--transition);
}
.analysis-tab:hover { color: var(--accent); }
.analysis-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.analysis-panel { display: none; padding: 24px 0; }
.analysis-panel.active { display: block; }
.key-points-list { list-style: none; }
.key-points-list li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.key-points-list li::before { content: ''; display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.entities-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.entity-chip { background: rgba(46,109,164,0.1); color: var(--accent); padding: 4px 12px; border-radius: 50px; font-size: 13px; font-weight: 500; }
.raw-text-box { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; font-size: 13px; font-family: monospace; line-height: 1.7; max-height: 400px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.loading-spinner {
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    padding: 60px; color: var(--text-muted);
}
.spinner {
    width: 48px; height: 48px; border: 4px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Document Grid Library */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.doc-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    overflow: hidden; transition: transform var(--transition), box-shadow var(--transition);
}
.doc-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.doc-card-thumb {
    height: 120px; background: linear-gradient(135deg, var(--bg), var(--border));
    display: flex; align-items: center; justify-content: center; color: var(--accent);
}
.doc-card-body { padding: 14px; }
.doc-card-name { font-size: 14px; font-weight: 600; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.doc-card-actions { display: flex; gap: 6px; }

/* Search & Filter Bar */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.toolbar .form-control { max-width: 280px; }
.view-toggle { display: flex; border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.view-toggle button {
    padding: 8px 12px; background: var(--surface); border: none;
    color: var(--text-muted); transition: all var(--transition);
}
.view-toggle button.active { background: var(--accent); color: #fff; }

/* Settings Sections */
.settings-section { margin-bottom: 32px; }
.settings-section-title { font-size: 16px; font-weight: 700; border-bottom: 2px solid var(--border); padding-bottom: 10px; margin-bottom: 20px; }
.danger-zone { border: 2px solid var(--danger); border-radius: var(--radius-lg); padding: 24px; }
.danger-zone h3 { color: var(--danger); font-size: 16px; margin-bottom: 8px; }
.danger-zone p { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; }

/* Comparison View */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.compare-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.compare-panel h3 { font-size: 15px; margin-bottom: 14px; }
.similarity-badge {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; border-radius: var(--radius-lg); padding: 24px; text-align: center; margin-bottom: 24px;
}
.similarity-score { font-size: 56px; font-weight: 800; color: #fff; }
.similarity-label { font-size: 14px; color: rgba(255,255,255,0.8); }
.diff-highlight-a { background: rgba(16,185,129,0.2); border-radius: 2px; }
.diff-highlight-b { background: rgba(239,68,68,0.2); border-radius: 2px; }
.diff-highlight-shared { background: rgba(100,116,139,0.15); border-radius: 2px; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
    background: var(--surface); border-radius: var(--radius-lg); padding: 32px; max-width: 480px; width: 90%;
    box-shadow: var(--shadow-lg); transform: scale(0.95); transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal h3 { font-size: 18px; margin-bottom: 10px; }
.modal p  { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   SIDEBAR COMPONENT
   ============================================================ */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
    background: var(--primary); color: #fff; display: flex; flex-direction: column;
    z-index: 500; transition: transform var(--transition);
    overflow-y: auto;
}
.sidebar-header {
    padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 18px; font-weight: 800; text-decoration: none; }
.sidebar-brand:hover { color: #fff; }
.sidebar-brand-name { font-size: 17px; }
.sidebar-close-btn { background: none; border: none; color: rgba(255,255,255,0.6); display: none; }
.sidebar-nav { flex: 1; padding: 16px 0; }
.sidebar-nav ul { display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
    display: flex; align-items: center; gap: 12px; padding: 11px 20px;
    color: rgba(255,255,255,0.7); font-size: 14px; font-weight: 500;
    border-left: 3px solid transparent; transition: all var(--transition);
    text-decoration: none;
}
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,0.06); }
.sidebar-link.active { color: #fff; background: rgba(255,255,255,0.1); border-left-color: var(--highlight); }
.sidebar-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 10px 16px; }
.sidebar-footer {
    padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--highlight);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { display: block; font-size: 14px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; }
.sidebar-logout { color: rgba(255,255,255,0.5); transition: color var(--transition); flex-shrink: 0; }
.sidebar-logout:hover { color: #fff; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 499; }

/* Mobile hamburger inside app */
.app-topbar {
    display: none; position: sticky; top: 0; z-index: 100;
    background: var(--surface); padding: 0 20px; height: 56px;
    border-bottom: 1px solid var(--border); align-items: center; justify-content: space-between;
    box-shadow: var(--shadow-sm);
}
.app-topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--primary); font-size: 16px; }
.hamburger-app { background: none; border: none; color: var(--primary); }

/* ============================================================
   404 PAGE
   ============================================================ */
.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: 40px; }
.error-code { font-size: 120px; font-weight: 900; color: var(--border); line-height: 1; }
.error-title { font-size: 28px; margin-bottom: 12px; }
.error-text { font-size: 16px; color: var(--text-muted); margin-bottom: 28px; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
.fade-in { opacity: 0; transform: translateY(20px); transition: opacity 0.6s ease, transform 0.6s ease; }
.fade-in.visible { opacity: 1; transform: translateY(0); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* ============================================================
   RESPONSIVE — COMPREHENSIVE
   ============================================================ */

/* ── Global base fixes ── */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
body {
    overflow-x: hidden;
    min-width: 320px;
}
/* Prevent iOS auto-zoom on form focus */
input, textarea, select, button {
    font-size: 16px;
}
/* Smooth touch response — no 300ms delay */
button, a, label {
    touch-action: manipulation;
}
/* Fluid typography */
h1 { font-size: clamp(1.5rem, 5vw, 2.6rem); }
h2 { font-size: clamp(1.2rem, 4vw, 1.9rem); }
h3 { font-size: clamp(1rem, 3vw, 1.4rem); }

/* ── lg: ≤1024px — sidebar collapses ── */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .sidebar-close-btn { display: flex; }
    .app-main { margin-left: 0; }
    .app-topbar { display: flex; }
    .app-main { padding-top: 16px; }
    /* Ensure topbar hamburger is large enough to tap */
    .hamburger-app { min-width: 44px; min-height: 44px; }
}

/* ── md: ≤768px — tablets and phones ── */
@media (max-width: 768px) {
    /* Landing page */
    .hero-grid { grid-template-columns: 1fr; }
    .hero-visual { display: none; }
    .auth-page { grid-template-columns: 1fr; }
    .auth-panel-left { display: none; }
    .nav-links { display: none; }
    .hamburger { display: flex; }

    /* Comparison page */
    .compare-grid { grid-template-columns: 1fr; }

    /* App shell */
    .app-main { padding: 16px; }
    .welcome-banner { flex-direction: column; align-items: flex-start; }
    .welcome-banner .btn { width: 100%; justify-content: center; }

    /* Cards */
    .card-header { padding: 14px 16px; flex-wrap: wrap; }
    .card-body   { padding: 16px; }

    /* Toolbar — search takes full width */
    .toolbar { gap: 8px; }
    .toolbar .form-control { max-width: 100%; }

    /* Settings — form rows stack */
    .form-row {
        display: flex;
        flex-direction: column;
        gap: 0;
    }
    .settings-avatar-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    /* Analysis tabs — hide scrollbar but allow scroll */
    .analysis-tabs {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        scroll-behavior: smooth;
    }
    .analysis-tabs::-webkit-scrollbar { display: none; }
    .analysis-tab { padding: 10px 14px; font-size: 13px; }
    .analysis-panel { padding: 16px 0; }

    /* Modals — slide up from bottom */
    .modal-overlay { align-items: flex-end; }
    .modal {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 90vh;
        overflow-y: auto;
        padding: 24px 20px;
    }
    .modal-actions {
        flex-direction: column-reverse;
        gap: 10px;
    }
    .modal-actions .btn { width: 100%; justify-content: center; }

    /* File preview (analyze/bulk) — stack on mobile */
    .file-preview {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* Tables — horizontal scroll wrapper */
    .table-responsive { -webkit-overflow-scrolling: touch; }
    .table-responsive table { min-width: 520px; }

    /* Sidebar links — ensure 44px touch target */
    .sidebar-link { min-height: 44px; }

    /* Pagination — wrap on small screens */
    .pagination { gap: 4px; }
    .pagination a, .pagination span {
        min-width: 32px; height: 32px; font-size: 13px;
    }

    /* Doc grid — 2 columns on tablet */
    .doc-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

    /* Upload zone */
    .upload-zone { padding: 36px 20px; }

    /* Options grid (analyze) — 2 col */
    .options-grid { grid-template-columns: repeat(2, 1fr); }

    /* Toolbar — analyze bar */
    .analyze-bar { flex-wrap: wrap; }
    .analyze-bar .btn { flex: 1; min-width: 140px; }
}

/* ── sm: ≤480px — small phones ── */
@media (max-width: 480px) {
    /* App shell */
    .app-main { padding: 12px 12px 20px; }

    /* Typography — reduce page header */
    .page-header h1 { font-size: 20px; }

    /* Stats cards — 2 columns */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 22px; }

    /* Landing page */
    .features-grid { grid-template-columns: 1fr; }
    .hero-actions { flex-direction: column; gap: 10px; }
    .hero-actions .btn { width: 100%; justify-content: center; }

    /* Buttons in headers */
    .card-header { gap: 8px; }
    .card-header .btn-sm { font-size: 12px; padding: 5px 10px; }

    /* Welcome banner */
    .welcome-banner { padding: 20px 16px; }
    .welcome-banner h2 { font-size: 18px; }

    /* Doc grid — 1 column on small phones */
    .doc-grid { grid-template-columns: 1fr; }

    /* Tabs — very compact */
    .analysis-tab { padding: 9px 12px; font-size: 12px; }

    /* Options grid — 1 col on tiny screens */
    .options-grid { grid-template-columns: 1fr; }

    /* Table cells — smaller padding */
    thead th, tbody td { padding: 8px 10px; font-size: 13px; }

    /* Modals — tight padding */
    .modal { padding: 20px 16px; }
    .modal h3 { font-size: 16px; }

    /* Error page */
    .error-code { font-size: 72px; }
    .error-title { font-size: 20px; }

    /* Upload zone — compact */
    .upload-zone { padding: 28px 16px; }
    .upload-zone h3 { font-size: 15px; }

    /* Similarity score */
    .similarity-score { font-size: 40px; }
}

/* ── xs: ≤360px — very small phones ── */
@media (max-width: 360px) {
    .app-main { padding: 10px 10px 16px; }
    .app-topbar { padding: 0 12px; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 20px; }
    .btn { padding: 9px 14px; font-size: 14px; }
    .card-body { padding: 12px; }
    .analysis-tab { padding: 8px 10px; font-size: 11px; }
}

/* ── prefers-reduced-motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
