/* SIRA console — dark, calm, functional. */
:root {
  --bg: #0e1116;
  --bg2: #151a22;
  --bg3: #1c232e;
  --border: #2a3341;
  --text: #dfe6ef;
  --muted: #8b97a8;
  --accent: #d4a24c;       /* qalam gold */
  --accent-soft: #d4a24c26;
  --green: #4ec98c;
  --green-soft: #4ec98c22;
  --blue: #5aa7e8;
  --blue-soft: #5aa7e822;
  --orange: #e8a15a;
  --orange-soft: #e8a15a22;
  --red: #e86a6a;
  --red-soft: #e86a6a22;
  --radius: 10px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); font-size: .9em; }
a { color: var(--blue); }

/* ---------- login ---------- */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 70% -10%, #1a2230 0%, var(--bg) 60%);
  z-index: 50;
}
.login-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 14px;
  padding: 42px 46px; width: 340px; text-align: center;
}
.brand-mark { font-size: 40px; color: var(--accent); margin-bottom: 4px; }
.login-card h1 { margin: 0; letter-spacing: 6px; font-size: 22px; }
.login-card form { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand-icon { font-size: 26px; color: var(--accent); }
.brand-name { font-weight: 700; letter-spacing: 4px; }
.brand-sub { font-size: .72em; color: var(--muted); letter-spacing: 1px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: var(--muted); text-decoration: none; padding: 9px 12px; border-radius: 8px; font-size: .95em;
}
.sidebar nav a:hover { background: var(--bg3); color: var(--text); }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.visa-banner {
  background: var(--green-soft); border: 1px solid #2c5c45; color: var(--green);
  border-radius: 8px; padding: 8px 10px; font-size: .78em; line-height: 1.4;
}
.main { flex: 1; padding: 28px 34px; max-width: 1200px; }

/* ---------- common ---------- */
h2.page-title { margin: 0 0 4px; font-size: 1.5em; }
.page-sub { color: var(--muted); margin: 0 0 22px; font-size: .95em; }
.card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

button, .btn {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg3); color: var(--text); padding: 8px 14px;
}
button:hover, .btn:hover { border-color: #3d4b5f; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1204; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: .85em; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--red); }
button:disabled { opacity: .5; cursor: wait; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { width: 100%; resize: vertical; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em; line-height: 1.5; }

/* ---------- stats ---------- */
.stats-line { display: flex; gap: 26px; flex-wrap: wrap; padding: 4px 2px 0; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 1.5em; color: var(--text); }
.stat span { font-size: .8em; color: var(--muted); }

/* ---------- job cards ---------- */
.job-card {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px;
}
.job-card:hover { border-color: #3d4b5f; }
.job-score {
  flex-shrink: 0; width: 48px; height: 48px; border-radius: 10px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-weight: 700; background: var(--bg3);
}
.job-score small { font-size: .55em; font-weight: 400; color: var(--muted); }
.job-score.hot { background: var(--accent-soft); color: var(--accent); }
.job-body { flex: 1; min-width: 0; }
.job-title { font-weight: 600; }
.job-title a { color: var(--text); text-decoration: none; }
.job-title a:hover { color: var(--accent); }
.job-meta { color: var(--muted); font-size: .85em; margin-top: 2px; }
.job-reason { color: var(--blue); font-size: .82em; margin-top: 4px; font-style: italic; }
.job-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex-shrink: 0; }

.badge {
  display: inline-block; font-size: .72em; padding: 2px 8px; border-radius: 20px; white-space: nowrap;
  border: 1px solid transparent; margin-right: 6px;
}
.badge.eligible_now { background: var(--green-soft); color: var(--green); border-color: #2c5c45; }
.badge.sponsor_offered { background: var(--blue-soft); color: var(--blue); border-color: #2c4a66; }
.badge.remote { background: var(--orange-soft); color: var(--orange); border-color: #6b4a2a; }
.badge.sponsor_required { background: var(--bg3); color: var(--muted); border-color: var(--border); }
.badge.source { background: var(--bg3); color: var(--muted); }
.badge.status-applied, .badge.status-interviewing, .badge.status-offer { background: var(--green-soft); color: var(--green); }
.badge.status-saved { background: var(--blue-soft); color: var(--blue); }
.badge.status-rejected { background: var(--red-soft); color: var(--red); }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input[type=text] { min-width: 220px; }

/* ---------- tailor result ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button {
  background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--muted); padding: 8px 14px;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.preview-frame { width: 100%; height: 760px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.cover-letter { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; font-size: .95em; }
.analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.analysis-grid .card { margin: 0; }
.analysis-grid h4 { margin: 0 0 8px; font-size: .85em; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.analysis-grid ul { margin: 0; padding-left: 18px; }
.analysis-grid li { margin: 4px 0; font-size: .92em; }
.fit-score { font-size: 2.2em; font-weight: 700; color: var(--accent); }
.kw { display: inline-block; background: var(--bg3); border-radius: 6px; padding: 2px 8px; margin: 2px; font-size: .8em; }
.kw.miss { color: var(--orange); }
.visa-note {
  background: var(--green-soft); border: 1px solid #2c5c45; border-radius: var(--radius);
  padding: 14px 16px; font-size: .93em; margin-bottom: 14px;
}

/* ---------- documents / settings tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); font-size: .92em; }
th { color: var(--muted); font-weight: 500; font-size: .8em; text-transform: uppercase; letter-spacing: 1px; }
tr:hover td { background: var(--bg3); }

.search-row { display: grid; grid-template-columns: 40px 1fr 1.4fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }

/* ---------- toast / spinner ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 18px; max-width: 380px; z-index: 100; font-size: .92em;
  box-shadow: 0 8px 30px rgba(0,0,0,.45);
}
.toast.err { border-color: var(--red); }
.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid var(--muted);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: -2px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-note { text-align: center; color: var(--muted); padding: 40px 0; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .main { padding: 18px; }
  .analysis-grid { grid-template-columns: 1fr; }
}
