:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --info: #7c3aed;
    --info-bg: #ede9fe;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary); }

/* ---- app shell ---- */
.app-shell { display: flex; min-height: 100vh; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.app-content { padding: 24px 32px 48px; }

/* ---- sidebar ---- */
.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand .logo-badge {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), var(--info));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 2px;
}

.sidebar-link svg { flex-shrink: 0; opacity: .8; }

.sidebar-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }

.sidebar-link.active { background: var(--info-bg); color: var(--primary); }
.sidebar-link.active svg { opacity: 1; }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); font-size: 13px; }

.region-select {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.system-status { display: flex; flex-direction: column; gap: 4px; color: var(--text-muted); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; margin-right: 6px; }

/* ---- topbar ---- */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar-search {
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    background: var(--bg);
}

.topbar-daterange {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    white-space: nowrap;
}

.btn-primary-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.btn-primary-pill:hover { background: var(--primary-dark); color: #fff; }

.topbar-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--info));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; flex-shrink: 0;
}

/* ---- page header ---- */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.page-header p { color: var(--text-muted); font-size: 14px; margin: 0; }

/* ---- tab strip (Overview sub-nav) ---- */
.tab-strip {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
}

.tab-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    text-decoration: none;
}

.tab-item:hover { color: var(--text); text-decoration: none; }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- cards ---- */
.card-flat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px;
}

.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title-row h3 { font-size: 15px; font-weight: 700; margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }

.stat-card { display: flex; align-items: flex-start; gap: 14px; }

.stat-icon {
    width: 44px; height: 44px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.stat-label { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-trend { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ---- badges ---- */
.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: #f1f5f9; color: var(--text-muted); }

/* ---- tables ---- */
.simple-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.simple-table th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.simple-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.simple-table tr:last-child td { border-bottom: none; }
.simple-table tr:hover td { background: var(--bg); }

/* ---- progress bars ---- */
.bar-track { height: 8px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }

/* ---- list rows (candidates, templates) ---- */
.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
}

.list-row:hover { background: var(--bg); }
.list-row.selected { background: var(--info-bg); border-color: #ddd6fe; }

.two-col { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
.three-col { display: grid; grid-template-columns: 380px 1fr 320px; gap: 20px; align-items: start; }

@media (max-width: 1100px) {
    .two-col, .three-col { grid-template-columns: 1fr; }
}

.chip { display: inline-flex; padding: 3px 9px; border-radius: 999px; background: #f1f5f9; color: var(--text-muted); font-size: 12px; margin: 2px 4px 2px 0; }

.msg-bubble { padding: 10px 0; border-bottom: 1px solid var(--border); }
.msg-bubble:last-child { border-bottom: none; }
.msg-speaker { font-weight: 700; font-size: 13px; margin-bottom: 3px; }
.msg-text { font-size: 14px; line-height: 1.5; }
