/* ===========================
   CSS Design System — Nomor Surat Generator
   =========================== */

/* --- CSS Variables / Tokens --- */
:root {
    /* Colors */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.8);
    --bg-input: rgba(15, 23, 42, 0.8);
    --bg-input-focus: rgba(15, 23, 42, 1);

    --border-color: rgba(99, 102, 241, 0.15);
    --border-color-hover: rgba(99, 102, 241, 0.35);
    --border-color-focus: rgba(99, 102, 241, 0.6);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
    --accent-glow: rgba(99, 102, 241, 0.4);

    --purple: #a855f7;
    --purple-bg: rgba(168, 85, 247, 0.12);
    --teal: #14b8a6;
    --teal-bg: rgba(20, 184, 166, 0.12);
    --amber: #f59e0b;
    --amber-bg: rgba(245, 158, 11, 0.12);
    --red: #ef4444;
    --red-hover: #f87171;
    --red-bg: rgba(239, 68, 68, 0.12);
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.12);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(99, 102, 241, 0.08);
    --shadow-card-hover: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(99, 102, 241, 0.15);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
    --shadow-btn: 0 4px 16px rgba(99, 102, 241, 0.3);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

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

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* --- Animated Background --- */
.bg-gradient {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99, 102, 241, 0.12), transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(139, 92, 246, 0.08), transparent 60%),
        radial-gradient(ellipse 50% 40% at 50% 50%, rgba(20, 184, 166, 0.04), transparent 60%);
    z-index: 0;
    pointer-events: none;
}

.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0;
    pointer-events: none;
}

.floating-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    z-index: 0;
    pointer-events: none;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: rgba(99, 102, 241, 0.15);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: rgba(168, 85, 247, 0.1);
    bottom: -50px;
    right: -80px;
    animation-delay: -7s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: rgba(20, 184, 166, 0.08);
    top: 50%;
    left: 50%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(15px, 35px) scale(1.02); }
}

/* --- Glass Card --- */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

.glass-card:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-card-hover);
}

/* --- App Container --- */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* --- Header --- */
.app-header {
    padding: var(--space-lg) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    margin: 0 calc(-1 * var(--space-lg));
    padding-left: var(--space-lg);
    padding-right: var(--space-lg);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1440px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-btn);
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.org-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.header-actions {
    display: flex;
    gap: var(--space-sm);
}

/* --- Buttons --- */
.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.btn-icon.btn-danger:hover {
    background: var(--red-bg);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--red);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 14px var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: white;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-btn);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
}

.btn-primary:hover::before {
    opacity: 1;
}

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

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.btn-danger-solid {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    background: var(--red-bg);
    color: var(--red);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-danger-solid:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
    color: var(--red-hover);
}

/* --- Stats Section --- */
.stats-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin: var(--space-xl) 0;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    transition: all var(--transition-base);
}

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

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary);
    flex-shrink: 0;
}

.stat-icon-purple {
    background: var(--purple-bg);
    color: var(--purple);
}

.stat-icon-teal {
    background: var(--teal-bg);
    color: var(--teal);
}

.stat-icon-amber {
    background: var(--amber-bg);
    color: var(--amber);
}

.stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--text-primary);
}

.stat-value-small {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0;
    word-break: break-all;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* --- Content Grid --- */
.content-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
    align-items: start;
}

/* --- Form Section --- */
.form-section {
    padding: var(--space-lg);
    position: sticky;
    top: 90px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.section-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.section-header h2 svg {
    color: var(--accent-primary);
}

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

.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group label svg {
    color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group select {
    width: 100%;
    padding: 12px var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    outline: none;
}

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

.form-group input:focus,
.form-group select:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 40px;
    cursor: pointer;
}

.select-chevron {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* --- Preview Box --- */
.preview-box {
    margin: var(--space-lg) 0;
    padding: var(--space-lg);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.06));
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-md);
    text-align: center;
    transition: all var(--transition-base);
}

.preview-box.has-value {
    border-style: solid;
    border-color: rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.08));
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.1);
}

.preview-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.preview-number {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-primary-hover);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    word-break: break-all;
    transition: all var(--transition-base);
}

/* --- Table Section --- */
.table-section {
    padding: var(--space-lg);
    min-height: 400px;
}

.table-controls {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.search-box {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--border-color-focus);
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    width: 160px;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.filter-select {
    min-width: 140px;
}

.filter-select select {
    width: 100%;
    padding: 8px var(--space-md);
    padding-right: 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.8rem;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-fast);
}

.filter-select select:focus {
    border-color: var(--border-color-focus);
}

.table-wrapper {
    margin-top: var(--space-md);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 12px var(--space-md);
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

tbody tr {
    transition: background var(--transition-fast);
    animation: fadeInRow 0.3s ease forwards;
}

tbody tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

tbody td {
    padding: 12px var(--space-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(99, 102, 241, 0.06);
    white-space: nowrap;
}

tbody td:first-child {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
}

.cell-nomor {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-weight: 600;
    font-size: 0.8rem !important;
    color: var(--accent-primary-hover) !important;
    letter-spacing: -0.01em;
}

.cell-jenis {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem !important;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary-hover) !important;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.cell-perihal {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-tujuan {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-pemohon {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    color: var(--text-primary) !important;
}

.btn-delete-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-delete-row:hover {
    background: var(--red-bg);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--red);
}

.btn-copy-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-copy-row:hover {
    background: var(--green-bg);
    border-color: rgba(34, 197, 94, 0.2);
    color: var(--green);
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-muted);
    text-align: center;
}

.empty-state svg {
    margin-bottom: var(--space-md);
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.empty-state span {
    font-size: 0.8rem;
}

.empty-state.hidden {
    display: none;
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 12px var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    backdrop-filter: blur(20px);
    animation: toastIn 0.35s ease forwards;
    min-width: 280px;
}

.toast.toast-success {
    border-color: rgba(34, 197, 94, 0.3);
}

.toast.toast-success .toast-dot {
    background: var(--green);
}

.toast.toast-error {
    border-color: rgba(239, 68, 68, 0.3);
}

.toast.toast-error .toast-dot {
    background: var(--red);
}

.toast.toast-info {
    border-color: rgba(99, 102, 241, 0.3);
}

.toast.toast-info .toast-dot {
    background: var(--accent-primary);
}

.toast-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

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

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

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    padding: var(--space-xl);
    text-align: center;
    max-width: 380px;
    width: 90%;
    transform: scale(0.9);
    transition: transform var(--transition-base);
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--red-bg);
    color: var(--red);
    margin-bottom: var(--space-md);
}

.modal-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.modal-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.modal-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
}

/* --- Animations --- */
@keyframes fadeInRow {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.1); }
    50% { box-shadow: 0 0 30px rgba(99, 102, 241, 0.2); }
}

/* --- Responsive --- */
@media (max-width: 1100px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    .form-section {
        position: static;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 0 var(--space-md);
    }

    .app-header {
        margin: 0 calc(-1 * var(--space-md));
        padding-left: var(--space-md);
        padding-right: var(--space-md);
    }

    .stats-section {
        grid-template-columns: repeat(2, 1fr);
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn-icon {
        flex: 1;
        justify-content: center;
    }

    .table-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box input {
        width: 100%;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

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

    .stat-card {
        padding: var(--space-md);
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.4);
}

/* Action cell */
.action-cell {
    display: flex;
    gap: 4px;
}

/* Spinner Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Login Gate --- */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 14, 26, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-overlay.active {
    opacity: 1;
    visibility: visible;
}

.login-card {
    position: relative;
    padding: var(--space-xl) var(--space-xl) var(--space-lg);
    max-width: 420px;
    width: 90%;
    text-align: center;
    transform: scale(0.92) translateY(20px);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.login-overlay.active .login-card {
    transform: scale(1) translateY(0);
}

.login-glow {
    position: absolute;
    top: -60%;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.18) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: loginGlowPulse 4s ease-in-out infinite;
}

@keyframes loginGlowPulse {
    0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.15); }
}

.login-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.35);
    margin-bottom: var(--space-lg);
    position: relative;
    z-index: 1;
}

.login-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    position: relative;
    z-index: 1;
}

.login-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: var(--space-xl);
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    z-index: 1;
}

.login-input-group {
    margin-bottom: var(--space-lg);
    position: relative;
    z-index: 1;
}

.login-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 var(--space-md);
    transition: all var(--transition-fast);
}

.login-input-wrapper:focus-within {
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1), 0 0 24px rgba(99, 102, 241, 0.08);
    background: var(--bg-input-focus);
}

.login-input-wrapper.error {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
    animation: loginShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes loginShake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-4px); }
    30%, 70% { transform: translateX(4px); }
}

.login-input-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    margin-right: var(--space-sm);
}

.login-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    padding: 14px 0;
    width: 100%;
}

.login-input-wrapper input::placeholder {
    color: var(--text-muted);
}

.login-toggle-pw {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
    flex-shrink: 0;
}

.login-toggle-pw:hover {
    color: var(--text-secondary);
}

.login-error {
    font-size: 0.8rem;
    color: var(--red);
    margin-top: var(--space-sm);
    min-height: 1.2em;
    text-align: left;
    padding-left: 2px;
    transition: opacity var(--transition-fast);
}

.login-btn {
    position: relative;
    z-index: 1;
}

.login-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
    position: relative;
    z-index: 1;
}

.login-footer-text {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* Login overlay exit animation */
.login-overlay.exiting {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.login-overlay.exiting .login-card {
    transform: scale(1.05) translateY(-20px);
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 480px) {
    .login-card {
        padding: var(--space-lg) var(--space-md);
    }

    .login-title {
        font-size: 1.2rem;
    }
}
