/* Job Tracker — refined editorial dashboard
   Warm paper palette · Fraunces display serif · IBM Plex Sans/Mono */
@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap");

:root {
  --paper: #f4f1e8;
  --surface: #fffdf8;
  --surface-2: #faf7ef;
  --ink: #1c1a16;
  --muted: #6f6a5f;
  --faint: #9b958859;
  --line: #e3ddcf;
  --line-strong: #d3ccba;
  --accent: #1f6f5c;
  --accent-ink: #14483c;
  --accent-soft: #e2efe9;
  --danger: #b23b2b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(28, 26, 22, .04), 0 8px 24px -12px rgba(28, 26, 22, .18);
  --shadow-sm: 0 1px 2px rgba(28, 26, 22, .05);
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(1200px 500px at 80% -10%, #ffffff66, transparent 70%),
    radial-gradient(900px 400px at -10% 0%, var(--accent-soft) 0%, transparent 60%);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px clamp(18px, 5vw, 56px);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.brand h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -.01em;
  margin: 0;
}
.brand .dot { color: var(--accent); }

/* ---------- Layout ---------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(18px, 5vw, 56px) 80px;
}

.tabs { display: flex; gap: 4px; margin: 0 0 26px; border-bottom: 1px solid var(--line); }
.tab-btn {
  appearance: none;
  border: 0;
  background: none;
  font: 500 14px/1 var(--sans);
  color: var(--muted);
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.is-active { color: var(--accent-ink); border-bottom-color: var(--accent); }

.tab-content { display: none; animation: rise .4s ease both; }
.tab-content.active { display: block; }

/* ---------- Stat cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-card .label {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.stat-card .value {
  font-family: var(--mono);
  font-size: 30px; font-weight: 500; letter-spacing: -.02em;
  margin-top: 6px;
}
.stat-card .value.accent { color: var(--accent); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar .grow { flex: 1 1 220px; }
.checkbox-wrap { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.checkbox-wrap input { width: auto; cursor: pointer; }
.pagination .btn-page { min-width: 34px; text-align: center; font-size: 13px; padding: 7px 10px; }
.pagination .btn-page.is-current { background: var(--accent); color: #fff; border-color: var(--accent); }

input, select, textarea {
  font: 400 14px/1.4 var(--sans);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 78px; font-family: var(--sans); }
::placeholder { color: #a8a294; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  font: 500 13.5px/1 var(--sans);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .08s, background .15s, border-color .15s, color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary, .btn-info { background: var(--accent); color: #fff; }
.btn-primary:hover, .btn-info:hover { background: var(--accent-ink); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { background: none; color: var(--danger); border-color: transparent; padding: 6px 10px; }
.btn-danger:hover { background: #f6e3df; }
.btn-link { background: none; border: 0; color: var(--accent-ink); padding: 6px 10px; cursor: pointer; font: 500 13px var(--sans); }
.btn-link:hover { text-decoration: underline; }

/* ---------- Card / form ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 24px;
}
.panel h2 {
  font-family: var(--serif); font-weight: 500; font-size: 18px;
  margin: 0 0 16px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field.col-span { grid-column: 1 / -1; }
.field label {
  font-size: 12px; font-weight: 600; letter-spacing: .03em; color: var(--muted);
}
.form-actions { grid-column: 1 / -1; display: flex; gap: 10px; margin-top: 4px; }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted);
  padding: 13px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
tbody td { padding: 14px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
.cell-company { font-weight: 600; }
.cell-company a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--faint); }
.cell-company a:hover { border-bottom-color: var(--accent); }
.cell-role { color: var(--muted); font-size: 13.5px; }
.cell-date { font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions .btn { padding: 6px 10px; }
.job-link { color: var(--accent-ink); text-decoration: none; font-weight: 500; white-space: nowrap; }
.job-link:hover { text-decoration: underline; }

/* ---------- Status badges ---------- */
.badge {
  display: inline-block;
  font-size: 12px; font-weight: 600; letter-spacing: .01em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.s-neutral  { background: #efece2; color: #5f5a4e; border-color: #e2ddcf; }
.s-progress { background: #fbf0d8; color: #8a5a12; border-color: #f1e0bd; }
.s-applied  { background: #e2eef7; color: #1f5e86; border-color: #cfe2ef; }
.s-interview{ background: #eae7fb; color: #4b3aa6; border-color: #ddd6f6; }
.s-offer    { background: #dcf0e2; color: #1f7a44; border-color: #c7e7d1; }
.s-rejected { background: #f7e1dc; color: #a23522; border-color: #efcfc6; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center; color: var(--muted);
  padding: 56px 20px; font-size: 15px;
}
.empty-state .em { font-family: var(--serif); font-size: 19px; color: var(--ink); display: block; margin-bottom: 6px; }

/* ---------- Charts ---------- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  margin-top: 8px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.chart-card h3 {
  font-family: var(--serif); font-weight: 500; font-size: 15px; margin: 0 0 14px;
}
.chart-box { position: relative; height: 280px; }

/* ---------- Modal / detail ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: start center;
  padding: clamp(16px, 6vh, 64px) 16px;
  background: rgba(28, 26, 22, .42);
  backdrop-filter: blur(3px);
  overflow-y: auto;
  animation: fade .18s ease both;
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative;
  width: 100%; max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 70px -24px rgba(28, 26, 22, .5);
  padding: 30px clamp(22px, 4vw, 36px) 34px;
  animation: rise .22s ease both;
}
.modal-close {
  position: absolute; top: 14px; right: 16px;
  border: 0; background: none; cursor: pointer;
  font-size: 26px; line-height: 1; color: var(--muted);
}
.modal-close:hover { color: var(--ink); }

.detail-head { display: flex; align-items: flex-start; gap: 12px; margin: 0 28px 4px 0; }
.detail-head h2 { font-family: var(--serif); font-weight: 500; font-size: 24px; margin: 0; }
.detail-role { color: var(--muted); margin: 2px 0 18px; }
.detail-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 18px;
  padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.detail-grid .k { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.detail-grid .v { font-size: 14px; margin-top: 2px; word-break: break-word; }
.detail-grid .v a { color: var(--accent-ink); }
.detail-section { margin-top: 20px; }
.detail-section h4 { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.detail-section summary {
  cursor: pointer; list-style: none;
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent-ink);
}
.detail-section summary::-webkit-details-marker { display: none; }
.detail-section summary::before { content: "▸ "; }
.detail-section details[open] summary::before { content: "▾ "; }
.detail-notes {
  white-space: pre-wrap; font-size: 13.5px; line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px; max-height: 320px; overflow-y: auto;
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.cell-open { cursor: pointer; }
.cell-open .cell-company { color: var(--accent-ink); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.analytics-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }

/* ---------- Login ---------- */
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 44px 40px;
  text-align: center;
  max-width: 380px;
}
.login-card .mark { width: 52px; height: 52px; border-radius: 12px; margin-bottom: 18px; }
.login-card h1 { font-family: var(--serif); font-weight: 500; font-size: 28px; margin: 0 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.login-card .btn { width: 100%; padding: 12px; font-size: 15px; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* ---------- Responsive ---------- */
/* Phones and small tablets: single compact layout. */
@media (max-width: 768px) {
  /* Tab bar scrolls horizontally instead of wrapping. */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { flex: 0 0 auto; white-space: nowrap; }
  /* Safety net: any table still too wide scrolls rather than clipping. */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .app-header { padding: 12px clamp(14px, 5vw, 20px); gap: 12px; }
  .brand h1 { font-size: 19px; }

  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }

  /* Keep the whole toolbar usable: full-width search, controls wrap below. */
  .toolbar .grow { flex: 1 1 100%; }
  #statusFilter { flex: 1 1 auto; }
  #toggleForm { flex: 1 1 100%; }

  /* Table: keep Company/Role + Status + Actions; hide the rest. Stack the two
     row actions vertically so both stay visible in a narrow column (no clip). */
  thead th.hide-sm, tbody td.hide-sm { display: none; }
  thead th, tbody td { padding: 12px 10px; }
  .cell-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
  .cell-actions .btn { padding: 7px 8px; text-align: center; }
}
