:root {
  --bg: #14110d;
  --bg-2: #1c1813;
  --card: #231e17;
  --card-2: #2b251c;
  --line: #3a3226;
  --text: #f1e9da;
  --muted: #a99c86;
  --gold: #d4a94a;
  --gold-2: #f0cf7e;
  --gold-soft: rgba(212, 169, 74, 0.14);
  --wine: #8e2f3a;
  --red: #e07063;
  --red-soft: rgba(224, 112, 99, 0.14);
  --green: #79b88a;
  --green-soft: rgba(121, 184, 138, 0.14);
  --blue: #7ea6d6;
  --blue-soft: rgba(126, 166, 214, 0.14);
  --radius: 14px;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Manrope', system-ui, -apple-system, Segoe UI, sans-serif;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold-2); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.01em; margin: 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.gold { color: var(--gold); }
.red { color: var(--red); }
.green { color: var(--green); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { display: none; }
.main { flex: 1; min-width: 0; padding: 18px 16px calc(var(--nav-h) + var(--safe-b) + 24px); max-width: 1280px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(20, 17, 13, 0.94); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.bottom-nav button { background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 0.7rem; font-weight: 600; cursor: pointer; }
.bottom-nav button svg { width: 22px; height: 22px; }
.bottom-nav button.ativo { color: var(--gold); }

@media (min-width: 900px) {
  .bottom-nav { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 2px; width: 228px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
    padding: 22px 12px; border-right: 1px solid var(--line); background: var(--bg-2);
  }
  .sidebar .brand { padding: 4px 12px 20px; }
  .sidebar button { display: flex; align-items: center; gap: 12px; background: none; border: 0; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; cursor: pointer; text-align: left; }
  .sidebar button svg { width: 19px; height: 19px; }
  .sidebar button:hover { background: var(--card); color: var(--text); }
  .sidebar button.ativo { background: var(--gold-soft); color: var(--gold-2); }
  .sidebar .user { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); }
  .main { padding: 28px 32px 48px; }
}

.brand .t { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; color: var(--gold-2); line-height: 1; }
.brand .s { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

/* ---------- Cards / grids ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.tight { padding: 12px; }
.card h3 { margin-bottom: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.grid { display: grid; gap: 14px; }
@media (min-width: 700px) { .grid.c2 { grid-template-columns: 1fr 1fr; } .grid.c3 { grid-template-columns: repeat(3, 1fr); } .grid.c4 { grid-template-columns: repeat(4, 1fr); } }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi .l { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.kpi .v { font-family: var(--serif); font-size: 1.65rem; font-weight: 700; margin-top: 4px; line-height: 1.1; }
.kpi .d { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .t { font-weight: 600; }
.item .s { font-size: 0.8rem; color: var(--muted); margin-top: 1px; }
.item.click { cursor: pointer; }
.item.click:hover .t { color: var(--gold-2); }
.empty { color: var(--muted); font-size: 0.88rem; padding: 10px 0; }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--card-2); color: var(--text); padding: 9px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 40px; }
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a140a; }
.btn.primary:hover { background: var(--gold-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 0.84rem; }
.btn.icon { padding: 0; width: 36px; min-height: 36px; }
.btn svg { width: 17px; height: 17px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.fab { position: fixed; right: 18px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 25; width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--gold); color: #1a140a; box-shadow: 0 10px 28px rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.fab svg { width: 26px; height: 26px; }
@media (min-width: 900px) { .fab { bottom: 28px; right: 28px; } }

label.f { display: flex; flex-direction: column; gap: 5px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
input, select, textarea { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 42px; font-size: 16px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--gold); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; overflow-x: auto; max-width: 100%; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; font-size: 0.86rem; }
.seg button.ativo { background: var(--card-2); color: var(--gold-2); }

/* ---------- Chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; background: var(--card-2); color: var(--muted); white-space: nowrap; }
.chip.gold { background: var(--gold-soft); color: var(--gold-2); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 800; color: #1a140a; flex-shrink: 0; }

.progress { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 99px; transition: width .3s; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x mandatory; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
@media (min-width: 900px) { .kanban { margin: 0; padding-left: 0; padding-right: 0; } }
.col { flex: 0 0 84%; max-width: 300px; scroll-snap-align: start; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
@media (min-width: 700px) { .col { flex-basis: 250px; } }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px; font-weight: 700; font-size: 0.9rem; }
.col-head .n { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.col-body { padding: 4px 8px 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 60px; }
.col.over { border-color: var(--gold); background: var(--gold-soft); }
.kcard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px; cursor: pointer; user-select: none; }
.kcard:hover { border-color: #5a4c36; }
.kcard.dragging { opacity: 0.4; }
.kcard .t { font-weight: 700; line-height: 1.25; }
.kcard .meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; align-items: center; }
.kcard .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; }
.kcard .mv { display: flex; gap: 4px; }
.kcard .mv button { width: 30px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.kcard .mv button svg { width: 15px; height: 15px; }
.kcard img.thumb { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wd { text-align: center; font-size: 0.72rem; color: var(--muted); font-weight: 700; padding: 4px 0; }
.cal .day { min-height: 64px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 5px; font-size: 0.72rem; cursor: pointer; overflow: hidden; }
.cal .day.out { opacity: 0.3; cursor: default; }
.cal .day.today { border-color: var(--gold); }
.cal .day .n { font-weight: 700; font-size: 0.8rem; margin-bottom: 3px; }
.cal .day .ev { display: flex; gap: 3px; flex-wrap: wrap; }
.cal .day .lbl { display: none; }
@media (min-width: 700px) {
  .cal .day { min-height: 96px; }
  .cal .day .ev { display: none; }
  .cal .day .lbl { display: block; border-radius: 5px; padding: 1px 5px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
.lbl.enc, .dot.enc { background: var(--gold-soft); color: var(--gold-2); }
.dot.enc { background: var(--gold); }
.lbl.fin, .dot.fin { background: var(--red-soft); color: var(--red); }
.dot.fin { background: var(--red); }
.lbl.tar, .dot.tar { background: var(--blue-soft); color: var(--blue); }
.dot.tar { background: var(--blue); }
.lbl.met, .dot.met { background: var(--green-soft); color: var(--green); }
.dot.met { background: var(--green); }

/* ---------- Charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.bars .g { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .b { width: 40%; max-width: 22px; border-radius: 5px 5px 0 0; min-height: 2px; }
.bars .b.in { background: var(--green); }
.bars .b.out { background: var(--red); opacity: .85; }
.bars .m { font-size: 0.7rem; color: var(--muted); }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px 20px 0 0; width: 100%; max-width: 640px; max-height: 92vh; display: flex; flex-direction: column; animation: up .2s ease-out; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 20px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; gap: 10px; }
.sheet-body { padding: 4px 18px 18px; overflow-y: auto; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); flex-wrap: wrap; }
.sheet-foot .left { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 20px); transform: translateX(-50%); z-index: 80; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 600; font-size: 0.9rem; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(ellipse at top, #2a2116 0%, var(--bg) 60%); }
.login .box { width: 100%; max-width: 360px; text-align: center; }
.login .cross { width: 54px; height: 54px; margin: 0 auto 14px; }
.login .users { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 22px 0; }
.login .users button { border: 1px solid var(--line); background: var(--card); padding: 10px 14px; border-radius: 12px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.login .users button.ativo { border-color: var(--gold); background: var(--gold-soft); }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 18px 0; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--gold); }
.pin-dots i.on { background: var(--gold); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 270px; margin: 0 auto; }
.keypad button { height: 58px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); font-size: 1.35rem; font-weight: 600; cursor: pointer; }
.keypad button:active { background: var(--gold-soft); }

.tabs-inline { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.section-title { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 700; margin: 22px 0 10px; }
.check { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.check.done span { text-decoration: line-through; color: var(--muted); }
table.t { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.t td, table.t th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.t th { color: var(--muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: .06em; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 38px; height: 36px; border: 0; background: var(--card-2); cursor: pointer; font-size: 1.1rem; font-weight: 700; }
.stepper span { min-width: 40px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.banner { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; font-size: 0.88rem; }
.banner.warn { border-color: rgba(224,112,99,.4); background: var(--red-soft); }

/* ---------- Fotos ---------- */
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.foto { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.foto img { width: 100%; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; display: block; }
.foto figcaption { padding: 6px; display: flex; flex-direction: column; gap: 4px; font-size: 0.74rem; }
.foto figcaption input[type=checkbox] { width: 16px; height: 16px; }
.foto.add { align-items: center; justify-content: center; text-align: center; min-height: 130px; cursor: pointer; color: var(--muted); border-style: dashed; font-size: 0.8rem; font-weight: 600; }
.foto.add svg { width: 26px; height: 26px; color: var(--gold); }
.modal-extra .overlay { z-index: 70; }
.grid { grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
@media (min-width: 700px) { .grid.c2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
