/* ---------- Mobile-first base (phones) — dark theme for everyone ---------- */
:root {
  color-scheme: dark; /* dark date pickers, dropdowns and scrollbars too */
  --bg: #0f1117;
  --surface: #181b24;
  --text: #e8e9ee;
  --muted: #9aa0b2;
  --border: #2a2e3b;
  --primary: #8fb3f0;
  --primary-ink: #0f1117;
  --primary-soft: #1b2638;
  --danger: #f87171;
  --ok-bg: #12301f;
  --ok-ink: #7ee2a8;
  --warn-bg: #3a2a0f;
  --warn-ink: #fbbf6a;
  --error-bg: #3a1616;
  --error-ink: #fca5a5;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Nirmala UI", "Noto Sans Devanagari", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--primary); }

.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 40px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; text-decoration: none; color: var(--text); white-space: nowrap;
}
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand-mark rect { fill: #0e4194; }
.brand-mark path { fill: #ffffff; }
.nav { display: flex; gap: 4px; }
.nav a {
  text-decoration: none; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; font-size: .95rem;
}
.nav a.active { background: var(--primary); color: var(--primary-ink); }

/* small phones (most Android phones are 360px wide) */
@media (max-width: 400px) {
  .wrap { padding: 0 12px; }
  .topbar-inner { gap: 8px; }
  .brand { font-size: .95rem; gap: 6px; }
  .brand-mark { width: 24px; height: 24px; }
  .nav { gap: 2px; }
  .nav a { padding: 7px 11px; font-size: .9rem; }
}
@media (max-width: 340px) {
  .brand-long { display: none; }
}

h1 { font-size: 1.5rem; margin: 0 0 4px; }
.muted { color: var(--muted); margin: 0 0 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
}

/* Form */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* stops iOS zoom on focus */
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
textarea { resize: vertical; min-height: 120px; }
.error { display: block; color: var(--danger); margin-top: 4px; }

.btn {
  display: block; width: 100%; min-height: 48px;
  padding: 14px; border: 0; border-radius: 10px;
  font: inherit; font-weight: 600;
  background: var(--primary); color: var(--primary-ink);
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }

.flash {
  background: var(--ok-bg); color: var(--ok-ink);
  padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500;
}

.warn {
  background: var(--warn-bg); color: var(--warn-ink);
  padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .9rem;
}

code {
  font-family: ui-monospace, Consolas, monospace; font-size: .9em;
  background: var(--bg); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 6px;
}

/* Dashboard */
.dash-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.dash-tools { display: flex; gap: 8px; align-items: center; }
.dash-tools form { margin: 0; }
.dash-tools .search { flex: 1 1 auto; }
.btn-ghost {
  min-height: 48px; padding: 0 14px; white-space: nowrap; cursor: pointer;
  font: inherit; font-size: .9rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 8px; text-align: center;
}
.stat-num { display: block; font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 12px; font-size: .85rem;
}

.list { display: grid; gap: 12px; }
.entry-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.entry h2 { font-size: 1.05rem; margin: 0; word-break: break-word; }
.badge {
  font-size: .75rem; white-space: nowrap;
  padding: 2px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
}
.meta { margin: 4px 0 10px; font-size: .9rem; word-break: break-word; }
.dot { color: var(--muted); margin: 0 6px; }
.msg { margin: 0 0 12px; white-space: pre-wrap; word-break: break-word; }
.entry-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .85rem; color: var(--muted);
  border-top: 1px solid var(--border); padding-top: 10px;
}
.entry-foot form { margin: 0; }
.link-danger {
  background: none; border: 0; cursor: pointer;
  font: inherit; color: var(--danger);
  padding: 8px; margin: -8px; /* bigger tap target */
}
.empty { text-align: center; color: var(--muted); }

/* ---------- CV form ---------- */
.intro { margin-bottom: 16px; }
.intro .muted { margin-bottom: 12px; }
.note {
  background: var(--primary-soft); border-radius: 12px;
  padding: 12px 16px; font-size: .92rem; line-height: 1.6;
}
.note p { margin: 0 0 4px; }
.note ul { margin: 0; padding-left: 20px; }
.req { color: var(--danger); font-weight: 700; }

fieldset.card { margin: 0 0 16px; min-width: 0; }
fieldset.card > legend {
  float: left; width: 100%; padding: 0; margin: 0 0 16px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px;
  font-size: 1.1rem; font-weight: 700;
}
fieldset.card > legend + * { clear: both; }
fieldset.card > legend small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.step {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 50%; background: var(--primary); color: var(--primary-ink); font-size: .9rem;
}
h3.sub { font-size: 1rem; margin: 4px 0 12px; }
h3.sub small { font-weight: 500; color: var(--muted); }

.hint { display: block; margin-top: 5px; font-size: .82rem; line-height: 1.5; color: var(--muted); }
.hint.block { margin: 0 0 16px; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
input:disabled { opacity: .5; }

.check { display: flex; gap: 10px; align-items: flex-start; margin: -4px 0 16px; cursor: pointer; }
.check input { width: 20px; height: 20px; padding: 0; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
.check > span { font-weight: 600; font-size: .92rem; }
.check .hint { font-weight: 400; margin-top: 2px; }

details.more-job { border-top: 1px dashed var(--border); padding-top: 12px; margin-top: 4px; }
details.more-job + details.more-job { margin-top: 12px; }
details.more-job > summary {
  cursor: pointer; font-weight: 600; color: var(--primary);
  padding: 8px 0 12px; list-style: none;
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px;
}
details.more-job > summary::before {
  content: "+"; display: inline-grid; place-items: center; flex: none;
  width: 24px; height: 24px; margin-right: 4px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; line-height: 1;
}
details.more-job[open] > summary::before { content: "−"; }
details.more-job > summary::-webkit-details-marker { display: none; }
details.more-job > summary .summary-hint {
  flex-basis: 100%; padding-left: 34px;
  font-size: .85rem; font-weight: 500; color: var(--primary);
}
details.more-job[open] > summary .summary-hint { display: none; }
details.more-job > summary small { font-weight: 500; color: var(--muted); }
details.more-job[open] > summary { color: var(--text); }

.photo-pick { display: flex; align-items: center; gap: 12px; }
.photo-pick input { flex: 1; min-width: 0; font-size: 14px; padding: 10px; }
#photo-preview {
  width: 72px; height: 96px; object-fit: cover; flex: none;
  border-radius: 8px; border: 1px solid var(--border);
}

.submit-bar { text-align: center; padding: 8px 0 24px; }
.submit-bar .btn { margin-bottom: 6px; }
.btn:disabled { opacity: .7; cursor: progress; }
.flash-error { background: var(--error-bg); color: var(--error-ink); }

/* ---------- Dashboard cards ---------- */
.applicant { display: flex; gap: 12px; align-items: center; }
.applicant-main { flex: 1; min-width: 0; }
.applicant .meta { margin: 2px 0 0; }
.avatar {
  width: 48px; height: 64px; flex: none; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border); background: var(--primary-soft);
}
.avatar-empty { display: grid; place-items: center; font-weight: 700; color: var(--primary); font-size: 1.2rem; }
.jobs { margin: 12px 0 8px; padding-left: 18px; font-size: .9rem; }
.jobs li { margin-bottom: 4px; }
.jobs .muted { margin: 0; font-size: .85rem; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 12px; font-size: .85rem; color: var(--muted); }
.facts b { color: var(--text); font-weight: 600; }
.actions { display: flex; align-items: center; gap: 16px; }
.btn.btn-sm {
  display: inline-flex; align-items: center; width: auto; min-height: 40px;
  padding: 8px 16px; font-size: .9rem; text-decoration: none;
}

/* ---------- Tablet and up ---------- */
@media (min-width: 640px) {
  main.wrap { padding-top: 32px; }
  .form-card { max-width: 640px; margin: 0 auto; padding: 28px; }
  .cv-form, .intro { max-width: 760px; margin-left: auto; margin-right: auto; }
  fieldset.card { padding: 24px 28px; }
  .form-card.narrow { max-width: 420px; }
  .row { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; align-items: start; }
  .submit-bar .btn { min-width: 260px; }
  .btn { width: auto; padding: 12px 28px; }
  .dash-head { flex-direction: row; align-items: center; justify-content: space-between; }
  .dash-tools .search { flex: 0 0 300px; }
}

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  .list { grid-template-columns: repeat(2, 1fr); }
}
