/* JobMatch design system
   One palette, defined light-first on :root and re-stated for dark. Nothing
   gets its only definition inside a media query. */

:root {
  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #f0f2f5;
  --line:      #e2e5ea;
  --line-soft: #eef0f4;
  --text:      #14171c;
  --text-dim:  #616a76;
  --text-mute: #8b95a3;
  --accent:    #2f5cff;
  --accent-dim:#e8edff;
  --accent-tx: #ffffff;
  --good:      #0f8a52;
  --good-bg:   #e3f5eb;
  --mid:       #9a6a00;
  --mid-bg:    #fdf1d8;
  --low:       #6b7280;
  --low-bg:    #eceef1;
  --danger:    #b8203a;
  --danger-bg: #fdeaee;
  --warn-bg:   #fff8e6;
  --warn-line: #f0dca8;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(16,20,28,.06), 0 4px 16px rgba(16,20,28,.05);
  --shadow-lg: 0 2px 6px rgba(16,20,28,.08), 0 18px 44px rgba(16,20,28,.10);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0e1116;
    --surface:   #161a21;
    --surface-2: #1c2129;
    --line:      #272d37;
    --line-soft: #1f242c;
    --text:      #e8ecf2;
    --text-dim:  #a2acba;
    --text-mute: #7a8593;
    --accent:    #6c8cff;
    --accent-dim:#1c2542;
    --accent-tx: #0e1116;
    --good:      #4ade80;
    --good-bg:   #12301f;
    --mid:       #fbbf24;
    --mid-bg:    #33270a;
    --low:       #9aa4b2;
    --low-bg:    #232830;
    --danger:    #fb7185;
    --danger-bg: #341219;
    --warn-bg:   #2a2308;
    --warn-line: #4d4114;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.5), 0 18px 44px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2); padding: 1px 5px; border-radius: 5px;
}

/* --- layout --------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650;
         color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); font-size: 15px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  padding: 6px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 14px; font-weight: 500;
}
.topbar nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar nav a.on { background: var(--accent-dim); color: var(--accent); }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { font-size: 14px; color: var(--text-dim); }

.wrap { max-width: 940px; margin: 0 auto; padding: 32px 24px 72px; }
.narrow { max-width: 420px; margin: 0 auto; padding: 68px 24px; }

.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--text-dim); }
h2 { font-size: 15px; letter-spacing: -.01em; margin: 32px 0 12px; }

/* --- cards ---------------------------------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.stack > * + * { margin-top: 12px; }

/* --- forms ---------------------------------------------------------- */

label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%; padding: 9px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: 14px;
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}
.field + .field { margin-top: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-tx);
  border: 1px solid transparent; font: inherit; font-size: 14px; font-weight: 550;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-ghost { background: var(--surface); color: var(--text-dim); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); filter: none; }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: var(--danger-bg); filter: none; }
.btn-block { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --- flashes -------------------------------------------------------- */

.flash {
  background: var(--accent-dim); color: var(--text);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 11px 14px; margin-bottom: 20px; font-size: 14px;
}
.flash-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* --- upload dropzone ------------------------------------------------ */

.drop {
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 28px; text-align: center;
}
.drop:hover { border-color: var(--accent); }
.drop h3 { margin: 0 0 4px; font-size: 15px; }
.drop p { margin: 0 0 16px; color: var(--text-dim); font-size: 13.5px; }
.file-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
input[type=file] {
  font: inherit; font-size: 13.5px; color: var(--text-dim); max-width: 100%;
}
input[type=file]::file-selector-button {
  font: inherit; font-size: 13.5px; margin-right: 10px; padding: 7px 12px; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}

/* --- lists ---------------------------------------------------------- */

.row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.row + .row { margin-top: 8px; }
.row-main { min-width: 0; flex: 1; }
.row-title { font-weight: 550; letter-spacing: -.01em;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.row-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.empty {
  text-align: center; padding: 40px 20px; color: var(--text-mute);
  border: 1px dashed var(--line); border-radius: var(--radius); font-size: 14px;
}

/* --- chips / badges ------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12.5px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--line-soft);
}
.chip-accent { background: var(--accent-dim); color: var(--accent); border-color: transparent; }

.badge {
  font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--low-bg); color: var(--low);
}
.badge-run  { background: var(--accent-dim); color: var(--accent); }
.badge-done { background: var(--good-bg); color: var(--good); }
.badge-err  { background: var(--danger-bg); color: var(--danger); }

/* --- profile facts -------------------------------------------------- */

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px;
         background: var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.fact { background: var(--surface); padding: 14px 16px; }
.fact dt { font-size: 12px; color: var(--text-mute); text-transform: uppercase;
           letter-spacing: .05em; margin-bottom: 3px; }
.fact dd { margin: 0; font-size: 14.5px; font-weight: 550; }

/* --- results -------------------------------------------------------- */

.match { display: flex; gap: 16px; align-items: flex-start;
         padding: 18px; background: var(--surface);
         border: 1px solid var(--line); border-radius: var(--radius); }
.match + .match { margin-top: 10px; }
.match:hover { box-shadow: var(--shadow-lg); }

.score {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 680; font-size: 17px;
  background: var(--low-bg); color: var(--low);
}
.score-hi  { background: var(--good-bg); color: var(--good); }
.match-body { min-width: 0; flex: 1; }
.match-title { font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; }
.match-meta { font-size: 13px; color: var(--text-dim); margin-top: 2px;
              display: flex; flex-wrap: wrap; gap: 4px 10px; }
.match-reason { font-size: 14px; color: var(--text-dim); margin-top: 9px; }
.match-apply { margin-top: 11px; }

/* --- progress ------------------------------------------------------- */

.progress { display: flex; align-items: center; gap: 13px;
            padding: 22px; background: var(--surface);
            border: 1px solid var(--line); border-radius: var(--radius); }
.spinner {
  flex: none; width: 19px; height: 19px; border-radius: 50%;
  border: 2.5px solid var(--accent-dim); border-top-color: var(--accent);
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.progress-text { font-size: 14px; }
.progress-sub { font-size: 13px; color: var(--text-mute); margin-top: 2px; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-request.hide-on-load { display: none; }

/* --- auth ----------------------------------------------------------- */

.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo .brand-mark { font-size: 26px; }
.auth-logo h1 { font-size: 20px; margin: 8px 0 4px; letter-spacing: -.02em; }
.auth-logo p { margin: 0; color: var(--text-dim); font-size: 14px; }
.auth-alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--text-dim); }

/* --- admin ---------------------------------------------------------- */

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.inline-form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.cred { display: grid; gap: 8px; }
.cred > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cred span { font-size: 12px; color: var(--text-mute); text-transform: uppercase;
             letter-spacing: .05em; min-width: 86px; }
.cred code { font-size: 13.5px; padding: 4px 9px; user-select: all; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
     color: var(--text-mute); padding: 0 12px 8px; font-weight: 600; }
td { padding: 12px; border-top: 1px solid var(--line-soft); }
.table-wrap { overflow-x: auto; background: var(--surface);
              border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 6px 6px; }

@media (max-width: 620px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .who { display: none; }
  .wrap { padding: 22px 14px 60px; }
  .match { gap: 12px; padding: 15px; }
  .row { flex-wrap: wrap; }
}
