:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}

nav .brand {
  font-weight: 700;
  margin-right: 24px;
  color: var(--accent-dark);
  letter-spacing: -0.01em;
}

nav a {
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.15s, color 0.15s;
}

nav a:hover { background: var(--bg); color: var(--text); }
nav a.active { background: #eef2ff; color: var(--accent-dark); }

.lang-switch {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  flex: 0 0 auto;
}

.lang-switch .lang-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  box-shadow: none;
}

.lang-switch .lang-btn:hover { background: transparent; color: var(--text); }
.lang-switch .lang-btn.active { background: var(--panel); color: var(--accent-dark); box-shadow: var(--shadow-sm); }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

h1 { font-size: 23px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 28px 0 12px; }
.subtitle { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  transition: box-shadow 0.15s, transform 0.15s;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat .num { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat .label { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 500; }

.stat.stat-total { border-top-color: var(--accent); }
.stat.stat-total .num { color: var(--accent-dark); }
.stat.stat-Drafted { border-top-color: #64748b; }
.stat.stat-Applied { border-top-color: #2563eb; }
.stat.stat-Interview { border-top-color: #d97706; }
.stat.stat-Offer { border-top-color: #16a34a; }
.stat.stat-Rejected { border-top-color: #dc2626; }
.stat.stat-Withdrawn { border-top-color: #9ca3af; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; background: #fafbfd; }
thead tr { border-bottom: 1px solid var(--border); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable .sort-arrow { color: #c3c8d1; margin-left: 2px; }
th.sortable.active .sort-arrow { color: var(--accent); }
tbody tr { transition: background-color 0.1s; }
tbody tr:nth-child(even) { background: #fbfcfe; }
tbody tr:hover { background: #eef2ff; }
tr:last-child td { border-bottom: none; }
td.notes {
  color: var(--muted);
  max-width: 260px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: default;
}

.table-scroll { overflow-x: auto; }
td.nowrap { white-space: nowrap; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.pagination .page-size { display: flex; align-items: center; gap: 8px; }
.pagination .page-size select { width: auto; padding: 5px 8px; font-size: 13px; }
.pagination .page-nav { display: flex; align-items: center; gap: 8px; }
.pagination button.page-btn { padding: 6px 14px; font-size: 13px; border-radius: 999px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.Drafted { background: #f1f5f9; color: #475569; }
.badge.Applied { background: #dbeafe; color: #1d4ed8; }
.badge.Interview { background: #fef3c7; color: #b45309; }
.badge.Offer { background: #dcfce7; color: #15803d; }
.badge.Rejected { background: #fee2e2; color: #b91c1c; }
.badge.Withdrawn { background: #f3f4f6; color: #6b7280; }

select, input[type=text], input[type=url], input[type=date], textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

select:focus, input[type=text]:focus, input[type=url]:focus, input[type=date]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

select.status-select {
  width: auto;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}
select.status-select.Drafted { background: #f1f5f9; color: #475569; }
select.status-select.Applied { background: #dbeafe; color: #1d4ed8; }
select.status-select.Interview { background: #fef3c7; color: #b45309; }
select.status-select.Offer { background: #dcfce7; color: #15803d; }
select.status-select.Rejected { background: #fee2e2; color: #b91c1c; }
select.status-select.Withdrawn { background: #f3f4f6; color: #6b7280; }

select.fit-level-select {
  width: auto;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}
select.fit-level-select.A { background: #dcfce7; color: #15803d; }
select.fit-level-select.B { background: #dbeafe; color: #1d4ed8; }
select.fit-level-select.C { background: #fef3c7; color: #b45309; }
select.fit-level-select.D { background: #fee2e2; color: #b91c1c; }

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
}

label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--text); }
label:first-child { margin-top: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  color: white;
  transition: background-color 0.15s, box-shadow 0.15s;
}
button:hover { background: var(--accent-dark); }
button:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 2px; }
button.secondary { background: #eef0f3; color: var(--text); }
button.secondary:hover { background: #e2e5ea; }
button.danger { background: var(--red); }
button.danger:hover { background: #b91c1c; }
button:disabled { opacity: 0.55; cursor: default; }

.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 200px; }

.date-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 8px 6px 16px;
}
.date-filter .date-filter-icon { font-size: 14px; line-height: 1; }
.date-filter .date-filter-label { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.date-filter input[type=date] {
  width: auto;
  max-width: 150px;
  border: 1px solid transparent;
  background: var(--panel);
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 999px;
}
.date-filter input[type=date]:hover { border-color: var(--border); }
.date-filter .link-btn {
  margin-left: auto;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
}
.date-filter .link-btn:hover { background: #eef2ff; color: var(--accent-dark); }

@media (max-width: 640px) {
  .date-filter { border-radius: var(--radius); padding: 10px 12px; }
  .date-filter .link-btn { margin-left: 0; }
}

.msg { padding: 10px 14px; border-radius: 8px; font-size: 13.5px; margin: 12px 0; }
.msg.error { background: #fee2e2; color: #991b1b; }
.msg.success { background: #dcfce7; color: #166534; }
.msg.info { background: #eff6ff; color: #1e40af; }
.msg.warning { background: #fef3c7; color: #92400e; }

a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }

.empty { color: var(--muted); font-size: 14px; padding: 40px 0; text-align: center; }
.empty::before { content: "📭"; display: block; font-size: 26px; margin-bottom: 8px; }

.search-hit {
  border-top: 1px solid var(--border);
  padding: 12px 0;
}
.search-hit:first-child { border-top: none; padding-top: 4px; }
.search-hit ul { margin: 6px 0 0; padding-left: 18px; }
.search-hit li { margin: 3px 0; color: var(--muted); }

pre.log {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  font-size: 11.5px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
}

.markdown-body {
  font-size: 14px;
  line-height: 1.6;
  max-height: 480px;
  overflow: auto;
  padding: 2px 4px;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 16px 0 8px; }
.markdown-body h1:first-child, .markdown-body h2:first-child, .markdown-body h3:first-child { margin-top: 0; }
.markdown-body p { margin: 0 0 10px; }
.markdown-body ul { margin: 0 0 10px; padding-left: 20px; }
.markdown-body li { margin: 3px 0; }
.markdown-body a { color: var(--accent); }
.markdown-body.no-scroll { max-height: none; overflow: visible; }
textarea.no-scroll { height: auto; overflow: hidden; resize: none; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Dashboard: daily-applications trend chart ---------- */
.trend-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.range-switch { display: inline-flex; gap: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.range-switch .range-btn { border: none; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 4px 12px; border-radius: 999px; box-shadow: none; }
.range-switch .range-btn:hover { background: transparent; color: var(--text); }
.range-switch .range-btn.active { background: var(--panel); color: var(--accent-dark); box-shadow: var(--shadow-sm); }
.trend-chart { position: relative; }
.trend-tip { position: absolute; transform: translateX(-50%); pointer-events: none; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-md); padding: 6px 10px; font-size: 12.5px; white-space: nowrap; z-index: 2; }
.trend-tip-date { color: var(--muted); font-size: 11.5px; margin-bottom: 2px; }
.trend-tip-key { display: inline-block; width: 12px; height: 2px; background: var(--accent); vertical-align: middle; margin-right: 6px; }
.trend-table { margin-top: 10px; font-size: 13px; }
.trend-table summary { cursor: pointer; color: var(--muted); }
.trend-table table { margin-top: 8px; max-width: 320px; }
.trend-table > div { max-height: 240px; overflow: auto; }

/* signed-in user chip (session.js) */
nav .user-chip { margin-left: 12px; display: inline-flex; align-items: center; gap: 8px; color: var(--muted, #667); font-size: 13px; }

/* ---- AU additions: eligibility badge, follow-up chips, attention list, funnel ---- */
.elig { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.elig-green { background: #dcfce7; color: #166534; }
.elig-yellow { background: #fef9c3; color: #854d0e; }
.elig-red { background: #fee2e2; color: #991b1b; }
.elig-unknown { background: #eef0f3; color: #6b7280; }
.chip { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.chip-due { background: #fee2e2; color: #991b1b; }
.chip-stale { background: #fef3c7; color: #92400e; }
.chip-closing { background: #e0e7ff; color: #3730a3; }
.attention-list { list-style: none; margin: 0; padding: 0; }
.attention-list li { padding: 8px 0; border-bottom: 1px solid #eceef2; }
.attention-list li:last-child { border-bottom: none; }
.attention-list .chip { margin-left: 0; margin-right: 8px; }
.muted { color: var(--muted, #6b7280); }
.funnel-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.funnel-label { width: 84px; font-size: 13px; }
.funnel-bar { flex: 1; height: 14px; background: #eef0f3; border-radius: 7px; overflow: hidden; }
.funnel-bar > span { display: block; height: 100%; background: var(--accent, #4f46e5); border-radius: 7px; }
.funnel-num { width: 90px; font-size: 13px; font-variant-numeric: tabular-nums; }
.funnel-num small, .funnel-table small { color: var(--muted, #6b7280); }
.funnel-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-top: 16px; }
.funnel-table h3 { margin: 0 0 6px; font-size: 14px; }
.funnel-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.funnel-table th, .funnel-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid #eceef2; }

.row3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.row3 label { display: block; font-size: 12.5px; margin-bottom: 4px; color: var(--muted, #6b7280); }
.row3 input, .row3 select { width: 100%; box-sizing: border-box; }
.status-history { list-style: none; margin: 0; padding: 0; }
.status-history li { padding: 4px 0; }

.bookmarklet-btn { display: inline-block; padding: 8px 16px; border-radius: 999px; background: var(--accent, #4f46e5); color: #fff !important; font-weight: 600; text-decoration: none; cursor: grab; }

.snip-block { margin: 12px 0; }
.snip-block .copy-btn { padding: 2px 10px; font-size: 12px; margin-left: 6px; }
