:root {
  --paper: #e6ebf2;
  --card: #f8fafd;
  --ink: #18213d;
  --ink-2: #2a3558;
  --muted: #5d6785;
  --line: #cfd6e2;
  --signal: #5b2eff;
  --signal-soft: #e9e3ff;

  --st-confirmar: #a86a12;
  --st-pesquisar: #6b7389;
  --st-pronto: #1f62d6;
  --st-enviado: #5b2eff;
  --st-respondeu: #0d7f74;
  --st-reuniao: #2c7d36;
  --st-sem: #b8364f;

  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, sans-serif;
  --rail: 232px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
svg { width: 20px; height: 20px; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
  background: var(--ink); color: #dfe4f2; padding: 22px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 0 8px; }
.brand__mark { width: 26px; height: 26px; border-radius: 8px 8px 8px 2px; background: var(--signal); box-shadow: inset -6px -6px 0 rgba(255,255,255,.18); }
.brand__name { font: 800 22px/1 var(--display); letter-spacing: -0.02em; color: #fff; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  text-decoration: none; font-weight: 500; color: #b9c1d8;
}
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a[aria-current="page"] { background: #fff; color: var(--ink); }
.sync {
  margin-top: auto; display: flex; align-items: center; gap: 8px; text-align: left;
  border: 0; background: none; color: #b9c1d8; font-size: 13px; padding: 8px 12px; border-radius: 10px; cursor: pointer;
}
.sync:hover { background: var(--ink-2); }
.sync__dot { width: 8px; height: 8px; border-radius: 50%; background: #8a93ad; }
.sync[data-mode="cloud"] .sync__dot { background: #3ccf8e; }
.sync[data-mode="local"] .sync__dot { background: #f0b44c; }

.page { padding: 36px clamp(18px, 4vw, 48px) 64px; max-width: 1280px; width: 100%; outline: none; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font: 800 clamp(32px, 5vw, 52px)/0.95 var(--display); letter-spacing: -0.035em; margin: 0; }
.lede { color: var(--muted); margin: 10px 0 0; max-width: 64ch; font-size: 16px; }
.lede b { color: var(--ink); font-weight: 600; }

/* ---------- Blocks ---------- */
.block { background: var(--card); border-radius: 18px; padding: 20px 22px; }
.block + .block { margin-top: 16px; }
.block h2 { font: 700 20px/1.2 var(--display); letter-spacing: -0.01em; margin: 0 0 4px; }
.block .hint { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.home { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.home .block + .block { margin-top: 0; }
.home .col { display: grid; gap: 16px; }

/* funnel bar */
.funnel { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--paper); margin: 8px 0 14px; }
.funnel span { display: block; height: 100%; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* action rows */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 11px 6px; border-top: 1px solid var(--line); cursor: pointer; border-radius: 8px;
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--paper); }
.row b { font-weight: 600; }
.row small { display: block; color: var(--muted); font-size: 13px; }
.row .when { font-size: 13px; color: var(--muted); white-space: nowrap; }
.row .when.late { color: var(--st-sem); font-weight: 600; }
.empty { color: var(--muted); padding: 10px 0; }

.prio { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); }
.prio.alta { background: var(--signal); border-color: var(--signal); }
.prio.media { border-color: var(--signal); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.search { position: relative; flex: 1 1 280px; max-width: 420px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input { width: 100%; padding: 10px 14px 10px 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; cursor: pointer; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Studio tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.tile {
  text-align: left; border: 0; cursor: pointer; background: var(--card); border-radius: 18px; padding: 18px 18px 16px;
  display: flex; flex-direction: column; gap: 10px; min-height: 170px; position: relative;
}
.tile:hover { box-shadow: 0 0 0 2px var(--ink); }
.tile.is-alta::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 4px; border-radius: 0 4px 4px 0; background: var(--signal); }
.tile.is-unconfirmed { background: transparent; border: 1.5px dashed var(--line); }
.tile__top { display: flex; justify-content: space-between; gap: 10px; }
.tile h3 { font: 700 21px/1.1 var(--display); letter-spacing: -0.015em; margin: 0; }
.tile .group { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.flag { font-size: 18px; line-height: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; list-style: none; margin: 0; padding: 0; }
.tags li { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--paper); }
.tile__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 10px 3px 8px; border-radius: 999px; background: var(--paper); color: var(--ink); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--muted)); }

/* ---------- Pipeline ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x proximity; }
.lane { background: var(--card); border-radius: 16px; padding: 12px; min-height: 360px; scroll-snap-align: start; border-top: 4px solid var(--c); }
.lane.is-over { box-shadow: inset 0 0 0 2px var(--c); }
.lane h3 { display: flex; justify-content: space-between; font: 700 16px/1.2 var(--display); margin: 2px 4px 10px; }
.lane h3 span { color: var(--muted); font-weight: 500; font-family: var(--body); }
.card { background: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; border: 1px solid var(--line); }
.card:active { cursor: grabbing; }
.card.is-dragging { opacity: .4; }
.card b { display: block; font-weight: 600; }
.card small { color: var(--muted); font-size: 12.5px; }
.card .meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ---------- Sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(24, 33, 61, .38); z-index: 20; }
.sheet {
  position: fixed; z-index: 21; top: 0; right: 0; bottom: 0; width: min(620px, 100vw);
  background: var(--card); overflow-y: auto; padding: 24px 26px 40px; box-shadow: -20px 0 60px rgba(24,33,61,.18);
}
.sheet__close { position: sticky; top: 0; float: right; border: 0; background: var(--paper); border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; }
.sheet h2 { font: 800 34px/1 var(--display); letter-spacing: -0.03em; margin: 6px 0 6px; padding-right: 48px; }
.sheet .group { color: var(--muted); margin: 0; }
.sheet .place { margin: 8px 0 14px; display: flex; gap: 8px; align-items: center; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 12px; text-decoration: none;
  font-weight: 600; font-size: 14px; border: 1.5px solid var(--ink); background: transparent; cursor: pointer;
}
.btn:hover { background: var(--ink); color: #fff; }
.btn.solid { background: var(--ink); color: #fff; }
.btn.solid:hover { background: var(--ink-2); }
.btn.small { padding: 6px 10px; font-size: 13px; border-width: 1px; border-color: var(--line); }
.btn.small:hover { border-color: var(--ink); }
.btn svg { width: 17px; height: 17px; }
.notes { color: var(--muted); margin: 0 0 6px; }
.warn { background: #fff4e0; color: #7a4c0a; padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 10px 0; }
.sheet h3 { font: 700 18px/1.2 var(--display); margin: 24px 0 8px; }

.person { border-top: 1px solid var(--line); padding: 14px 0; }
.person__top { display: flex; gap: 12px; align-items: start; justify-content: space-between; flex-wrap: wrap; }
.person__who b { font-size: 16px; }
.person__who small { display: block; color: var(--muted); }
.person__who .note { color: var(--st-confirmar); }
.person__acts { display: flex; gap: 6px; align-items: center; }
.fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 12px; }
.fields label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.fields select, .fields input, .person textarea {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px; width: 100%;
}
.person textarea { margin-top: 10px; min-height: 64px; resize: vertical; }
.sources { font-size: 13px; color: var(--muted); margin-top: 22px; }
.sources a { margin-right: 10px; }

/* ---------- Settings ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 8px 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.steps { margin: 8px 0 0; padding-left: 20px; }
.steps li { margin: 4px 0; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 30; display: grid; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 10px 30px rgba(24,33,61,.25); }

/* ---------- Mobile: bottom tab bar + bottom sheet ---------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 15;
    flex-direction: row; padding: 6px 8px calc(6px + var(--safe-b)); gap: 0;
  }
  .brand, .sync { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 3px; font-size: 11.5px; padding: 6px 10px; }
  .nav a[aria-current="page"] { background: var(--ink-2); color: #fff; }
  .page { padding: 22px 16px calc(96px + var(--safe-b)); }
  .home { grid-template-columns: 1fr; }
  .toolbar .chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; scrollbar-width: none; }
  .chip { white-space: nowrap; }
  .sheet { top: auto; width: 100vw; max-height: 92vh; border-radius: 22px 22px 0 0; padding: 18px 18px calc(30px + var(--safe-b)); }
  .fields { grid-template-columns: 1fr 1fr; }
  .fields label:first-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: no-preference) {
  .sheet:not([hidden]) { animation: slide-in .22s ease-out; }
  @keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
  @media (max-width: 820px) {
    .sheet:not([hidden]) { animation: slide-up .24s ease-out; }
    @keyframes slide-up { from { transform: translateY(40px); opacity: 0; } }
  }
}
