:root {
  --bg: #0f1117;
  --bg2: #171a23;
  --bg3: #1e2130;
  --border: #2a2e40;
  --accent: #e8a020;
  --accent2: #c47a10;
  --accent-dim: rgba(232,160,32,0.12);
  --text: #e8eaf0;
  --text2: #8890aa;
  --text3: #555c7a;
  --green: #2ecc71;
  --red: #e74c3c;
  --blue: #3498db;
  --radius: 10px;
  --font-head: 'Barlow Condensed', sans-serif;
  --font-body: 'Barlow', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; background: var(--bg); color: var(--text); }

body {
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 680px;
  margin: 0 auto;
}

/* ── Header ── */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
  flex-shrink: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.05em;
}

nav {
  display: flex;
  gap: 4px;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text2);
  font-family: var(--font-body);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color .15s, background .15s;
}

.nav-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

.nav-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Main ── */
main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.view { display: none; padding: 16px; }
.view.active { display: block; }

/* ── FAB ── */
#fab {
  position: fixed;
  bottom: calc(20px + var(--safe-bot));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(232,160,32,0.4);
  transition: transform .15s, box-shadow .15s;
  stroke: currentColor;
}
#fab:active { transform: scale(.93); box-shadow: 0 2px 10px rgba(232,160,32,0.3); }

/* ── Cards / sections ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text2);
}

/* ── Stat blocks ── */
.stat-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.stat-label {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}
.stat-value.accent { color: var(--accent); }
.stat-value.warn { color: var(--red); }
.stat-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── Month picker ── */
.month-picker {
  display: flex;
  align-items: center;
  gap: 4px;
}

.month-picker button {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.month-label {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 600;
  min-width: 110px;
  text-align: center;
}

/* ── Client rows (dashboard) ── */
.cliente-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cliente-row:last-child { border-bottom: none; }
.cliente-row-name { font-weight: 600; }
.cliente-row-stats { display: flex; gap: 12px; }
.cliente-row-stat { font-size: 13px; color: var(--text2); }

/* ── Service list ── */
.servico-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s;
}
.servico-item:active { border-color: var(--accent); }

.servico-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.servico-data { font-size: 12px; color: var(--text2); margin-bottom: 2px; }
.servico-cliente { font-weight: 600; font-size: 15px; }
.servico-desc { font-size: 13px; color: var(--text2); margin-top: 3px; white-space: pre-line; }
.servico-valor { font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--accent); white-space: nowrap; }

.servico-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.chip {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
}
.chip.hora { border-color: #2a3a55; color: var(--blue); }
.chip.horim { border-color: #2e2a1a; color: var(--accent); }
.chip.billing { border-color: #2a3a2a; color: var(--green); }

.pago-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 20px;
  margin-top: 4px;
}
.pago-tag.pago { background: rgba(46,204,113,0.15); color: var(--green); }
.pago-tag.pendente { background: rgba(231,76,60,0.12); color: var(--red); }

/* ── Client list ── */
.cliente-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.cliente-nome { font-weight: 600; }
.cliente-detail { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* ── Modal ── */
.hidden { display: none !important; }

#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: flex-end;
  z-index: 100;
  padding: 0;
}

#modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 700;
}

#modal-close {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
}

#modal-body {
  overflow-y: auto;
  padding: 16px 18px calc(16px + var(--safe-bot));
  -webkit-overflow-scrolling: touch;
}

/* ── Form ── */
.form-grid { display: flex; flex-direction: column; gap: 12px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text2);
}

.form-hint { font-size: 10px; color: var(--text3); font-style: italic; }

.form-control {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 9px 11px;
  width: 100%;
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text3); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 72px; }

/* ── Horímetro hint ── */
.horim-hint {
  font-size: 13px;
  color: var(--accent);
  padding: 6px 10px;
  background: var(--accent-dim);
  border-radius: 6px;
  margin-top: 4px;
}

/* ── Actions ── */
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 4px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { opacity: .85; transform: scale(.97); }

.btn-primary { background: var(--accent); color: #000; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(231,76,60,0.15); color: var(--red); border: 1px solid rgba(231,76,60,0.3); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-sm { font-size: 12px; padding: 6px 10px; border-radius: 6px; }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text3);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--text2); margin-bottom: 6px; }
.empty-sub { font-size: 13px; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bot));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 200;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { border-color: var(--green); color: var(--green); }
#toast.error { border-color: var(--red); color: var(--red); }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Export bar ── */
.export-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.servico-item, .cliente-item { animation: fadeIn .2s ease; }

/* ── Light theme override ── */
[data-theme="light"] {
  --bg: #f4f5f7;
  --bg2: #ffffff;
  --bg3: #ebedf0;
  --border: #d0d4de;
  --text: #1a1e2e;
  --text2: #555c7a;
  --text3: #9098b0;
}

/* ── Footer ── */
#app-footer {
  text-align: center;
  padding: 10px 16px calc(10px + var(--safe-bot));
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
