/* ==========================================================================
   Jobbie — design system
   Neutral slate surfaces, one blue accent, restrained borders/shadows.
   ========================================================================== */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #fafbfc;
  --surface-muted: #f2f4f7;
  --ink: #101828;
  --ink-soft: #344054;
  --muted: #667085;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --accent-line: #c7d7fe;

  --green: #067647;
  --green-soft: #ecfdf3;
  --green-line: #abefc6;
  --amber: #b54708;
  --amber-soft: #fffaeb;
  --amber-line: #fedf89;
  --red: #b42318;
  --red-soft: #fef3f2;
  --red-line: #fecdca;
  --purple: #5925dc;
  --purple-soft: #f4f3ff;

  --radius-card: 12px;
  --radius-control: 8px;
  --radius-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.14);
  --ease: 180ms cubic-bezier(0.2, 0.8, 0.2, 1);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
}

*,
*::before,
*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
::selection { background: #dbe8ff; color: var(--ink); }
:focus-visible { outline: none; }

/* ==========================================================================
   App shell / top navigation
   ========================================================================== */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.sidebar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 60px;
  padding: 10px var(--space-6);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 0 auto; }
.logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand h1 { font-size: 15px; line-height: 1.2; font-weight: 650; letter-spacing: -0.02em; }
.brand p { margin-top: 2px; color: var(--muted); font-size: 11px; }
.side-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.side-nav::-webkit-scrollbar { display: none; }
.side-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.side-item svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.side-item:hover { background: var(--surface-muted); color: var(--ink); text-decoration: none; }
.side-item.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.side-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  padding-left: var(--space-3);
  border-left: 1px solid var(--line);
  flex: 0 0 auto;
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.side-user-info { min-width: 0; max-width: 140px; }
.side-user-info b {
  display: block;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-user-info small {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-area { flex: 1; min-width: 0; width: 100%; }
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-8) 0;
}
.topbar h1 {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.topbar p { margin-top: 5px; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: var(--space-2); align-items: center; }
.main-area main,
main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--space-5) var(--space-8) var(--space-8);
}
.page { display: grid; gap: var(--space-5); }
.page[hidden] { display: none !important; }

/* ==========================================================================
   Typography helpers
   ========================================================================== */

.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { color: var(--muted); font-size: 11.5px; }
.eyebrow,
.bento-eyebrow {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.file-name {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

/* ==========================================================================
   Buttons / forms
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-control);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: none;
  transition: background var(--ease), border-color var(--ease), color var(--ease), opacity var(--ease), transform var(--ease);
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; text-decoration: none; }
.btn:focus-visible { box-shadow: var(--ring); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink-soft); }
.btn.ghost:hover { background: var(--surface-muted); border-color: var(--line-strong); color: var(--ink); }
.btn.danger { background: var(--surface); border-color: var(--red-line); color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red-line); color: var(--red); }
.btn.small { min-height: 30px; padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn.is-loading { pointer-events: none; opacity: 0.8; }
.btn.is-loading::after {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  margin-left: 6px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.link {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-size: 12px;
  font-weight: 600;
}
.link:hover { text-decoration: underline; }

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
textarea { min-height: 76px; resize: vertical; }
input::placeholder,
textarea::placeholder { color: #98a2b3; }
input:hover,
select:hover,
textarea:hover { border-color: #b8c0cc; }
input:focus,
select:focus,
textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 12px; white-space: nowrap; }
.check input { width: 15px; height: 15px; min-height: 0; accent-color: var(--accent); }
.stack { display: grid; gap: var(--space-3); }
.stack label { display: grid; gap: 5px; color: var(--muted); font-size: 11.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); }
.form-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 11.5px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.row { display: flex; align-items: center; gap: var(--space-2); }
.row input { flex: 1; }

/* ==========================================================================
   Cards / surfaces
   ========================================================================== */

.panel,
.bento-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.panel-head h2 { font-size: 16px; line-height: 1.3; font-weight: 650; letter-spacing: -0.01em; }
.panel-head h3,
.bento-card h3,
.bento-card-head h3 {
  font-size: 13px;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.panel-head > .head-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.head-actions .btn { white-space: nowrap; }
.bento-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--space-4); }
.bento-page > .bento-card { height: 100%; min-height: 220px; display: flex; flex-direction: column; }
.bento-page > .bento-card > .panel-head { flex: 0 0 auto; }
.bento-page > .eq-3 { grid-column: span 3; }
.bento-page > .eq-4 { grid-column: span 4; }
.bento-page > .eq-6 { grid-column: span 6; }
.bento-page > .eq-12 { grid-column: span 12; }
.bento-page > .bento-card.user-stat { min-height: 160px; }
.bento-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-3); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

/* Dashboard stats */
.stats.page-stats,
.bento-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-3);
  background: transparent;
  border: 0;
  padding: 0;
  box-shadow: none;
}
.bento-stats .stat,
.page-stats .stat {
  min-width: 0;
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-xs);
}
.stat b { display: block; font-size: 24px; line-height: 1.1; font-weight: 650; letter-spacing: -0.02em; }
.stat span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Generic card grid (candidate cards) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-3); margin-top: var(--space-3); }
.card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: none;
  transition: border-color var(--ease), background var(--ease);
}
.card:hover { border-color: #c7d0dd; background: #fcfcfd; }
.card.selected { border-color: var(--accent); background: var(--accent-soft); }
.card-top { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.card-title { flex: 1; min-width: 0; }
.card h3 { font-size: 14px; line-height: 1.35; font-weight: 650; letter-spacing: -0.01em; }
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); min-width: 0; }
.card-foot .score { flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-foot .btn { flex: 0 0 auto; }
.cv-select { display: flex; align-items: flex-start; padding-top: 1px; }
.cv-select input { width: 15px; height: 15px; min-height: 0; accent-color: var(--accent); cursor: pointer; }
.contact { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 12px; }
.badges { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: var(--surface-muted); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.4;
}
.empty {
  padding: 40px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-card);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}
.load-more { text-align: center; margin-top: var(--space-4); }

/* ==========================================================================
   Dashboard
   ========================================================================== */

.recent-list { display: grid; gap: 6px; min-width: 0; max-height: 180px; overflow-y: auto; padding-right: 2px; }
.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}
.recent-item:hover { border-color: #c7d0dd; background: var(--surface-soft); }
.recent-item > div { flex: 1; min-width: 0; overflow: hidden; }
.recent-item b { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item .meta { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-actions { display: grid; grid-template-columns: 1fr; gap: var(--space-2); }
.quick-actions .btn { width: 100%; }
.usage-bar { height: 6px; background: var(--surface-muted); border-radius: var(--radius-pill); overflow: hidden; margin: 10px 0 5px; }
.usage-bar > div { height: 100%; background: var(--accent); border-radius: var(--radius-pill); }
.billing-plan-name, .settings-plan-name { margin-top: 6px; color: var(--ink); font-size: 26px; line-height: 1.1; font-weight: 650; letter-spacing: -0.03em; }
.user-stat { justify-content: center; gap: 4px; }
.user-stat b { color: var(--ink); font-size: 32px; line-height: 1; font-weight: 650; letter-spacing: -0.03em; }
.user-stat > span:last-child { color: var(--muted); font-size: 12px; }
.tips-list { display: grid; gap: 8px; margin: 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.tips-list code { padding: 1px 4px; border-radius: 4px; background: var(--surface-muted); font-size: 11.5px; }

/* ==========================================================================
   CV page
   ========================================================================== */

.bento-hero {
  grid-column: span 4;
  min-height: 200px;
  position: relative;
  overflow: hidden;
  color: var(--ink);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.bento-hero h2 { margin: 4px 0 5px; font-size: 26px; line-height: 1.15; font-weight: 650; letter-spacing: -0.03em; }
.bento-hero p { color: var(--muted); font-size: 13px; }
.bento-hero .bento-eyebrow { color: var(--accent); }
.bento-metrics { display: flex; gap: var(--space-6); margin-top: auto; padding-top: var(--space-5); }
.bento-metrics b { display: block; color: var(--ink); font-size: 24px; line-height: 1; font-weight: 650; letter-spacing: -0.03em; }
.bento-metrics span { display: block; margin-top: 5px; color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.bento-actions { grid-column: span 4; min-height: 200px; display: flex; flex-direction: column; }
.bento-action-stack { display: flex; flex-direction: column; gap: var(--space-2); height: 100%; align-items: stretch; }
.bento-action-stack .btn { width: 100%; }
.bento-action-stack .view-toggle { align-self: flex-end; }
.bento-selected { margin-top: auto; color: var(--muted); font-size: 11.5px; text-align: right; }
.bento-selected b { color: var(--accent); font-size: 17px; font-weight: 650; }
.bento-skills { grid-column: span 4; min-height: 200px; }
.bento-skills .chips { max-height: 120px; overflow: hidden; }
.bento-filter { grid-column: span 12; padding-bottom: var(--space-4); }
.bento-results { grid-column: span 12; padding-bottom: var(--space-4); }

.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-items: center; }
.filters input[name="q"] { grid-column: span 2; }
.filters .check { grid-column: span 1; }
.filters .filter-actions { grid-column: span 3; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.advanced { margin-top: var(--space-3); }
.advanced summary { color: var(--muted); font-size: 12px; cursor: pointer; }
.advanced textarea { margin: 10px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.view-toggle { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-muted); }
.view-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  transition: background var(--ease), color var(--ease), box-shadow var(--ease);
}
.view-btn:hover { background: var(--surface); color: var(--ink); }
.view-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-xs); }
.cards.bento-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.cards.bento-cards .card { height: 280px; overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th,
.data-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--surface-soft);
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--ease); }
.data-table tbody tr:hover { background: var(--surface-soft); }
.data-table .meta { max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.data-table .right, .cv-table .right { text-align: right; }
.cv-table tbody tr { cursor: pointer; }
.cv-table tbody tr.selected { background: var(--accent-soft); }
.cv-table .chips { max-width: 280px; }
.cv-table .btn + .btn { margin-left: 6px; }

/* ==========================================================================
   Upload / preview
   ========================================================================== */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 190px;
  padding: var(--space-6);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-card);
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { color: var(--ink); font-size: 14px; font-weight: 600; }
.dropzone small { max-width: 380px; color: var(--muted); font-size: 12px; }
.folder-import { margin-top: var(--space-3); color: var(--muted); font-size: 12px; }
.folder-import summary { cursor: pointer; }
.log { display: grid; gap: 6px; margin-top: var(--space-3); }
.log-row {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 12px;
}
.log-row.ok { border-color: var(--green-line); background: var(--green-soft); color: var(--green); }
.log-row.dup { border-color: var(--amber-line); background: var(--amber-soft); color: var(--amber); }
.log-row.err { border-color: var(--red-line); background: var(--red-soft); color: var(--red); }
.preview-box { border-color: var(--accent-line); }
.preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin-top: var(--space-4); }
.preview-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 11.5px; }
.preview-grid .span-2 { grid-column: 1 / -1; }
.preview-readonly { display: grid; gap: 10px; margin-top: var(--space-4); }
.preview-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: var(--space-4); }
.raw-text {
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* ==========================================================================
   Chat
   ========================================================================== */

main.chat-mode { padding: var(--space-3) var(--space-8) var(--space-3); }
main.chat-mode .page[data-page-view="chat"] { height: calc(100dvh - 204px); min-height: 500px; }
.chat-panel { height: 100%; display: flex; flex-direction: column; padding: var(--space-4) var(--space-5); }
.chat-head { align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; flex: 0 0 auto; }
.chat-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.chat-tools select { width: auto; max-width: 260px; }
.chat-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--space-4); flex: 1 1 auto; min-height: 0; }
.chat-layout.no-history { grid-template-columns: minmax(0, 1fr); }
.chat-history { display: flex; flex-direction: column; min-height: 0; padding-right: var(--space-3); border-right: 1px solid var(--line); }
.chat-history-title { margin-bottom: 8px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.chat-session-list { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow-y: auto; }
.chat-session {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  font-size: 12px;
  transition: background var(--ease), border-color var(--ease);
}
.chat-session:hover { background: var(--surface-muted); }
.chat-session.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.chat-session span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-session small { color: var(--muted); font-size: 10px; }
.chat-main { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface-soft);
}
.chat-empty { max-width: 540px; margin: auto; padding: var(--space-6) var(--space-4); color: var(--muted); text-align: center; }
.chat-empty strong { display: block; margin-bottom: 6px; color: var(--ink); font-size: 15px; font-weight: 600; }
.chat-empty p { font-size: 12.5px; line-height: 1.6; }
.chat-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: var(--space-4); }
.chat-suggestions button {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 11.5px;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
}
.chat-suggestions button:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-bubble { max-width: 86%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); line-height: 1.55; }
.chat-msg.user .chat-bubble { border-color: var(--accent-line); background: var(--accent-soft); }
.chat-text { font-size: 13px; word-break: break-word; }
.chat-text code { padding: 1px 4px; border-radius: 4px; background: var(--surface-muted); font-size: 11.5px; }
.chat-warning { margin-top: 7px; padding: 6px 8px; border: 1px solid var(--amber-line); border-radius: 6px; background: var(--amber-soft); color: var(--amber); font-size: 11.5px; }
.chat-candidates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.chat-candidate {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
}
.chat-candidate:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.chat-candidate small { display: block; margin-top: 2px; color: var(--muted); font-weight: 400; }
.chat-meta { margin-top: 6px; color: var(--muted); font-size: 10.5px; }
.chat-composer { display: flex; align-items: flex-end; gap: 8px; flex: 0 0 auto; margin-top: 10px; }
.chat-composer textarea { flex: 1; min-height: 44px; max-height: 140px; resize: vertical; }
#chatStatus { min-height: 16px; margin-top: 6px; }

/* ==========================================================================
   Plans / billing
   ========================================================================== */

.plan-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.plan-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.plan-card.current { border-color: var(--accent); background: var(--accent-soft); }
.plan-card h3 { font-size: 14px; font-weight: 650; }
.plan-price { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.plan-price small { color: var(--muted); font-size: 11px; font-weight: 400; }
.plan-card ul { display: grid; gap: 4px; margin: 0; padding-left: 16px; color: var(--muted); font-size: 11.5px; }
.plan-card .btn { margin-top: auto; width: 100%; }

/* ==========================================================================
   LLM
   ========================================================================== */

.llm-list { display: grid; gap: 8px; max-height: 460px; overflow-y: auto; }
.llm-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color var(--ease), background var(--ease);
}
.llm-card:hover { border-color: #c7d0dd; background: var(--surface-soft); }
.llm-card-main { display: flex; align-items: flex-start; gap: 10px; flex: 1; min-width: 0; }
.llm-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
}
.llm-title { font-size: 13px; font-weight: 600; }
.llm-card .meta { margin-top: 2px; color: var(--muted); font-size: 11.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.llm-actions { display: flex; flex: 0 0 auto; flex-wrap: nowrap; gap: 6px; }
.llm-actions .btn { padding: 5px 8px; }

/* ==========================================================================
   Settings / users
   ========================================================================== */

.kv { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 7px 12px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { min-width: 0; margin: 0; color: var(--ink-soft); }
.settings-plan { margin-top: 6px; }

/* ==========================================================================
   Kanban
   ========================================================================== */

.kanban {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-3);
  padding-bottom: 4px;
  overflow-x: auto;
  align-items: start;
}
.kanban-col {
  min-width: 0;
  min-height: 360px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}
.kanban-col.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.kanban-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 1px 2px 9px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.kanban-head b { padding: 1px 6px; border-radius: var(--radius-pill); background: var(--surface-muted); color: var(--ink-soft); font-size: 10px; }
.kanban-cards { display: grid; gap: 6px; }
.kanban-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: grab;
  transition: border-color var(--ease), background var(--ease);
}
.kanban-card:hover { border-color: #c7d0dd; background: #fcfcfd; }
.kanban-card.dragging { opacity: 0.55; }
.kanban-card b { min-width: 0; font-size: 12.5px; font-weight: 600; }
.kanban-company { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kanban-card .meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kanban-foot { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.kanban-status { flex: 1; min-width: 0; min-height: 28px; padding: 3px 5px; border-radius: 6px; font-size: 10.5px; }
.kanban-del {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid var(--red-line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--red);
  line-height: 1;
}
.kanban-del:hover { background: var(--red-soft); }
.kanban-empty { padding: 24px 4px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); text-align: center; font-size: 11.5px; }
.apply-modal-card { width: min(680px, 96vw); }

/* ==========================================================================
   Drawer / modal / toast
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(16, 24, 40, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease);
}
.overlay.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  width: min(680px, 94vw);
  padding: var(--space-6);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transform: translateX(102%);
  transition: transform var(--ease);
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}
.drawer-close:hover { background: var(--surface-muted); color: var(--ink); }
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: rgba(16, 24, 40, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease);
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal-card {
  width: min(860px, 96vw);
  max-height: 86vh;
  overflow-y: auto;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.modal-head h2 { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.pdf-modal-card { width: min(1100px, 96vw); height: min(88vh, 900px); max-height: 88vh; display: flex; flex-direction: column; }
.pdf-modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: 10px; }
.pdf-modal-head > div:first-child { min-width: 0; }
.pdf-modal-head .file-name { max-width: 620px; color: var(--muted); font-size: 12px; }
.pdf-frame { flex: 1; min-height: 0; width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 90;
  transform: translate(-50%, 16px);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease), transform var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Detail drawer content */
.detail h2 { font-size: 22px; line-height: 1.2; font-weight: 650; letter-spacing: -0.03em; }
.detail .headline { margin-top: 4px; color: var(--muted); font-size: 13px; }
.detail h3 {
  margin: 20px 0 8px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.detail .summary { color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
.timeline { display: grid; gap: 10px; }
.timeline-item { padding-left: 12px; border-left: 2px solid var(--line); }
.timeline-item b { display: block; font-size: 12.5px; font-weight: 600; }
.timeline-item .meta { margin: 2px 0 4px; }
.timeline-item p { color: var(--ink-soft); font-size: 12.5px; line-height: 1.5; white-space: pre-line; }
.dup-list { display: grid; gap: 6px; }
.dup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
}
.file-actions { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; }
.file-actions .file-name { flex: 1; color: var(--muted); font-size: 11.5px; }
.file-actions .btn { flex: 0 0 auto; }
.badges { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }

/* ==========================================================================
   Login
   ========================================================================== */

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: var(--bg);
}
.login-card {
  width: min(420px, 100%);
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-5); }
.login-brand h1 { font-size: 19px; font-weight: 650; letter-spacing: -0.02em; }
.login-brand p { margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.login-tabs { display: flex; gap: 2px; margin-bottom: var(--space-4); padding: 3px; border-radius: var(--radius-control); background: var(--surface-muted); }
.login-tabs button { flex: 1; padding: 7px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.login-tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }
.login-form { display: grid; gap: 10px; }
.login-form label { display: grid; gap: 5px; color: var(--muted); font-size: 11.5px; }
.login-form .btn { width: 100%; }
.login-links { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11.5px; }
.login-divider { display: flex; align-items: center; gap: 8px; margin: 12px 0; color: var(--muted); font-size: 10.5px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
}
.google-btn:hover { background: var(--surface-muted); }
.login-msg { min-height: 18px; margin-top: 8px; color: var(--red); font-size: 11.5px; }
.login-msg.ok { color: var(--green); }
.dev-link { margin-top: 10px; padding: 8px; border: 1px solid var(--amber-line); border-radius: 7px; background: var(--amber-soft); color: var(--amber); font-size: 11px; word-break: break-all; }
.dev-link a { color: var(--amber); }
.login-foot { margin-top: var(--space-4); color: var(--muted); font-size: 10.5px; text-align: center; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1200px) {
  .bento-page > .eq-3,
  .bento-page > .eq-4 { grid-column: span 6; }
  .bento-page > .eq-6 { grid-column: span 12; }
  .bento-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cards.bento-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side-user-info { display: none; }
}
@media (max-width: 980px) {
  .sidebar { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .brand { order: 1; }
  .side-user { order: 2; margin-left: auto; border-left: 0; padding-left: 0; }
  .side-nav { order: 3; flex-basis: 100%; width: 100%; padding-bottom: 2px; }
  .topbar { padding: var(--space-5) var(--space-4) 0; }
  .main-area main { padding: var(--space-4) var(--space-4) var(--space-6); }
  .bento-grid { gap: var(--space-3); }
  .bento-hero, .bento-actions, .bento-skills { grid-column: span 12; }
  .bento-actions .bento-action-stack { flex-direction: row; flex-wrap: wrap; }
  .bento-actions .bento-action-stack .btn { width: auto; flex: 1 1 160px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters input[name="q"], .filters .check, .filters .filter-actions { grid-column: span 2; }
  .cards.bento-cards { grid-template-columns: 1fr; }
  .cards.bento-cards .card { height: auto; min-height: 240px; }
  main.chat-mode { padding: var(--space-3) var(--space-4); }
  main.chat-mode .page[data-page-view="chat"] { height: calc(100dvh - 250px); min-height: 500px; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-history { display: none; }
}
@media (max-width: 760px) {
  .topbar { padding: var(--space-4) var(--space-4) 0; }
  .topbar h1 { font-size: 22px; }
  .topbar p { font-size: 12px; }
  .main-area main { padding: var(--space-3) var(--space-4) var(--space-6); }
  .page { gap: var(--space-4); }
  .panel, .bento-card { padding: var(--space-4); }
  .bento-page > .eq-3,
  .bento-page > .eq-4,
  .bento-page > .eq-6 { grid-column: span 12; }
  .bento-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .form-grid, .preview-grid { grid-template-columns: 1fr; }
  .form-grid .span-2, .preview-grid .span-2 { grid-column: auto; }
  .bento-hero, .bento-actions, .bento-skills { grid-column: span 12; }
  .bento-hero h2 { font-size: 22px; }
  .bento-metrics { gap: var(--space-4); }
  .plan-grid { grid-template-columns: 1fr; }
  .chat-tools { width: 100%; }
  .chat-tools select { flex: 1; max-width: none; }
  .chat-composer { align-items: stretch; }
  .chat-composer .btn { min-width: 64px; }
  .file-actions { flex-wrap: wrap; }
  .file-actions .file-name { flex-basis: 100%; order: 3; }
  .pdf-modal-card { width: 98vw; height: 92vh; }
  .modal-card { width: 96vw; padding: var(--space-4); }
  .side-user .btn { display: inline-flex; padding: 6px 10px; }
  .side-item { font-size: 12px; padding: 7px 9px; }
  .kanban { grid-template-columns: repeat(6, 235px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* CV table action column + stacked meta */
.cv-table th:last-child,
.cv-table td:last-child { width: 132px; white-space: nowrap; text-align: right; }
.cv-table td:last-child .btn { display: inline-flex; }
.data-table .meta.file-name { display: block; }

.view-btn.active, .login-tabs button.active { box-shadow: none; }

/* Email templates / compose */
.email-template-list { display: grid; gap: 6px; max-height: 470px; overflow-y: auto; }
.email-template-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color var(--ease), background var(--ease);
}
.email-template-card:hover { border-color: #c7d0dd; background: var(--surface-soft); }
.email-template-main { min-width: 0; flex: 1; }
.email-template-main b { display: block; font-size: 12.5px; font-weight: 600; }
.email-template-main .meta { margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-template-actions { display: flex; flex: 0 0 auto; flex-wrap: nowrap; gap: 5px; }
.email-preview-wrap { padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.email-preview-frame { width: 100%; height: 240px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.template-modal-card { width: min(760px, 96vw); }
@media (max-width: 760px) {
  .email-template-card { align-items: flex-start; flex-direction: column; }
  .email-template-actions { width: 100%; }
  .email-preview-frame { height: 200px; }
}

.side-user-info { display: none; }
