/* O atributo HTML `hidden` deve sempre esconder o elemento, mesmo quando há
   uma regra de autor com `display` (ex.: .login-screen usa display:flex e sem
   isto continuaria visível por cima do app ao fazer login). */
[hidden] { display: none !important; }

:root {
  --ink: #15212e;
  --ink-2: #1d2c3d;
  --paper: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --line: #d6dde4;
  --line-strong: #c2cdd7;
  --accent: #0e8a93;
  --accent-deep: #0a6b72;
  --amber: #b9781a;
  --amber-bg: #fbf1dd;
  --text: #1b2733;
  --muted: #5d6b78;
  --muted-2: #8896a3;
  --danger: #b23b3b;

  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --display: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 10px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--body);
  color: var(--text);
  background: var(--paper);
  font-size: 14px;
  line-height: 1.5;
}

button { font-family: inherit; }

.mono-count, .pill { font-family: var(--mono); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  height: 60px;
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 26px; width: auto; display: block; }
.brand-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8fb6ba;
  padding-left: 12px;
  border-left: 1px solid #2c3e50;
}

.search-wrap { flex: 1; max-width: 560px; }
#search {
  width: 100%;
  height: 38px;
  border: 1px solid #2c3e50;
  background: #11202c;
  color: #eef4f5;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 13.5px;
  outline: none;
}
#search::placeholder { color: #6f8593; }
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(14,138,147,0.25); }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ---------- Buttons ---------- */
.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .14s, border-color .14s, color .14s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost { background: transparent; color: #cdd9df; border-color: #324656; }
.btn-ghost:hover { background: #1d2c3d; color: #fff; }
.btn-small {
  height: 30px; padding: 0 10px; font-size: 12px;
  background: var(--surface); color: var(--accent-deep);
  border: 1px solid var(--line-strong);
}
.btn-small:hover { background: var(--surface-2); border-color: var(--accent); }
.btn.is-active { background: var(--amber); border-color: var(--amber); color: #fff; }

.pill {
  display: inline-block;
  min-width: 18px;
  text-align: center;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 20px;
  background: rgba(255,255,255,0.16);
}
.btn.is-active .pill { background: rgba(0,0,0,0.18); }

.icon-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 16px; color: var(--muted); width: 32px; height: 32px;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 60px);
}

/* ---------- Sidebar ---------- */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 10px;
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex; align-items: center; gap: 7px;
}
.mono-count { color: var(--accent-deep); }

.empresa-list { list-style: none; margin: 0; padding: 4px 8px 24px; }
.empresa-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  padding: 11px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
}
.empresa-item:hover { background: var(--surface-2); }
.empresa-item.selected { background: #e6f3f4; border-color: #bfe1e3; }
.emp-code {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-deep);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
  height: fit-content;
  letter-spacing: 0.02em;
}
.empresa-item.selected .emp-code { background: #fff; border-color: #bfe1e3; }
.emp-main { min-width: 0; }
.emp-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.emp-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 3px;
  font-size: 11.5px; color: var(--muted);
}
.emp-area {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}
.emp-proj {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted-2);
  white-space: nowrap;
}
.flag-dot { color: var(--amber); font-size: 13px; }

/* ---------- Detail ---------- */
.detail { overflow-y: auto; padding: 0; }
.empty-state {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--muted); padding: 40px;
}
.empty-title { font-family: var(--display); font-size: 20px; color: var(--ink); margin: 0 0 6px; }
.empty-sub { margin: 0; max-width: 360px; }

.detail-inner { padding: 28px 34px 60px; max-width: 920px; }

.detail-header { border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 22px; }
.detail-eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent-deep); margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.detail-eyebrow .sep { color: var(--line-strong); }
.detail-title-row { display: flex; align-items: flex-start; gap: 14px; }
.detail-title {
  font-family: var(--display); font-weight: 700; font-size: 30px;
  line-height: 1.1; color: var(--ink); margin: 0; flex: 1;
}
.detail-actions { display: flex; gap: 7px; flex-shrink: 0; }

.detail-area-chip {
  display: inline-block; font-size: 12px; color: var(--accent-deep);
  background: #e6f3f4; border: 1px solid #cfe6e7; border-radius: 20px;
  padding: 3px 11px; margin-top: 12px;
}
.detail-desc { margin: 16px 0 0; color: #33414e; font-size: 14.5px; line-height: 1.62; max-width: 720px; }
.detail-site { margin-top: 12px; font-size: 13px; }
.detail-site a { color: var(--accent-deep); text-decoration: none; }
.detail-site a:hover { text-decoration: underline; }

/* projects */
.proj-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 30px 0 14px;
}
.proj-head .eyebrow { color: var(--ink); }
.proj-grid { display: grid; gap: 14px; }

.proj-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
}
.proj-card.needs-review { border-left: 3px solid var(--amber); background: #fffdf8; }
.proj-card-top { display: flex; align-items: flex-start; gap: 12px; }
.proj-name {
  font-family: var(--display); font-weight: 600; font-size: 17px;
  color: var(--ink); margin: 0; flex: 1;
}
.proj-card-actions { display: flex; gap: 4px; }
.status-chip {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 5px;
  border: 1px solid var(--line-strong); color: var(--muted); background: var(--surface-2);
}
.status-chip.ativo { color: #1f7a4d; background: #e7f5ec; border-color: #c3e6d1; }
.status-chip.concluido { color: #3a5a8a; background: #eaf0f9; border-color: #cdddf0; }
.status-chip.desenvolvimento { color: var(--amber); background: var(--amber-bg); border-color: #ecd8ad; }
.status-chip.pausado { color: #8a5a3a; background: #f6ece4; border-color: #e6cdb8; }

.proj-desc { margin: 12px 0 0; color: #3c4853; font-size: 13.5px; line-height: 1.58; }
.proj-desc.placeholder { color: var(--amber); font-style: italic; }

.proj-foot { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; align-items: center; }
.tag-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted-2); margin-right: 2px;
}
.tag {
  font-family: var(--mono); font-size: 11px;
  padding: 3px 8px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink-2);
}
.tag.modulo { background: #eef4f9; border-color: #d6e4ef; color: #355777; }

.proj-empty {
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: 22px; text-align: center; color: var(--muted); background: var(--surface-2);
}

/* ---------- Drawer ---------- */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(21,33,46,0.42);
  z-index: 40; animation: fade .15s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 440px; max-width: 92vw;
  background: var(--surface); z-index: 50;
  box-shadow: -12px 0 40px rgba(21,33,46,0.18);
  display: flex; flex-direction: column;
  animation: slidein .18s ease;
}
@keyframes slidein { from { transform: translateX(20px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-family: var(--display); font-size: 18px; margin: 0; color: var(--ink); }
.drawer-form { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.drawer-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.field input, .field textarea, .field select {
  font-family: var(--body); font-size: 14px; color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 9px 11px; background: #fff; outline: none; width: 100%;
}
.field textarea { resize: vertical; min-height: 110px; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px rgba(14,138,147,0.18);
}
.field .hint { font-size: 11.5px; color: var(--muted-2); }
.checkbox-row { display: flex; align-items: center; gap: 9px; }
.checkbox-row input { width: auto; }
.checkbox-row label { text-transform: none; letter-spacing: 0; font-family: var(--body); font-size: 13.5px; color: var(--text); }

/* Chips de sugestão (tecnologias/módulos já usados em outros projetos) */
.suggest-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.suggest-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted-2); margin-right: 2px;
}
.suggest-chip {
  font-family: var(--mono); font-size: 11px; line-height: 1;
  padding: 4px 9px; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
}
.suggest-chip:hover { border-color: var(--accent); color: var(--accent-deep); }
.suggest-chip.is-on {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.suggest-chip.is-on::before { content: "✓ "; }

.drawer-extra { margin-top: 4px; padding-top: 14px; border-top: 1px dashed var(--line); }

/* Editor de versões no drawer */
.versoes-list { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 10px; }
.versoes-empty { font-size: 12.5px; color: var(--muted-2); padding: 4px 0; }
.versao-row { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; background: var(--surface-2); }
.versao-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.versao-num {
  font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--accent-deep);
  background: #e6f3f4; border: 1px solid #cfe7e9; border-radius: 5px; padding: 2px 7px;
}
.versao-nome { flex: 1; }
.versao-grid { display: grid; grid-template-columns: 1fr 1fr 84px; gap: 8px; }
.versao-cell { display: flex; flex-direction: column; gap: 4px; }
.versao-cell-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted-2);
}
.versao-grid input.is-auto { background: #eef4f9; color: var(--muted); cursor: not-allowed; }

/* Versões exibidas no card do projeto */
.card-versoes { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.versao-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.versao-chip {
  font-family: var(--mono); font-size: 11px;
  padding: 3px 8px; border-radius: 5px;
  background: #f3f0fa; border: 1px solid #e0d8ef; color: #4a3d6b;
}

.drawer-danger {
  margin-top: 4px; padding-top: 16px; border-top: 1px dashed var(--line);
}
.btn-danger {
  background: transparent; color: var(--danger); border: 1px solid #e3c4c4;
  height: 34px; padding: 0 12px; border-radius: var(--radius-sm); font-size: 12.5px; cursor: pointer;
}
.btn-danger:hover { background: #fbf0f0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 8px;
  font-size: 13.5px; z-index: 60; box-shadow: 0 8px 24px rgba(21,33,46,0.28);
  animation: fade .15s ease;
}
.toast.error { background: var(--danger); }

/* ---------- Mode banner ---------- */
.mode-banner {
  background: var(--amber-bg); color: #7a5210; text-align: center;
  font-size: 12.5px; padding: 7px 16px; border-bottom: 1px solid #ecd8ad;
}
.mode-banner strong { font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .sidebar { max-height: 42vh; border-right: none; border-bottom: 1px solid var(--line); }
  .search-wrap { display: none; }
  .detail-title { font-size: 24px; }
  .detail-inner { padding: 20px 18px 50px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Login ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #20384a 0%, rgba(32,56,74,0) 60%),
    linear-gradient(180deg, #16242f 0%, #0f1922 100%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border-radius: 14px;
  padding: 34px 32px 30px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.45);
  text-align: center;
}
.login-logo { width: 168px; max-width: 70%; height: auto; display: block; margin: 4px auto 0; }
.login-sub {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted); margin: 12px 0 22px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form .field label { color: var(--muted); }
.login-btn { width: 100%; height: 42px; justify-content: center; font-size: 14px; margin-top: 6px; }
.login-error {
  margin: 0; font-size: 12.5px; color: var(--danger);
  background: #fbf0f0; border: 1px solid #e9cccc; border-radius: 7px; padding: 8px 11px;
}

/* esconde a aplicação enquanto a tela de login estiver ativa */
body.locked .topbar,
body.locked .layout,
body.locked .mode-banner { display: none; }
