/* ============================================================
   Skyline — design system
   ============================================================ */

:root {
  --bg: #eaecf1;
  --surface: #ffffff;
  --surface-2: #f0f1f5;
  --border: #dadde3;
  --border-strong: #c3c7d1;

  --text: #1c1e24;
  --text-muted: #565c68;
  --text-faint: #838995;

  --primary: #3d3a7d;
  --primary-hover: #302d64;
  --primary-soft: #e6e5f2;
  --primary-soft-text: #3d3a7d;

  --green: #206b4c;
  --green-soft: #dceee3;
  --amber: #8a5a12;
  --amber-soft: #f2e6cd;
  --red: #9c2e3e;
  --red-soft: #f1dde1;
  --slate: #495363;
  --slate-soft: #e2e5ea;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Reset link styling everywhere — no default blue/underline, ever */
a {
  color: inherit;
  text-decoration: none;
}

/* ---------- Top bar ---------- */

header.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 20;
}

header.topbar .marca {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}

header.topbar .marca .mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #5b5896);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  flex-shrink: 0;
}

header.topbar nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
  margin-left: var(--space-8);
  overflow-x: auto;
  scrollbar-width: none;
}
header.topbar nav::-webkit-scrollbar { display: none; }

header.topbar nav a {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}

header.topbar nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

header.topbar .user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

header.topbar .user .nome {
  color: var(--text);
  font-weight: 600;
}

header.topbar .user a.sair {
  color: var(--text-faint);
  font-weight: 500;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

header.topbar .user a.sair:hover {
  background: var(--red-soft);
  color: var(--red);
}

/* ---------- Layout ---------- */

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-8);
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-5);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: var(--space-8) 0 var(--space-3);
}

p { color: var(--text-muted); }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}

/* ---------- Tables ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  white-space: nowrap;
}

thead th:first-child { border-top-left-radius: var(--radius-sm); }
thead th:last-child { border-top-right-radius: var(--radius-sm); }

tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background 0.1s ease;
}

tbody tr:hover td {
  background: var(--surface-2);
}

td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* allow observation/notes columns to wrap sensibly, never numeric columns */
td.wrap {
  white-space: normal;
  min-width: 220px;
}

.table-scroll {
  overflow-x: auto;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.6;
}

.badge.aberto { background: var(--green-soft); color: var(--green); }
.badge.em_aprovacao { background: var(--amber-soft); color: var(--amber); }
.badge.aprovado { background: var(--primary-soft); color: var(--primary-soft-text); }
.badge.fechado { background: var(--slate-soft); color: var(--slate); }
.badge.admin { background: var(--red-soft); color: var(--red); }
.badge.editor { background: var(--primary-soft); color: var(--primary-soft-text); }
.badge.consulta { background: var(--slate-soft); color: var(--slate); }
.badge.incompleto { background: var(--red-soft); color: var(--red); }
.badge.fds { background: var(--amber-soft); color: var(--amber); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.05s ease;
  box-shadow: var(--shadow-sm);
}

.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:active { transform: translateY(1px); }

.btn.secundario {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
.btn.secundario:hover { background: var(--slate-soft); border-color: var(--text-faint); }

.btn.perigo { background: var(--red); border-color: var(--red); }
.btn.perigo:hover { background: #7f2531; border-color: #7f2531; }

.btn.pequeno { padding: 6px 12px; font-size: 0.79rem; }

form.inline { display: inline; }

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-5);
  max-width: 680px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 0;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  min-width: 0;
  width: 100%;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

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

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

.form-grid.sub-form {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.checkbox-label {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 10px !important;
  font-weight: 500 !important;
  color: var(--text) !important;
}
.checkbox-label input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ---------- Flash messages ---------- */

.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-5);
  font-size: 0.87rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.flash.ok { background: var(--green-soft); color: var(--green); border-color: #c9ebdb; }
.flash.erro { background: var(--red-soft); color: var(--red); border-color: #f4c9cf; }

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.tabs a {
  padding: var(--space-2) var(--space-4);
  color: var(--text-muted);
  font-size: 0.87rem;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a.ativo { color: var(--primary); border-color: var(--primary); }

/* ---------- Login ---------- */

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

.login-box { width: 100%; max-width: 380px; }

.login-box .mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #5b5896);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  margin: 0 auto var(--space-4);
  box-shadow: var(--shadow-md);
}

.login-box h1 {
  text-align: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: var(--space-1);
}

.login-box .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.87rem;
  margin-bottom: var(--space-6);
}

.login-box .card { padding: var(--space-8) var(--space-6); box-shadow: var(--shadow-md); }

.login-box .form-grid { max-width: none; grid-template-columns: 1fr; }

.login-box .btn { width: 100%; padding: 11px 16px; margin-top: var(--space-2); }

/* ---------- Utility ---------- */

.muted { color: var(--text-faint); font-size: 0.82rem; }
.center { text-align: center; }
.actions-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.actions-row.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }

.name-link { font-weight: 600; color: var(--text); }
.name-link:hover { color: var(--primary); }

h1 .h1-sub { font-size: 1rem; font-weight: 500; }

.ellipsis {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-with-margin { margin-top: var(--space-4); }

.file-input {
  font-size: 0.85rem;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  background: var(--surface-2);
}
.file-input::file-selector-button {
  margin-right: var(--space-3);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}
.file-input::file-selector-button:hover { background: var(--surface-2); }

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details[open] summary { margin-bottom: var(--space-2); }

hr.sep { border: none; border-top: 1px solid var(--border); margin: var(--space-5) 0; }

.back-link {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
}
.back-link:hover { color: var(--primary); }

tr.row-fds td { background: var(--amber-soft); }
tr.row-fds:hover td { background: #faead0; }

/* ---------- Correction popover ---------- */

details.corrigir { position: relative; }
details.corrigir summary::after { content: ""; }

.corrigir-painel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: var(--space-4);
}

.corrigir-painel input,
.corrigir-painel select {
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: inherit;
}

.corrigir-painel input[type="time"] { flex: 1; min-width: 0; }
.corrigir-painel input[type="text"] { width: 100%; }
.corrigir-painel .actions-row { flex-wrap: nowrap; }
.corrigir-painel .actions-row select { flex: 1; min-width: 0; }
