/* ============================================================================
   Dashboard — "engineering logbook" theme.
   Extends the linkedin-filter style with:
     • portal switcher nav in the masthead
     • row thumbnails (cars, real-estate)
     • photo grid (vinted)
     • price-drop badge
   ========================================================================== */

:root {
  --paper:     #f4efe4;
  --paper-2:   #ffffff;
  --panel:     #ece5d6;
  --ink:       #221e18;
  --ink-soft:  #6f665a;
  --ink-faint: #9b9183;
  --hair:      rgba(34, 30, 24, 0.12);
  --hair-2:    rgba(34, 30, 24, 0.06);
  --accent:    #c0512c;
  --accent-dk: #993d1e;

  /* score tiers */
  --hi:    #2f6b4a;   --hi-bg:  #e2ede4;
  --mid:   #b07410;   --mid-bg: #f3ead4;
  --lo:    #8a8377;   --lo-bg:  #ece7db;

  --serif: "Fraunces", Georgia, serif;
  --sans:  "IBM Plex Sans", system-ui, sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, var(--hair-2) 1px, transparent 0);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Masthead ──────────────────────────────────────────────────────────────── */
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 239, 228, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hair);
}
.masthead-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}
.brand h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}
.brand .dot { color: var(--accent); }
.brand .sub {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Portal switcher (top-level nav) ──────────────────────────────────────── */
/*
  WHY a separate nav above the tabs? The user asked for a "top menu" to switch
  between portals. The tabs below are per-portal (inbox/interested/…). Keeping
  the two navs separate makes the hierarchy obvious at a glance.
*/
.portal-nav {
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
  margin-bottom: 0.1rem;
}
.portal-link {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.65rem;
  border-radius: 5px;
  color: var(--ink-soft);
  border: 1px solid transparent;
  transition: background 0.13s, color 0.13s;
}
.portal-link:hover {
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
}
.portal-link.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dk);
}

/* ── Tabs (per-portal: inbox / zainteresowane / …) ────────────────────────── */
.tabs { display: flex; gap: 0.15rem; flex-wrap: wrap; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border-radius: 7px 7px 0 0;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.92rem;
  border-bottom: 2px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { background: var(--hair-2); text-decoration: none; color: var(--ink); }
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.tab .count {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-soft);
}
.tab.active .count { background: var(--accent); color: #fff; }

/* ── Filter toolbar ────────────────────────────────────────────────────────── */
.wrap { max-width: 1080px; margin: 0 auto; padding: 1.5rem; }

.toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.toolbar input[type="text"],
.toolbar input[type="number"],
.toolbar select {
  font-family: var(--sans);
  font-size: 0.88rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--hair);
  border-radius: 8px;
  background: var(--paper-2);
  color: var(--ink);
}
.toolbar input[type="text"] { flex: 1; min-width: 180px; }
.toolbar input[type="number"] { width: 110px; }
.toolbar input:focus, .toolbar select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192, 81, 44, 0.14);
}
.btn {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.btn:hover { background: var(--accent-dk); }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--hair);
  border: 1px solid var(--hair);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  display: inline-block;
}
.btn-ghost:hover { background: var(--hair-2); color: var(--ink); text-decoration: none; }

/* ── Row list ──────────────────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; }

.job-row {
  display: grid;
  /* score | [thumb] | body | actions */
  grid-template-columns: 70px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.95rem 0.6rem 0.95rem 1rem;
  border-bottom: 1px solid var(--hair);
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s, opacity 0.25s, transform 0.25s;
  animation: rise 0.4s both;
}
/* Rows with thumbnail: add thumb column between score and body */
.job-row.has-thumb {
  grid-template-columns: 70px 72px 1fr auto;
}
.job-row:hover { background: var(--paper-2); }
.job-row.htmx-swapping { opacity: 0; transform: translateX(14px); }

/* Staggered entrance animation */
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.job-row:nth-child(1){animation-delay:.02s}.job-row:nth-child(2){animation-delay:.05s}
.job-row:nth-child(3){animation-delay:.08s}.job-row:nth-child(4){animation-delay:.11s}
.job-row:nth-child(5){animation-delay:.14s}.job-row:nth-child(6){animation-delay:.17s}
.job-row:nth-child(7){animation-delay:.20s}.job-row:nth-child(8){animation-delay:.23s}
.job-row:nth-child(9){animation-delay:.26s}.job-row:nth-child(10){animation-delay:.29s}

/* Triage state cues on the left rail */
.job-row.status-interested { border-left-color: var(--mid); }
.job-row.status-contacted  { border-left-color: #3f6f93; }
.job-row.status-dismissed  { opacity: 0.45; }
.job-row.status-dismissed .row-title { text-decoration: line-through; }

/* ── Thumbnail (cars, real-estate) ────────────────────────────────────────── */
.thumb-col { width: 72px; }
.thumb {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.thumb-placeholder {
  width: 72px;
  height: 54px;
  border-radius: 6px;
  background: var(--panel);
}

/* ── Score readout ────────────────────────────────────────────────────────── */
.score {
  font-family: var(--mono);
  text-align: center;
  border-radius: 9px;
  padding: 0.35rem 0;
  line-height: 1;
}
.score .n { display: block; font-size: 1.75rem; font-weight: 600; }
.score .d { display: block; font-size: 0.62rem; letter-spacing: 0.08em; opacity: 0.7; margin-top: 2px; }
.score.tier-hi  { background: var(--hi-bg);  color: var(--hi); }
.score.tier-mid { background: var(--mid-bg); color: var(--mid); }
.score.tier-lo  { background: var(--lo-bg);  color: var(--lo); }
.score.tier-none{ background: var(--lo-bg);  color: var(--ink-faint); }

/* ── Row body ─────────────────────────────────────────────────────────────── */
.row-body { min-width: 0; }
.row-title {
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.row-title:hover { color: var(--accent-dk); text-decoration: none; }
.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.7rem;
  margin-top: 0.25rem;
  font-size: 0.83rem;
  color: var(--ink-soft);
}
.row-meta .company { font-weight: 600; color: var(--ink); }
.row-meta .salary  { font-family: var(--mono); font-weight: 600; color: var(--accent-dk); }
.row-meta .sep { color: var(--ink-faint); }

/* ── Chips / badges ────────────────────────────────────────────────────────── */
.chip {
  font-size: 0.7rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.08rem 0.4rem;
  border-radius: 5px;
  background: var(--panel);
  color: var(--ink-soft);
}
/* Job source chips — match linkedin-filter colours */
.chip.src-pracuj   { background: #d9e6f4; color: #1c4e84; }
.chip.src-justjoin { background: #f7dcde; color: #99313b; }
.chip.src-nofluff  { background: #d6ece7; color: #1f6d5f; }
.chip.src-linkedin { background: #d6e4f3; color: #1a4f86; }
/* Car site chips */
.chip.src-otomoto  { background: #fce3cc; color: #8a3600; }
.chip.src-olx      { background: #d6eef4; color: #165c6a; }
/* Real-estate portal chips */
.chip.src-otodom   { background: #e0d6f5; color: #4a2b8a; }
.chip.src-morizon  { background: #d6f0e0; color: #1a5c35; }
/* Evaluation status chips */
.chip.hi  { background: var(--hi-bg);  color: var(--hi); }
.chip.mid { background: var(--mid-bg); color: var(--mid); }
.chip.lo  { background: var(--lo-bg);  color: var(--lo); }
/* Price-drop badge — green because it's good news (price fell) */
.chip.price-drop { background: var(--hi-bg); color: var(--hi); font-weight: 600; }

.row-reason {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink-soft);
  font-style: italic;
  max-width: 80ch;
}

/* ── Row actions ───────────────────────────────────────────────────────────── */
.row-actions { display: flex; gap: 0.3rem; }
.row-actions form { display: flex; gap: 0.3rem; margin: 0; }
.act {
  font-family: var(--sans);
  font-size: 0.95rem;
  width: 2.1rem; height: 2.1rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--hair);
  background: var(--paper-2);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.13s;
}
.act:hover { border-color: var(--ink-soft); color: var(--ink); transform: translateY(-1px); }
.act.on-interested.active { background: var(--mid); border-color: var(--mid); color: #fff; }
.act.on-contacted.active  { background: #3f6f93; border-color: #3f6f93; color: #fff; }
.act.on-dismissed.active  { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ── Vinted photo grid ────────────────────────────────────────────────────── */
/*
  WHY grid not rows? Vinted items have no numeric score and their key signal
  is visual — the photo tells you more than the title. A photo-dominant
  grid lets you scan 12–16 items per screen instead of 5–6.
*/
.vinted-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.vinted-card {
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s, opacity 0.25s, transform 0.25s;
  animation: rise 0.4s both;
  border-left: 3px solid transparent;
}
.vinted-card:hover { box-shadow: 0 4px 16px rgba(34,30,24,0.10); }
.vinted-card.htmx-swapping { opacity: 0; transform: translateY(8px); }

.vinted-card.status-interested { border-left-color: var(--mid); }
.vinted-card.status-contacted  { border-left-color: #3f6f93; }
.vinted-card.status-dismissed  { opacity: 0.4; }
.vinted-card.status-dismissed .vinted-title { text-decoration: line-through; }

.vinted-photo-link {
  display: block;
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--panel);
}
.vinted-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.vinted-photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--ink-faint);
}
/* Match badge overlaid on the photo corner */
.vinted-match-badge {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.vinted-match-badge.tier-hi  { background: var(--hi);  color: #fff; }
.vinted-match-badge.tier-lo  { background: var(--lo-bg); color: var(--lo); }

.vinted-body { padding: 0.6rem 0.7rem 0.5rem; display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.vinted-title {
  font-family: var(--serif);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  /* Clamp to 2 lines so cards stay uniform height */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.vinted-title:hover { color: var(--accent-dk); text-decoration: none; }
.vinted-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.vinted-meta .company { font-weight: 600; color: var(--ink); }
.vinted-meta .salary  { font-family: var(--mono); font-weight: 600; color: var(--accent-dk); }
.vinted-actions { display: flex; gap: 0.25rem; margin-top: auto; padding-top: 0.4rem; }
.vinted-actions form { display: flex; gap: 0.25rem; margin: 0; }

/* ── Pagination / empty ────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 0.6rem; justify-content: center; margin-top: 1.6rem; }
.empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--ink-faint);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.1rem;
}

/* ── Detail page ───────────────────────────────────────────────────────────── */
.crumbs { font-size: 0.82rem; color: var(--ink-soft); margin-bottom: 1.25rem; }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2.5rem;
  align-items: start;
}
@media (max-width: 820px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-head { display: flex; gap: 1.1rem; align-items: flex-start; margin-bottom: 1.5rem; }
.detail-head .score { flex: 0 0 84px; padding: 0.55rem 0; }
.detail-head .score .n { font-size: 2.2rem; }
.detail-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.85rem;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0.1rem 0 0.5rem;
}
.detail-sub { display: flex; flex-wrap: wrap; gap: 0.4rem 0.7rem; align-items: center; font-size: 0.9rem; color: var(--ink-soft); }

/* Detail photo */
.detail-photo-wrap { margin: 1rem 0; border-radius: 10px; overflow: hidden; max-height: 400px; }
.detail-photo { width: 100%; max-height: 400px; object-fit: cover; display: block; }

.verdict {
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  margin: 1.5rem 0;
}
.verdict h3 {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin: 0 0 0.5rem;
}
.verdict p { margin: 0; font-size: 1rem; line-height: 1.55; white-space: pre-wrap; }

.specs { width: 100%; border-collapse: collapse; margin: 1.25rem 0; }
.specs th, .specs td { text-align: left; padding: 0.55rem 0; border-bottom: 1px solid var(--hair-2); vertical-align: top; }
.specs th { width: 36%; font-weight: 500; color: var(--ink-soft); font-size: 0.85rem; }
.specs td { font-size: 0.92rem; }
.specs td.salary { font-family: var(--mono); font-weight: 600; color: var(--accent-dk); }

/* Price history section on detail page */
.price-history { margin: 1.5rem 0; }
.price-history h4 {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin: 0 0 0.4rem;
}

.ext { display: inline-block; margin-top: 0.5rem; font-weight: 600; }

/* Aside */
.aside { position: sticky; top: 120px; display: flex; flex-direction: column; gap: 1.5rem; }
.aside h4 {
  font-family: var(--mono);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-faint); margin: 0 0 0.6rem;
}
.aside .stack { display: flex; flex-direction: column; gap: 0.4rem; }
.aside .stack button {
  width: 100%; text-align: left;
  font-family: var(--sans); font-size: 0.9rem; font-weight: 500;
  padding: 0.6rem 0.8rem; border-radius: 9px;
  border: 1px solid var(--hair); background: var(--paper-2); color: var(--ink);
  cursor: pointer; transition: all 0.13s;
}
.aside .stack button:hover { border-color: var(--ink-soft); }
.aside .stack button.active.s-interested { background: var(--mid); border-color: var(--mid); color: #fff; }
.aside .stack button.active.s-contacted  { background: #3f6f93; border-color: #3f6f93; color: #fff; }
.aside .stack button.active.s-dismissed  { background: var(--ink); border-color: var(--ink); color: #fff; }
.aside textarea {
  width: 100%; font-family: var(--sans); font-size: 0.9rem;
  padding: 0.7rem; border: 1px solid var(--hair); border-radius: 9px;
  background: var(--paper-2); color: var(--ink); resize: vertical;
}
.aside textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(192,81,44,.14); }
.save-confirm { color: var(--hi); font-size: 0.78rem; font-family: var(--mono); }
