/* DevOps Job Hunter — design system (data-dense dashboard, light/dark).
   No external fonts/CDN (CSP): system font stack, tabular numbers. */

:root {
  --primary: #2563eb; --primary-hover: #1d4ed8; --primary-soft: #eff6ff; --on-primary: #fff;
  --accent: #059669; --accent-hover: #047857; --accent-soft: #ecfdf5;
  --warn: #b45309; --warn-soft: #fffbeb; --danger: #dc2626; --danger-soft: #fef2f2;
  --bg: #f8fafc; --surface: #ffffff; --surface-2: #f1f5f9; --sidebar: #0f172a;
  --text: #0f172a; --text-2: #475569; --text-3: #64748b; --border: #e2e8f0;
  --ring: #2563eb; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --shadow-lg: 0 10px 30px -12px rgba(15,23,42,.25);
  --radius: 12px; --radius-sm: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --primary: #60a5fa; --primary-hover: #93c5fd; --primary-soft: rgba(96,165,250,.12); --on-primary: #0b1220;
  --accent: #34d399; --accent-hover: #6ee7b7; --accent-soft: rgba(52,211,153,.12);
  --warn: #fbbf24; --warn-soft: rgba(251,191,36,.12); --danger: #f87171; --danger-soft: rgba(248,113,113,.12);
  --bg: #0b1220; --surface: #111a2e; --surface-2: #17233b; --sidebar: #070d18;
  --text: #e2e8f0; --text-2: #b4c0d3; --text-3: #8b9bb4; --border: #1f2c46;
  --ring: #60a5fa; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 10px 30px -12px rgba(0,0,0,.7);
  color-scheme: dark;
}

/* ---- base -------------------------------------------------------------------------------- */
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.55;
       -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
h1, h2, h3, .h1, .h2, .h3, .h4, .h5, .h6 { color: var(--text); font-weight: 650; letter-spacing: -.01em; }
.text-muted, small.text-muted { color: var(--text-3) !important; }
code { color: var(--primary); background: var(--primary-soft); padding: 1px 6px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px;
             z-index: 1000; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.ico { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.ico-sm { width: 15px; height: 15px; vertical-align: -2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- layout: sidebar + main ------------------------------------------------------------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: #cbd5e1; padding: 20px 14px; position: sticky; top: 0;
           height: 100vh; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700;
         padding: 4px 10px 18px; text-decoration: none; letter-spacing: -.01em; }
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
              background: linear-gradient(135deg, #2563eb, #059669); color: #fff; }
.brand small { display: block; font-weight: 500; color: #94a3b8; font-size: .75rem; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b;
               padding: 14px 10px 6px; }
.nav-link-x { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px;
              color: #cbd5e1; text-decoration: none; font-weight: 500; transition: background .15s, color .15s; }
.nav-link-x:hover { background: rgba(148,163,184,.12); color: #fff; text-decoration: none; }
.nav-link-x.active { background: rgba(37,99,235,.22); color: #fff; box-shadow: inset 3px 0 0 #60a5fa; }
.nav-link-x .badge-x { margin-left: auto; background: #2563eb; color: #fff; border-radius: 999px;
                       font-size: .72rem; padding: 1px 8px; font-weight: 600; }
.sidebar-foot { margin-top: auto; display: flex; gap: 6px; padding-top: 12px; border-top: 1px solid #1e293b; }
.sidebar-foot form { flex: 1; }
.btn-side { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
            background: transparent; border: 1px solid #1e293b; color: #cbd5e1; border-radius: 9px;
            padding: 8px; cursor: pointer; transition: background .15s; }
.btn-side:hover { background: rgba(148,163,184,.12); color: #fff; }
.main { min-width: 0; padding: 28px 32px 48px; max-width: 1480px; width: 100%; }
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
             padding: 10px; gap: 2px; }
  .brand { padding: 4px 10px 4px 4px; } .brand small, .nav-section, .nav-label { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .main { padding: 18px 14px 40px; }
}

/* ---- page header ------------------------------------------------------------------------ */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
             gap: 12px; margin-bottom: 22px; }
.page-head h1 { font-size: 1.6rem; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--text-3); }
.section-title { display: flex; align-items: center; gap: 10px; font-size: 1.02rem; font-weight: 650;
                 margin: 0 0 12px; }
.section-title .count { color: var(--text-3); font-weight: 500; font-size: .9rem; }
.section-title .spacer { flex: 1; }

/* ---- surfaces ---------------------------------------------------------------------------- */
.card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
                box-shadow: var(--shadow); color: var(--text); }
.panel { padding: 18px 20px; margin-bottom: 22px; }
.card-body { color: var(--text); }
.grid { display: grid; gap: 18px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 24px; }
.grid-2 { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-halves { grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
       box-shadow: var(--shadow); padding: 16px 18px; display: flex; gap: 14px; align-items: center;
       text-decoration: none; color: var(--text); transition: transform .15s, box-shadow .15s; }
a.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); text-decoration: none; color: var(--text); }
.kpi-ico { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.kpi-ico .ico { width: 21px; height: 21px; }
.kpi-val { font-size: 1.65rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-lbl { color: var(--text-3); font-size: .82rem; line-height: 1.3; display: inline-block; }
.tone-blue { background: var(--primary-soft); color: var(--primary); }
.tone-green { background: var(--accent-soft); color: var(--accent); }
.tone-amber { background: var(--warn-soft); color: var(--warn); }
.tone-red { background: var(--danger-soft); color: var(--danger); }
.tone-slate { background: var(--surface-2); color: var(--text-2); }

/* ---- lists ------------------------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.row-item { display: flex; align-items: center; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: 0; }
.row-main { min-width: 0; flex: 1; }
.row-title { font-weight: 600; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis;
             white-space: nowrap; }
a.row-title:hover { color: var(--primary); text-decoration: none; }
.row-sub { color: var(--text-3); font-size: .85rem; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.row-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.empty { color: var(--text-3); padding: 22px 8px; text-align: center; }
.empty .ico { width: 28px; height: 28px; display: block; margin: 0 auto 8px; opacity: .6; }

.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none;
          font-weight: 700; font-size: .85rem; color: #fff; background: linear-gradient(135deg, #3b82f6, #6366f1); }
.avatar.sm { width: 30px; height: 30px; font-size: .75rem; }
.avatar.c1 { background: linear-gradient(135deg, #059669, #10b981); }
.avatar.c2 { background: linear-gradient(135deg, #d97706, #f59e0b); }
.avatar.c3 { background: linear-gradient(135deg, #db2777, #ec4899); }
.avatar.c4 { background: linear-gradient(135deg, #7c3aed, #a78bfa); }

/* ---- pills / chips ----------------------------------------------------------------------- */
.score { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 26px;
         padding: 0 8px; border-radius: 999px; font-weight: 700; font-size: .82rem;
         font-variant-numeric: tabular-nums; flex: none; }
.score-hi { background: var(--accent-soft); color: var(--accent); }
.score-mid { background: var(--warn-soft); color: var(--warn); }
.score-lo { background: var(--surface-2); color: var(--text-3); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 600;
        padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2);
        border: 1px solid var(--border); white-space: nowrap; }
.chip.blue { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.chip.green { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.amber { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.red { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dot.ko { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot.idle { background: var(--text-3); }

/* ---- buttons ----------------------------------------------------------------------------- */
.btn { border-radius: 9px; font-weight: 600; font-size: .86rem; padding: 7px 13px; display: inline-flex;
       align-items: center; gap: 7px; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn-success, .btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-success:hover, .btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-ghost, .btn-outline-secondary, .btn-outline-primary, .btn-outline-success, .btn-outline-danger,
.btn-outline-warning, .btn-outline-light { background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.btn-ghost:hover, .btn-outline-secondary:hover, .btn-outline-primary:hover, .btn-outline-success:hover,
.btn-outline-danger:hover, .btn-outline-warning:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-danger-ghost { background: var(--surface); border: 1px solid var(--border); color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); color: var(--danger); }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }
.btn-icon.sm { width: 30px; height: 30px; }
.btn-warning { background: var(--warn-soft); border: 1px solid transparent; color: var(--warn); }
form.inline { display: inline; margin: 0; }

/* ---- dropdown menu (details/summary, no JS) ---------------------------------------------- */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary { background: var(--surface-2); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 210px;
            background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
            box-shadow: var(--shadow-lg); padding: 6px; }
.menu-pop form { margin: 0; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0;
             background: none; color: var(--text); border-radius: 7px; font-size: .86rem; text-align: left;
             cursor: pointer; text-decoration: none; }
.menu-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* ---- email draft cards ------------------------------------------------------------------- */
.draft { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
         box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px; }
.draft-head { display: flex; gap: 14px; align-items: flex-start; }
.draft-subject { font-weight: 650; font-size: 1rem; color: var(--text); margin: 0 0 3px; }
.draft-meta { color: var(--text-3); font-size: .85rem; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.draft-meta a { color: var(--text-2); font-weight: 600; }
.draft-meta a:hover { color: var(--primary); }
.draft details summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .85rem; margin-top: 10px; }
.draft-body { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
              padding: 14px 16px; margin-top: 10px; font-size: .9rem; color: var(--text); max-height: 340px; overflow: auto; }
.draft-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---- tables ------------------------------------------------------------------------------ */
.table { color: var(--text); margin: 0; }
.table thead th { border-top: 0; border-bottom: 1px solid var(--border); color: var(--text-3); font-size: .74rem;
                  text-transform: uppercase; letter-spacing: .05em; font-weight: 600; padding: 10px 12px; }
.table td { border-top: 1px solid var(--border); padding: 11px 12px; vertical-align: middle !important; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* ---- bars / pipeline --------------------------------------------------------------------- */
.bar-row { display: grid; grid-template-columns: 120px 1fr 36px; gap: 10px; align-items: center; font-size: .86rem; padding: 4px 0; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #818cf8); border-radius: 99px; }
.bar.green > span { background: linear-gradient(90deg, var(--accent), #34d399); }
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.stage { background: var(--surface-2); border-radius: 10px; padding: 12px; text-align: center; }
.stage b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stage span { font-size: .75rem; color: var(--text-3); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 10px; padding: 7px 0; font-size: .85rem; color: var(--text-2); border-bottom: 1px dashed var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--text-3); font-variant-numeric: tabular-nums; flex: none; width: 92px; }

/* ---- forms ------------------------------------------------------------------------------- */
.form-control, .form-control-sm, textarea.form-control, select.form-control {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 9px; }
.form-control:focus { background: var(--surface); color: var(--text); border-color: var(--primary);
                      box-shadow: 0 0 0 3px var(--primary-soft); }
label { font-weight: 600; font-size: .85rem; color: var(--text-2); }
.check { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; margin-right: 14px; cursor: pointer; }
.code-area { font-family: var(--mono); font-size: .82rem; line-height: 1.5; }
.terminal { background: #0b1220; color: #d1e0f5; font-family: var(--mono); font-size: .82rem; border-radius: 12px;
            padding: 16px 18px; max-height: 70vh; overflow: auto; white-space: pre-wrap; border: 1px solid #1f2c46; }

/* ---- alerts / toasts --------------------------------------------------------------------- */
.toasts { display: grid; gap: 8px; margin-bottom: 18px; }
.toast-x { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px; font-size: .9rem;
           border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.toast-x.success { border-left: 4px solid var(--accent); }
.toast-x.danger { border-left: 4px solid var(--danger); }
.toast-x.warning { border-left: 4px solid var(--warn); }
.toast-x.info { border-left: 4px solid var(--primary); }

/* ---- auth pages ------------------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
        background: radial-gradient(1200px 600px at 10% -10%, rgba(37,99,235,.18), transparent 60%),
                    radial-gradient(900px 500px at 110% 110%, rgba(5,150,105,.16), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
             border-radius: 16px; box-shadow: var(--shadow-lg); padding: 30px 30px 26px; }
.auth-card .brand { color: var(--text); padding: 0 0 18px; }
.auth-card .brand small { color: var(--text-3); }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; }

/* ---- Flask-Admin pages share the tokens -------------------------------------------------- */
.navbar.bg-dark { background: var(--sidebar) !important; }
.qr svg { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 12px; }
.js-copy.copied { background: var(--accent-soft) !important; color: var(--accent) !important; border-color: transparent !important; }
@media (max-width: 600px) { .section-title .count { display: none; } }
