/* ===== Tokens ===== */
:root {
  --bg:       #09090b;
  --surface:  #111113;
  --surface-2:#18181b;
  --surface-3:#222226;
  --border:   #2c2c32;
  --text:     #f4f4f6;
  --muted:    #71717a;
  --subtle:   #3f3f46;
  --accent:   #22c55e;
  --accent-dim:rgba(34,197,94,.12);
  --accent-border:rgba(34,197,94,.35);
  --danger:   #ef4444;
  --danger-dim:rgba(239,68,68,.12);
  --warning:  #f59e0b;
  --nav-h:    64px;
  --radius-sm:10px;
  --radius:   14px;
  --radius-lg:20px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
  -webkit-font-smoothing: antialiased;
}

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.brand .logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.brand span { color: var(--muted); font-weight: 400; }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  letter-spacing: .3px;
}
.badge-off { background: var(--surface-3); color: var(--muted); }
.badge-on  { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-border); }

/* ===== Pages ===== */
main { padding: 16px 16px 16px; }

.page { display: none; flex-direction: column; gap: 14px; }
.page.active { display: flex; }

/* ===== Period Toggle ===== */
.periodo {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.periodo .tab {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.periodo .tab.active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* ===== Summary Cards ===== */
.summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-lucro {
  background: linear-gradient(135deg, #15803d 0%, #16a34a 50%, #22c55e 100%);
  border-radius: var(--radius-lg);
  padding: 20px 20px 18px;
  position: relative;
  overflow: hidden;
}
.card-lucro::after {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,.07);
  border-radius: 50%;
}
.card-lucro .card-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.7);
  margin-bottom: 6px;
}
.card-lucro .card-val {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -1px;
  line-height: 1;
}

.cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

/* ===== Navegação de mês ===== */
.mes-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.mes-nav.hidden { display: none; }
.mes-nav span {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-transform: capitalize;
}
.mes-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
}
.mes-btn:hover { color: var(--text); }

.cards-row-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.card .card-icon {
  font-size: 16px;
  margin-bottom: 2px;
}
.card .card-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
}
.card .card-val {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card.receita .card-val    { color: var(--accent); }
.card.despesa .card-val    { color: var(--danger); }
.card.combustivel .card-val{ color: var(--warning); }
.card.aluguel .card-val    { color: #a78bfa; }

/* ===== Panel ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.panel-header {
  padding: 14px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
}
.panel-body { padding: 12px 16px 16px; }

/* ===== Form Tabs ===== */
.form-tabs {
  display: flex;
  gap: 6px;
  padding: 14px 16px 0;
}
.form-tab {
  flex: 1;
  padding: 9px 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: all .15s;
}
.form-tab.active {
  background: var(--accent);
  color: #052e14;
  border-color: var(--accent);
}

/* ===== Forms ===== */
.lform {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lform.hidden { display: none; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 2px;
}

input, select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder { color: var(--subtle); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2371717a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

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

/* ===== Buttons ===== */
.btn-primary {
  background: var(--accent);
  color: #052e14;
  border: none;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: opacity .15s, transform .1s;
  letter-spacing: .1px;
}
.btn-primary:active { opacity: .85; transform: scale(.98); }

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,.3);
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.btn-danger:active { background: rgba(239,68,68,.2); }

.btn-outline {
  background: var(--surface-2);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  padding: 13px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: background .15s;
}
.btn-outline:active { background: var(--accent-dim); }

/* ===== Jornada Section ===== */
.jornada-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 0 8px;
  text-align: center;
}
.jornada-empty .j-icon {
  font-size: 40px;
  line-height: 1;
}
.jornada-empty p {
  font-size: 14px;
  color: var(--muted);
  max-width: 200px;
}

.jornada-active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.jornada-stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.jornada-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.jornada-stat .js-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
}
.jornada-stat .js-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.jornada-end-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.jornada-end-row .field { flex: 1; }

/* ===== Economia ===== */
.economia {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-align: center;
  line-height: 1.4;
}
.economia.hidden { display: none; }
.economia.ok {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}
.economia.ok b { font-size: 16px; font-weight: 800; }
.economia.zero {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ===== History ===== */
.hist { list-style: none; display: flex; flex-direction: column; }
.hist li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.hist li:last-child { border-bottom: none; }
.hist-left { display: flex; align-items: center; gap: 11px; min-width: 0; }
.hist-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.hist-icon.receita    { background: var(--accent-dim); }
.hist-icon.combustivel{ background: rgba(245,158,11,.12); }
.hist-icon.despesa    { background: var(--danger-dim); }
.hist-info { min-width: 0; }
.hist-tipo {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--muted);
}
.hist-nome {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.hist-money {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.hist-money.pos { color: var(--accent); }
.hist-money.neg { color: var(--danger); }
.btn-del {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.35;
  padding: 4px;
  line-height: 1;
  transition: opacity .15s;
}
.btn-del:hover { opacity: 1; }

.empty {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty .e-icon { font-size: 32px; opacity: .5; }

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(9,9,11,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 20;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  transition: color .15s;
}
.nav-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke .15s;
}
.nav-item.active { color: var(--accent); }
.nav-item.active svg { stroke-width: 2.2; }

/* ===== Config page ===== */
.dias-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.dia-btn {
  padding: 9px 0;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: all .15s;
}
.dia-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-border);
}
.config-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding-top: 2px;
}
.config-calc {
  margin-top: 10px;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--muted);
  min-height: 42px;
}
.config-calc b { color: var(--text); }
.config-saved {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding: 4px;
}

/* ===== Page title ===== */
.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-bottom: 2px;
}
.page-sub {
  font-size: 13px;
  color: var(--muted);
}
