:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e6e8ec;
  --border-strong: #d7dbe1;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #6b7280;
  --blue: #1f63f0;
  --blue-soft: #e9f0fe;
  --blue-text: #1d4ed8;
  --green: #16a34a;
  --green-soft: #e7f6ec;
  --green-text: #15803d;
  --red: #dc2626;
  --red-soft: #fdecec;
  --red-text: #b91c1c;
  --amber: #d97706;
  --amber-soft: #fef3e2;
  --amber-text: #b45309;
  --gray-soft: #f1f3f5;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / 4%);
  --shadow-lift: 0 4px 14px rgb(16 24 40 / 8%);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
  padding: 18px 10px; background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; }
.brand strong { display: block; font-size: 14px; }
.brand span { color: var(--muted); font-size: 12px; }
.brand-logo {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none;
  border-radius: 9px; background: var(--blue); color: #fff;
}
.brand-logo svg { fill: #fff; stroke: none; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px;
  border: 1px solid transparent; border-radius: 10px;
  transition: background 150ms var(--ease);
}
.nav a:hover { background: var(--surface-2); }
.nav a:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.nav b { display: block; font-weight: 600; font-size: 13px; }
.nav small { color: var(--muted); font-size: 11.5px; }
.nav-ico {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none;
  border-radius: 8px; background: var(--gray-soft); color: var(--text-2);
}
.nav a.active { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-lift); }
.nav a.active .nav-ico { background: var(--blue); color: #fff; }
.account {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 10px; border: 1px solid var(--border); border-radius: 10px;
}
.account b { display: block; font-size: 13px; }
.account small { color: var(--muted); font-size: 11.5px; }
.avatar {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none;
  border-radius: 8px; background: var(--text); color: #fff; font-weight: 600;
}

/* Topbar */
.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.pill-blue { background: var(--blue-soft); border-color: transparent; color: var(--blue-text); }

.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-head-main { display: flex; gap: 12px; align-items: flex-start; }
.card-ico { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--blue-soft); color: var(--blue); }
.card h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-2); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi { padding: 4px 20px; border-left: 1px solid var(--border); }
.kpi:first-child { border-left: 0; padding-left: 0; }
.kpi .label { display: flex; align-items: center; gap: 6px; }
.kpi .label svg { width: 14px; height: 14px; }
.kpi strong { display: block; margin: 10px 0 4px; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi-bad strong { color: var(--red); }

/* Chips */
.chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.chip-todo { background: var(--gray-soft); color: var(--text-2); }
.chip-doing { background: var(--blue-soft); color: var(--blue-text); }
.chip-blocked { background: var(--amber-soft); color: var(--amber-text); }
.chip-done { background: var(--green-soft); color: var(--green-text); }
.chip-late { background: var(--red-soft); color: var(--red-text); }
.chip-id { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-family: ui-monospace, SFMono-Regular, monospace; font-weight: 500; }

/* Progress */
.bar { height: 4px; border-radius: 4px; background: var(--gray-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--blue); transform-origin: left; animation: grow 700ms var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }

/* Journey */
.journey {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 28px 34px; padding: 28px;
  border-radius: 10px; background: var(--surface-2);
  background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 16px 16px;
}
.node {
  position: relative; padding: 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease);
}
.node:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.node:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.node:not(:nth-child(5n))::after {
  content: ""; position: absolute; right: -30px; top: 50%; width: 22px; height: 2px; background: var(--blue);
}
.node:not(:nth-child(5n))::before {
  content: ""; position: absolute; right: -32px; top: calc(50% - 4px);
  border: 5px solid transparent; border-left-color: var(--blue);
}
.node-head { display: flex; justify-content: space-between; gap: 6px; align-items: flex-start; }
.node b { font-size: 12px; font-weight: 600; line-height: 1.3; }
.node small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.node hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0 8px; }
.node .label { font-size: 9.5px; color: var(--muted); }
.node strong { display: block; font-size: 18px; font-weight: 600; margin: 2px 0 8px; }
.node-current { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

/* Tables */
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.rows { display: flex; flex-direction: column; }
.row {
  display: grid; grid-template-columns: 62px 1fr auto auto; gap: 12px; align-items: center;
  padding: 11px 4px; border-top: 1px solid var(--border); text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0;
  transition: background 150ms var(--ease);
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--surface-2); }
.row:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.row-title { font-weight: 500; }
.row-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.empty { color: var(--muted); padding: 12px 4px; }

/* Toolbar */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.segmented button { border: 0; background: none; padding: 6px 11px; border-radius: 6px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-lift); }
select, input[type="search"] {
  font: inherit; font-size: 12px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text);
}
input[type="search"] { min-width: 220px; }

/* Kanban */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.column { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 200px; }
.column-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.column-head b { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.column-head span { color: var(--muted); font-size: 12px; font-weight: 500; }
.cards { display: flex; flex-direction: column; gap: 8px; }
.task-card {
  display: flex; flex-direction: column; gap: 9px; width: 100%; padding: 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease), border-color 200ms var(--ease);
}
.task-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--border-strong); }
.task-card:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.task-card-top { display: flex; gap: 6px; flex-wrap: wrap; }
.task-card b { font-weight: 500; line-height: 1.4; }
.task-card-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 11.5px; }

/* Gantt */
.gantt { overflow: auto; max-height: calc(100vh - 210px); border: 1px solid var(--border); border-radius: 10px; }
.g-inner { position: relative; }
.g-head, .g-row { display: grid; grid-template-columns: var(--label) 1fr; }
.g-head { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--border); }
.g-label {
  position: sticky; left: 0; z-index: 2; padding: 0 12px; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; align-items: center; gap: 8px; min-width: 0;
}
.g-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-days { position: relative; height: 44px; }
.g-day { position: absolute; top: 0; bottom: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 6px; font-size: 10px; color: var(--muted); }
.g-day.mon { color: var(--text); font-weight: 600; }
.g-month { position: absolute; top: 6px; font-size: 10.5px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; padding-left: 4px; }
.g-shade { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(-45deg, var(--surface-2), var(--surface-2) 4px, #eef0f3 4px, #eef0f3 5px); }
.g-row { height: 34px; border-bottom: 1px solid #f0f1f4; }
.g-row.phase { background: var(--surface-2); height: 38px; }
.g-row.phase .g-label { background: var(--surface-2); font-weight: 600; }
.g-track { position: relative; }
.g-bar {
  position: absolute; top: 9px; height: 16px; border-radius: 5px; border: 0; padding: 0;
  background: #c9d7f8; transition: filter 150ms var(--ease);
}
.g-bar:hover { filter: brightness(0.94); }
.g-bar:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.g-bar.doing { background: var(--blue); }
.g-bar.done { background: #86d4a2; }
.g-bar.blocked { background: #f5c27a; }
.g-bar.late { background: #f3a3a3; }
.g-bar.phase-bar { top: 12px; height: 14px; background: transparent; border: 1.5px solid var(--blue); }
.g-bar.phase-bar > i { display: block; height: 100%; background: var(--blue-soft); border-radius: 3px; }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); z-index: 1; pointer-events: none; }
.g-today::before { content: "hoje"; position: absolute; top: 2px; left: 4px; font-size: 9.5px; font-weight: 600; color: var(--red); }
.g-golive { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed var(--green); z-index: 1; pointer-events: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-2); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 8px; border-radius: 3px; }

/* Edição */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 12.5px; font-weight: 600; transition: filter 150ms var(--ease), transform 150ms var(--ease); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn-primario { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primario:hover { filter: brightness(1.08); }
.btn-perigo { color: var(--red-text); border-color: #f3c4c4; background: var(--surface); }
.btn-perigo:hover, .btn-perigo[data-confirmar="1"] { background: var(--red-soft); }
.form { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 18px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.form input, .form select { font: inherit; font-size: 13px; font-weight: 400; letter-spacing: 0; text-transform: none; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); }
.form input:focus, .form select:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-acoes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
.editando .board .task-card { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.fantasma { position: fixed; top: 0; left: 0; z-index: 40; pointer-events: none; margin: 0; transition: none; box-shadow: 0 14px 34px rgb(16 24 40 / 18%); border-color: var(--blue); }
body.arrastando-card, body.arrastando-card * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.task-card.arrastando { opacity: 0.45; }
.column { transition: border-color 150ms var(--ease), background 150ms var(--ease); }
.column.drop-alvo { border-color: var(--blue); background: var(--blue-soft); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; transform: translateX(-50%); padding: 10px 16px; border-radius: 10px; background: var(--text); color: #fff; font-size: 12.5px; font-weight: 500; box-shadow: var(--shadow-lift); animation: fade 200ms var(--ease); max-width: calc(100% - 32px); }
.toast-ruim { background: var(--red-text); }

/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgb(17 24 39 / 25%); z-index: 20; animation: fade 200ms var(--ease); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 21; width: min(440px, 100%);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -12px 0 32px rgb(16 24 40 / 12%);
  padding: 22px 24px; overflow-y: auto; animation: slide 300ms var(--ease);
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-close { float: right; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; width: 32px; height: 32px; display: grid; place-items: center; }
.drawer h2 { font-size: 18px; font-weight: 600; margin: 14px 0 10px; line-height: 1.35; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 18px 0; }
.facts div { background: var(--surface); padding: 12px; }
.facts .label { font-size: 10px; color: var(--muted); }
.facts b { display: block; margin-top: 4px; font-weight: 600; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 18px; }
.links button { border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 6px 9px; font-size: 12px; text-align: left; }
.links button:hover { border-color: var(--blue); color: var(--blue-text); }
.note { padding: 12px; border-radius: 10px; background: var(--blue-soft); color: var(--blue-text); font-size: 12px; }

.error { padding: 20px; border-radius: var(--radius); background: var(--red-soft); color: var(--red-text); }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 18px; }
  .kpi:nth-child(4) { border-left: 0; padding-left: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .journey { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
  .node::after, .node::before { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .brand > div, .account, .nav small { display: none; }
  .nav { flex-direction: row; }
  .nav a { padding: 6px 10px 6px 6px; gap: 8px; white-space: nowrap; }
  .topbar { position: static; padding: 14px 16px; }
  .content { padding: 16px 16px 40px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-left: 0; padding: 4px 0; }
  .journey { padding: 14px; }
  .row { grid-template-columns: 54px 1fr; }
  .row .row-meta, .row .chip:not(.chip-id) { grid-column: 2; justify-self: start; }
  input[type="search"] { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
