:root {
  --bg: #fafafa;
  --surface: #fff;
  --surface-2: #f5f5f5;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #0f172a;
  --accent: #2563eb;
  --critical: #dc2626;
  --critical-bg: #fee2e2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --ok: #059669;
  --ok-bg: #d1fae5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --surface: #111827;
    --surface-2: #1f2937;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --border: #1f2937;
    --primary: #f3f4f6;
    --accent: #60a5fa;
    --critical: #f87171;
    --critical-bg: #3f1d1d;
    --warning: #fbbf24;
    --warning-bg: #3a2a08;
    --ok: #34d399;
    --ok-bg: #06281f;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body { padding: 16px; }
.container { max-width: 1200px; margin: 0 auto; }

header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
header h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
header .meta { color: var(--muted); font-size: 12px; }
header .meta strong { color: var(--text); font-weight: 600; }
@media (min-width: 640px) {
  header { flex-direction: row; justify-content: space-between; align-items: baseline; }
  header h1 { font-size: 20px; }
  header .meta { font-size: 13px; }
}

.kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); gap: 12px; } }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: 10px;
}
.kpi-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
@media (min-width: 640px) { .kpi-value { font-size: 32px; } }
.kpi.critical .kpi-value { color: var(--critical); }
.kpi.warning .kpi-value { color: var(--warning); }
.kpi.ok .kpi-value { color: var(--ok); }

section { margin-bottom: 28px; }
section + section {
  border-top: 1px solid var(--border);
  padding-top: 28px;
  margin-top: 36px;
}
@media (min-width: 640px) {
  section + section { padding-top: 36px; margin-top: 48px; }
}
section h2 {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.diag-list {
  display: grid;
  gap: 0;
}
.diag-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.diag-row:last-child { border-bottom: none; }
.diag-row:hover { background: var(--surface-2); }
.diag-row.active {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}
.diag-date {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.diag-summary {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.diag-summary span { white-space: nowrap; }
.diag-arrow { color: var(--muted); font-size: 18px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.critical { background: var(--critical-bg); color: var(--critical); }
.badge.warning  { background: var(--warning-bg);  color: var(--warning); }
.badge.ok       { background: var(--ok-bg);       color: var(--ok); }

.markdown {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-top: 12px;
  overflow-x: auto;
}
@media (min-width: 640px) { .markdown { padding: 28px; } }
.markdown h1 { font-size: 20px; font-weight: 700; margin: 0 0 12px; }
.markdown h2 { font-size: 17px; font-weight: 700; margin: 24px 0 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.markdown h2:first-of-type { border-top: none; padding-top: 0; }
.markdown h3 { font-size: 15px; font-weight: 600; margin: 16px 0 6px; }
.markdown p { margin: 8px 0; font-size: 14px; }
.markdown ul, .markdown ol { margin: 8px 0 8px 22px; font-size: 14px; }
.markdown li { margin: 4px 0; }
.markdown table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
  font-size: 13px;
  display: block;
  overflow-x: auto;
}
.markdown th, .markdown td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.markdown th { background: var(--surface-2); font-weight: 600; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.markdown code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.markdown strong { font-weight: 700; }

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
@media (min-width: 640px) {
  .filters { grid-template-columns: 1fr 1fr auto; }
}
.filters select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
.filters .clear {
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.filters .clear:hover { color: var(--text); }

.restricoes-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.restricoes { width: 100%; border-collapse: collapse; min-width: 520px; }
table.restricoes thead th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
table.restricoes tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
}
table.restricoes tbody tr:last-child td { border-bottom: none; }
.dias {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dias.alto { color: var(--critical); }
.dias.medio { color: var(--warning); }
.desc { max-width: 480px; }

.count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.sub-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: -8px;
  margin-bottom: 14px;
}

.resp { line-height: 1.35; }
.resp .nome { font-weight: 600; color: var(--text); }
.resp .tel  { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.resp .tel a { color: var(--accent); text-decoration: none; }
.resp .tel a:hover { text-decoration: underline; }

.cat-pill {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.cat-pill.material   { background: #fef3c7; color: #92400e; }
.cat-pill.projeto    { background: #dbeafe; color: #1e40af; }
.cat-pill.qualidade  { background: #ede9fe; color: #5b21b6; }
.cat-pill.sesmt      { background: #fee2e2; color: #991b1b; }
.cat-pill.equipe     { background: #d1fae5; color: #065f46; }
@media (prefers-color-scheme: dark) {
  .cat-pill.material  { background: #3a2a08; color: #fbbf24; }
  .cat-pill.projeto   { background: #1e293b; color: #93c5fd; }
  .cat-pill.qualidade { background: #2e1065; color: #c4b5fd; }
  .cat-pill.sesmt     { background: #3f1d1d; color: #f87171; }
  .cat-pill.equipe    { background: #064e3b; color: #6ee7b7; }
}

.empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.loading {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}
footer a { color: var(--accent); text-decoration: none; }
