/* ================================================================
   CORRIDA DE CONTRATOS v2 — PIT WALL
   Carbon-fibre editorial racing aesthetic
   ================================================================ */

/* ---- Dark theme (default) ---- */
:root {
  --bg:    #0c0d0f;
  --panel: #141619;
  --panel-2:#181b1f;
  --inset: #101214;
  --line:  #24282e;
  --line-2:#31363d;
  --line-3:#41474f;
  --ink:   #eef0f2;
  --dim:   #969ca4;
  --faint: #5e646c;
  --accent:#ff4326;
  --accent-soft:rgba(255,67,38,.14);
  --go:    #3fd29a;
  --warn:  #f3b13a;
  --info:  #7aa2ff;
  --grid:  rgba(255,255,255,.025);
  --shadow:0 1px 0 rgba(255,255,255,.03), 0 24px 60px -32px rgba(0,0,0,.7);
  --font:  "Archivo", sans-serif;
  --mono:  "IBM Plex Mono", monospace;
  --transition: .2s ease;
}

/* ---- Light theme ---- */
[data-theme="light"] {
  --bg:    #e9e7e0;
  --panel: #f6f5f1;
  --panel-2:#f1efe9;
  --inset: #eae8e1;
  --line:  #dad7cd;
  --line-2:#cbc7bb;
  --line-3:#b6b1a3;
  --ink:   #181a1d;
  --dim:   #6c7178;
  --faint: #9a9890;
  --accent:#e03415;
  --accent-soft:rgba(224,52,21,.1);
  --go:    #1f9e6e;
  --warn:  #c98412;
  --info:  #3a63c4;
  --grid:  rgba(0,0,0,.025);
  --shadow:0 1px 0 rgba(255,255,255,.5), 0 24px 50px -34px rgba(60,55,40,.45);
}

/* ================================================================
   RESET & BASE
   ================================================================ */

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.55;
  overflow-x: hidden;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  outline: none;
  transition: all var(--transition);
}

input, select, textarea {
  font-family: inherit;
  font-size: .95rem;
}

h1, h2, h3, h4 {
  font-family: var(--font);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.02em;
}

ul { list-style: none; }

/* ================================================================
   SCROLLBAR
   ================================================================ */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-3); }

/* ================================================================
   HEADER
   ================================================================ */

#app-header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 62px;
  position: sticky;
  top: 0;
  z-index: 100;
}

#app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* BL mark — CSS mask so it inherits --ink color */
.mark {
  width: 28px;
  height: 27px;
  background: var(--ink);
  -webkit-mask: url(/static/img/bl-mark.svg) center/contain no-repeat;
  mask: url(/static/img/bl-mark.svg) center/contain no-repeat;
  flex-shrink: 0;
}

/* Brand wordmark: stacked BAPTISTA LEAL / GRUPO */
.brand-txt {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 3px;
}

.brand-txt b {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  color: var(--ink);
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-txt span {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .38em;
  color: var(--faint);
  text-transform: uppercase;
}

/* System name pill — red mono text with left border separator */
.sysname {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .3em;
  color: var(--accent);
  text-transform: uppercase;
  padding-left: 18px;
  border-left: 1px solid var(--line-2);
  white-space: nowrap;
  font-feature-settings: "zero";
}

/* Keep legacy selectors from breaking */
#app-logo .logo-img { height: 28px; width: auto; opacity: .9; }
#app-logo .logo-text { display: flex; flex-direction: column; line-height: 1.1; }
#app-logo .logo-title { font-family: var(--font); font-size: .82rem; font-weight: 800; color: var(--ink); }

#app-nav {
  display: flex;
  gap: .4rem;
  flex: 1;
}

.nav-btn {
  background: transparent;
  color: var(--dim);
  padding: .5rem .9rem;
  border-radius: 0;
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .02em;
  border: none;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: .4rem;
  position: relative;
}

.nav-btn:hover {
  color: var(--ink);
}

.nav-btn.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

#app-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}

.user-badge {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .3rem .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
}

.user-badge .user-name {
  color: var(--ink);
  font-weight: 500;
  font-family: var(--mono);
  font-feature-settings: "zero";
}

.user-badge .user-role {
  color: var(--faint);
  font-size: .7rem;
  font-family: var(--mono);
  font-feature-settings: "zero";
}

/* Avatar initials circle */
.av {
  width: 28px;
  height: 28px;
  border-radius: 3px;
  background: var(--inset);
  border: 1px solid var(--line-2);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

/* Sync status indicator */
.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
}
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
  transition: background .3s;
}
.sync-dot.online  { background: var(--go); }
.sync-dot.offline { background: var(--accent); }
.sync-text {
  font-size: .7rem;
  color: var(--faint);
  font-family: var(--mono);
  font-feature-settings: "zero";
  white-space: nowrap;
}

/* Header action buttons */
.btn-header {
  background: var(--panel-2);
  color: var(--dim);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 0 13px;
  height: 34px;
  font-size: 11px;
  font-family: var(--mono);
  font-feature-settings: "zero";
  letter-spacing: .06em;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-header svg { width: 13px; height: 13px; flex-shrink: 0; }
.btn-header:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-header:disabled {
  opacity: .5;
  cursor: wait;
}

.btn-logout {
  background: transparent;
  color: var(--faint);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 0 13px;
  height: 34px;
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: .06em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-logout svg { width: 13px; height: 13px; }

.btn-logout:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Theme toggle button */
.btn-theme {
  background: transparent;
  color: var(--faint);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s;
}

.btn-theme svg { width: 15px; height: 15px; }
.btn-theme:hover {
  color: var(--warn);
  border-color: var(--warn);
}

/* Light-theme login logo */
[data-theme="light"] .login-logo-img {
  filter: brightness(.3);
}

[data-theme="light"] #login-overlay {
  background: var(--bg);
}

[data-theme="light"] #login-overlay::before {
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
}

[data-theme="light"] #login-overlay::after {
  display: none;
}

[data-theme="light"] .login-box {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

[data-theme="light"] .login-header h2 {
  color: var(--accent);
  -webkit-text-fill-color: var(--accent);
  background: none;
}

/* ================================================================
   MAIN CONTENT
   ================================================================ */

#app-main {
  max-width: 1680px;
  margin: 0 auto;
  padding: 30px 28px;
}

/* ================================================================
   LOGIN OVERLAY
   ================================================================ */

#login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow: hidden;
}

#login-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, black 20%, transparent 70%);
  animation: gridPulse 8s ease-in-out infinite;
}

#login-overlay::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  animation: glowFloat 6s ease-in-out infinite;
}

@keyframes gridPulse {
  0%, 100% { opacity: .5; }
  50% { opacity: 1; }
}

@keyframes glowFloat {
  0%, 100% { transform: translateX(-50%) translateY(0); opacity: .6; }
  50% { transform: translateX(-50%) translateY(-20px); opacity: 1; }
}

.login-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2.75rem 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
  animation: loginBoxIn .6s cubic-bezier(.16, 1, .3, 1);
}

@keyframes loginBoxIn {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.login-header {
  text-align: center;
  margin-bottom: 2.25rem;
}

.login-header .login-logo {
  font-size: 2.5rem;
  margin-bottom: .5rem;
}

.login-header .login-logo-img {
  height: 36px;
  width: auto;
  margin-bottom: 1.25rem;
  opacity: .85;
}

.login-header h2 {
  font-family: var(--font);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.login-header p {
  color: var(--faint);
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .72rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  margin-top: .35rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .72rem;
  font-weight: 500;
  color: var(--dim);
  margin-bottom: .4rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  padding: .7rem 1rem;
  transition: border-color var(--transition);
  font-size: .9rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group select option {
  background: var(--panel);
  color: var(--ink);
}

.form-error {
  color: var(--accent);
  font-size: .8rem;
  margin-top: .75rem;
  text-align: center;
  padding: .5rem;
  background: var(--accent-soft);
  border-radius: 3px;
  border: 1px solid rgba(255,67,38,.3);
}

.form-info {
  color: var(--info);
  font-size: .8rem;
  margin-top: .75rem;
  text-align: center;
  padding: .5rem;
  background: rgba(122,162,255,.1);
  border-radius: 3px;
  border: 1px solid rgba(122,162,255,.25);
}

/* ================================================================
   BUTTONS
   ================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.2rem;
  border-radius: 4px;
  font-size: .875rem;
  font-weight: 600;
  transition: all var(--transition);
  border: 1px solid transparent;
  height: 34px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  padding: .75rem;
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .04em;
  border-radius: 4px;
  height: 44px;
}

.btn-primary::after { display: none; }

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--panel-2);
  color: var(--dim);
  border-color: var(--line-2);
}

.btn-secondary:hover {
  color: var(--ink);
  border-color: var(--line-3);
}

.btn-success {
  background: rgba(63,210,154,.12);
  color: var(--go);
  border-color: rgba(63,210,154,.35);
}

.btn-success:hover {
  background: rgba(63,210,154,.2);
}

.btn-danger {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(255,67,38,.35);
}

.btn-danger:hover {
  background: rgba(255,67,38,.2);
}

.btn-ghost {
  background: transparent;
  color: var(--faint);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--ink);
  background: var(--panel-2);
}

.btn-sm {
  padding: .35rem .75rem;
  font-size: .8rem;
  height: 28px;
}

.btn-icon {
  padding: .45rem;
  font-size: 1rem;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none !important;
}

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */

#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .85rem 1.25rem;
  font-size: .85rem;
  min-width: 250px;
  max-width: 380px;
  box-shadow: var(--shadow);
  animation: toastIn .35s cubic-bezier(.16, 1, .3, 1), toastOut .3s ease 2.7s forwards;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.toast-success { border-left: 3px solid var(--go); }
.toast-error   { border-left: 3px solid var(--accent); }
.toast-info    { border-left: 3px solid var(--info); }
.toast-warning { border-left: 3px solid var(--warn); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg  { flex: 1; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ================================================================
   PAGE HEADER / VIEW TITLE
   ================================================================ */

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.view-title {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.view-title h1 {
  font-family: var(--font);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.02em;
}

.view-title .view-icon {
  font-size: 1.75rem;
}

.view-subtitle {
  color: var(--faint);
  font-size: .85rem;
  margin-top: .2rem;
  font-family: var(--mono);
  font-feature-settings: "zero";
}

/* ================================================================
   MONTH SELECTOR
   ================================================================ */

.month-selector {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .4rem .75rem;
}

.month-selector .month-btn {
  background: transparent;
  color: var(--faint);
  width: 28px;
  height: 28px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.month-selector .month-btn:hover {
  color: var(--accent);
}

.month-selector .month-label {
  font-family: var(--font);
  font-size: .88rem;
  font-weight: 700;
  color: var(--ink);
  min-width: 130px;
  text-align: center;
  text-transform: capitalize;
  letter-spacing: .01em;
}

/* ================================================================
   SEARCH & FILTER BAR
   ================================================================ */

.toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  padding: .55rem .9rem .55rem 2.2rem;
  transition: border-color var(--transition);
  height: 34px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-tabs {
  display: flex;
  gap: .3rem;
}

.filter-tab {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 3px;
  padding: .4rem .85rem;
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .02em;
  height: 34px;
  display: inline-flex;
  align-items: center;
}

.filter-tab:hover {
  border-color: var(--line-2);
  color: var(--ink);
}

.filter-tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.filter-tab.active-red {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-tab.active-green {
  background: var(--go);
  border-color: var(--go);
  color: #fff;
}

/* ================================================================
   STATS BAR  (legacy — still rendered by JS)
   ================================================================ */

.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0;
  margin-bottom: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.stat-card {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 1.1rem 1.25rem;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}

.stat-card:last-child { border-right: none; }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--line-2);
}

.stat-card::after { display: none; }

.stat-card.stat-total::before  { background: var(--info); }
.stat-card.stat-done::before   { background: var(--go); }
.stat-card.stat-progress::before { background: var(--accent); }
.stat-card.stat-overdue::before  { background: var(--accent); }
.stat-card.stat-pct::before    { background: var(--dim); }

.stat-card:hover {
  background: var(--panel-2);
}

.stat-value {
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  margin-bottom: .35rem;
  position: relative;
  z-index: 1;
  color: var(--ink);
}

.stat-card.stat-total .stat-value    { color: var(--info); }
.stat-card.stat-done .stat-value     { color: var(--go); }
.stat-card.stat-progress .stat-value { color: var(--accent); }
.stat-card.stat-overdue .stat-value  { color: var(--accent); }
.stat-card.stat-pct .stat-value      { color: var(--ink); }

.stat-label {
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .65rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

/* ================================================================
   KPI TOWER  (new 5-column grid)
   ================================================================ */

.tower {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  margin-bottom: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.kpi {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 1.1rem 1.25rem;
  position: relative;
}

.kpi:last-child { border-right: none; }

.kpi .stat-value,
.kpi .kpi-value {
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  margin-bottom: .35rem;
  color: var(--ink);
}

.kpi .stat-label,
.kpi .kpi-label {
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .65rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
}

.kpi.live {
  border-top: 3px solid var(--accent);
}

.kpi.live .stat-value,
.kpi.live .kpi-value {
  color: var(--accent);
}

/* ================================================================
   PHASE RULER
   ================================================================ */

.corrida-container {
  position: relative;
}

.phase-ruler {
  display: grid;
  grid-template-columns: 340px 1fr;
  margin: 0;
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.phase-ruler-item {
  flex: 1;
  text-align: center;
  padding: .5rem .25rem .4rem;
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .55rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--faint);
  position: relative;
  background: transparent;
  border-right: 1px solid var(--line);
}

.phase-ruler-item:last-child { border-right: none; }

.phase-ruler-item .phase-icon {
  font-size: 1rem;
  display: block;
  margin-bottom: .15rem;
}

.phase-ruler-item .phase-type {
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .44rem;
  font-weight: 500;
  opacity: .5;
  display: block;
  margin-top: .1rem;
  letter-spacing: .03em;
}

/* All phase ruler colors are now neutral */
.pr-0, .pr-1, .pr-2, .pr-3, .pr-4, .pr-5 {
  color: var(--faint);
  background: transparent;
  border-radius: 0;
}

/* Ruler dividers — all neutral now */
.phase-ruler-item::after { display: none; }

/* ================================================================
   GUIDE LINES
   ================================================================ */

.lanes-with-guides {
  position: relative;
}

.guide-lines {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 340px;
  right: 0;
  pointer-events: none;
  z-index: 3;
  display: flex;
}

.guide-segment {
  flex: 1;
  position: relative;
}

.guide-segment::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: -1px;
  width: 1px;
  background: var(--line);
  opacity: .6;
}

.guide-segment:last-child::after { display: none; }

[data-theme="light"] .guide-segment::after { opacity: .8; }
[data-theme="light"] .phase-ruler-item { background: transparent; }

/* ================================================================
   RACE LANES (legacy layout: info | track | meta)
   ================================================================ */

.lanes-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  z-index: 2;
}

.lane {
  background: var(--panel);
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  overflow: hidden;
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  flex-direction: column;
  opacity: 0;
  animation: fadeSlideIn .4s cubic-bezier(.16, 1, .3, 1) forwards;
}

.lane:nth-child(1)  { animation-delay: 0s; }
.lane:nth-child(2)  { animation-delay: .04s; }
.lane:nth-child(3)  { animation-delay: .08s; }
.lane:nth-child(4)  { animation-delay: .12s; }
.lane:nth-child(5)  { animation-delay: .16s; }
.lane:nth-child(6)  { animation-delay: .20s; }
.lane:nth-child(7)  { animation-delay: .24s; }
.lane:nth-child(8)  { animation-delay: .28s; }
.lane:nth-child(9)  { animation-delay: .32s; }
.lane:nth-child(10) { animation-delay: .36s; }
.lane:nth-child(n+11) { animation-delay: .4s; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lane:hover {
  background: var(--panel-2);
}

.lane.lane-active  { border-left: 3px solid var(--accent); }
.lane.lane-overdue { border-left: 3px solid var(--accent); }
.lane.lane-done    { border-left: 3px solid var(--go); opacity: .75; }

.lane-row {
  display: flex;
  align-items: stretch;
}

.lane-info {
  width: 340px;
  min-width: 340px;
  padding: .75rem 1.1rem;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.lane-contract-name {
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -.01em;
}

.lane-contract-object {
  font-size: .68rem;
  color: var(--faint);
  margin-top: .15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lane-contract-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: .3rem;
  font-size: .6rem;
}

.lane-building { font-size: .6rem; color: var(--faint); }
.lane-dept     { font-size: .6rem; color: var(--faint); }
.lane-vigencia { font-size: .6rem; color: var(--faint); }

.lane-financial {
  display: flex;
  gap: 10px;
  margin-top: .25rem;
  font-size: .62rem;
  flex-wrap: wrap;
}

.lane-monthly     { color: var(--go); font-weight: 600; font-family: var(--mono); font-feature-settings: "zero"; font-size: .6rem; }
.lane-balance     { color: var(--dim); font-family: var(--mono); font-feature-settings: "zero"; font-size: .6rem; }
.lane-balance.zero { color: var(--accent); font-weight: 600; }
.lane-measurement { color: var(--info); font-family: var(--mono); font-feature-settings: "zero"; font-size: .6rem; }

.lane-track-area {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  min-height: 52px;
  background-image: repeating-linear-gradient(
    90deg,
    var(--grid),
    var(--grid) 1px,
    transparent 1px,
    transparent 16.6667%
  );
}

.track-bg {
  position: absolute;
  inset: 0;
  display: flex;
}

.track-bg-seg {
  flex: 1;
  transition: background .3s;
  position: relative;
}

.track-bg-seg::after {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  right: 0;
  width: 1px;
  background: var(--line);
  opacity: .5;
}

.track-bg-seg:last-child::after { display: none; }

[data-theme="light"] .track-bg-seg::after { opacity: .6; }

.track-bg-seg.seg-done         { background: rgba(63,210,154,.06); }
.track-bg-seg.seg-current      { background: var(--accent-soft); }
.track-bg-seg.seg-current-late { background: rgba(255,67,38,.06); }

[data-theme="light"] .track-bg-seg.seg-done         { background: rgba(31,158,110,.06); }
[data-theme="light"] .track-bg-seg.seg-current       { background: var(--accent-soft); }
[data-theme="light"] .track-bg-seg.seg-current-late  { background: rgba(224,52,21,.05); }

.lane-car {
  position: absolute;
  font-size: 1.4rem;
  z-index: 5;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: left .8s cubic-bezier(.34, 1.56, .64, 1);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
}

.lane-car.car-done    { animation: winPulse 2s ease infinite; }
.lane-car.car-overdue { animation: shake .5s ease infinite alternate; }

@keyframes shake {
  from { transform: translate(-50%, -50%) rotate(-5deg); }
  to   { transform: translate(-50%, -50%) rotate(5deg); }
}

@keyframes winPulse {
  0%, 100% { filter: drop-shadow(0 2px 6px rgba(63,210,154,.3)); }
  50%      { filter: drop-shadow(0 2px 16px rgba(63,210,154,.8)); }
}

.lane-meta {
  width: 120px;
  min-width: 120px;
  padding: .5rem .75rem;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: .25rem;
}

.lane-due           { font-size: .62rem; color: var(--faint); font-family: var(--mono); font-feature-settings: "zero"; }
.lane-due.due-late  { color: var(--accent); font-weight: 600; }
.lane-due.due-soon  { color: var(--warn); }

.lane-approval      { font-size: .6rem; color: var(--info); font-weight: 600; font-family: var(--mono); font-feature-settings: "zero"; }
.lane-amount        { font-size: .62rem; color: var(--warn); font-weight: 600; font-family: var(--mono); font-feature-settings: "zero"; }
.lane-days-phase    { font-size: .58rem; color: var(--faint); font-style: italic; font-family: var(--mono); font-feature-settings: "zero"; }

.lane-progress      { height: 3px; background: var(--inset); }
.lane-progress-fill { height: 100%; border-radius: 0 2px 2px 0; transition: width .8s ease; }
.lane-progress-fill.fill-normal { background: var(--accent); }
.lane-progress-fill.fill-late   { background: var(--accent); animation: glowPulse 2s ease infinite; }
.lane-progress-fill.fill-done   { background: var(--go); }

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 4px rgba(255,67,38,.3); }
  50%      { box-shadow: 0 0 10px rgba(255,67,38,.5); }
}

/* ================================================================
   NEW RACE LAYOUT (JS v2 — grid-based)
   ================================================================ */

.race {
  display: grid;
  grid-template-columns: 340px 1fr;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  background: var(--panel);
  margin-top: 0;
}

.race-cols {
  display: contents;
}

.race-cols .ident {
  background: var(--panel-2);
  padding: .75rem 1rem;
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .55rem;
  font-weight: 500;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-right: 1px solid var(--line);
  display: flex;
  align-items: center;
}

/* Phase header grid */
.phases {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  padding: 0 !important;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

.ph {
  padding: 10px 12px;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ph:first-child { border-left: none; }

.pi {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pi svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--dim);
}

.pn {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--ink);
}

.ph .meta { margin-top: 2px; }

.ph .mode {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .14em;
  color: var(--faint);
  text-transform: uppercase;
}

.ph .mode.man { color: var(--warn); }

.ph .cnt {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--dim);
  letter-spacing: .04em;
}

.ph .cnt b { color: var(--ink); font-weight: 600; }

.ph .lim {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--faint);
  letter-spacing: .06em;
}

/* Global SVG icon sizing for inline icons */
.nav-btn svg, .btn svg, .chip svg, .icbtn svg,
.toast-icon svg, .search-icon svg, .filter-tab svg,
.view-icon svg { width: 15px; height: 15px; }

.view-icon { display: flex; align-items: center; }

.row {
  display: contents;
}

.row:hover .ident,
.row:hover .track {
  background: var(--panel-2);
}

.ident {
  padding: .65rem 1rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
}

.ct-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.ct-code {
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .65rem;
  font-weight: 600;
  color: var(--faint);
  flex-shrink: 0;
}

.ct-name {
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ct-desc {
  font-size: .68rem;
  color: var(--faint);
  margin-top: .1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: .3rem;
}

.tag {
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .58rem;
  font-weight: 500;
  padding: .1rem .45rem;
  border-radius: 2px;
  border: 1px solid var(--line-2);
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .03em;
  line-height: 1.5;
}

.tag.warn {
  border-color: rgba(243,177,58,.35);
  color: var(--warn);
  background: rgba(243,177,58,.08);
}

.tag.dept {
  border-color: rgba(122,162,255,.3);
  color: var(--info);
  background: rgba(122,162,255,.08);
}

.tag.go {
  border-color: rgba(63,210,154,.3);
  color: var(--go);
  background: rgba(63,210,154,.08);
}

.tag.accent {
  border-color: rgba(255,67,38,.3);
  color: var(--accent);
  background: var(--accent-soft);
}

.ct-foot {
  display: flex;
  gap: 12px;
  margin-top: .25rem;
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .6rem;
}

.saldo {
  color: var(--go);
  font-weight: 600;
}

.saldo.zero {
  color: var(--accent);
}

.prazo {
  color: var(--faint);
}

.prazo.late {
  color: var(--accent);
  font-weight: 600;
}

.prazo.soon {
  color: var(--warn);
}

/* Track area in new grid */
.track {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  min-height: 56px;
  cursor: pointer;
  background-image: repeating-linear-gradient(
    90deg,
    var(--grid),
    var(--grid) 1px,
    transparent 1px,
    transparent 16.6667%
  );
}

.track .lane {
  border: none;
  border-right: 1px solid var(--line);
  border-bottom: none;
  background: transparent;
  border-radius: 0;
  opacity: 1;
  animation: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  min-height: auto;
  flex-direction: row;
}

.track .lane:last-child { border-right: none; }

/* Bar overlay (progress marker) — stretches full track width */
.bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  pointer-events: none;
}

/* Rail — horizontal baseline */
.rail {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--line-2);
  z-index: 1;
  transform: translateY(-50%);
}

/* Trail — gradient leading to node */
.trail {
  position: absolute;
  top: 50%;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 100%);
  z-index: 3;
  transform: translateY(-50%);
  transition: width .6s cubic-bezier(.34, 1.56, .64, 1);
}

/* Node — triangular position marker */
.node {
  position: absolute;
  top: 50%;
  z-index: 4;
  transform: translate(-100%, -50%);
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 14px solid var(--accent);
  transition: left .6s cubic-bezier(.34, 1.56, .64, 1);
}

/* Position label — small label above the node */
.poslabel {
  position: absolute;
  top: 5px;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: 8px;
  font-weight: 500;
  color: var(--faint);
  letter-spacing: .06em;
  text-transform: uppercase;
  z-index: 5;
  white-space: nowrap;
}

/* Leader tag — shown below the node for leading contracts */
.leader-tag {
  position: absolute;
  bottom: 5px;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: 8px;
  font-weight: 600;
  color: var(--go);
  text-transform: uppercase;
  letter-spacing: .1em;
  z-index: 5;
  white-space: nowrap;
}

/* Checkered finish line */
.finish {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 8px;
  z-index: 1;
  background-image:
    linear-gradient(45deg, var(--line-2) 25%, transparent 25%),
    linear-gradient(-45deg, var(--line-2) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--line-2) 75%),
    linear-gradient(-45deg, transparent 75%, var(--line-2) 75%);
  background-size: 4px 4px;
  background-position: 0 0, 0 2px, 2px -2px, -2px 0;
}

/* State colors for track elements */
.trail.go, .node.go  { --accent: var(--go); }
.trail.go   { background: linear-gradient(90deg, transparent 0%, var(--go) 100%); }
.node.go    { border-left-color: var(--go); }
.poslabel.go { color: var(--go); }

.trail.warn, .node.warn  { --accent: var(--warn); }
.trail.warn  { background: linear-gradient(90deg, transparent 0%, var(--warn) 100%); }
.node.warn   { border-left-color: var(--warn); }
.poslabel.warn { color: var(--warn); }

/* Pulse animation for leading contracts */
@keyframes nodePulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .6; }
}

.node.lead { animation: nodePulse 1.5s ease infinite; }

/* ================================================================
   BADGES (legacy)
   ================================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: .15rem .55rem;
  border-radius: 2px;
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  border: 1px solid var(--line-2);
  color: var(--dim);
}

.badge-blue   { border-color: rgba(122,162,255,.35); color: var(--info); background: rgba(122,162,255,.08); }
.badge-green  { border-color: rgba(63,210,154,.35); color: var(--go); background: rgba(63,210,154,.08); }
.badge-red    { border-color: rgba(255,67,38,.35); color: var(--accent); background: var(--accent-soft); }
.badge-orange { border-color: rgba(243,177,58,.35); color: var(--warn); background: rgba(243,177,58,.08); }
.badge-purple { border-color: rgba(122,162,255,.35); color: var(--info); background: rgba(122,162,255,.08); }
.badge-gray   { border-color: var(--line-2); color: var(--dim); background: transparent; }

/* ================================================================
   CONFETTI
   ================================================================ */

.confetti-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9000;
  overflow: hidden;
}

.confetti-particle {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 2px;
  top: -10px;
  animation: confettiFall 2.5s ease-in forwards;
}

@keyframes confettiFall {
  0%   { transform: translateY(0)    rotate(0deg)   scale(1);   opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg) scale(.3); opacity: 0; }
}

@keyframes badgeBounce {
  0%   { transform: scale(.8); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.badge-bounce { animation: badgeBounce .4s ease; }

@keyframes syncPulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.4); opacity: .7; }
}

.sync-dot.syncing { animation: syncPulse 1.5s ease infinite; }

/* ================================================================
   EMPTY STATE
   ================================================================ */

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--faint);
}

.empty-state .empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: .4;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--dim);
  margin-bottom: .5rem;
}

.empty-state p {
  font-size: .85rem;
}

/* ================================================================
   LOADING
   ================================================================ */

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--faint);
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================================================================
   MODAL
   ================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
  animation: overlayIn .2s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn .35s cubic-bezier(.16, 1, .3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.modal-title {
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

.modal-subtitle {
  font-size: .8rem;
  color: var(--faint);
  margin-top: .2rem;
  font-family: var(--mono);
  font-feature-settings: "zero";
}

.modal-close {
  background: transparent;
  color: var(--faint);
  font-size: 1.3rem;
  line-height: 1;
  border-radius: 3px;
  padding: .2rem .4rem;
}

.modal-close:hover {
  color: var(--ink);
  background: var(--inset);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ================================================================
   PHASE TIMELINE (in modal)
   ================================================================ */

.phase-timeline {
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem;
  position: relative;
}

.phase-timeline::before {
  content: '';
  position: absolute;
  top: 20px; left: 20px; right: 20px;
  height: 2px;
  background: var(--line);
  z-index: 0;
}

.phase-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}

.phase-step-dot {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  border: 2px solid var(--line);
  background: var(--bg);
  margin-bottom: .4rem;
  transition: all var(--transition);
}

.phase-step.completed .phase-step-dot {
  background: rgba(63,210,154,.15);
  border-color: var(--go);
}

.phase-step.current .phase-step-dot {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.phase-step-name {
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .6rem;
  color: var(--faint);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 500;
}

.phase-step.current .phase-step-name {
  color: var(--accent);
  font-weight: 600;
}

.phase-step.completed .phase-step-name {
  color: var(--go);
}

/* ================================================================
   CHECKLIST
   ================================================================ */

.checklist-section {
  margin-bottom: 1.5rem;
}

.checklist-title {
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.checklist-items {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .9rem;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition);
}

.checklist-item:hover {
  border-color: var(--line-2);
}

.checklist-item.checked {
  background: rgba(63,210,154,.05);
  border-color: rgba(63,210,154,.25);
}

.checklist-checkbox {
  width: 20px; height: 20px;
  border-radius: 3px;
  border: 2px solid var(--line-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  flex-shrink: 0;
  transition: all var(--transition);
}

.checklist-item.checked .checklist-checkbox {
  background: var(--go);
  border-color: var(--go);
  color: white;
}

.checklist-label {
  font-size: .875rem;
  color: var(--ink);
  flex: 1;
}

.checklist-item.checked .checklist-label {
  text-decoration: line-through;
  color: var(--faint);
}

.checklist-progress {
  font-size: .75rem;
  color: var(--faint);
  margin-top: .5rem;
  text-align: right;
  font-family: var(--mono);
  font-feature-settings: "zero";
}

/* ================================================================
   MODAL FORM FIELDS
   ================================================================ */

.modal-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.modal-fields .form-group {
  margin-bottom: 0;
}

.modal-fields .form-group.full-width {
  grid-column: 1 / -1;
}

/* ================================================================
   DASHBOARD
   ================================================================ */

.dashboard-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0;
  margin-bottom: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.overview-card {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 1.25rem;
  text-align: center;
  transition: all var(--transition);
}

.overview-card:last-child { border-right: none; }

.overview-card:hover {
  background: var(--panel-2);
}

.overview-num {
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: 2.5rem;
  font-weight: 600;
  line-height: 1;
  margin-bottom: .35rem;
}

.overview-lbl {
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .65rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
}

.ranking-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.ranking-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ranking-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.ranking-table {
  width: 100%;
}

.ranking-row {
  display: flex;
  align-items: center;
  padding: .85rem 1.5rem;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  transition: background var(--transition);
  cursor: pointer;
}

.ranking-row:last-child { border-bottom: none; }
.ranking-row:hover      { background: var(--panel-2); }

.ranking-pos {
  width: 28px; height: 28px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
  font-family: var(--mono);
  font-feature-settings: "zero";
}

.ranking-pos.pos-1     { background: rgba(243,177,58,.15); color: var(--warn); border: 1px solid rgba(243,177,58,.35); }
.ranking-pos.pos-2     { background: rgba(150,156,164,.12); color: var(--dim); border: 1px solid var(--line-2); }
.ranking-pos.pos-3     { background: rgba(205,127,50,.12); color: #cd7f32; border: 1px solid rgba(205,127,50,.3); }
.ranking-pos.pos-other { background: var(--inset); color: var(--faint); border: 1px solid var(--line); }

.ranking-name {
  flex: 1;
  font-size: .9rem;
  font-weight: 500;
}

.ranking-bar-wrap {
  width: 150px;
  height: 6px;
  background: var(--inset);
  border-radius: 3px;
  overflow: hidden;
}

.ranking-bar {
  height: 100%;
  border-radius: 3px;
  transition: width .6s ease;
}

.ranking-pct {
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .85rem;
  font-weight: 600;
  min-width: 45px;
  text-align: right;
}

.ranking-count {
  font-size: .75rem;
  color: var(--faint);
  min-width: 60px;
  text-align: right;
  font-family: var(--mono);
  font-feature-settings: "zero";
}

/* ================================================================
   ADMIN PANEL
   ================================================================ */

.admin-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
}

.admin-tab {
  background: transparent;
  color: var(--faint);
  padding: .6rem 1.2rem;
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .02em;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  transition: all var(--transition);
}

.admin-tab:hover {
  color: var(--dim);
}

.admin-tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

.admin-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
}

.admin-form-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1.25rem;
}

.admin-form-card h3 {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.admin-list-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.admin-list-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-list-header h3 {
  font-size: .95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.admin-list-items {
  display: flex;
  flex-direction: column;
}

.admin-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  transition: background var(--transition);
}

.admin-item:last-child { border-bottom: none; }
.admin-item:hover      { background: var(--panel-2); }

.admin-item-info {
  flex: 1;
  min-width: 0;
}

.admin-item-name {
  font-size: .9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-item-sub {
  font-size: .75rem;
  color: var(--faint);
  margin-top: .1rem;
}

.admin-item-actions {
  display: flex;
  gap: .4rem;
  flex-shrink: 0;
}

/* ================================================================
   TOTP / 2FA SETUP
   ================================================================ */

.totp-setup {
  text-align: center;
}

.qr-placeholder {
  background: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  border-radius: 4px;
  margin: 1rem auto;
  font-size: .75rem;
  color: #333;
  word-break: break-all;
  max-width: 300px;
}

.recovery-codes {
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1rem;
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .85rem;
  color: var(--go);
  text-align: left;
  margin: 1rem 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .3rem;
}

/* ================================================================
   SECTION DIVIDER
   ================================================================ */

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

.section-label {
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .65rem;
  font-weight: 500;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ================================================================
   ALERTS
   ================================================================ */

.alert-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.alert-item:last-child { border-bottom: none; }

.alert-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: .1rem; }
.alert-text { flex: 1; font-size: .875rem; }
.alert-time { font-size: .75rem; color: var(--faint); flex-shrink: 0; font-family: var(--mono); font-feature-settings: "zero"; }

/* ================================================================
   PROGRESS BAR (generic)
   ================================================================ */

.progress-bar-wrap {
  background: var(--inset);
  border-radius: 3px;
  height: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width .6s cubic-bezier(.4, 0, .2, 1);
}

/* ================================================================
   MODAL CONTRACT DETAILS
   ================================================================ */

.modal-contract-details {
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .9rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.contract-detail-row {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  font-size: .85rem;
}

.contract-detail-label {
  font-size: .72rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
  min-width: 90px;
  font-family: var(--mono);
  font-feature-settings: "zero";
}

.contract-detail-val {
  color: var(--ink);
  flex: 1;
}

.contract-detail-value {
  color: var(--warn);
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-weight: 600;
}

/* ================================================================
   PAINEL GESTOR
   ================================================================ */

.painel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.painel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.painel-card-header {
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.painel-card-header h3 {
  font-size: .95rem;
  font-weight: 700;
}

.painel-card-body {
  max-height: 400px;
  overflow-y: auto;
}

.empty-panel-msg {
  padding: 2rem;
  text-align: center;
  color: var(--faint);
  font-size: .85rem;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .8rem 1.25rem;
  border-bottom: 1px solid var(--line);
  transition: background var(--transition);
}

.activity-item:last-child { border-bottom: none; }
.activity-item:hover      { background: var(--panel-2); }

.activity-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: .1rem;
}

.activity-text { flex: 1; min-width: 0; }

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 1100px) {
  .phase-ruler {
    margin-left: 260px;
    margin-right: 0;
  }
  .guide-lines {
    left: 260px;
    right: 0;
  }
  .lane-info {
    width: 260px;
    min-width: 260px;
  }
  .lane-meta {
    width: 100px;
    min-width: 100px;
  }
  .race {
    grid-template-columns: 260px 1fr;
  }
  .ident { min-width: 0; }
}

@media (max-width: 900px) {
  #app-main { padding: 1rem; }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .painel-grid {
    grid-template-columns: 1fr;
  }

  .phase-ruler   { display: none; }
  .guide-lines   { display: none; }

  .lane-row {
    flex-direction: column;
  }

  .lane-info {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .lane-track-area {
    min-height: 44px;
  }

  .lane-meta {
    display: none;
  }

  .modal-fields {
    grid-template-columns: 1fr;
  }

  .race {
    grid-template-columns: 1fr;
  }

  .ident {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .track {
    min-height: 44px;
  }

  .tower {
    grid-template-columns: repeat(3, 1fr);
  }

  .tower .kpi:nth-child(4),
  .tower .kpi:nth-child(5) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  #app-header {
    height: auto;
    padding: .75rem;
    flex-wrap: wrap;
    gap: .75rem;
  }

  #app-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: .25rem;
  }

  .stats-bar {
    grid-template-columns: repeat(3, 1fr);
  }

  .dashboard-overview {
    grid-template-columns: repeat(2, 1fr);
  }

  .tower {
    grid-template-columns: repeat(2, 1fr);
  }

  .ranking-bar-wrap { display: none; }
}

/* ================================================================
   Approval levels (alcadas ZEPP)
   ================================================================ */
.approval-section {
  margin: 1rem 0;
  padding: 1rem;
  background: rgba(122,162,255,.06);
  border: 1px solid rgba(122,162,255,.15);
  border-radius: 4px;
}
.approval-section .section-title {
  font-weight: 700;
  margin-bottom: .75rem;
  color: var(--info);
}
.approval-levels {
  display: flex;
  gap: .5rem;
  margin-bottom: .75rem;
}
.approval-level {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .75rem .5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all .2s;
  border: 1px solid var(--line);
  font-size: .8rem;
}
.approval-level:hover { background: rgba(122,162,255,.08); }
.approval-level.approved {
  background: rgba(63,210,154,.08);
  border-color: var(--go);
}
.approval-level.current {
  background: rgba(243,177,58,.08);
  border-color: var(--warn);
}
.approval-level.pending { opacity: .5; }
.approval-dot { font-size: 1.2rem; margin-bottom: .25rem; }
.approval-status {
  font-size: .8rem;
  text-align: center;
  padding-top: .5rem;
  font-family: var(--mono);
  font-feature-settings: "zero";
}
.lane-approval {
  font-size: .7rem;
  color: var(--info);
  font-weight: 600;
  font-family: var(--mono);
  font-feature-settings: "zero";
}

/* ----------------------------------------------------------------
   Stalled process indicators
   ---------------------------------------------------------------- */
.lane-stalled {
  border-left-color: var(--warn) !important;
  animation: pulse-warn 2s infinite;
}
.lane-stalled-critical {
  border-left-color: var(--accent) !important;
  animation: pulse-accent 1.5s infinite;
}
@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(243,177,58,0); }
  50%      { box-shadow: 0 0 8px 2px rgba(243,177,58,.2); }
}
@keyframes pulse-accent {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,67,38,0); }
  50%      { box-shadow: 0 0 8px 2px rgba(255,67,38,.3); }
}

/* ----------------------------------------------------------------
   Drag & drop zones (admin)
   ---------------------------------------------------------------- */
.drop-zone {
  cursor: move;
  transition: background .2s;
}
.drop-zone.drop-hover {
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  border-radius: 3px;
}
.lane-car[draggable="true"] {
  cursor: grab;
}
.lane-car[draggable="true"]:active {
  cursor: grabbing;
}

/* ================================================================
   TOGGLE SWITCH (iOS style)
   ================================================================ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px; height: 26px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0; height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--line-2);
  border-radius: 26px;
  transition: .3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px; width: 20px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: .3s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--go);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}
.toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 0 2px rgba(63,210,154,.3);
}

/* ================================================================
   REGRAS (Admin rules cards)
   ================================================================ */
.regra-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  margin-bottom: 1rem;
  overflow: hidden;
}
.regra-header {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.regra-header .regra-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: .1rem;
}
.regra-header h4 {
  font-size: .95rem;
  margin-bottom: .15rem;
}
.regra-header p {
  color: var(--faint);
  font-size: .8rem;
  line-height: 1.4;
}
.regra-body {
  padding: 1rem 1.25rem;
}
.regra-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.regra-table th {
  text-align: left;
  color: var(--faint);
  font-family: var(--mono);
  font-feature-settings: "zero";
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--line);
}
.regra-table td {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--line);
}
.regra-table tr:last-child td { border-bottom: none; }
.regra-input {
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  padding: .4rem .6rem;
  font-size: .85rem;
  font-family: var(--mono);
  font-feature-settings: "zero";
  width: 70px;
  text-align: center;
}
.regra-input:focus {
  outline: none;
  border-color: var(--accent);
}
.regra-input:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.regra-toggle-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.regra-toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 0;
  border-bottom: 1px solid var(--line);
  font-size: .85rem;
  color: var(--dim);
}
.regra-toggle-item:last-child {
  border-bottom: none;
}
