:root {
    --bg: #0a0a0b;
    --surface: #121214;
    --surface-hover: #1a1a1e;
    --surface-glass: rgba(22, 22, 24, 0.95);
    --border: rgba(255, 255, 255, 0.08);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text: #fafaf9;
    --text-muted: #a1a1aa;
    --text-dim: #52525b;
    --gold: #f5c542;
    --gold-dim: rgba(245, 197, 66, 0.25);
    --gold-hover: rgba(245, 197, 66, 0.12);
    --green: #10b981;
    --red: #f43f5e;
    --amber: #f59e0b;
    --radius: 12px;
    --radius-lg: 16px;
    --font-body: 'DM Sans', -apple-system, sans-serif;
    --font-header: 'Syne', sans-serif;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-theme { position: relative; }

.site-theme::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 100% 80% at 50% -10%, rgba(245, 197, 66, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(59, 130, 246, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 20% 80%, rgba(239, 68, 68, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

body > * { position: relative; z-index: 1; }

/* ---- Header ---- */
.app-header {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(10, 10, 11, 0.95);
    backdrop-filter: blur(8px);
}
@media (min-width: 768px) {
    .app-header { padding: 10px 16px; }
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: color 0.2s;
    justify-self: start;
}
@media (min-width: 768px) { .nav-link { font-size: 14px; } }
.nav-link:hover { color: var(--gold); }

.nav-title {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}
@media (min-width: 768px) { .nav-title { font-size: 14px; } }

.nav-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.nav-icon-btn {
    padding: 8px;
    height: 36px;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--gold);
    cursor: pointer;
    transition: all 0.2s;
}
@media (min-width: 768px) {
    .nav-icon-btn { padding: 10px; height: 40px; width: 40px; }
}
.nav-icon-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}
.nav-icon-btn.syncing {
    opacity: 0.5;
    pointer-events: none;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Main ---- */
main {
    flex: 1;
    padding: 24px 16px;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
}

/* ---- Footer (3-column grid) ---- */
footer {
    border-top: 1px solid var(--border-subtle);
    padding: 12px 16px;
    margin-top: auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    font-size: 10px;
    color: var(--text-dim);
    gap: 8px;
}
.footer-left { justify-self: start; }
.footer-center { justify-self: center; }
.footer-right { justify-self: end; }
.footer-right a {
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.2s;
}
.footer-right a:hover { color: var(--text-muted); }

/* ---- Cards (glass-morphism) ---- */
.card {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.card-title {
    font-family: var(--font-header);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.card-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ---- Forms ---- */
.form-row {
    margin-bottom: 16px;
}

.form-row label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.select-input, .text-input, .password-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: all 0.2s;
}
.select-input:focus, .text-input:focus, .password-input:focus {
    border-color: rgba(245, 197, 66, 0.5);
    box-shadow: 0 0 0 2px rgba(245, 197, 66, 0.15);
}

.text-input {
    resize: vertical;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.6;
}

.text-input::placeholder,
.password-input::placeholder { color: var(--text-muted); }

/* ---- Buttons ---- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--gold);
    background: var(--surface);
    border: 1px solid var(--gold-dim);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(245, 197, 66, 0.1);
}
.btn-primary:hover {
    background: var(--surface-hover);
    border-color: rgba(245, 197, 66, 0.4);
    transform: scale(1.02);
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-full { width: 100%; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:hover {
    color: var(--text);
    border-color: var(--border-hover);
    background: var(--surface-hover);
}

/* ---- Table ---- */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    position: sticky;
    top: 0;
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

tbody tr.is-duplicate {
    opacity: 0.45;
    text-decoration: line-through;
}
tbody tr.excluded { opacity: 0.3; }

.cat-select {
    padding: 4px 8px;
    font-size: 13px;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    min-width: 120px;
}
.cat-select:focus { border-color: rgba(245, 197, 66, 0.5); }

.split-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--gold);
    cursor: pointer;
}

.split-input {
    width: 80px;
    padding: 4px 8px;
    font-size: 13px;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
}
.split-input:focus { border-color: rgba(245, 197, 66, 0.5); }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    white-space: nowrap;
}
.badge-dupe { background: rgba(244, 63, 94, 0.15); color: var(--red); }
.badge-new { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.badge-uncategorized { background: rgba(245, 158, 11, 0.15); color: var(--amber); }

/* ---- Review actions ---- */
.review-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ---- Results ---- */
.result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}
.result-item.success { border-color: rgba(16, 185, 129, 0.3); }
.result-item.fail { border-color: rgba(244, 63, 94, 0.3); }
.result-icon { font-size: 18px; flex-shrink: 0; }

/* ---- Sync banner ---- */
.sync-banner {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}
.sync-banner.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--green);
}
.sync-banner.error {
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.25);
    color: var(--red);
}
.sync-banner.loading {
    background: rgba(245, 197, 66, 0.1);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
}

/* ---- Login (matches Reminders pattern) ---- */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
    padding: 0 16px;
}

.login-hero {
    text-align: center;
    margin-bottom: 32px;
}

.hero-title {
    font-family: var(--font-header);
    font-size: 36px;
    font-weight: 800;
    color: var(--gold);
    filter: drop-shadow(0 0 20px rgba(245, 197, 66, 0.2));
}
@media (min-width: 768px) { .hero-title { font-size: 48px; } }

.hero-subtitle {
    font-family: var(--font-header);
    font-size: 30px;
    font-weight: 700;
    color: var(--text);
}
@media (min-width: 768px) { .hero-subtitle { font-size: 40px; } }

.hero-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 8px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.login-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.lock-icon-box {
    padding: 8px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lock-icon { color: var(--gold); }

.login-card-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.password-input {
    margin-bottom: 12px;
}

.error-msg {
    padding: 8px 14px;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.25);
    border-radius: 8px;
    color: var(--red);
    font-size: 13px;
    margin-bottom: 12px;
}

/* ---- Utilities ---- */
.hidden { display: none !important; }
.gold { color: var(--gold); }

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}
.animate-fade-in-up {
    animation: fadeInUp 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
    main { padding: 16px 12px; }
    .card { padding: 16px; }
    .review-actions { flex-direction: column; }
    .review-actions .btn-primary,
    .review-actions .btn-secondary { width: 100%; }
    table { font-size: 12px; }
    thead th, tbody td { padding: 8px 6px; }
    .login-card { margin: 0 4px; }
}
