:root {
  --primary: #003366;
  --primary-light: #1a5c9e;
  --accent: #00a0e3;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1a2332;
  --muted: #5c6b7a;
  --border: #dde3ea;
  --success: #0d7a4e;
  --warning: #b45309;
  --danger: #c41e3a;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,51,102,.08);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }
.view { display: none; min-height: 100vh; }
.view.active { display: flex; flex-direction: column; }
#view-login.active { display: block; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); padding: 1.5rem; }
.login-card { background: var(--surface); border-radius: 16px; padding: 2.5rem; max-width: 420px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.2); text-align: center; }
.login-brand h1 { font-size: 1.5rem; margin: .75rem 0 .25rem; color: var(--primary); }
.login-sub { color: var(--muted); font-size: .95rem; }
.login-hint { margin: 1.5rem 0 1rem; font-size: .9rem; color: var(--muted); }
.demo-note { margin-top: 1rem; font-size: .75rem; color: var(--muted); font-style: italic; }
.brand-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; background: var(--primary); color: #fff; font-weight: 700; border-radius: 8px; font-size: 1.1rem; }
.brand-icon.lg { width: 56px; height: 56px; font-size: 1.75rem; border-radius: 12px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .75rem 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  width: 100%; max-width: 100%; box-sizing: border-box;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; color: var(--primary); flex: 1; min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.btn-logout-icon { display: none; font-size: 1.1rem; line-height: 1; }
.menu-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; cursor: pointer; font-size: 1.1rem; }
.lang-select { padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 8px; font-size: .85rem; }
.user-chip { display: flex; align-items: center; gap: .5rem; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 600; }
.user-name { font-size: .9rem; font-weight: 500; }

/* Layout */
.layout { display: flex; flex: 1; min-height: calc(100vh - 57px); }
.sidebar { width: 240px; background: var(--surface); border-right: 1px solid var(--border); padding: 1rem 0; flex-shrink: 0; overflow-y: auto; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .75rem 1.25rem .35rem; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: .65rem; padding: .65rem 1.25rem; color: var(--text); text-decoration: none; font-size: .9rem; border-left: 3px solid transparent; transition: background .15s; }
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: #e8f2fa; color: var(--primary); border-left-color: var(--accent); font-weight: 600; }
.nav-logout-mobile { display: none; }
.nav-icon { font-size: 1.1rem; width: 1.4rem; text-align: center; }
.content { flex: 1; padding: 1.5rem; overflow-y: auto; max-width: 1200px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem; border-radius: 8px; font-size: .9rem; font-weight: 500; cursor: pointer; border: none; transition: opacity .15s, transform .1s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* Cards */
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.5rem; color: var(--primary); margin-bottom: .25rem; }
.page-header p { color: var(--muted); font-size: .95rem; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 1rem; overflow: hidden; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Stats */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 1rem 1.25rem; border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat-card .label { font-size: .8rem; color: var(--muted); }
.stat-card .value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat-card .sub { font-size: .75rem; color: var(--muted); margin-top: .2rem; }

/* Tags & badges */
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-success { background: #d4edda; color: var(--success); }
.badge-warning { background: #fff3cd; color: var(--warning); }
.badge-info { background: #cce5ff; color: var(--primary); }
.tag { display: inline-block; padding: .25rem .6rem; background: var(--bg); border-radius: 6px; font-size: .8rem; margin: .15rem; border: 1px solid var(--border); }
.match-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: .35rem; }
.match-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--success)); border-radius: 3px; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; color: var(--text); }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 8px; font-size: .9rem; font-family: inherit;
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tab { padding: .6rem 1rem; background: none; border: none; cursor: pointer; font-size: .9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--primary); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Job list */
.job-item { padding: 1rem; border-bottom: 1px solid var(--border); display: flex; gap: 1rem; align-items: flex-start; }
.job-item:last-child { border-bottom: none; }
.job-item:hover { background: #fafbfc; }
.job-match { font-size: 1.25rem; font-weight: 700; color: var(--accent); min-width: 48px; text-align: center; }
.job-meta { font-size: .85rem; color: var(--muted); margin-top: .25rem; }

/* Chat */
.chat-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; min-height: 480px; }
@media (max-width: 700px) { .chat-layout { grid-template-columns: 1fr; } }
.chat-topics { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-topic { display: block; width: 100%; text-align: left; padding: .75rem 1rem; border: none; background: var(--surface); border-bottom: 1px solid var(--border); cursor: pointer; font-size: .85rem; }
.chat-topic.active, .chat-topic:hover { background: #e8f2fa; }
.chat-window { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.chat-messages { flex: 1; padding: 1rem; overflow-y: auto; max-height: 380px; min-height: 300px; }
.msg { margin-bottom: 1rem; max-width: 85%; }
.msg.user { margin-left: auto; }
.msg-bubble { padding: .75rem 1rem; border-radius: 12px; font-size: .9rem; }
.msg.ai .msg-bubble { background: var(--bg); border: 1px solid var(--border); }
.msg.user .msg-bubble { background: var(--primary); color: #fff; }
.msg-time { font-size: .7rem; color: var(--muted); margin-top: .25rem; }
.chat-input-row { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 8px; }

/* CV preview */
.cv-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; background: #fff; min-height: 400px; font-size: .9rem; }
.cv-preview h1 { font-size: 1.4rem; color: var(--primary); margin-bottom: .25rem; }
.cv-preview h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin: 1rem 0 .5rem; border-bottom: 1px solid var(--border); padding-bottom: .25rem; }
.cv-preview .cv-section { margin-bottom: .75rem; }
.cv-template-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.template-thumb { border: 2px solid var(--border); border-radius: 8px; padding: .75rem; cursor: pointer; text-align: center; font-size: .8rem; transition: border-color .15s; }
.template-thumb.selected { border-color: var(--accent); background: #e8f2fa; }
.template-thumb .thumb-preview { height: 80px; background: linear-gradient(180deg, var(--primary) 30%, #eee 30%); border-radius: 4px; margin-bottom: .5rem; }

/* Career path */
.career-timeline { position: relative; padding-left: 2rem; }
.career-step { position: relative; padding-bottom: 1.5rem; }
.career-step::before { content: ''; position: absolute; left: -1.5rem; top: .35rem; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--accent); }
.career-step::after { content: ''; position: absolute; left: calc(-1.5rem + 5px); top: 1.1rem; width: 2px; height: calc(100% - .5rem); background: var(--border); }
.career-step:last-child::after { display: none; }
.career-step.current::before { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.career-step.future { opacity: .75; }

/* Analysis */
.skill-gap { display: flex; align-items: center; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.skill-gap:last-child { border-bottom: none; }
.demand-indicator { width: 8px; height: 40px; border-radius: 4px; }
.demand-high { background: var(--success); }
.demand-med { background: var(--warning); }
.demand-low { background: var(--muted); }

/* Admin table */
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th, .data-table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--bg); font-weight: 600; color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.chart-bar-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.chart-bar-label { width: 80px; font-size: .8rem; }
.chart-bar-track { flex: 1; height: 20px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.chart-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; }
.chart-bar-val { width: 40px; font-size: .8rem; text-align: right; color: var(--muted); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 1rem; }
.modal { background: var(--surface); border-radius: 12px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; }
.modal-close { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--muted); }

/* Toast */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 300; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: var(--text); color: #fff; padding: .75rem 1.25rem; border-radius: 8px; font-size: .9rem; box-shadow: 0 4px 20px rgba(0,0,0,.2); animation: slideIn .3s ease; max-width: 360px; }
.toast.info { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Prototype banner */
.proto-banner { background: #fff8e6; border: 1px solid #f0d78c; color: #7a5c00; padding: .5rem 1rem; font-size: .8rem; text-align: center; }
.ai-pulse { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; color: var(--accent); }
.ai-pulse::before { content: ''; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* Resource cards */
.resource-card { padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: box-shadow .15s; }
.resource-card:hover { box-shadow: var(--shadow); }
.resource-card h4 { font-size: .95rem; margin-bottom: .35rem; }
.resource-card p { font-size: .85rem; color: var(--muted); }

/* Responsive sidebar */
@media (max-width: 768px) {
  body { overflow-x: hidden; }
  .menu-toggle { display: block; flex-shrink: 0; }
  .topbar { padding: .5rem .6rem; gap: .35rem; }
  .brand { flex: 0 0 auto; min-width: 0; }
  .brand-text { display: none; }
  .topbar-actions { gap: .25rem; margin-left: auto; }
  .lang-select {
    width: 3.1rem; min-width: 0; max-width: 3.1rem;
    padding: .3rem .2rem; font-size: .7rem;
  }
  .user-chip { flex-shrink: 0; }
  .user-name { display: none; }
  .btn-logout {
    padding: .35rem .4rem;
    min-width: 2rem;
    flex-shrink: 0;
  }
  .topbar .btn-logout { display: none !important; }
  .nav-logout-mobile { display: flex; margin-top: .5rem; border-top: 1px solid var(--border); color: var(--danger); }
  .nav-logout-mobile:hover { background: #fde8ec; }
  .layout { display: block; }
  .sidebar {
    position: fixed;
    top: 57px;
    left: 0;
    bottom: 0;
    width: min(220px, 78vw);
    max-width: 220px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 150;
    box-shadow: 4px 0 20px rgba(0, 0, 0, .12);
    flex-shrink: 0;
  }
  .sidebar.open { transform: translateX(0); }
  .nav-item { padding: .6rem 1rem; font-size: .85rem; }
  .nav-label { padding: .6rem 1rem .25rem; }
  .content {
    width: 100%;
    max-width: 100%;
    padding: 1rem;
    min-width: 0;
  }
  body.sidebar-open::before {
    content: '';
    position: fixed;
    inset: 57px 0 0 0;
    background: rgba(0, 0, 0, .35);
    z-index: 140;
  }
}