:root {
  --navy: #0f1e33;
  --navy-2: #16273f;
  --orange: #e07b1f;
  --green: #1a7a4c;
  --purple: #6b3fa0;
  --gray: #6b7280;
  --red: #b3492f;
  --light-blue: #e8eef7;
  --light-gray-status: #e3e6ea;
  --bg: #f3f5f8;
  --border: #dfe4ec;
  --text: #1f2937;
  --text-light: #6b7280;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- LOGIN ---------- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy), #1c3352);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  text-align: center;
}
.login-card .bar { width: 46px; height: 4px; background: var(--orange); margin: 0 auto 18px; border-radius: 2px; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; color: var(--navy); }
.login-card p { font-size: 13px; color: var(--text-light); margin: 0 0 22px; }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; margin-bottom: 12px;
}
.login-card button {
  width: 100%; padding: 12px; border: none; border-radius: 8px;
  background: var(--navy); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer;
}
.login-card button:hover { background: var(--navy-2); }
.login-error { color: #c0392b; font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- APP SHELL ---------- */
#app { display: none; min-height: 100vh; }
#app.visible { display: block; }

header.topbar {
  background: var(--navy);
  color: #fff;
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
header.topbar .brand { display: flex; align-items: center; gap: 10px; }
header.topbar .brand-logo { height: 26px; width: auto; }
header.topbar .brand .bar { width: 4px; height: 26px; background: var(--orange); border-radius: 2px; }
header.topbar h1 { font-size: 16px; margin: 0; }
.role-badge {
  font-size: 10px; font-weight: 700; background: var(--orange); color: #fff; padding: 2px 8px;
  border-radius: 10px; vertical-align: middle; margin-left: 6px; text-transform: uppercase;
}
header.topbar .sub { font-size: 11px; color: #aebad0; margin-top: 2px; }
header.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

button.btn {
  border: none; border-radius: 8px; padding: 9px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: #c96a17; }
.btn-secondary { background: #24405f; color: #fff; }
.btn-secondary:hover { background: #2d4d72; }
/* Seletor do PDF: mesmo acabamento dos botões do cabeçalho */
header.topbar .actions #pdf-scope {
  appearance: auto;
  -webkit-appearance: auto;
  background: #24405f;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: normal;
  height: 35px;
  cursor: pointer;
}
header.topbar .actions #pdf-scope:hover { background: #2d4d72; }
header.topbar .actions #pdf-scope:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
header.topbar .actions #pdf-scope option { background: #24405f; color: #fff; }
.btn-ghost { background: transparent; color: #cdd8e8; border: 1px solid #33517a; }
.btn-danger { background: #b3492f; color: #fff; }
button.btn:disabled { opacity: .5; cursor: not-allowed; }

main { padding: 18px; max-width: 1200px; margin: 0 auto; }

.summary { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; margin-bottom: 16px; }
.summary .card {
  background: #fff; border-radius: 10px; padding: 12px 14px; border: 1px solid var(--border);
}
.summary .card .n { font-size: 20px; font-weight: 700; color: var(--navy); }
.summary .card .l { font-size: 11px; color: var(--text-light); text-transform: uppercase; letter-spacing: .03em; }
.summary .card.vgv { background: var(--navy); border-color: var(--navy); }
.summary .card.vgv .n { color: #fff; font-size: 15px; }
.summary .card.vgv .l { color: #aebad0; }
.summary .card.vgv-gerado { background: var(--green); border-color: var(--green); }
.summary .card.vgv-gerado .l { color: #d3ecdf; }

.toolbar {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px;
}
.toolbar select, .toolbar input[type="text"] {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px;
}
.toolbar .spacer { flex: 1; }

.adjust-panel {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.adjust-panel strong { font-size: 13px; color: var(--navy); margin-right: 4px; }
.adjust-panel input[type="number"] {
  width: 90px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px;
}
.adjust-panel select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; }
.hint { font-size: 11.5px; color: var(--text-light); width: 100%; }

.status-pill {
  display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 10.5px; font-weight: 700;
  color: #fff; text-transform: uppercase; letter-spacing: .02em;
}
.status-disponivel { background: var(--light-gray-status); color: var(--navy); }
.status-vendido { background: var(--green); }
.status-reservado { background: var(--orange); }
.status-decorado { background: var(--purple); }
.status-bloqueado { background: var(--red); }

/* ---------- TABLE (desktop) ---------- */
.table-wrap {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
table.units { width: 100%; border-collapse: collapse; font-size: 13px; }
table.units th {
  background: var(--navy); color: #fff; text-align: left; padding: 10px 8px; font-size: 11px;
  text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0;
}
table.units td { padding: 8px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
table.units tr.pav-row td {
  background: #fef4e9; color: #9a5311; font-weight: 700; font-size: 11.5px; padding: 6px 8px;
}
table.units tr:hover td { background: #f8fafc; }
table.units input[type="text"], table.units input[type="number"] {
  width: 100%; border: 1px solid transparent; border-radius: 6px; padding: 5px 6px; font-size: 12.5px;
  background: transparent;
}
table.units input[type="text"]:hover, table.units input[type="number"]:hover,
table.units input[type="text"]:focus, table.units input[type="number"]:focus {
  border-color: var(--border); background: #fff;
}
table.units select.status-select {
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 6px; font-size: 12px; width: 100%; min-width: 115px; box-sizing: border-box;
  padding-right: 22px; white-space: nowrap;
  font-weight: 600; cursor: pointer;
}
.st-disponivel { background: var(--light-gray-status); color: var(--navy); }
.st-vendido { background: var(--green); color: #fff; }
.st-reservado { background: var(--orange); color: #fff; }
.st-decorado { background: var(--purple); color: #fff; }
.st-bloqueado { background: var(--red); color: #fff; }
.st-vendido option, .st-reservado option, .st-decorado option, .st-bloqueado option { color: #000; background: #fff; }
.col-check { width: 30px; text-align: center; }
.col-check input { width: auto; }

/* ---------- CARDS (mobile) ---------- */
.cards-wrap { display: none; }
.unit-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px;
}
.unit-card .top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.unit-card .id { font-size: 16px; font-weight: 700; color: var(--navy); }
.unit-card .meta { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.unit-card .field { margin-top: 8px; }
.unit-card label { font-size: 10.5px; text-transform: uppercase; color: var(--text-light); display: block; margin-bottom: 3px; }
.unit-card input[type="text"], .unit-card input[type="number"], .unit-card select {
  width: 100%; padding: 8px 9px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px;
}
.pav-heading {
  font-size: 12px; font-weight: 700; color: #9a5311; background: #fef4e9; padding: 6px 10px;
  border-radius: 7px; margin: 14px 0 8px;
}

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .2s;
  z-index: 100;
}
.toast.show { opacity: 1; }

.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,30,51,.55);
  align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 640px; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; justify-content: space-between;
}
.modal-header h2 { font-size: 15px; margin: 0; color: var(--navy); }
.modal-close { border: none; background: none; font-size: 16px; cursor: pointer; color: var(--text-light); }
.modal-body { padding: 12px 18px; overflow-y: auto; }
.log-entry { padding: 10px 0; border-bottom: 1px solid #eef1f5; }
.log-entry:last-child { border-bottom: none; }
.log-entry .log-meta { font-size: 11.5px; color: var(--text-light); margin-bottom: 4px; }
.log-entry .log-role {
  display: inline-block; background: var(--orange); color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 10px; margin-right: 6px; text-transform: uppercase;
}
.log-entry ul { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; }
.log-entry li { margin-bottom: 2px; }
.log-empty { color: var(--text-light); font-size: 13px; text-align: center; padding: 30px 0; }

@media (max-width: 860px) {
  .summary { grid-template-columns: repeat(3, 1fr); }
  .summary .card.vgv .n { font-size: 13px; white-space: normal; word-break: break-word; }
  .table-wrap { display: none; }
  .cards-wrap { display: block; }
  main { padding: 12px; }
  header.topbar { padding: 12px 14px; }
}


/* Cabeçalho: dimensões e tipografia uniformes para links, botões e seletor. */
header.topbar .actions { align-items: center; }
header.topbar .actions > .btn {
  box-sizing: border-box;
  height: 38px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: normal;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  white-space: nowrap;
}
header.topbar .actions > a.btn { text-decoration: none; }
header.topbar .actions > #pdf-scope {
  height: 38px;
  min-height: 38px;
  line-height: normal;
  padding: 0 32px 0 14px;
}
