:root {
  --primary: #000000;
  --primary-soft: #2f2f2f;
  --surface: #f9f9f9;
  --surface-low: #f3f3f4;
  --surface-high: #e8e8e8;
  --surface-card: rgba(255, 255, 255, 0.84);
  --ink: #1a1c1c;
  --muted: #7f8488;
  --ok: #1a7f4b;
  --warn: #9e6b00;
  --error: #ba1a1a;
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-14: 3.5rem;
  --space-16: 4rem;
}

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

html,
body {
  min-height: 100%;
}

body {
  font-family: "Inter", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at -10% -15%, #ffffff 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 10%, #eceef0 0%, transparent 60%),
    var(--surface);
  line-height: 1.45;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(18px);
  background: rgba(249, 249, 249, 0.82);
  border-bottom: 1px solid rgba(198, 198, 198, 0.18);
}

.topbar-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.8rem var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 220px;
}

.brand-mark {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #101214;
}

.nav-links {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.nav-link {
  padding: 0.5rem 0.82rem;
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5f656b;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background: #ebedef;
  color: #282d31;
}

.nav-link.active {
  background: linear-gradient(180deg, #000000 0%, #2f2f2f 100%);
  color: #ececec;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-chip {
  font-size: 0.75rem;
  color: #61676d;
  background: #eef0f2;
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn,
.btn-ghost,
.btn-danger {
  border: none;
  border-radius: 999px;
  padding: 0.62rem 1.08rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
  font-family: inherit;
}

.btn:active,
.btn-ghost:active,
.btn-danger:active {
  transform: translateY(1px);
}

.btn {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-soft) 100%);
  color: #ececec;
}

.btn:hover {
  background: linear-gradient(180deg, #1a1a1a 0%, #434343 100%);
}

.btn-ghost {
  background: #eceef0;
  color: #353b40;
}

.btn-ghost:hover {
  background: #dfe3e7;
}

.btn-danger {
  background: #f5e6e6;
  color: var(--error);
}

.btn-danger:hover {
  background: #f0d9d9;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-12) var(--space-6) var(--space-16);
}

.hero {
  margin-bottom: var(--space-10);
}

.hero-tag {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: var(--space-2);
  font-weight: 600;
}

.hero-title {
  font-size: clamp(2.1rem, 5vw, 3.2rem);
  letter-spacing: -0.03em;
  font-weight: 800;
  margin-bottom: var(--space-2);
  color: #0a0a0a;
  line-height: 1.06;
}

.hero-sub {
  max-width: 840px;
  color: #656b70;
  font-size: 1rem;
  line-height: 1.6;
}

.panel {
  background: var(--surface-card);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: 0 18px 48px rgba(26, 28, 28, 0.08);
}

.panel + .panel {
  margin-top: var(--space-6);
}

.panel-title {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7a7f84;
  font-weight: 700;
  margin-bottom: var(--space-5);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.panel-subtitle {
  font-size: 1.04rem;
  font-weight: 600;
  color: #1e2225;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field-full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8d9399;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: none;
  background: var(--surface-low);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 0.92rem;
  padding: 0.72rem 0.88rem;
  outline: none;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 160px;
}

input:focus,
select:focus,
textarea:focus {
  background: #ffffff;
  box-shadow: 0 0 0 1px #bfc6cc;
}

.status {
  margin-top: 0.55rem;
  font-size: 0.8rem;
  min-height: 1rem;
  color: #6f757b;
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: var(--warn);
}

.status.error {
  color: var(--error);
}

.empty-state {
  text-align: center;
  color: #90969b;
  background: var(--surface-low);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  font-size: 0.9rem;
}

.muted-box {
  background: var(--surface-low);
  border-radius: var(--radius-lg);
  padding: 1rem;
  color: #7d8388;
  font-size: 0.86rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.32rem 0.7rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
}

.badge.plan {
  color: #5f656b;
  background: #eceff2;
}

.badge.exec {
  color: #1d5f89;
  background: #e7f2f9;
}

.badge.done {
  color: #1a7f4b;
  background: #e6f7ef;
}

.badge.delay {
  color: #9e6b00;
  background: #fdf3dc;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  box-shadow: 0 14px 34px rgba(20, 20, 20, 0.06);
}

.stat-label {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8b9197;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.9rem;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: #141618;
  font-weight: 800;
}

.toolbar {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-4);
}

.toolbar input {
  flex: 1;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.project-card {
  background: rgba(255, 255, 255, 0.86);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  box-shadow: 0 12px 28px rgba(20, 20, 20, 0.06);
  display: grid;
  gap: 0.6rem;
  transition: box-shadow 0.18s, transform 0.18s;
}

.project-card:hover {
  box-shadow: 0 18px 40px rgba(20, 20, 20, 0.1);
  transform: translateY(-1px);
}

.project-top {
  display: flex;
  align-items: flex-start;
}

.project-name {
  font-size: 1.02rem;
  color: #17191b;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 0.1rem;
}

.project-meta {
  display: grid;
  gap: 0.35rem;
  color: #6f757b;
  font-size: 0.83rem;
}

.project-actions {
  margin-top: 0.2rem;
}

.kpi {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  color: #6f757b;
  font-size: 0.8rem;
}

.kpi-strong {
  font-weight: 700;
  color: #151719;
  letter-spacing: -0.01em;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.kv-list {
  display: grid;
  gap: 0.55rem;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--surface-low);
  border-radius: var(--radius-md);
  padding: 0.62rem 0.8rem;
  font-size: 0.86rem;
}

.kv-key {
  color: #747b81;
  font-weight: 500;
}

.kv-val {
  color: #1e2124;
  text-align: right;
}

.simple-list {
  display: grid;
  gap: 0.48rem;
}

.simple-item {
  background: var(--surface-low);
  border-radius: var(--radius-md);
  padding: 0.72rem 0.88rem;
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  color: #202326;
  font-size: 0.87rem;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border-radius: var(--radius-md);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 640px;
}

.table th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8b9197;
  font-weight: 700;
  padding: 0.62rem 0.7rem;
  background: #f2f3f4;
}

.table td {
  padding: 0.62rem 0.7rem;
  background: #fbfbfb;
  border-top: 1px solid #f0f0f0;
  font-size: 0.86rem;
  color: #232629;
}

.table tfoot td {
  font-weight: 700;
  background: #f2f3f4;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.timeline-list {
  position: relative;
  padding-left: 2.6rem;
  display: grid;
  gap: 0;
}

.timeline-list::before {
  content: '';
  position: absolute;
  left: 0.7rem;
  top: 0.55rem;
  bottom: 0.4rem;
  width: 1.5px;
  background: linear-gradient(
    to bottom,
    #c0c5ca 0%,
    #dde0e3 65%,
    transparent 100%
  );
  pointer-events: none;
}

.timeline-item {
  position: relative;
  padding-bottom: 2rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.95rem;
  top: 0.38rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa0a6;
  box-shadow: 0 0 0 2.5px #fff, 0 0 0 4px #d4d8dc;
  transition: box-shadow 0.15s ease;
}

.timeline-item--key::before {
  background: #1a1c1c;
  width: 10px;
  height: 10px;
  left: -2.05rem;
  top: 0.28rem;
  box-shadow: 0 0 0 3px #fff, 0 0 0 4.5px #a8adb2;
}

.timeline-item--minor::before {
  background: #c8cdd2;
  width: 6px;
  height: 6px;
  left: -1.85rem;
  top: 0.48rem;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px #dde0e3;
}

.timeline-date {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #9aa0a6;
  font-weight: 700;
  margin-bottom: 0.18rem;
}

.timeline-title {
  font-size: 0.92rem;
  color: #1e2225;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.2rem;
}

.timeline-title-transition {
  font-weight: 400;
  color: #8d9399;
}

.timeline-desc {
  color: #62686e;
  font-size: 0.82rem;
  line-height: 1.5;
  margin-bottom: 0.3rem;
}

.timeline-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.timeline-chip {
  font-size: 0.7rem;
  font-weight: 600;
  background: #f0f2f4;
  color: #4a5056;
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  letter-spacing: 0.02em;
}

.timeline-actor {
  font-size: 0.72rem;
  color: #a8adb2;
  margin-top: 0.35rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(10, 12, 14, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  width: min(540px, 100%);
  max-height: calc(100vh - var(--space-4) * 2);
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(15, 18, 20, 0.24);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overflow: hidden;
}

.modal-grid {
  display: grid;
  gap: var(--space-3);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.text-right {
  text-align: right;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.87);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: 0 18px 42px rgba(20, 20, 20, 0.1);
}

.auth-title {
  font-size: 2rem;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin-bottom: var(--space-2);
}

.auth-sub {
  color: #656b70;
  font-size: 0.92rem;
  margin-bottom: var(--space-6);
}

.auth-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.auth-actions .btn,
.auth-actions .btn-ghost {
  flex: 1;
}

@media (max-width: 1080px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

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

@media (max-width: 820px) {
  .topbar-wrap {
    padding: 0.72rem var(--space-4);
    flex-wrap: wrap;
  }

  .brand {
    min-width: auto;
  }

  .topbar-user {
    margin-left: auto;
  }

  .page {
    padding: var(--space-8) var(--space-4) var(--space-12);
  }

  .panel {
    padding: var(--space-5);
  }

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

  .hero {
    margin-bottom: var(--space-6);
  }

  .hero-sub {
    font-size: 0.9rem;
  }
}

@media (max-width: 580px) {
  /* Nav scrollável horizontal — sem quebra de linha */
  .nav-links {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-link {
    flex: 0 0 auto;
    white-space: nowrap;
    text-align: left;
  }

  /* Toolbar: input full-width, botões lado a lado */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-btns {
    display: flex;
    gap: var(--space-3);
  }

  .toolbar-btns .btn-ghost {
    flex: 1;
  }

  .hero-title {
    font-size: clamp(1.6rem, 8vw, 2rem);
  }

  .hero-sub {
    display: none;
  }

  .auth-card {
    padding: var(--space-6);
  }
}

/* ====================================================
   UnsavedGuard — Modal de confirmação de saída
   ==================================================== */

@keyframes ug-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes ug-card-in {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

@keyframes ug-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-4px); }
  40%       { transform: translateX(4px); }
  60%       { transform: translateX(-3px); }
  80%       { transform: translateX(3px); }
}

#ug-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(7, 9, 11, 0.52);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: ug-backdrop-in 0.18s ease both;
}

#ug-overlay.open {
  display: flex;
}

#ug-card {
  width: min(460px, 100%);
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow:
    0 2px 8px rgba(0,0,0,0.04),
    0 12px 40px rgba(0,0,0,0.16),
    0 0 0 1px rgba(0,0,0,0.06);
  padding: var(--space-8) var(--space-8) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  animation: ug-card-in 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
  position: relative;
}

#ug-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1.5px solid #fde68a;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#ug-icon-wrap svg {
  width: 26px;
  height: 26px;
  color: #d97706;
}

#ug-overlay.open #ug-icon-wrap {
  animation: ug-shake 0.5s ease 0.15s both;
}

#ug-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

#ug-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #111315;
  line-height: 1.25;
}

#ug-desc {
  font-size: 0.88rem;
  color: #5f656b;
  line-height: 1.55;
}

#ug-warning-box {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  background: #fff7ed;
  border: 1px solid #fde8c5;
  border-radius: var(--radius-md);
  padding: 0.72rem 0.88rem;
  font-size: 0.81rem;
  color: #92400e;
  line-height: 1.5;
}

#ug-warning-box svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin-top: 1px;
  color: #d97706;
}

#ug-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  flex-wrap: wrap;
}

#ug-btn-cancel {
  border: none;
  border-radius: 999px;
  padding: 0.62rem 1.2rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  background: #f0f2f4;
  color: #3a4046;
  font-family: inherit;
  transition: background 0.12s ease, transform 0.1s ease;
}

#ug-btn-cancel:hover  { background: #e3e7eb; }
#ug-btn-cancel:active { transform: translateY(1px); }

#ug-btn-leave {
  border: none;
  border-radius: 999px;
  padding: 0.62rem 1.2rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: #fff;
  font-family: inherit;
  transition: filter 0.12s ease, transform 0.1s ease;
}

#ug-btn-leave:hover  { filter: brightness(1.08); }
#ug-btn-leave:active { transform: translateY(1px); }

@media (max-width: 480px) {
  #ug-card {
    padding: var(--space-6) var(--space-5) var(--space-5);
  }

  #ug-actions {
    flex-direction: column-reverse;
  }

  #ug-btn-cancel,
  #ug-btn-leave {
    width: 100%;
    text-align: center;
  }
}

/* ====================================================
   Budget health — mini bar nos cards do dashboard
   ==================================================== */

.card-budget-health {
  display: grid;
  gap: 0.3rem;
}

.card-budget-bar-track {
  background: #e5e5e5;
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}

.card-budget-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--ok);
  transition: width 0.3s;
}

.card-budget-bar-fill.amarelo { background: var(--warn); }
.card-budget-bar-fill.laranja { background: #ea580c; }
.card-budget-bar-fill.vermelho { background: var(--error); }

.card-budget-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #6f757b;
}

.card-budget-info .badge {
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
}

/* ====================================================
   Tendencia — card de projecao no detalhe do projeto
   ==================================================== */

.tendencia-card {
  background: var(--surface-low);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  border-left: 3px solid #6366f1;
}

.tendencia-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8b9197;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.tendencia-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.tendencia-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.tendencia-label {
  font-size: 0.72rem;
  color: #8b9197;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.tendencia-value {
  font-size: 1rem;
  font-weight: 700;
  color: #141618;
}

