:root {
    --primary: #0F172A;
    --primary-light: #1E293B;
    --accent: #D4AF37;
    --accent-hover: #B8960C;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;
    --bg-app: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-subtle: #F1F5F9;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);
    --radius: 12px;
    --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Satoshi', sans-serif; }
body { background-color: var(--bg-app); color: var(--text-main); overflow-x: hidden; }
h1, h2, h3, h4, .logo { font-family: 'Fraunces', serif; }
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }

/* Login */
.overlay {
    position: fixed; inset: 0;
    background: radial-gradient(circle at top left, #1e293b, #0f172a);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.login-card {
    background: white; padding: 2.5rem; border-radius: 24px;
    width: 100%; max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
}
.login-header h1 { font-size: 1.75rem; margin-bottom: 0.5rem; }
.login-header p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 2rem; }

.input-group { text-align: left; margin-bottom: 1.25rem; }
.input-group label {
    display: block; font-size: 0.8rem; font-weight: 600;
    margin-bottom: 0.5rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.input-group input, .input-group select, .input-group textarea {
    width: 100%; padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--border); border-radius: 10px;
    font-size: 0.95rem; background: white; transition: all 0.2s;
}
.input-group input:focus, .input-group select:focus, .input-group textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.1);
}

/* Buttons */
.btn-primary {
    padding: 0.7rem 1.2rem; background: var(--primary); color: white;
    border: none; border-radius: 10px; font-weight: 600; cursor: pointer;
    transition: transform 0.15s, background 0.2s; font-size: 0.9rem;
}
.btn-primary:hover { background: var(--primary-light); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 0.55rem 1rem; background: white;
    border: 1.5px solid var(--border); border-radius: 10px;
    font-weight: 600; cursor: pointer; font-size: 0.85rem;
    color: var(--text-main); transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-danger { background: var(--error); color: white; border: none; }
.btn-danger:hover { background: #DC2626; }
.btn-success { background: var(--success); color: white; border: none; }
.btn-success:hover { background: #059669; }
.btn-link {
    background: none; border: none; color: var(--info); cursor: pointer;
    font-weight: 600; font-size: 0.85rem; padding: 0;
}
.btn-link:hover { text-decoration: underline; }

.btn-icon {
    width: 32px; height: 32px; display: inline-flex;
    align-items: center; justify-content: center;
    border-radius: 8px; border: 1px solid var(--border);
    background: white; cursor: pointer; transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg-subtle); border-color: var(--border-strong); }

.btn-call {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0.4rem 0.75rem; background: var(--success); color: white;
    border: none; border-radius: 8px; font-size: 0.8rem; font-weight: 600;
    cursor: pointer; text-decoration: none;
}
.btn-call:hover { background: #059669; }

/* Dashboard Layout */
.dashboard-container { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--primary); color: white;
    padding: 1.75rem 1.25rem; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar-header .logo { font-size: 1.5rem; font-weight: 700; }
.sidebar-header .logo span { color: var(--accent); }
.sidebar-sub {
    font-size: 0.7rem; color: #94A3B8; margin-top: 4px;
    letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600;
    margin-bottom: 2.5rem;
}

.sidebar-nav { flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 0.7rem 0.9rem; color: #94A3B8;
    border-radius: 10px; margin-bottom: 0.25rem;
    transition: all 0.15s; font-size: 0.9rem; font-weight: 500;
    position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: white; }
.nav-item.active { background: var(--accent); color: var(--primary); font-weight: 700; }
.nav-count {
    margin-left: auto; font-size: 0.7rem; background: rgba(255,255,255,0.1);
    color: white; padding: 2px 8px; border-radius: 10px; font-weight: 700;
}
.nav-item.active .nav-count { background: rgba(15,23,42,0.2); color: var(--primary); }

.sidebar-footer { border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 1rem; }
.whoami { color: #94A3B8; font-size: 0.75rem; margin-bottom: 0.75rem; line-height: 1.4; }
.whoami strong { color: white; display: block; font-size: 0.85rem; }
#logout-btn {
    width: 100%; display: flex; align-items: center; gap: 10px;
    background: transparent; border: none; color: #94A3B8;
    cursor: pointer; font-weight: 500; padding: 0.5rem 0.25rem; font-size: 0.85rem;
}
#logout-btn:hover { color: white; }

/* Main Content */
.main-content { padding: 2rem 2.5rem; max-height: 100vh; overflow-y: auto; }
.main-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 2rem;
}
.header-info h2 { font-size: 1.75rem; margin-bottom: 0.25rem; }
.header-info p { color: var(--text-muted); font-size: 0.9rem; }

/* Stat Grid */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: white; padding: 1.25rem 1.5rem;
    border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.stat-card.stat-accent { border-left: 3px solid var(--accent); }
.stat-card.stat-success { border-left: 3px solid var(--success); }
.stat-card.stat-warning { border-left: 3px solid var(--warning); }
.stat-card.stat-info { border-left: 3px solid var(--info); }
.stat-card.stat-danger { border-left: 3px solid var(--error); }
.stat-label {
    color: var(--text-muted); font-size: 0.75rem; font-weight: 700;
    margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.04em;
}
.stat-value {
    font-size: 1.75rem; font-weight: 700; font-family: 'Fraunces', serif;
    line-height: 1.1;
}
.stat-sub {
    font-size: 0.75rem; color: var(--text-muted); margin-top: 0.4rem;
}

/* Data Cards & Tables */
.data-card {
    background: white; border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--border);
    overflow: hidden; margin-bottom: 1.5rem;
}
.data-card-header {
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; flex-wrap: wrap;
}
.data-card-header h3 {
    font-family: 'Satoshi', sans-serif; font-weight: 700; font-size: 1rem;
}
.data-card-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { background: var(--bg-subtle); border-bottom: 1.5px solid var(--border); }
th {
    padding: 0.75rem 1.25rem; font-size: 0.7rem;
    text-transform: uppercase; font-weight: 700;
    color: var(--text-muted); letter-spacing: 0.04em; white-space: nowrap;
}
td {
    padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--border);
    font-size: 0.875rem; vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-subtle); }
.td-primary { font-weight: 600; }
.td-muted { color: var(--text-muted); font-size: 0.8rem; }
.td-stack { line-height: 1.3; }
.td-stack strong { display: block; }

/* Filter Bar */
.filter-bar {
    display: flex; gap: 0.75rem; flex-wrap: wrap;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
    background: #fafbfc;
}
.filter-bar select, .filter-bar input {
    padding: 0.5rem 0.8rem; border: 1.5px solid var(--border);
    border-radius: 8px; font-size: 0.85rem; background: white;
    min-width: 140px;
}
.filter-bar .search-input { min-width: 220px; flex: 1; }
.filter-bar select:focus, .filter-bar input:focus {
    outline: none; border-color: var(--accent);
}
.filter-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0.4rem 0.75rem; background: var(--primary); color: white;
    border-radius: 20px; font-size: 0.75rem; font-weight: 600;
}
.filter-chip button {
    background: transparent; border: none; color: white;
    cursor: pointer; opacity: 0.7; font-size: 0.9rem;
}

/* Badges */
.badge {
    padding: 3px 10px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 700; text-transform: capitalize;
    display: inline-block; white-space: nowrap;
}
.badge-new, .badge-submitted { background: #E0F2FE; color: #075985; }
.badge-pending { background: #FEF3C7; color: #92400E; }
.badge-working { background: #DBEAFE; color: #1E40AF; }
.badge-verified { background: #D1FAE5; color: #065F46; }
.badge-paid { background: #D1FAE5; color: #065F46; }
.badge-rejected { background: #FEE2E2; color: #991B1B; }
.badge-flagged { background: #FEE2E2; color: #991B1B; }
.badge-dormant { background: #F1F5F9; color: #475569; }
.badge-duplicate { background: #FEF3C7; color: #92400E; }
.badge-active { background: #D1FAE5; color: #065F46; }
.badge-inactive { background: #F1F5F9; color: #475569; }

/* Profile card */
.profile-card {
    background: white; border-radius: var(--radius-lg);
    padding: 2rem; box-shadow: var(--shadow); border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}
.profile-head {
    display: flex; align-items: center; gap: 1.25rem; margin-bottom: 1.5rem;
}
.avatar {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 700; font-family: 'Fraunces', serif;
    flex-shrink: 0;
}
.avatar.avatar-accent { background: var(--accent); color: var(--primary); }
.profile-head h3 { font-size: 1.5rem; margin: 0 0 4px; }
.profile-head p { color: var(--text-muted); margin: 0; font-size: 0.9rem; }

.profile-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
}
.field-label {
    font-size: 0.7rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.field-value { font-size: 0.95rem; font-weight: 500; }
.field-value.muted { color: var(--text-muted); font-style: italic; font-weight: 400; }

/* Layout grids */
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

/* Back link */
.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-muted); font-size: 0.85rem; font-weight: 600;
    margin-bottom: 1rem; cursor: pointer; background: none; border: none;
}
.back-link:hover { color: var(--primary); }

/* Empty state */
.empty {
    padding: 3rem 2rem; text-align: center; color: var(--text-muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.empty h4 { color: var(--text-main); margin-bottom: 0.4rem; font-family: 'Satoshi', sans-serif; }

/* Skeletons */
@keyframes shimmer {
    0% { background-position: -468px 0; }
    100% { background-position: 468px 0; }
}
.skeleton {
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 800px 104px;
    display: inline-block; position: relative;
    animation: shimmer 1.2s infinite linear;
    border-radius: 4px;
}
.loading-container { display: flex; flex-direction: column; gap: 1.5rem; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1100; padding: 1rem;
}
.modal-card {
    background: white; width: 100%; max-width: 520px;
    border-radius: 20px; padding: 1.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    max-height: 90vh; overflow-y: auto;
}
.modal-card.modal-wide { max-width: 720px; }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.25rem;
}
.modal-header h3 { font-size: 1.2rem; font-family: 'Fraunces', serif; }
.modal-close {
    background: transparent; border: none; font-size: 1.25rem;
    cursor: pointer; color: var(--text-muted); padding: 4px 8px;
}
.modal-actions {
    display: flex; gap: 0.75rem; margin-top: 1.5rem;
    justify-content: flex-end;
}
.modal-actions .btn-secondary, .modal-actions .btn-primary { flex: 0 0 auto; }

/* Toast */
.toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    padding: 0.85rem 1.25rem; background: var(--primary); color: white;
    border-radius: 10px; box-shadow: var(--shadow-lg);
    z-index: 2000; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem; font-weight: 500; max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.info { background: var(--info); }

/* Utility */
.flex-row { display: flex; align-items: center; gap: 0.5rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.gap-sm { gap: 0.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Duplicate indicator */
.dup-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; font-size: 0.7rem; font-weight: 700;
    background: #FEF3C7; color: #92400E; border-radius: 12px;
    margin-left: 6px;
}

/* Timeline */
.timeline { position: relative; padding-left: 1.25rem; }
.timeline::before {
    content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px;
    width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 1rem; }
.timeline-item::before {
    content: ''; position: absolute; left: -1.25rem; top: 6px;
    width: 12px; height: 12px; border-radius: 50%;
    background: white; border: 2px solid var(--accent);
}
.timeline-date {
    font-size: 0.75rem; color: var(--text-muted); font-weight: 600;
}
.timeline-title { font-size: 0.9rem; font-weight: 600; margin-top: 2px; }

/* Network map */
.network-node {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.85rem 1rem; border: 1px solid var(--border);
    border-radius: 12px; margin-bottom: 0.5rem; background: white;
}
.network-node.is-first { border-color: var(--accent); background: #FFFBEB; }
.network-node .avatar { width: 40px; height: 40px; font-size: 1rem; }

/* Responsive */
@media (max-width: 900px) {
    .dashboard-container { grid-template-columns: 1fr; }
    .sidebar {
        position: relative; height: auto; flex-direction: row;
        overflow-x: auto; padding: 1rem;
    }
    .sidebar-header, .sidebar-footer { display: none; }
    .sidebar-nav { display: flex; flex: none; gap: 0.5rem; }
    .nav-item { margin-bottom: 0; flex-shrink: 0; }
    .main-content { padding: 1.5rem; }
    .main-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
}
