/* ============================================================
   Indicador de Atendimento FME — CGR/SES-SP
   Tema institucional claro. Sem fontes externas (intranet).
   ============================================================ */

:root {
  --bg: #eef3f1;
  --surface: #ffffff;
  --surface-2: #f7faf9;
  --ink: #132420;
  --muted: #5a6b64;
  --line: #d9e3df;
  --accent: #0b6b4f;
  --accent-dark: #084d39;
  --accent-soft: #e2f1ea;
  --ok: #15803d;
  --ok-soft: #dcf3e3;
  --warn: #b45309;
  --warn-soft: #fdf0dd;
  --danger: #b3261e;
  --danger-soft: #fbe5e3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(19, 36, 32, 0.06), 0 8px 24px rgba(19, 36, 32, 0.07);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
}

button, input, select { font: inherit; color: inherit; }

/* ---------------- Barra superior ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}

.brand strong { display: block; font-size: 1rem; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 0.75rem; }

.topbar-right { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.chip {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
  font-size: 0.8rem;
  max-width: 40ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- Botões ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  border-color: var(--line);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  text-decoration: none;
}

.btn:hover { background: #eef4f1; border-color: #c4d2cc; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(11, 107, 79, 0.35); outline-offset: 1px; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.ghost { background: transparent; }
.btn.small { padding: 0.35rem 0.8rem; font-size: 0.85rem; }
.btn.big { width: 100%; padding: 0.85rem 1.2rem; font-size: 1.05rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------------- Login ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  width: min(880px, 100%);
  background: var(--surface);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.login-brand {
  background: linear-gradient(160deg, var(--accent-dark), var(--accent));
  color: #fff;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
}

.login-brand h1 { font-size: 1.7rem; line-height: 1.25; font-weight: 800; }
.login-brand p { color: rgba(255, 255, 255, 0.85); font-size: 0.95rem; }
.login-brand .org { font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(255,255,255,0.7); font-weight: 700; }

.login-form { padding: 2.5rem 2.2rem; display: flex; flex-direction: column; gap: 1.1rem; }
.login-form h2 { font-size: 1.15rem; }
.login-form .hint { margin-top: -0.6rem; }

/* ---------------- Campos ---------------- */
.field { display: flex; flex-direction: column; gap: 0.4rem; }

.field > label { font-weight: 700; font-size: 0.92rem; }

.field select,
.field input[type="number"],
.field input[type="password"],
.field input[type="text"] {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.field select:focus-visible,
.field input:focus-visible {
  outline: 3px solid rgba(11, 107, 79, 0.3);
  outline-offset: 0;
  border-color: var(--accent);
}

.hint { color: var(--muted); font-size: 0.82rem; }

.check-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.check-row input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

/* Botões segmentados SIM / NÃO */
.segmented { display: flex; gap: 0.5rem; }

.segmented label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.6rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  background: var(--surface);
  transition: all 0.12s ease;
  user-select: none;
}

.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented label:hover { border-color: #b9cac2; background: var(--surface-2); }

.segmented input:checked + span { color: inherit; }
.segmented label.checked { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.segmented input:focus-visible ~ span { outline: 2px solid var(--accent); outline-offset: 8px; }

/* ---------------- Layout do formulário ---------------- */
.layout-form {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
  gap: 1.25rem;
  width: min(1120px, 100%);
  margin: 1.5rem auto 3rem;
  padding: 0 1.25rem;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.panel-head { margin-bottom: 1.25rem; }
.panel-head h1 { font-size: 1.45rem; font-weight: 800; }
.panel-head p { color: var(--muted); font-size: 0.92rem; }

.form-panel { display: flex; flex-direction: column; gap: 1rem; }

.q-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.q-card.off { display: none; }

.q-title { display: flex; gap: 0.6rem; align-items: baseline; font-weight: 700; font-size: 0.95rem; }

.q-num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
}

.dias-row { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.dias-row input[type="number"] { width: 7.5rem; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 10px; }

/* Mensagens */
.msg { padding: 0.8rem 1rem; border-radius: 10px; font-weight: 600; font-size: 0.92rem; }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.error { background: var(--danger-soft); color: var(--danger); }
.hidden { display: none; }

/* ---------------- Grade anual ---------------- */
.side-panel h2 { font-size: 1.05rem; margin-bottom: 0.25rem; }

.year-month { margin-top: 0.9rem; }
.year-month h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.35rem; }

.week-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.week-chip {
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 8px;
  min-width: 2.4rem;
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.12s ease;
}

.week-chip:hover { border-color: #b9cac2; }
.week-chip.done { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.week-chip.selected { outline: 2.5px solid var(--accent); outline-offset: 1px; }

.legend { display: flex; gap: 1rem; margin-top: 1rem; font-size: 0.78rem; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.dot { width: 0.7rem; height: 0.7rem; border-radius: 3px; display: inline-block; border: 1.5px solid var(--line); background: var(--surface); }
.dot.done { background: var(--ok-soft); border-color: var(--ok); }

/* ---------------- Painel administrativo ---------------- */
.layout-admin {
  width: min(1240px, 100%);
  margin: 1.5rem auto 3rem;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.admin-controls { display: flex; align-items: end; gap: 1rem; flex-wrap: wrap; }
.admin-controls .field { min-width: 230px; }
.admin-controls .spacer { flex: 1; }

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

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow);
}

.kpi .kpi-label { color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi .kpi-value { font-size: 1.9rem; font-weight: 800; line-height: 1.2; }
.kpi .kpi-sub { color: var(--muted); font-size: 0.8rem; }
.kpi.alert .kpi-value { color: var(--danger); }
.kpi.good .kpi-value { color: var(--ok); }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; }

.chart-panel h2, .table-panel h2 { font-size: 1.05rem; margin-bottom: 0.75rem; }
.chart-box { width: 100%; overflow-x: auto; }
.chart-box svg { display: block; width: 100%; height: auto; }

/* Tabelas */
.table-wrap { overflow-x: auto; }

table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.86rem;
}

table.data th, table.data td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.data th {
  background: var(--surface-2);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  position: sticky;
  top: 0;
}

table.data tr.missing td { color: var(--danger); background: var(--danger-soft); }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--accent-soft); }

.tag { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }

.pend-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pend-list .chip { background: var(--danger-soft); color: var(--danger); max-width: none; }
.pend-empty { color: var(--ok); font-weight: 700; }

/* Importação */
.import-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.import-row input[type="file"] {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  background: var(--surface);
  max-width: 100%;
}
.import-result { margin-top: 1rem; }
.import-result ul { margin: 0.5rem 0 0 1.2rem; font-size: 0.85rem; }
.import-result li { margin-bottom: 0.2rem; }
.import-warnings { max-height: 16rem; overflow-y: auto; }

.unit-link { color: inherit; text-decoration: none; }
.unit-link:hover, .unit-link:focus-visible { text-decoration: underline; color: var(--accent-dark); }

/* ---------------- Responsivo ---------------- */
@media (max-width: 900px) {
  .login-card { grid-template-columns: 1fr; }
  .login-brand { padding: 1.8rem 1.6rem; }
  .layout-form { grid-template-columns: 1fr; }
  /* Alvo de toque maior para os chips de semana no celular */
  .week-chip { min-width: 3rem; padding: 0.55rem 0.5rem; }
}
