/* Roteiro · Forever Energy — estilos */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --line: #e2e7ec;
  --line-strong: #cfd7df;
  --text: #17212b;
  --text-2: #4c5966;
  --text-3: #7b8794;
  --accent: #0f7a5c;
  --accent-soft: #e3f3ed;
  --accent-text: #0b5e47;
  --danger: #c2372b;
  --danger-soft: #fdecea;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --info: #2459c4;
  --info-soft: #e8effc;
  --violet: #6b46c1;
  --violet-soft: #f0ebfb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Arranque e ecrãs de estado ─────────────────────────────────────── */
.boot, .gate {
  min-height: 100vh; display: grid; place-content: center; text-align: center;
  color: var(--text-2); gap: 12px; padding: 24px;
}
.gate h1 { margin: 0; font-size: 20px; color: var(--text); }
.gate p { margin: 0; max-width: 440px; }
.spinner {
  width: 28px; height: 28px; margin: 0 auto; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Estrutura ──────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; }
.top {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; flex-direction: column; min-width: 150px; }
.brand b { font-size: 16px; letter-spacing: -.01em; }
.brand small { color: var(--text-3); }
.top .grow { flex: 1; }
.body { display: grid; grid-template-columns: 232px 1fr; min-height: 0; }
.nav {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 57px; height: calc(100vh - 57px); overflow: auto;
}
.nav h3 {
  margin: 14px 10px 4px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3); font-weight: 600;
}
.nav h3:first-child { margin-top: 2px; }
.nav button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border: 0; background: none; border-radius: 8px;
  cursor: pointer; text-align: left; color: var(--text-2);
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav .ico { width: 18px; text-align: center; opacity: .8; }
.nav .count {
  margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12px; text-align: center; color: var(--text-2); font-weight: 600;
}
.nav .count.red { background: var(--danger); border-color: var(--danger); color: #fff; }
.nav .count.amber { background: var(--warn-soft); border-color: #f3d39d; color: var(--warn); }
.main { padding: 20px 24px 60px; min-width: 0; }
.main-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.main-head h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.main-head p { margin: 2px 0 0; color: var(--text-3); }
.main-head .grow { flex: 1; }

/* ── Controlos ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface);
  cursor: pointer; white-space: nowrap; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  border-radius: 8px; border: 1px solid transparent; background: none; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }
select.input, input.input, textarea.input {
  width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface);
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.scope { width: auto; min-width: 180px; max-width: 260px; }

/* Pesquisa global */
.search { position: relative; width: min(420px, 40vw); }
.search input { padding-left: 32px; }
.search .mag { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 60vh; overflow: auto; padding: 6px;
}
.results h4 { margin: 8px 8px 4px; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.results button {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%;
  padding: 7px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left;
}
.results button:hover, .results button.on { background: var(--surface-2); }
.results small { color: var(--text-3); }
.results .empty { padding: 10px; color: var(--text-3); }

/* ── Listas ─────────────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 8px; }
.group-title {
  display: flex; align-items: center; gap: 8px; margin: 18px 0 2px;
  font-size: 13px; font-weight: 700; color: var(--text-2);
}
.group-title:first-child { margin-top: 0; }
.group-title .n { color: var(--text-3); font-weight: 500; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start;
  padding: 11px 14px; position: relative;
}
.row.pri-1::before, .row.pri-3::before {
  content: ""; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0;
}
.row.pri-1::before { background: var(--danger); }
.row.pri-3::before { background: var(--line-strong); }
.row.done { opacity: .55; }
.row.done .t-title { text-decoration: line-through; }
.row .t-title { font-weight: 600; cursor: pointer; }
.row .t-title:hover { color: var(--accent-text); }
.row .t-sub { display: flex; gap: 10px; flex-wrap: wrap; color: var(--text-3); font-size: 13px; margin-top: 2px; }
.row .t-desc { color: var(--text-2); font-size: 13px; margin-top: 4px; white-space: pre-line; max-height: 3.2em; overflow: hidden; }
.row .t-side { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.check {
  width: 20px; height: 20px; margin-top: 1px; border-radius: 6px; border: 2px solid var(--line-strong);
  background: var(--surface); cursor: pointer; display: grid; place-items: center; padding: 0; color: #fff;
}
.check:hover { border-color: var(--accent); }
.check.on { background: var(--accent); border-color: var(--accent); }
.check svg { width: 12px; height: 12px; }
.link { color: var(--info); cursor: pointer; background: none; border: 0; padding: 0; font: inherit; }
.link:hover { text-decoration: underline; }

/* Etiquetas */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--line); white-space: nowrap;
}
.badge.red { background: var(--danger-soft); color: var(--danger); border-color: #f6c9c4; }
.badge.amber { background: var(--warn-soft); color: var(--warn); border-color: #f3d39d; }
.badge.green { background: var(--accent-soft); color: var(--accent-text); border-color: #bfe3d5; }
.badge.blue { background: var(--info-soft); color: var(--info); border-color: #c8d8f6; }
.badge.violet { background: var(--violet-soft); color: var(--violet); border-color: #d9cdf3; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--info-soft); color: var(--info); font-size: 11px; font-weight: 700; flex: none;
}
.chip-select {
  appearance: none; border: 1px solid var(--line); border-radius: 99px; padding: 2px 22px 2px 9px;
  font-size: 12px; font-weight: 600; cursor: pointer; background: var(--surface-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237b8794'/%3E%3C/svg%3E") no-repeat right 8px center;
}
.chip-select.em_curso { background-color: var(--info-soft); color: var(--info); border-color: #c8d8f6; }
.chip-select.a_aguardar { background-color: var(--violet-soft); color: var(--violet); border-color: #d9cdf3; }

/* Menu de ações */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 210px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px;
}
.menu button {
  display: flex; width: 100%; gap: 8px; align-items: center; padding: 7px 10px;
  border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left;
}
.menu button:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.menu .lbl { padding: 4px 10px; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }

/* Vazio e erros */
.empty-state {
  padding: 40px 20px; text-align: center; color: var(--text-3);
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface);
}
.empty-state b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }
.alert { padding: 10px 14px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); margin-bottom: 12px; }
.note { padding: 10px 14px; border-radius: 8px; background: var(--info-soft); color: var(--info); margin-bottom: 12px; }
.skeleton { height: 64px; border-radius: var(--radius); background: linear-gradient(90deg, #eef1f4, #f7f9fa, #eef1f4); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

/* ── Painel lateral (ficha) ─────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 32, .32); z-index: 50; animation: fade .15s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(880px, 92vw); z-index: 51;
  background: var(--bg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(30px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.drawer-head {
  background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 20px 0;
}
.drawer-head .line1 { display: flex; align-items: flex-start; gap: 10px; }
.drawer-head h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.drawer-head .meta { color: var(--text-3); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 3px; }
.drawer-head .grow { flex: 1; }
.tabs { display: flex; gap: 2px; margin-top: 12px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 9px 12px; cursor: pointer; color: var(--text-2);
  border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap;
}
.tabs button.on { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .n { color: var(--text-3); font-weight: 500; margin-left: 3px; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 20px 40px; }

/* Formulários e grelhas de campos */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 18px; }
.field label, .field .k { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 3px; font-weight: 500; }
.field .v { min-height: 20px; word-break: break-word; }
.field .v.vazio { color: var(--line-strong); }
.field.wide { grid-column: 1 / -1; }
.opts { display: flex; flex-wrap: wrap; gap: 6px 14px; padding-top: 4px; }
.opts label { display: flex; align-items: center; gap: 5px; color: var(--text); font-size: 14px; margin: 0; }
.section { padding: 16px; margin-bottom: 14px; }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.section-head h3 { margin: 0; font-size: 15px; }
.section-head .grow { flex: 1; }
.section-head small { color: var(--text-3); }
.nested { margin: 14px 0 0 14px; padding-left: 14px; border-left: 2px solid var(--line); }
.nested .section { background: var(--surface-2); box-shadow: none; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.files a { display: block; }

/* Modal */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 32, .4); animation: fade .12s; }
.modal { width: min(560px, 100%); max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal header { padding: 16px 20px 0; display: flex; align-items: center; }
.modal header h2 { margin: 0; font-size: 17px; flex: 1; }
.modal .content { padding: 14px 20px; display: grid; gap: 12px; }
.modal footer { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.picker { position: relative; }
.picked { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); }
.picked .grow { flex: 1; }

/* Notas */
.notes { display: flex; flex-direction: column; gap: 10px; }
.note-item { padding: 10px 14px; }
.note-item .who { font-size: 12px; color: var(--text-3); margin-bottom: 3px; }
.note-item .txt { white-space: pre-line; }

/* Avisos */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: 10px;
  background: #1d2733; color: #fff; box-shadow: var(--shadow-lg); animation: fade .15s; max-width: 92vw;
}
.toast.err { background: var(--danger); }
.toast button { background: none; border: 0; color: #9fe0c8; font-weight: 700; cursor: pointer; padding: 0; }

/* Processos */
.proc-edit { padding: 12px 14px 14px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.kv { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── Ecrãs estreitos ────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .body { grid-template-columns: 1fr; }
  .nav {
    position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 8px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .nav h3 { display: none; }
  .nav button { width: auto; white-space: nowrap; }
  .top { flex-wrap: wrap; padding: 10px 16px; }
  .search { width: 100%; order: 5; }
  .main { padding: 16px 16px 60px; }
  .row { grid-template-columns: auto 1fr; }
  .row .t-side { grid-column: 2; justify-content: flex-start; }
  .two { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
}
