/* ==========================================================
   movfit — Cornell Red / Jet / Silver / Anti-Flash White
   ========================================================== */

:root {
  /* surfaces */
  --bone: #EFEFEF;          /* anti-flash white */
  --bone-2: #E5E5E5;
  --paper: #FFFFFF;
  --paper-warm: #F6F6F6;
  --ink: #292929;            /* jet */
  --ink-2: #3A3A3A;
  --muted: #6B6B6B;
  --muted-2: #BEBEBE;        /* silver */
  --line: #D8D8D8;
  --line-soft: #E5E5E5;
  --line-strong: #BEBEBE;

  /* accent — cornell red */
  --saffron: #AE040F;
  --saffron-deep: #8A0309;
  --saffron-soft: #F2D2D5;
  --saffron-tint: #FBE9EA;

  /* status (mapped to brand) */
  --sage: #2F7A4D;
  --sage-soft: #D5E8DC;
  --brick: #AE040F;
  --brick-soft: #F2D2D5;
  --slate: #292929;
  --slate-soft: #DDDDDD;

  /* type — executive sans, Apple-inspired */
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* radius */
  --r-xs: 2px;
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  /* shadows */
  --sh-sm: 0 1px 0 rgba(20,23,28,.04), 0 1px 2px rgba(20,23,28,.04);
  --sh-md: 0 1px 0 rgba(20,23,28,.04), 0 8px 22px rgba(20,23,28,.06);
  --sh-lg: 0 30px 60px rgba(20,23,28,.10);
}

* { box-sizing: border-box; }

html, body, #root { height: 100%; }

body {
  margin: 0;
  background: var(--bone);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* very subtle paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(41,41,41,.018) 1px, transparent 0);
  background-size: 4px 4px;
  z-index: 0;
  opacity: .5;
}

button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

input, select, textarea { font: inherit; color: inherit; }

.icon,
svg.icon {
  width: 16px;
  height: 16px;
  max-width: 16px;
  max-height: 16px;
  flex: 0 0 16px;
  display: inline-block;
  vertical-align: middle;
}

::selection { background: var(--saffron-soft); color: var(--ink); }

/* ============= APP SHELL ============= */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: #D9D6CE;
  display: flex;
  flex-direction: column;
  padding: 22px 18px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid #1F232A;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 4px 22px;
}
.brand-mark {
  width: 48px; height: 48px;
  border-radius: var(--r-sm);
  background: transparent;
  display: grid; place-items: center;
  position: relative;
  padding: 0;
  border: none;
}
.brand-mark img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.brand-name {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: #EFEFEF;
  line-height: 1;
  text-transform: lowercase;
}
.brand-sub {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #BEBEBE;
  margin-top: 4px;
  display: block;
}

.nav-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #6F7269;
  padding: 14px 10px 6px;
}

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: #C9C5BA;
  cursor: pointer;
  font-size: 13.5px;
  border: 1px solid transparent;
  position: relative;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: #F2EDE2; }
.nav-item.active {
  background: #1F232A;
  color: #FBF1DE;
  border-color: #2A2F37;
}
.nav-item.active::before {
  content: ""; position: absolute; left: -18px; top: 8px; bottom: 8px;
  width: 2px; background: var(--saffron);
}
.nav-item .icon { width: 16px; height: 16px; opacity: .8; flex: 0 0 16px; }
.nav-item .badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--saffron);
  background: rgba(213,138,58,.10);
  padding: 1px 6px;
  border-radius: 3px;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #1F232A;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #AE040F, #8A0309);
  display: grid; place-items: center;
  color: var(--paper);
  font-weight: 600;
  font-size: 13px;
  font-family: var(--sans);
}
.user-name { color: #F2EDE2; font-size: 13px; line-height: 1.1; }
.user-role {
  font-family: var(--mono); font-size: 9px;
  letter-spacing: .12em; text-transform: uppercase;
  color: #80847C; margin-top: 3px;
}
.signout {
  margin-left: auto;
  background: transparent; border: 1px solid #2A2F37;
  color: #C9C5BA; padding: 6px 8px; border-radius: var(--r-sm);
  cursor: pointer; display: grid; place-items: center;
}
.signout:hover { color: #F2EDE2; border-color: #3A4049; }

/* ============= MAIN ============= */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  min-height: 74px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(242,237,226,.7);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 10;
}
.crumbs {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
  display: flex; align-items: center; gap: 10px;
}
.crumbs .sep { color: var(--line-strong); }
.crumbs .now { color: var(--ink); }

.search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0 12px;
  width: min(320px, 32vw);
  height: 42px;
  color: var(--muted);
}
.search > svg.icon {
  width: 18px !important;
  height: 18px !important;
  max-width: 18px !important;
  max-height: 18px !important;
  flex: 0 0 18px !important;
  color: var(--muted);
}
.search input {
  border: 0; background: transparent; outline: none; flex: 1;
  min-width: 0;
  font-size: 13px; color: var(--ink);
}
.search kbd {
  font-family: var(--mono); font-size: 10px;
  background: var(--paper); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 3px; color: var(--muted);
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--paper);
  display: grid; place-items: center;
  cursor: pointer; color: var(--ink-2);
}
.icon-btn > svg.icon {
  width: 17px !important;
  height: 17px !important;
  max-width: 17px !important;
  max-height: 17px !important;
  flex: 0 0 17px !important;
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn .dot {
  position: absolute; transform: translate(8px, -8px);
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--saffron); border: 2px solid var(--paper);
}

/* ============= PAGE ============= */
.page { padding: 28px 32px 60px; flex: 1; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.page-eyebrow {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--saffron-deep);
  margin-bottom: 6px;
}
.page-title {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.02em;
  margin: 0;
  font-weight: 400;
}
.page-title em {
  font-style: normal;
  font-weight: 600;
  color: var(--saffron);
}
.page-sub {
  color: var(--muted); margin: 10px 0 0; max-width: 60ch;
  font-size: 14px;
}
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ============= BUTTONS ============= */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all .12s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn-primary {
  background: var(--ink);
  color: var(--bone);
  border-color: var(--ink);
}
.btn-primary:hover { background: #000; }
.btn-accent {
  background: var(--saffron);
  color: var(--paper);
  border-color: var(--saffron-deep);
}
.btn-accent:hover { background: var(--saffron-deep); color: var(--paper-warm); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--paper); border-color: var(--line); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn .icon { width: 14px; height: 14px; }

/* ============= METRIC CARDS ============= */
.metric-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 28px;
  min-height: 126px;
}
.metric {
  padding: 20px 26px 18px;
  border-right: 1px solid var(--line);
  position: relative;
  background: var(--paper);
  min-width: 0;
  min-height: 126px;
  display: flex;
  flex-direction: column;
}
.metric:last-child { border-right: 0; }
.metric-label {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
  display: flex; align-items: center; gap: 6px;
  line-height: 1.25;
  min-height: 16px;
}
.metric-label > svg.icon {
  width: 13px !important;
  height: 13px !important;
  max-width: 13px !important;
  max-height: 13px !important;
  flex: 0 0 13px !important;
  color: var(--saffron-deep);
}
.metric-value {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  margin-top: 14px;
  letter-spacing: -.02em;
  font-weight: 400;
  display: flex; align-items: baseline; gap: 8px;
  min-width: 0;
  white-space: nowrap;
}
.metric-value .unit {
  font-family: var(--sans);
  font-size: 12px; color: var(--muted);
  letter-spacing: 0; font-weight: 500;
  white-space: nowrap;
}
.metric-delta {
  margin-top: auto;
  font-family: var(--mono); font-size: 11px;
  display: flex; align-items: center; gap: 6px;
  color: var(--muted);
  line-height: 1.3;
  max-width: 160px;
}
.metric-delta > svg.icon {
  width: 16px !important;
  height: 16px !important;
  max-width: 16px !important;
  max-height: 16px !important;
  flex: 0 0 16px !important;
}
.metric-delta.up { color: var(--sage); }
.metric-delta.down { color: var(--brick); }

/* ============= PANELS ============= */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-warm);
}
.panel-title {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0;
  font-weight: 400;
  display: flex; align-items: center; gap: 10px;
}
.panel-title .count {
  font-family: var(--mono); font-size: 10px;
  color: var(--muted);
  background: var(--bone-2);
  padding: 2px 6px; border-radius: 3px;
  letter-spacing: .08em;
}
.panel-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.panel-body { padding: 0; }

.cadastro-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.cadastro-card {
  padding: 18px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
}
.cadastro-card h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
}
.cadastro-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.cadastro-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -10px 0 18px;
}
.section-tab {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}
.section-tab:hover {
  border-color: var(--ink);
}
.section-tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* ============= TABLE ============= */
.t {
  width: 100%; border-collapse: collapse;
}
.t th, .t td {
  padding: 12px 20px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.t th {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  background: var(--paper-warm);
  border-bottom: 1px solid var(--line);
}
.t tbody tr { transition: background .1s; cursor: pointer; }
.t tbody tr:hover { background: var(--paper-warm); }
.t tbody tr:last-child td { border-bottom: 0; }
.t .num { font-family: var(--mono); text-align: right; }
.t .code { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.t .strong { font-weight: 500; color: var(--ink); }
.t a { color: var(--ink); border-bottom: 1px solid transparent; }
.t a:hover { border-bottom-color: var(--saffron); }

/* ============= PILLS / CHIPS ============= */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--bone-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
}
.pill.sage  { background: var(--sage-soft); color: #3F5740; border-color: #C8D5C2; }
.pill.brick { background: var(--brick-soft); color: #8C3A28; border-color: #E5BFB4; }
.pill.saff  { background: var(--saffron-tint); color: var(--saffron-deep); border-color: var(--saffron-soft); }
.pill.slate { background: var(--slate-soft); color: #2F4150; border-color: #BCCBD3; }
.pill.muted { background: var(--bone-2); color: var(--muted); }
.pill.plain { background: transparent; }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
}

/* ============= FORMS ============= */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
}
.field input, .field select, .field textarea {
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  font-size: 14px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(213,138,58,.15);
}

/* ============= LOGIN ============= */
.auth {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--bone);
}
.auth-stage {
  background: var(--ink);
  color: var(--bone);
  padding: 48px;
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-stage::before {
  /* blueprint grid */
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(213,138,58,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(213,138,58,.06) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
}
.auth-stage::after { content: none; }
.auth-brand { display: flex; align-items: center; gap: 12px; position: relative; }
.auth-stage h1 {
  position: relative;
  font-family: var(--display);
  font-size: 52px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -.025em;
  margin: 0 0 18px;
  font-weight: 400;
  max-width: 12ch;
}
.auth-stage h1 em { color: var(--saffron); font-style: normal; font-weight: 600; }
.auth-stage p {
  position: relative;
  font-size: 15px;
  color: #B7B3A6;
  max-width: 44ch;
  line-height: 1.55;
}
.auth-meta {
  position: relative;
  display: flex; gap: 32px;
  font-family: var(--mono); font-size: 11px;
  color: #80847C;
  text-transform: uppercase; letter-spacing: .14em;
}
.auth-meta strong { display: block; color: var(--bone); font-family: var(--display); font-size: 22px; letter-spacing: -.01em; text-transform: none; margin-bottom: 4px; font-weight: 600; }

.auth-form {
  display: grid; place-items: center;
  padding: 48px;
}
.auth-card {
  width: 100%; max-width: 380px;
}
.auth-eyebrow {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--saffron-deep);
  margin-bottom: 12px;
}
.auth-card h2 {
  font-family: var(--display); font-size: 28px; line-height: 1.1;
  letter-spacing: -.02em; margin: 0 0 8px;
  font-weight: 600;
}
.auth-card .lede { color: var(--muted); margin: 0 0 28px; }

.auth-fields { display: flex; flex-direction: column; gap: 16px; }

.auth-foot {
  margin-top: 22px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted);
}
.auth-foot a { color: var(--ink); border-bottom: 1px solid var(--line-strong); }

/* ============= MISC ============= */
.row-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.row-2-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

.kv {
  display: grid; grid-template-columns: 130px 1fr;
  row-gap: 12px; column-gap: 16px;
  padding: 18px 20px;
}
.kv dt {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
}
.kv dd { margin: 0; font-size: 14px; }

.bar {
  height: 4px; background: var(--bone-2); border-radius: 2px; overflow: hidden;
  position: relative;
}
.bar > i {
  display: block; height: 100%;
  background: var(--saffron);
}
.bar.thin { height: 3px; }

.divider {
  height: 1px; background: var(--line-soft); margin: 0;
}

.empty {
  padding: 46px 20px; text-align: center; color: var(--muted);
  font-size: 13px;
}
.empty .icon { width: 22px; height: 22px; color: var(--muted-2); margin-bottom: 8px; }

/* ============= TIMELINE / WORKFLOW ============= */
.flow {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
  margin: 6px 0 22px;
}
.flow-step {
  position: relative;
  padding: 14px 16px 16px;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-right: 0;
}
.flow-step:last-child { border-right: 1px solid var(--line); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.flow-step:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.flow-step .n {
  font-family: var(--mono); font-size: 10px;
  color: var(--muted-2); letter-spacing: .12em;
}
.flow-step .lbl {
  font-family: var(--display); font-size: 14px; font-weight: 600;
  margin-top: 6px; line-height: 1;
}
.flow-step .meta {
  font-family: var(--mono); font-size: 10px;
  color: var(--muted); margin-top: 8px;
  letter-spacing: .06em; text-transform: uppercase;
}
.flow-step.done { background: var(--ink); color: var(--bone); border-color: var(--ink); }
.flow-step.done .n { color: var(--saffron); }
.flow-step.done .meta { color: #B7B3A6; }
.flow-step.now {
  background: var(--saffron-tint);
  border-color: var(--saffron-soft);
}
.flow-step.now .n { color: var(--saffron-deep); }
.flow-step.now .meta { color: var(--saffron-deep); }

/* gantt */
.gantt {
  padding: 18px 20px 22px;
}
.gantt-head, .gantt-row {
  display: grid;
  grid-template-columns: 220px 1fr 60px;
  align-items: center; gap: 14px;
}
.gantt-head {
  font-family: var(--mono); font-size: 10px;
  color: var(--muted); letter-spacing: .12em; text-transform: uppercase;
  padding-bottom: 10px; border-bottom: 1px solid var(--line-soft);
  margin-bottom: 8px;
}
.gantt-months { display: flex; justify-content: space-between; }
.gantt-months span { flex: 1; }
.gantt-row { padding: 10px 0; border-bottom: 1px dashed var(--line-soft); }
.gantt-row:last-child { border-bottom: 0; }
.gantt-name { font-size: 13px; }
.gantt-name .sub { display: block; color: var(--muted); font-size: 11px; font-family: var(--mono); margin-top: 2px; }
.gantt-track {
  position: relative; height: 22px;
  background:
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px) 0 0/16.66% 100%,
    var(--paper-warm);
  border-radius: 3px;
  overflow: hidden;
}
.gantt-bar {
  position: absolute; top: 4px; bottom: 4px;
  border-radius: 2px;
  background: var(--saffron);
  display: flex; align-items: center; padding: 0 8px;
  color: var(--ink); font-family: var(--mono); font-size: 10px;
}
.gantt-bar.done { background: var(--ink); color: var(--bone); }
.gantt-bar.future { background: repeating-linear-gradient(45deg, var(--saffron-soft), var(--saffron-soft) 4px, transparent 4px, transparent 8px); color: var(--saffron-deep); border: 1px solid var(--saffron-soft); }
.gantt-pct { font-family: var(--mono); font-size: 11px; text-align: right; color: var(--muted); }

/* spark */
.spark {
  display: flex; align-items: end; gap: 3px;
  height: 36px;
}
.spark > i {
  flex: 1; background: var(--bone-2); border-radius: 1px;
  transition: background .2s;
}
.spark > i.hi { background: var(--saffron); }
.spark > i.lo { background: var(--ink-2); }

/* segmented */
.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--paper);
  padding: 2px;
}
.seg button {
  background: transparent; border: 0;
  padding: 6px 12px; font-size: 12px;
  border-radius: 3px; cursor: pointer;
  color: var(--muted);
}
.seg button.on { background: var(--ink); color: var(--bone); }

/* mini avatars */
.stack { display: inline-flex; }
.stack .a {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bone-2); color: var(--ink-2);
  border: 2px solid var(--paper);
  display: grid; place-items: center;
  font-size: 10px; font-weight: 600;
  margin-left: -6px;
}
.stack .a:first-child { margin-left: 0; }

/* photo placeholders */
.photo {
  background:
    repeating-linear-gradient(135deg, transparent 0 6px, rgba(20,23,28,.04) 6px 12px),
    var(--bone-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--muted-2); font-family: var(--mono); font-size: 10px;
  letter-spacing: .14em; text-transform: uppercase;
  aspect-ratio: 4/3;
}

/* kanban */
.kan { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kan-col {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  min-height: 360px;
}
.kan-col h3 {
  margin: 0 0 12px;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
}
.kan-col h3 .c {
  font-family: var(--mono); background: var(--paper);
  border: 1px solid var(--line); padding: 1px 6px; border-radius: 3px;
  color: var(--ink-2);
}
.kan-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px;
  margin-bottom: 10px;
  cursor: grab;
}
.kan-card .ttl { font-size: 13px; font-weight: 500; }
.kan-card .meta {
  font-family: var(--mono); font-size: 10px;
  color: var(--muted); margin-top: 8px;
  display: flex; justify-content: space-between; align-items: center;
}

/* tabs */
.tabs {
  display: flex; gap: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
.tabs button {
  background: transparent; border: 0;
  padding: 12px 0;
  font-size: 13px; color: var(--muted);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
  display: flex; align-items: center; gap: 8px;
}
.tabs button .c {
  font-family: var(--mono); font-size: 10px;
  background: var(--bone-2); padding: 1px 6px;
  border-radius: 3px; color: var(--muted);
}
.tabs button:hover { color: var(--ink); }
.tabs button.on {
  color: var(--ink);
  border-bottom-color: var(--saffron);
  font-weight: 500;
}
.tabs button.on .c { background: var(--saffron-tint); color: var(--saffron-deep); }
.tabs { overflow-x: auto; }
.tabs button { flex: 0 0 auto; white-space: nowrap; }

/* Painéis de aba (detalhe da obra) */
.tab-panel[hidden] { display: none; }
.tab-panel { animation: tab-fade .18s ease; }
@keyframes tab-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Estado vazio dentro de painéis/tabelas */
.empty { color: var(--muted); font-size: 13px; padding: 18px 20px; text-align: center; }
td.empty { padding: 16px; }

/* Blocos de etapa / solicitação */
.etapa-bloco { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.etapa-bloco:last-child { border-bottom: 0; }
.etapa-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.etapa-head .sub { display: block; }

/* Totais (resumo de orçamento / financeiro) */
.totais {
  display: grid; grid-template-columns: 1fr auto;
  gap: 10px 24px; max-width: 420px; margin: 4px 20px 18px auto;
  padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--r-md);
}
.totais.totais-wide { max-width: none; margin: 4px 20px 18px; }
.totais dt { color: var(--muted); font-size: 13px; }
.totais dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 13px; }
.totais .grand-dt, .totais .grand-dd {
  border-top: 1px solid var(--line); padding-top: 10px; margin-top: 2px;
  font-weight: 700; font-size: 15px; color: var(--ink);
}
.totais .sage-num { color: var(--sage, #4a7a5a); }
.totais .brick-num { color: var(--brick, #b0553d); }

/* scroll niceties */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 2px solid var(--bone); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1180px) {
  .app { grid-template-columns: 220px 1fr; }
  .topbar { padding-inline: 24px; }
  .page { padding-inline: 24px; }
  .metric-row { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .row-2 { grid-template-columns: 1fr; }
  .cadastro-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }
  .topbar {
    position: static;
    flex-wrap: wrap;
    min-height: 0;
    gap: 10px;
  }
  .crumbs { width: 100%; }
  .search {
    order: 2;
    width: 100%;
  }
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .page-title { font-size: 28px; line-height: 1.1; }
  .metric-row { grid-template-columns: 1fr; }
  .metric,
  .metric:nth-child(2),
  .metric:nth-child(-n+2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .metric:last-child { border-bottom: 0; }
  .t { min-width: 680px; }
  .panel-body { overflow-x: auto; }
  .cadastro-grid { grid-template-columns: 1fr; }
}

/* ==========================================================
   Tema escuro — ativado por [data-theme="dark"] no <html>
   ========================================================== */
[data-theme="dark"] {
  --bone: #13161B;
  --bone-2: #171B21;
  --paper: #1B1F26;
  --paper-warm: #222730;
  --ink: #E9EAEC;
  --ink-2: #CFD2D7;
  --muted: #9BA1AB;
  --muted-2: #5C636E;
  --line: #2A303A;
  --line-soft: #232931;
  --line-strong: #3A424E;

  --saffron: #F2555C;
  --saffron-deep: #D23F46;
  --saffron-soft: #3A1F22;
  --saffron-tint: #2A1719;

  --sage: #54C98A;
  --sage-soft: #16321F;
  --brick: #F2555C;
  --brick-soft: #3A1F22;
  --slate: #C9D2DC;
  --slate-soft: #222932;

  --sh-sm: 0 1px 2px rgba(0,0,0,.40);
  --sh-md: 0 8px 22px rgba(0,0,0,.45);
  --sh-lg: 0 30px 60px rgba(0,0,0,.55);

  color-scheme: dark;
}

/* superfícies que usam --ink como FUNDO (não como texto) precisam de override */
[data-theme="dark"] .sidebar { background: #0E1115; color: #C9CCD2; border-right-color: #20242B; }
[data-theme="dark"] .topbar  { background: rgba(16,18,22,.72); }
[data-theme="dark"] body::before { opacity: 0; }

/* botão accent permanece com texto branco sobre o vermelho */
[data-theme="dark"] .btn-accent { color: #FFFFFF; }

/* pills: texto/bordas legíveis sobre fundos escuros */
[data-theme="dark"] .pill.sage  { color: #9FE3B8; border-color: #234A33; }
[data-theme="dark"] .pill.brick { color: #F4A39F; border-color: #5A2E2C; }
[data-theme="dark"] .pill.slate { color: #AEBDC9; border-color: #37414C; }

/* campos de formulário e select nativos */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: var(--paper-warm); border-color: var(--line); }

/* elementos que usam --ink como FUNDO (chip/ativo/botão) — manter superfície escura
   com texto claro no tema escuro, em vez de inverter para fundo claro */
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .section-tab.active,
[data-theme="dark"] .flow-step.done,
[data-theme="dark"] .gantt-bar.done,
[data-theme="dark"] .seg button.on {
  background: #2C323D; color: #E9EAEC; border-color: #2C323D;
}
[data-theme="dark"] .btn-primary:hover { background: #39414D; }
[data-theme="dark"] .auth-stage { background: #0E1115; color: #C9CCD2; }
[data-theme="dark"] .period-tab.active { background: #2C323D; color: #E9EAEC; }

/* ==========================================================
   Modal genérico (confirmações via HTMX)
   ========================================================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(10,12,16,.55); backdrop-filter: blur(3px);
  animation: modalFade .15s ease;
}
.modal-box {
  width: 100%; max-width: 460px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-lg); overflow: hidden;
  animation: modalPop .16s ease;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
}
.modal-title { font-family: var(--display); font-size: 16px; font-weight: 600; margin: 0; }
.modal-body { padding: 20px; font-size: 14px; color: var(--ink); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--line-soft); background: var(--paper-warm);
}
.btn-danger { background: var(--brick); color: #fff; border-color: var(--brick); }
.btn-danger:hover { background: var(--saffron-deep); color: #fff; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
