/* =========================================================================
   PAINEL ICEBERG — Estilos
   ========================================================================= */

:root {
  --navy: #0b2545;
  --navy-2: #13315c;
  --blue: #1f6feb;
  --blue-2: #3b82c4;
  --ice: #e8f3fb;
  --ice-2: #cfe5f5;
  --bg: #f4f7fa;
  --card: #ffffff;
  --line: #e2e8f0;
  --text: #1b2a3b;
  --muted: #64748b;

  --st-nao-iniciado: #64748b;
  --st-no-prazo: #15803d;
  --st-em-andamento: #a16207;
  --st-atrasado: #b91c1c;
  --st-concluido: #1d4ed8;
  --st-aguardando: #c2410c;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 37, 69, .05), 0 6px 18px rgba(11, 37, 69, .06);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); font-size: .88rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Topo ---------- */
.topbar {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 12px rgba(11, 37, 69, .25);
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  height: 52px; padding: 6px 12px; border-radius: 12px;
  background: #fff;
  display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
.brand-mark img { height: 38px; width: auto; max-width: 100%; display: block; }
.brand h1 { font-size: 1.25rem; letter-spacing: .12em; font-weight: 800; }
.brand p { color: var(--ice-2); font-size: .85rem; }

.tabs {
  max-width: 1280px; margin: 0 auto; padding: 0 24px;
  display: flex; gap: 4px; overflow-x: auto;
}
.tab {
  background: none; border: 0; color: var(--ice-2);
  padding: 10px 16px; cursor: pointer; font-weight: 600; font-size: .92rem;
  border-bottom: 3px solid transparent; white-space: nowrap;
  transition: color .2s, border-color .2s;
}
.tab:hover { color: #fff; }
.tab.is-active { color: #fff; border-bottom-color: #7cc0f5; }

.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px;
  background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(11, 37, 69, .25);
  padding: 6px; display: flex; flex-direction: column; z-index: 30;
}
.menu-list button {
  background: none; border: 0; text-align: left; padding: 10px 12px;
  border-radius: 8px; cursor: pointer; color: var(--text);
}
.menu-list button:hover { background: var(--ice); }

/* ---------- Layout ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 22px 24px 60px; }
.view { display: none; }
.view.is-active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
h2 { font-size: 1.15rem; color: var(--navy); margin-bottom: 4px; }

/* ---------- Botões ---------- */
.btn {
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 16px; cursor: pointer; font-weight: 600; font-size: .9rem;
  transition: background .15s, box-shadow .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible { outline: 3px solid #7cc0f5; outline-offset: 2px; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(31, 111, 235, .3); }
.btn-primary:hover { background: #1a5fd0; }
.btn-outline { background: #fff; border-color: var(--ice-2); color: var(--navy-2); }
.btn-outline:hover { background: var(--ice); }
.btn-ghost { background: rgba(255, 255, 255, .12); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, .22); }
.btn-link { background: none; color: var(--blue); padding: 9px 8px; }
.btn-link:hover { text-decoration: underline; }
.btn-sm { padding: 5px 10px; }
.btn-danger { color: var(--st-atrasado); }
.btn-danger:hover { background: #fee2e2; }

/* ---------- Semana ---------- */
.week-bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 14px 18px; margin-bottom: 18px; flex-wrap: wrap;
}
.week-center { display: flex; flex-direction: column; align-items: center; text-align: center; }
.week-center strong { font-size: 1.1rem; color: var(--navy); }
.week-right { display: flex; gap: 8px; flex-wrap: wrap; }
.week-tag {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 99px;
  background: var(--ice); color: var(--blue); font-size: .72rem; font-weight: 700; vertical-align: middle;
}

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
  border-top: 4px solid var(--ice-2);
  transition: transform .2s;
}
.kpi:hover { transform: translateY(-2px); }
.kpi-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-size: 2rem; line-height: 1.1; color: var(--navy); font-weight: 800; }
.kpi-sub { font-size: .78rem; color: var(--muted); }
.kpi-green { border-top-color: #22c55e; }
.kpi-yellow { border-top-color: #eab308; }
.kpi-red { border-top-color: #ef4444; }
.kpi-blue { border-top-color: #3b82f6; }
.kpi-main { border-top-color: var(--navy-2); background: linear-gradient(160deg, #fff, var(--ice)); }
.bar { height: 8px; background: var(--ice-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue-2), var(--blue)); border-radius: 99px; transition: width .5s ease; }

/* ---------- Toolbar / filtros ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters {
  display: grid; grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(120px, 1fr)) auto;
  gap: 10px; padding: 12px 14px; margin-bottom: 14px; align-items: center;
}
input[type="text"], input[type="search"], input[type="date"], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 111, 235, .15);
}
textarea { resize: vertical; }

/* ---------- Tabela ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; min-width: 860px; }
.grid th {
  text-align: left; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--navy-2); background: var(--ice); padding: 12px 14px; white-space: nowrap;
}
.grid td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.grid tbody tr { transition: background .15s; }
.grid tbody tr:hover { background: #f8fbfe; }
.grid tbody tr.is-done .task-link { color: var(--muted); text-decoration: line-through; text-decoration-color: #cbd5e1; }
.col-actions { text-align: right; width: 1%; white-space: nowrap; }
td.col-actions { text-align: right; white-space: nowrap; }

.task-link {
  background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
  font-weight: 600; color: var(--navy); font-size: .95rem;
}
.task-link:hover { color: var(--blue); text-decoration: underline; }
.task-meta { display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; align-items: center; }
.tag { font-size: .7rem; padding: 1px 8px; border-radius: 99px; background: #eef2f7; color: var(--muted); }
.tag-prio-alta, .tag-prio-critica { background: #fee2e2; color: #991b1b; }
.tag-prio-media { background: #fef3c7; color: #92400e; }
.late-note { font-size: .74rem; color: var(--st-atrasado); font-weight: 600; }

/* Status: badge + seletor rápido */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 99px; font-size: .76rem; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-nao-iniciado { color: var(--st-nao-iniciado); background: #f1f5f9; border-color: #e2e8f0; }
.st-no-prazo { color: var(--st-no-prazo); background: #dcfce7; border-color: #bbf7d0; }
.st-em-andamento { color: var(--st-em-andamento); background: #fef9c3; border-color: #fde68a; }
.st-atrasado { color: var(--st-atrasado); background: #fee2e2; border-color: #fecaca; }
.st-concluido { color: var(--st-concluido); background: #dbeafe; border-color: #bfdbfe; }
.st-aguardando { color: var(--st-aguardando); background: #ffedd5; border-color: #fed7aa; }

select.status-select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding: 4px 26px 4px 24px; width: auto; border-radius: 99px; font-size: .76rem; font-weight: 700;
  background-image: radial-gradient(circle, currentColor 3.5px, transparent 4px),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1l4 4 4-4' stroke='%23666' fill='none' stroke-width='1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: 9px center, right 9px center;
  background-size: 9px 9px, 10px 6px;
}

.prog { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.prog input[type="range"] { flex: 1; min-width: 70px; accent-color: var(--blue); padding: 0; height: 18px; border: 0; box-shadow: none; }
.prog output { font-size: .8rem; font-weight: 700; width: 38px; text-align: right; color: var(--navy-2); }

.icon-act {
  background: none; border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  padding: 6px 8px; font-size: .82rem; color: var(--navy-2); font-weight: 600;
}
.icon-act:hover { background: var(--ice); border-color: var(--ice-2); }
.icon-act.danger { color: var(--st-atrasado); }
.icon-act.danger:hover { background: #fee2e2; border-color: #fecaca; }

.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.foot-note { margin-top: 10px; }

/* ---------- Resumo ---------- */
.resumo-controls { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.resumo-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.field-inline { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); min-width: 240px; }
.resumo-week { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--navy); }
.resumo-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.resumo-doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 28px; overflow-x: auto; }
.resumo-doc h3 { color: var(--navy); font-size: 1.15rem; }
.resumo-doc .sub { color: var(--muted); font-size: .88rem; margin-bottom: 14px; }
table.sumtbl { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 560px; }
.sumtbl th { background: var(--navy); color: #fff; text-align: left; padding: 10px 12px; font-size: .8rem; letter-spacing: .04em; border: 1px solid var(--navy); }
.sumtbl td { padding: 9px 12px; border: 1px solid var(--line); }
.sumtbl tbody tr:nth-child(even) td { background: #f8fbfe; }
.sumtbl .st { font-weight: 700; text-align: center; white-space: nowrap; }
.sumtbl .st-nao-iniciado { background: #f1f5f9 !important; }
.sumtbl .st-no-prazo { background: #dcfce7 !important; }
.sumtbl .st-em-andamento { background: #fef9c3 !important; }
.sumtbl .st-atrasado { background: #fee2e2 !important; }
.sumtbl .st-concluido { background: #dbeafe !important; }
.sumtbl .st-aguardando { background: #ffedd5 !important; }
.sumtbl .dt { white-space: nowrap; text-align: center; }
.sum-foot { margin-top: 12px; font-size: .85rem; color: var(--muted); }

/* ---------- Histórico ---------- */
.card > h2 + .muted { margin-bottom: 12px; }
.week-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--ice-2); background: #fff; color: var(--navy-2); border-radius: 12px;
  padding: 8px 14px; cursor: pointer; text-align: left; font-size: .85rem; transition: background .15s;
}
.chip strong { display: block; }
.chip span { color: var(--muted); font-size: .75rem; }
.chip:hover { background: var(--ice); }
.chip.is-active { background: var(--navy-2); color: #fff; border-color: var(--navy-2); }
.chip.is-active span { color: var(--ice-2); }
.card { padding: 18px 20px; }
.table-card, .filters, .week-bar { padding-left: 0; padding-right: 0; }
.filters { padding: 12px 14px; }
.week-bar { padding: 14px 18px; }
#histDetail { margin-top: 18px; }
.hist-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.hist-actions { display: flex; gap: 8px; }

/* ---------- Modais ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(11, 37, 69, .5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
  animation: fade .2s ease;
}
.modal-box {
  background: #fff; border-radius: 16px; width: 100%; max-width: 640px; max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(11, 37, 69, .35);
}
.modal-box form { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 32px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { color: var(--navy); font-size: 1.1rem; }
.icon-btn { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); border-radius: 8px; padding: 2px 8px; }
.icon-btn:hover { background: var(--ice); color: var(--navy); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label, label.stack { display: flex; flex-direction: column; gap: 5px; font-size: .82rem; font-weight: 600; color: var(--navy-2); }
.span-2 { grid-column: span 2; }
.form-error { color: var(--st-atrasado); background: #fee2e2; padding: 8px 12px; border-radius: 8px; font-size: .85rem; }
input[type="range"] { accent-color: var(--blue); padding: 0; }

.detail-grid { display: grid; grid-template-columns: 140px 1fr; gap: 10px 14px; }
.detail-grid dt { color: var(--muted); font-size: .82rem; font-weight: 600; }
.detail-grid dd { margin: 0; }
.detail-desc { background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; white-space: pre-wrap; }
.pre { white-space: pre-wrap; }
.last-update { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: .84rem; color: var(--muted); }

.check { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 500; margin: 10px 0 6px; cursor: pointer; }
.check input { width: auto; accent-color: var(--blue); }
.copy-list-head { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.copy-list { border: 1px solid var(--line); border-radius: 10px; max-height: 280px; overflow-y: auto; margin: 6px 0 8px; }
.copy-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; margin: 0; }
.copy-item:last-child { border-bottom: 0; }
.copy-item:hover { background: var(--ice); }
.copy-item input { width: auto; accent-color: var(--blue); }
.copy-item small { color: var(--muted); display: block; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy);
  color: #fff; padding: 11px 20px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  z-index: 100; font-size: .9rem; animation: fade .2s ease; max-width: 90vw;
}
.toast.error { background: #991b1b; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .filters .search { grid-column: span 3; }
}
@media (max-width: 720px) {
  .page { padding: 14px 12px 50px; }
  .topbar-inner { padding: 10px 12px 4px; }
  .tabs { padding: 0 8px; }
  .brand p { display: none; }
  .brand h1 { font-size: 1.05rem; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-main { grid-column: span 2; }
  .kpi-value { font-size: 1.6rem; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .search { grid-column: span 2; }
  .week-bar { flex-direction: column; align-items: stretch; }
  .week-right { justify-content: space-between; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .detail-grid { grid-template-columns: 1fr; gap: 2px; }
  .detail-grid dd { margin-bottom: 8px; }
  .toolbar .btn { flex: 1; }

  /* Tabela vira lista de cartões no celular */
  table.grid { min-width: 0; }
  .grid thead { display: none; }
  .grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
  .grid tr { padding: 12px 14px; border-top: 1px solid var(--line); }
  .grid td { border: 0; padding: 4px 0; }
  .grid td[data-label]::before { content: attr(data-label) ": "; font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
  td.col-actions { text-align: left; }
}

/* ---------- Impressão ---------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .topbar, .toast, .modal, .page > .view:not(.printing), .resumo-controls { display: none !important; }
  .page { padding: 0; max-width: none; }
  .view.printing { display: block !important; animation: none; }
  .resumo-doc { box-shadow: none; border: 0; padding: 0; overflow: visible; }
  .sumtbl, .sumtbl th, .sumtbl td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sumtbl { min-width: 0; }
}
