/* Job Tracker — one stylesheet. Breakpoints: phone <768px, tablet 768–1024px, desktop >=1025px. */

:root,
[data-theme=dark] {
  --page: #1e1d30;
  --panel: #2a2940;
  --input: #37354a;
  --accent: #4a5fa0;
  --text: #e6e6ef;
  --on-accent: #0f1020;
  --muted: #a3a2b8;
  --border: #44425c;
  --btn: #7a8fd0;         /* button fill: 5.98:1 with #0f1020 (--accent alone is 3.08:1) */
  --tab-active: #9fb0ea;  /* 8.85:1 with #0f1020; brighter than inactive tabs */
  --chip: #6a7fc0;        /* secondary buttons / inactive tabs: 4.85:1 with #0f1020 */
  --link: #a9b8f0;
  --danger: #e58a8a;      /* button fill: 7.47:1 with #0f1020 */
  --error-fg: #ffa3ab;    /* error text on panel: 7.44:1 */
  --error-bg: #5a2330;
  --error-text: #ffd9de;
  --ok-bg: #22483a;
  --ok-text: #c8f0dc;
  --selected: #8fa3e0;
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  --badge-text: #1b1b2a;
  color-scheme: dark;
}

[data-theme=light] {
  --page: #f4f4f8;
  --panel: #ffffff;
  --input: #ececf3;
  --accent: #8fa3e0;
  --text: #1b1b2a;
  --on-accent: #0f1020;
  --muted: #5d5c72;
  --border: #d6d6e2;
  --btn: #8fa3e0;         /* 7.61:1 with #0f1020 */
  --tab-active: #8fa3e0;
  --chip: #d3daf3;        /* 13.5:1 with #0f1020 */
  --link: #3a4f96;
  --danger: #ef9a9a;
  --error-fg: #a32a3a;    /* error text on white: 7.12:1 */
  --error-bg: #fde3e6;
  --error-text: #7a1626;
  --ok-bg: #dcf3e6;
  --ok-text: #14513a;
  --selected: #4a5fa0;
  --shadow: 0 2px 10px rgba(30, 30, 60, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
a { color: var(--link); }
code { background: var(--input); padding: .1rem .35rem; border-radius: 4px; }
.muted, .hint { color: var(--muted); font-size: .9rem; }

main { padding: 0 1.25rem 2rem; }

/* ---------- Controls ---------- */
input, select, textarea, button { font: inherit; }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=search], input[type=datetime-local], select, textarea {
  width: 100%;
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .7rem;
  font-size: 16px;             /* >=16px: no iOS zoom on focus */
  min-height: 40px;
}
textarea { resize: vertical; min-height: 6rem; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--selected);
  outline-offset: 1px;
}
input[type=color] {
  width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--input); cursor: pointer;
}

/* Every button carries dark text on a coloured background — never white text. */
.btn, .tab, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 0; border-radius: 999px; cursor: pointer; text-decoration: none;
  background: var(--btn); color: var(--on-accent); font-weight: 600;
}
.btn { padding: .5rem 1rem; min-height: 38px; }
.btn.secondary { background: var(--chip); }
.btn.danger, .icon-btn.danger { background: var(--danger); color: var(--on-accent); }
.btn[aria-pressed=true] { box-shadow: 0 0 0 3px var(--selected); }
.btn:hover, .icon-btn:hover, .tab:hover { filter: brightness(1.08); }
.icon-btn { width: 42px; height: 42px; padding: 0; flex: none; }
.icon-btn.small { width: 38px; height: 38px; }
.icon-btn svg, .back-btn svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.link-btn {
  background: none; border: 0; padding: 0 .2rem; cursor: pointer;
  color: var(--link); text-decoration: underline; font-size: inherit;
}
.inline-form { display: inline; margin: 0; }
.guide-link { display: inline-flex; align-items: center; color: var(--link); text-decoration: underline; padding: 0 .2rem; }

/* ---------- Header ---------- */
.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: .8rem 1.25rem .4rem;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.35rem;
}
.topbar-icons { display: flex; justify-content: flex-end; gap: .5rem; }
.subbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 0 1.25rem .8rem; gap: 1rem;
}
.user-line { color: var(--muted); font-size: .85rem; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.user-name { color: var(--text); }
.today-inline { display: none; }
.today-card {
  background: var(--panel); border-radius: 12px; box-shadow: var(--shadow);
  padding: .5rem 1.1rem; text-align: center; min-width: 130px; line-height: 1.25;
}
.today-card:empty { display: none; }
.today-card .t-label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.today-card .t-date { font-weight: 700; font-size: 1.05rem; }
.today-card .t-day { color: var(--muted); font-size: .85rem; }

/* ---------- Flash, banner, panels ---------- */
.flash, .error, .notice, .banner {
  border-radius: 10px; padding: .65rem .9rem; margin: 0 0 1rem;
}
.flash.error, .error, .banner { background: var(--error-bg); color: var(--error-text); }
.flash.ok, .flash.message, .notice { background: var(--ok-bg); color: var(--ok-text); }
.banner { font-weight: 600; }
.panel {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}
.page-narrow { max-width: 1100px; margin: 0 auto; }
.empty, .empty-state { color: var(--muted); text-align: center; padding: 2rem 1rem; }

.stack-form { display: grid; gap: .8rem; max-width: 420px; }
.stack-form label, .field { display: grid; gap: .3rem; font-size: .9rem; color: var(--muted); }
.stack-form .btn { justify-self: start; }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--text); }
label.check input { width: 20px; height: 20px; }

/* ---------- Auth pages ---------- */
.auth-card {
  max-width: 420px; margin: 3rem auto; background: var(--panel); border-radius: 16px;
  box-shadow: var(--shadow); padding: 1.6rem;
}
.auth-card .stack-form { max-width: none; }

/* ---------- Main layout ---------- */
.layout {
  display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1.25rem;
  align-items: start;
}
.sidebar {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow);
  padding: .9rem; position: sticky; top: .75rem;
  max-height: calc(100vh - 1.5rem); display: flex; flex-direction: column;
}
.sidebar-tools { display: grid; gap: .5rem; margin-bottom: .75rem; }
.app-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: grid; gap: .5rem; }
.app-card a {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .7rem .8rem; border-radius: 10px; background: var(--input);
  border: 2px solid transparent; color: var(--text); text-decoration: none; min-height: 56px;
}
.app-card a:hover { border-color: var(--border); }
.app-card.selected a { border-color: var(--selected); }
.card-text { display: grid; min-width: 0; }
.card-company { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  flex: none; background: #8a8a99; color: var(--badge-text); font-weight: 700;
  font-size: .78rem; padding: .25rem .65rem; border-radius: 999px; white-space: nowrap;
  max-width: 45%; overflow: hidden; text-overflow: ellipsis;
}

.pane {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow);
  padding: 1.1rem 1.4rem; min-width: 0;
}
.pane-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.back-btn {
  display: none; width: 44px; height: 44px; border: 0; border-radius: 999px;
  background: var(--chip); color: var(--on-accent); cursor: pointer;
  align-items: center; justify-content: center;
}
.tabs { display: inline-flex; background: var(--input); border-radius: 999px; padding: 4px; gap: 4px; }
.tab { padding: .45rem 1.2rem; min-height: 36px; background: var(--chip); }
.tab.active { background: var(--tab-active); box-shadow: 0 0 0 2px var(--accent) inset; }

.tab-panel { display: grid; gap: .9rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.field-label { font-size: .9rem; color: var(--muted); }
.with-icon { display: flex; gap: .5rem; align-items: center; }

.upload-slot .slot-body { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-height: 40px; }
.file-link {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600;
}
.slot-error { margin: 0; color: var(--error-fg); font-size: .88rem; }

.pane-footer {
  display: flex; align-items: center; gap: 1rem; margin-top: .4rem;
  padding-top: .8rem; border-top: 1px solid var(--border);
}
.last-edit { margin-left: auto; color: var(--muted); font-size: .85rem; }
.save-indicator {
  color: var(--ok-text); background: var(--ok-bg); border-radius: 999px;
  padding: .15rem .7rem; font-size: .82rem; font-weight: 600;
  opacity: 0; transition: opacity .4s ease;
}
.save-indicator.show { opacity: 1; transition: none; }

/* Interviews */
#add-interview { justify-self: start; }
.iv-head, .iv-summary {
  display: grid; grid-template-columns: 1fr 1.2fr 1.4fr 1.4fr; gap: .75rem;
  padding: .55rem .8rem; align-items: center;
}
.iv-head { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.iv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.iv-item { background: var(--input); border-radius: 10px; border: 2px solid transparent; }
.iv-item.open { border-color: var(--selected); }
.iv-summary {
  width: 100%; border: 0; background: none; color: var(--text); text-align: left;
  cursor: pointer; min-height: 48px; font: inherit;
}
.iv-summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iv-summary .iv-lbl { display: none; }
.iv-form { display: grid; gap: .8rem; padding: .3rem .8rem .9rem; }
.iv-form .row3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; }
.iv-form input, .iv-form select, .iv-form textarea { background: var(--panel); }
.iv-form-foot { display: flex; align-items: center; gap: 1rem; }
.iv-table:has(.iv-list:empty) .iv-head { display: none; }

/* ---------- Settings ---------- */
.option-list { margin-bottom: 1.4rem; }
.option-list ul { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; gap: .4rem; }
.option-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  background: var(--input); border-radius: 10px; padding: .45rem .6rem;
}
.option-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0; }
.option-item > .option-row:first-child { flex: 1 1 320px; }
.option-row input[type=text] { width: auto; flex: 1 1 160px; background: var(--panel); }
.option-add input[type=text] { max-width: 320px; }
.option-row .btn { padding: .4rem .85rem; min-height: 36px; }

/* ---------- Admin ---------- */
.table-wrap { overflow-x: auto; max-width: 100%; }
.panel { min-width: 0; }
table.users { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.users th, table.users td {
  text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top;
}
table.users th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; }
td.actions form { display: inline-block; margin: 0 .3rem .3rem 0; }
td.actions .btn { padding: .35rem .75rem; min-height: 34px; font-size: .85rem; }
.temp-password { font-size: 1.1rem; user-select: all; }

/* ---------- Stats ---------- */
.stats-page { max-width: 1100px; margin: 0 auto; }
.stat-lines { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin-bottom: 1rem; }
.stat-line { margin: 0; font-size: 1.05rem; font-weight: 600; }
.status-grid { display: grid; grid-template-columns: 260px 1fr; gap: 1.5rem; align-items: center; }
.donut-wrap { display: flex; justify-content: center; color: var(--text); }
.donut-wrap svg { width: 100%; max-width: 240px; height: auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.tile {
  position: relative; overflow: hidden; border-radius: 12px; min-height: 92px;
  padding: .7rem .85rem; display: grid; align-content: start; gap: .1rem;
  color: #1b1b2a;
}
.tile-bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.tile::after {
  content: ""; position: absolute; right: 6px; bottom: 4px; width: 54px; height: 54px;
  background: url("briefcase.svg") no-repeat center / contain; opacity: .25; z-index: 1;
  pointer-events: none;
}
.tile-name, .tile-count, .tile-percent { position: relative; z-index: 2; color: #1b1b2a; }
.tile-name { font-weight: 700; font-size: .9rem; }
.tile-count { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.tile-percent { font-size: .85rem; font-weight: 600; }
.bars-wrap { overflow-x: auto; color: var(--text); }
.bars-wrap svg { display: block; max-width: none; height: auto; }

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 280px minmax(0, 1fr); gap: 1rem; }
  .status-grid { grid-template-columns: 220px 1fr; }
  .pane { padding: 1rem; }
  /* Tablet admin: keep the table at its natural width and scroll it inside the panel. */
  table.users { width: max-content; min-width: 100%; }
  table.users td.actions { white-space: nowrap; }
}

/* ---------- Phone ---------- */
@media (max-width: 767px) {
  main { padding: 0 .75rem 1.5rem; }
  .topbar { grid-template-columns: auto 1fr; padding: .6rem .75rem .3rem; }
  .topbar-side { display: none; }
  .brand { font-size: 1.15rem; }
  .brand img { width: 28px; height: 28px; }
  .topbar-icons { gap: .35rem; }
  .icon-btn { width: 44px; height: 44px; }
  .subbar { padding: 0 .75rem .6rem; }
  .today-card { display: none; }
  .today-inline { display: inline; }
  .today-inline::before { content: "· "; }

  .btn, .tab, .link-btn, .guide-link, .option-row .btn, td.actions .btn { min-height: 44px; }
  input[type=text], input[type=email], input[type=password], input[type=url],
  input[type=search], input[type=datetime-local], select { min-height: 44px; }

  .layout { grid-template-columns: 1fr; }
  .layout .pane { display: none; }
  .layout.show-detail .pane { display: block; }
  .layout.show-detail .sidebar { display: none; }
  .sidebar { position: static; max-height: none; }
  .back-btn { display: inline-flex; }
  .pane { padding: .9rem; }
  .row, .iv-form .row3 { grid-template-columns: 1fr; }
  .pane-footer { flex-wrap: wrap; }

  .iv-head { display: none; }
  .iv-summary { grid-template-columns: 1fr 1fr; row-gap: .35rem; padding: .7rem .8rem; }
  .iv-summary .iv-cell { display: grid; }
  .iv-summary .iv-lbl { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; }

  .status-grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }

  table.users, table.users tbody, table.users tr, table.users td { display: block; }
  table.users { width: auto; min-width: 0; }
  table.users td.actions { white-space: normal; }
  table.users thead { display: none; }
  table.users tr {
    background: var(--input); border-radius: 12px; padding: .5rem .75rem; margin-bottom: .75rem;
  }
  table.users td { border: 0; padding: .3rem 0; display: grid; grid-template-columns: 110px 1fr; gap: .5rem; }
  table.users td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; }
  table.users td.actions { display: flex; flex-wrap: wrap; }
  table.users td.actions::before { width: 100%; }
}
