:root {
  /* Cores Âncoras do Catedra Digital Design System */
  --gild-500: #CDA248;       /* Ouro (Acento Primário) */
  --gild-100: #F7F3E6;       /* Ouro Claro */
  --gild-700: #9B782E;       /* Ouro Escuro */
  --ink-900: #191818;        /* Near-Black (Texto/Sidebar) */
  
  --limestone-50: #FBFBFA;
  --limestone-100: #F2F0DA;   /* Creme (Superfície da Página) */
  
  --sage-50: #FDF9F9;
  --sage-500: #611B1A;       /* Maroon (Marca) */
  --sage-700: #441110;
  
  /* Cores Semânticas / Estados */
  --moss-500: #6B6A34;       /* Sucesso / Concluída / Ótimo */
  --moss-100: #F0F0E6;
  --amber-500: #AC8636;      /* Alerta / Em Progresso / Revisão */
  --amber-100: #F7F3E6;
  --oxblood-500: #7A2320;    /* Perigo / Atrasado / Alta Prioridade */
  --oxblood-100: #FDF1F1;
  --stone-500: #78716c;      /* Neutro / A Fazer */
  --stone-100: #f5f5f4;
  
  /* Superfícies (Tema Claro) */
  --bg-page: var(--limestone-100);
  --bg-surface: #FDFDFB;
  --surface-card: #FFFFFF;
  --surface-raised: #F8F7F0;
  --surface-sunken: #EBE9D0;
  --surface-inverse: var(--ink-900);
  
  --text-primary: #191818;
  --text-secondary: #4A4740;
  --text-muted: #827E72;
  --text-inverse: #FFFFFF;
  --text-link: var(--gild-700);
  
  --border-subtle: #E3E1C8;
  --border-default: #CFCDB2;
  
  /* Tipografia */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'Space Mono', monospace;
  
  /* Bordas */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-pill: 999px;
  
  /* Sombras */
  --shadow-sm: 0 1px 2px rgba(25, 24, 24, 0.05);
  
  /* Módulo de Espaço / Layout */
  --d-pad: 18px;
  --d-gap: 16px;
  --d-row: 44px;
  --d-fs: 14px;
  --brand: var(--sage-500);
  --brand-deep: var(--sage-700);
  --accent-contrast: #FFFFFF;
}

/* Tema Cripta (Escuro) */
#dashx[data-theme="crypt"] {
  --bg-page: #15140F;
  --bg-surface: #1a1913;
  --surface-card: #211F18;
  --surface-raised: #1c1b14;
  --surface-sunken: #100F0B;
  --surface-inverse: #0d0c09;
  
  --text-primary: #ECE8D4;
  --text-secondary: #C6C0A5;
  --text-muted: #8F8971;
  --text-inverse: #EBE9D0;
  --text-link: var(--gild-500);
  
  --border-subtle: #332F24;
  --border-default: #3d382a;
}

/* Densidade Compacta */
#dashx[data-density="compact"] {
  --d-pad: 12px;
  --d-gap: 12px;
  --d-row: 34px;
  --d-fs: 13px;
}

/* Reset Geral */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--d-fs);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  overflow: hidden;
}

#dashx {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============ SIDEBAR ============ */
aside {
  width: 224px;
  flex: none;
  background: var(--surface-inverse);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(242, 240, 218, 0.1);
  transition: width 0.16s ease;
}

aside[data-collapsed="true"] {
  width: 64px;
}

aside[data-collapsed="true"] .nav-label,
aside[data-collapsed="true"] .nav-badge,
aside[data-collapsed="true"] .sidebar-brand {
  display: none !important;
}

.sidebar-header {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(242, 240, 218, 0.1);
}

.sidebar-logo {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: var(--radius-sm);
  background: var(--gild-500);
  color: var(--ink-900);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
}

.sidebar-brand {
  min-width: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0.01em;
}

.brand-subtitle {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(242, 240, 218, 0.5);
  margin-top: 3px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: rgba(242, 240, 218, 0.7);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: rgba(242, 240, 218, 0.05);
  color: var(--text-inverse);
}

.nav-item.active {
  background: var(--gild-100);
  color: var(--gild-700);
}

#dashx[data-theme="crypt"] .nav-item.active {
  background: rgba(205, 162, 72, 0.15);
  color: var(--gild-500);
}

.nav-item i {
  width: 16px;
  height: 16px;
  flex: none;
}

.nav-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(242, 240, 218, 0.5);
  background: rgba(242, 240, 218, 0.1);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}

.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid rgba(242, 240, 218, 0.1);
}

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

.topbar {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.screen-subtitle {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-top: 2px;
}

.spacer {
  flex: 1;
}

.search-container {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 9px;
  color: var(--text-muted);
  width: 14px;
  height: 14px;
}

.search-container input {
  height: 34px;
  width: 200px;
  padding: 0 10px 0 30px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: width 0.15s ease;
}

.search-container input:focus {
  width: 260px;
  border-color: var(--gild-500);
}

.icon-button {
  width: 34px;
  height: 34px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.icon-button:hover {
  background: var(--surface-raised);
  border-color: var(--gild-500);
}

.operator-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 6px;
  border-left: 1px solid var(--border-subtle);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--brand);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

main {
  flex: 1;
  overflow-y: auto;
  padding: var(--d-pad);
}

/* ============ COMPONENTES GENÉRICOS ============ */

/* Grid de Métricas / KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--d-gap);
  margin-bottom: var(--d-gap);
}

.kpi-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.kpi-header {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.kpi-header i {
  width: 14px;
  height: 14px;
}

.kpi-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 26px;
  color: var(--text-primary);
  margin-top: 8px;
  letter-spacing: -0.01em;
}

.kpi-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.kpi-delta {
  font-family: var(--font-mono);
  font-weight: 700;
}

.kpi-delta.sucesso {
  color: var(--moss-500);
}
.kpi-delta.alerta {
  color: var(--amber-500);
}
.kpi-delta.perigo {
  color: var(--oxblood-500);
}

/* Chips / Badges de Status */
[data-chip] {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  font-weight: 600;
}

[data-chip="a_fazer"], [data-chip="descoberta"], [data-chip="novo"], [data-chip="pendente"] {
  background: var(--stone-100);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}
#dashx[data-theme="crypt"] [data-chip="a_fazer"] {
  background: var(--surface-sunken);
  color: var(--text-muted);
}

[data-chip="em_progresso"], [data-chip="em-obra"], [data-chip="bom"], [data-chip="gild"] {
  background: var(--gild-100);
  color: var(--gild-700);
}

[data-chip="revisao"] {
  background: var(--amber-100);
  color: #7a5f16;
}

[data-chip="concluida"], [data-chip="entregue"], [data-chip="otimo"], [data-chip="paga"] {
  background: var(--moss-100);
  color: #4a4920;
}

[data-chip="atencao"], [data-chip="atrasada"] {
  background: var(--oxblood-100);
  color: var(--oxblood-500);
}

/* Tabelas */
.table-container {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.table-header {
  display: grid;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border-default);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.table-row {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.15s ease;
}

.table-row:hover {
  background: var(--surface-raised);
}

.table-row:last-child {
  border-bottom: none;
}

/* Progress bar */
.progress-bar-container {
  width: 100%;
}
.progress-bar-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.progress-bar-track {
  height: 5px;
  border-radius: 99px;
  background: var(--surface-sunken);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.3s ease;
}

/* ============ LAYOUT DE DUAS COLUNAS (OVERVIEW) ============ */
.overview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: var(--d-gap);
  align-items: start;
}

.overview-main-col {
  display: flex;
  flex-direction: column;
  gap: var(--d-gap);
}

.overview-side-col {
  display: flex;
  flex-direction: column;
  gap: var(--d-gap);
}

/* Card Bloco */
.block-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.block-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}

.block-action-link {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-link);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  text-decoration: none;
}
.block-action-link:hover {
  background: var(--surface-raised);
}

/* ============ KANBAN BOARD ============ */
.kanban-board {
  display: flex;
  gap: var(--d-gap);
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-column {
  flex: 1;
  min-width: 250px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  border-bottom: 1px solid var(--border-subtle);
}

.kanban-column-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}

.column-dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
}
.column-dot.a_fazer { background: var(--stone-500); }
.column-dot.em_progresso { background: var(--gild-500); }
.column-dot.revisao { background: var(--amber-500); }
.column-dot.concluida { background: var(--moss-500); }

.kanban-tasks-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.kanban-tasks-list {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 200px;
  transition: background-color 0.2s ease;
}

.kanban-tasks-list.drag-over {
  background-color: rgba(205, 162, 72, 0.05);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.task-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.task-card:active {
  cursor: grabbing;
}

.task-card.dragging {
  opacity: 0.4;
  border: 2px dashed var(--gild-500);
}

.task-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(25, 24, 24, 0.08);
  border-color: var(--border-default);
}

.task-card-title {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.35;
  margin-bottom: 8px;
}

.task-card-project {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 9px;
}

.task-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-avatar {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
}

.task-priority {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.task-priority.alta { color: var(--oxblood-500); }
.task-priority.media { color: var(--amber-500); }
.task-priority.baixa { color: var(--text-muted); }

.task-due {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}
.task-due.overdue { color: var(--oxblood-500); }
.task-due.today { color: var(--gild-700); }
.task-due.done { color: var(--moss-500); }

/* ============ CALENDÁRIO ============ */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--border-subtle);
  gap: 1px;
}

.calendar-cell {
  background: var(--surface-card);
  min-height: 94px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-cell.empty {
  background: var(--surface-sunken);
  opacity: 0.6;
}

.calendar-cell.today {
  background: var(--gild-100);
}
#dashx[data-theme="crypt"] .calendar-cell.today {
  background: rgba(205, 162, 72, 0.15);
}

.calendar-day-num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.calendar-cell.today .calendar-day-num {
  color: var(--gild-700);
  font-weight: 700;
}

.calendar-event {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.calendar-event.task {
  background: var(--gild-100);
  color: var(--gild-700);
}
#dashx[data-theme="crypt"] .calendar-event.task {
  background: rgba(205, 162, 72, 0.15);
  color: var(--gild-500);
}
.calendar-event.task .event-dot {
  background: var(--gild-500);
}

.calendar-event.project {
  background: var(--brand);
  color: var(--text-inverse);
}
.calendar-event.project .event-dot {
  background: var(--limestone-50);
}

.event-dot {
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 99px;
}

/* ============ LOADING & SPINNER ============ */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 15px;
  color: var(--text-secondary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-default);
  border-top-color: var(--gild-500);
  border-radius: var(--radius-pill);
  animation: spin 0.8s linear infinite;
}

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

/* ============ LAYOUT DE DETALHES ============ */
.detail-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: var(--d-gap);
  align-items: start;
}

.detail-main-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 20px;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.detail-avatar-large {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
}

.detail-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  line-height: 1.1;
}

.detail-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.detail-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

.detail-stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.detail-stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 19px;
  margin-top: 5px;
}

.detail-stat-text {
  font-size: 14px;
  margin-top: 6px;
  color: var(--text-secondary);
}

/* ============ BOTÃO PRIMÁRIO ============ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  background: var(--gild-500);
  color: var(--ink-900);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-primary:hover {
  background: var(--gild-700);
  color: var(--text-inverse);
}
.btn-primary i {
  width: 14px;
  height: 14px;
}

/* ============ CONTROLES DA VISTA DE TAREFAS ============ */
.tasks-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--d-gap);
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface);
}

.segmented-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.segmented-item:hover {
  background: var(--surface-raised);
}
.segmented-item.active {
  background: var(--gild-100);
  color: var(--gild-700);
}
#dashx[data-theme="crypt"] .segmented-item.active {
  background: rgba(205, 162, 72, 0.15);
  color: var(--gild-500);
}

.segmented-item i {
  width: 14px;
  height: 14px;
}

/* ============ DETALHES DE PROJECT ============ */
.project-stats-block {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

.github-badge-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-link);
  text-decoration: none;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  background: var(--bg-surface);
  transition: all 0.15s ease;
}
.github-badge-link:hover {
  border-color: var(--gild-500);
  background: var(--surface-raised);
}
.github-badge-link i {
  width: 14px;
  height: 14px;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 2px 4px;
  cursor: pointer;
  user-select: none;
}
.back-button:hover {
  color: var(--text-primary);
}
.back-button i {
  width: 14px;
  height: 14px;
}
