:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --success: #10b981;
    --info: #3b82f6;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --input-bg: #ffffff;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --primary-light: #1e293b;
    --input-bg: #0f172a;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    margin-bottom: 3rem;
    text-align: center;
    position: relative;
}

.top-actions {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-pill {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.45rem 0.85rem;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Theme Toggle */
.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.auth-shell {
    width: min(100%, 420px);
}

.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}

.auth-card h1 {
    color: var(--primary);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.auth-card p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.auth-error {
    color: var(--danger);
    font-weight: 700;
    margin-top: 1rem;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* Navigation & Tabs */
.tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    background: var(--card-bg);
    padding: 0.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    position: sticky;
    top: 1rem;
    z-index: 50;
    border: 1px solid var(--border);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: calc(var(--radius) - 4px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    background: var(--bg);
    color: var(--primary);
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

/* Tab Content Transitions */
.tab-content {
    display: none;
    animation: slideDownFade 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-content.active {
    display: block;
}

@keyframes slideDownFade {
    from { 
        opacity: 0; 
        transform: translateY(-20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* Parsed section specific animation */
#parsed-section:not(.hidden) {
    animation: slideDownFade 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Layout Elements */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 2rem;
}

h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Grid & Forms */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--input-bg);
    color: var(--text-main);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

textarea {
    min-height: 120px;
    font-family: inherit;
}

.row {
    display: flex;
    gap: 1rem;
}

.hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--info);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-info { background: var(--info); color: white; }
.btn-info:hover { opacity: 0.9; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* Editable Table */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}

th {
    background: var(--bg);
    padding: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

.edit-table input, .edit-table select {
    padding: 0.5rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-main);
}

/* Loader */
.loader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    color: #fff;
}

.loader {
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

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

.hidden { display: none !important; }

/* Responsive adjustments */
@media (max-width: 768px) {
    .container { padding: 1rem; }
    header { padding-top: 4rem; }
    .top-actions { left: 0; justify-content: center; flex-wrap: wrap; }
    .tabs { flex-wrap: wrap; position: relative; top: 0; }
    .tab-btn { flex: 1 1 calc(50% - 1rem); }
}

.instructions-list {
    list-style: none;
}
.instructions-list li {
    padding-left: 2rem;
    position: relative;
    margin-bottom: 1rem;
}

/* Toast Notifications - Slide from top */
#toast-container {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 10001;
}

.toast {
    background: var(--card-bg);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 350px;
    animation: toastSlideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border);
    border-left-width: 4px;
}

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

@keyframes toastSlideDown {
    from { transform: translate(-50%, -100%); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* Override slideIn specifically for centered toast */
@keyframes toastSlideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.toast.fade-out {
    animation: toastFadeUp 0.3s ease-in forwards;
}

@keyframes toastFadeUp {
    to { transform: translateY(-20px); opacity: 0; }
}

/* Enhanced Buttons */
.btn svg {
    transition: transform 0.2s;
}

.btn:hover svg {
    transform: scale(1.1);
}

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