/* ---- Tokens ------------------------------------------------------------------------------ */
:root {
  --black: #0a0a0b;
  --ink: #111214;
  --ink-2: #3b3f46;
  --muted: #6b7079;
  --line: #e3e5e9;
  --line-strong: #cfd3d9;
  --white: #ffffff;
  --surface: #f4f5f7;
  --column: #eceef1;

  --blue: #69e4f9;          /* corporate light blue: highlights */
  --blue-soft: #e3fafe;
  --blue-ink: #05707f;      /* blue for text on white (contrast) */

  --done: #1d7f47;
  --done-soft: #e6f4eb;
  --rejected: #8a8f98;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgb(16 18 22 / 0.06), 0 1px 1px rgb(16 18 22 / 0.04);
  --shadow-hover: 0 6px 18px rgb(16 18 22 / 0.10), 0 1px 3px rgb(16 18 22 / 0.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --topbar-h: 60px;
  --sidebar-w: 248px;
  --column-w: 280px;

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--white);
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--blue-ink); text-underline-offset: 2px; }
button { font: inherit; color: inherit; }

.icon {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---- Buttons ----------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 999px;
  font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; }

.btn-primary { background: var(--blue); color: var(--black); }
.btn-primary:hover:not(:disabled) { background: #8eebfb; }
.btn-primary:disabled { background: #2a2c30; color: #75797f; }

.btn-dark { background: var(--black); color: var(--white); }
.btn-dark:hover { background: #26282c; }

.btn-action {
  height: 28px; padding: 0 12px; font-size: 12px;
  background: var(--blue-soft); color: var(--blue-ink); border-color: #b8f1fc;
}
.btn-action:disabled { opacity: .7; }
.btn-action .icon { width: 14px; height: 14px; }

.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: 999px; background: transparent; cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface); }
.icon-btn .icon { width: 18px; height: 18px; }

/* ---- Top bar ----------------------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px;
  background: var(--black); color: var(--white);
  min-width: 0;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.brand-name { font-size: 20px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }

.files {
  display: flex; align-items: center; gap: 16px;
  margin-left: auto; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
}
.file-slot { display: flex; align-items: center; gap: 8px; }
.file-label { font-size: 12px; color: #a9adb3; text-transform: uppercase; letter-spacing: .06em; }

.file-chip {
  display: inline-flex; align-items: baseline; gap: 8px;
  max-width: 260px; height: 34px; padding: 0 12px;
  border: 1px solid #3a3d42; border-radius: var(--radius-sm);
  background: #17181b; color: var(--white);
  cursor: pointer; line-height: 32px;
  transition: border-color .15s, background .15s;
}
.file-chip:hover { border-color: var(--blue); background: #1d1f23; }
.file-chip .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-chip .file-meta { font-size: 12px; color: #a9adb3; white-space: nowrap; }
.file-chip .file-meta:empty { display: none; }
.file-chip[data-state="empty"] { border-style: dashed; color: #c8cbd0; }
.file-chip[data-state="ok"] .file-meta { color: var(--blue); }
.file-chip[data-state="error"] { border-color: #b4474a; }
.file-chip[data-state="error"] .file-meta { color: #ff9a9c; }
.file-chip[data-state="needs-permission"] .file-meta { color: #f3c969; }

.loaded-at { font-size: 12px; color: #8d9197; white-space: nowrap; }
.loaded-at:empty { display: none; }

/* ---- Layout + sidebar -------------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 0;
}

.sidebar {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: var(--white);
  overflow-y: auto;
}

.nav, .nav-sub { list-style: none; margin: 0; padding: 0; }
.nav { display: grid; gap: 18px; }
.nav-group-title {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px; font-weight: 700; font-size: 13px;
}
.nav-num {
  display: grid; place-items: center; width: 22px; height: 22px;
  border-radius: 999px; background: var(--black); color: var(--white); font-size: 11px;
}
.nav-sub { margin-top: 8px; display: grid; gap: 2px; }
.nav-link {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 8px 40px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--surface); color: var(--ink); }
.nav-link.is-active { background: var(--blue-soft); color: var(--black); font-weight: 600; }
.nav-link.is-active::before {
  content: ""; position: absolute; left: 22px; top: 9px; bottom: 9px;
  width: 3px; border-radius: 3px; background: var(--blue);
}
.count {
  min-width: 22px; padding: 0 7px; border-radius: 999px;
  background: var(--surface); color: var(--muted);
  font-size: 12px; font-weight: 600; text-align: center; line-height: 20px;
}
.count:empty { display: none; }
.nav-link.is-active .count { background: var(--white); color: var(--blue-ink); }

.nav-group.is-disabled .nav-group-title { color: #a3a7ae; }
.nav-group.is-disabled .nav-num { background: #d9dce1; color: var(--white); }
.soon { display: block; margin: 4px 0 0 40px; font-size: 12px; color: #a3a7ae; }

.privacy-note {
  display: flex; gap: 8px; align-items: flex-start;
  margin-top: 24px; padding: 10px 12px;
  border-radius: var(--radius-sm); background: var(--surface);
  font-size: 12px; color: var(--muted);
}
.privacy-note .icon { width: 14px; height: 14px; margin-top: 2px; }

/* ---- Main view --------------------------------------------------------------------------- */
.main { min-width: 0; min-height: 0; background: var(--surface); }

.view { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.view-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 22px 24px 16px;
}
.view-kicker { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.view-head h1 { margin-top: 2px; font-size: 22px; letter-spacing: -.01em; }
.view-sub { margin-top: 2px; color: var(--muted); }

.stats { display: flex; gap: 8px; margin: 0; }
.stat {
  min-width: 92px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--white);
}
.stat dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat dd { margin: 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- Board ------------------------------------------------------------------------------- */
.board {
  flex: 1; min-height: 0;
  display: flex; align-items: stretch; gap: 12px;
  padding: 0 24px 20px;
  overflow-x: auto;
}

.column {
  flex: 0 0 var(--column-w);
  display: flex; flex-direction: column; min-height: 0;
  border-radius: var(--radius);
  background: var(--column);
}
.column-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 10px;
}
.col-label {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.col-count {
  padding: 0 8px; border-radius: 999px; background: var(--white);
  font-size: 12px; font-weight: 600; color: var(--muted); line-height: 20px;
  font-variant-numeric: tabular-nums;
}
.column-body {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 2px 10px 12px;
}
.column-empty {
  padding: 18px 8px; text-align: center; font-size: 12px; color: #9a9ea6;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
}

.column.kind-start .column-head { border-top: 3px solid var(--blue); border-radius: var(--radius) var(--radius) 0 0; }
.column.kind-done { background: var(--done-soft); }
.column.kind-done .column-head { color: var(--done); }
.column.kind-rejected { background: #eeeff1; }
.column.kind-rejected .column-head { color: var(--rejected); }
.column.kind-rejected .card { opacity: .72; }
.column.kind-rejected .card:hover { opacity: 1; }

/* ---- Card -------------------------------------------------------------------------------- */
.card {
  display: grid; gap: 8px;
  padding: 12px 12px 12px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--white); box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.card:hover { box-shadow: var(--shadow-hover); border-color: var(--line); transform: translateY(-1px); }
.card-title { font-size: 14px; font-weight: 700; line-height: 1.3; }
.card-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.card-tags:empty { display: none; }
.card-line, .card-since {
  display: flex; align-items: center; gap: 6px;
  color: var(--ink-2); font-size: 12.5px; min-width: 0;
}
.card-since { color: var(--muted); font-size: 12px; }
.card-line .icon, .card-since .icon { width: 14px; height: 14px; color: #9a9ea6; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px; cursor: default; }

.tag {
  padding: 1px 8px; border-radius: 999px;
  background: var(--black); color: var(--white);
  font-size: 11px; font-weight: 700; letter-spacing: .03em;
}
.priority {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--muted); font-weight: 500;
}
.priority .dots { display: inline-flex; gap: 2px; }
.priority .dots span { width: 5px; height: 10px; border-radius: 2px; background: var(--line-strong); }
.priority .dots span.on { background: var(--ink); }
.priority.p-alta { color: var(--ink); font-weight: 600; }
.priority.p-alta .dots span.on { background: var(--blue-ink); }

/* ---- Empty state ------------------------------------------------------------------------- */
.empty-state {
  margin: 40px auto; max-width: 420px; padding: 36px 28px;
  display: grid; justify-items: center; gap: 10px; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--white);
}
.empty-icon {
  display: grid; place-items: center; width: 48px; height: 48px;
  border-radius: 999px; background: var(--blue-soft); color: var(--blue-ink);
}
.empty-icon .icon { width: 22px; height: 22px; }
.empty-state h2 { font-size: 17px; }
.empty-state p { color: var(--muted); }
.empty-state .btn { margin-top: 8px; }

/* ---- Detail dialog ----------------------------------------------------------------------- */
.detail {
  width: min(860px, calc(100vw - 32px)); max-height: min(88vh, 900px);
  padding: 0; border: 0; border-radius: 16px;
  box-shadow: 0 24px 64px rgb(0 0 0 / .28);
  color: var(--ink);
}
.detail::backdrop { background: rgb(10 10 11 / .45); backdrop-filter: blur(2px); }
.detail[open] { display: flex; }
.detail-inner { display: flex; flex-direction: column; width: 100%; max-height: inherit; overflow-y: auto; }

.detail-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 24px 16px;
  background: var(--white); border-bottom: 1px solid var(--line);
}
.detail-kicker { font-size: 12px; color: var(--muted); }
.detail-head h2 { margin-top: 2px; font-size: 21px; letter-spacing: -.01em; }
.detail-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }

.stage-pill {
  padding: 2px 10px; border-radius: 999px;
  background: var(--blue-soft); color: var(--blue-ink);
  font-size: 12px; font-weight: 600;
}
.stage-pill.kind-done { background: var(--done-soft); color: var(--done); }
.stage-pill.kind-rejected { background: #eceef1; color: #5e636b; }

.detail-body {
  display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 28px;
  padding: 20px 24px 28px;
}
.detail-fields { display: grid; gap: 22px; align-content: start; }
.field-group h3, .detail-timeline h3 {
  margin-bottom: 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
.fields {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 20px;
  margin: 0;
}
.field dt { font-size: 12px; color: var(--muted); }
.field dd { margin: 0; overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); }
.muted { color: var(--muted); }

.detail-timeline {
  align-self: start;
  padding: 14px 16px; border-radius: var(--radius); background: var(--surface);
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  display: grid; grid-template-columns: 14px 1fr; column-gap: 10px;
  padding-bottom: 14px;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li:not(:last-child)::after {
  content: ""; position: absolute; left: 6px; top: 16px; bottom: 0;
  width: 2px; background: var(--line-strong);
}
.timeline li.is-done:not(:last-child)::after { background: var(--ink); }
.tl-dot {
  grid-row: span 2; width: 14px; height: 14px; margin-top: 3px;
  border-radius: 999px; border: 2px solid var(--line-strong); background: var(--white);
}
.is-done .tl-dot { border-color: var(--ink); background: var(--ink); }
.is-current .tl-dot { border-color: var(--blue-ink); background: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.is-current.kind-done .tl-dot { border-color: var(--done); background: var(--done); box-shadow: 0 0 0 3px var(--done-soft); }
.is-current.kind-rejected .tl-dot { border-color: var(--rejected); background: var(--rejected); box-shadow: none; }
.tl-label { font-weight: 600; font-size: 13px; }
.is-pending .tl-label { color: var(--muted); font-weight: 500; }
.tl-date { font-size: 12px; color: var(--muted); }

/* ---- Toast ------------------------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 10px 16px;
  border-radius: var(--radius-sm); background: var(--black); color: var(--white);
  box-shadow: var(--shadow-hover); font-size: 13px; z-index: 10;
}
.toast[hidden] { display: none; }

/* ---- Small screens ----------------------------------------------------------------------- */
@media (max-width: 860px) {
  body { display: block; overflow: auto; }
  .topbar { flex-wrap: wrap; gap: 10px; height: auto; padding: 12px 16px; }
  .files { margin-left: 0; width: 100%; flex-wrap: wrap; gap: 10px; }
  .file-chip { max-width: 200px; }
  .layout { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; }
  .nav { grid-auto-flow: column; justify-content: start; gap: 20px; overflow-x: auto; }
  .nav-sub { display: flex; gap: 4px; }
  .nav-group-title { display: none; }
  .nav-sub { margin-top: 0; }
  .nav-link { padding: 6px 12px; gap: 8px; white-space: nowrap; }
  .nav-link.is-active::before { display: none; }
  .nav-group.is-disabled, .privacy-note { display: none; }
  .view { height: auto; }
  .view-head { padding: 16px; }
  .stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; gap: 6px; }
  .stat { min-width: 0; padding: 6px 8px; }
  .stat dt { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .stat dd { font-size: 17px; }
  .board { padding: 0 16px 16px; }
  .column { max-height: 70vh; flex-basis: min(var(--column-w), calc(100vw - 48px)); }
  .detail-body { grid-template-columns: 1fr; padding: 16px; }
  .detail-head { padding: 16px; }
}
