.app {
  position: relative;
  display: flex;
  min-height: 100vh;
}

/* ---------- Barra Lateral (Sidebar Apple Style) ---------- */
.sidebar {
  width: 240px;
  flex: 0 0 240px;
  padding: 24px 16px;
  background: var(--canvas-surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 12px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

/* Status Pill */
.db-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  margin: 0 8px;
  background: rgba(48, 209, 88, 0.1);
  border: 1px solid rgba(48, 209, 88, 0.2);
  border-radius: var(--pill);
  font-size: 11px;
  font-weight: 600;
  color: var(--good);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
}

.nav a.on {
  background: rgba(10, 132, 255, 0.14);
  color: var(--primary);
  font-weight: 600;
}

.nav svg {
  width: 17px;
  height: 17px;
  flex: none;
  opacity: 0.8;
}

.nav a.on svg {
  opacity: 1;
}

.side-foot {
  margin-top: auto;
  padding: 8px;
  font-size: 11.5px;
  color: var(--muted-dark);
  line-height: 1.5;
  border-top: 1px solid var(--line);
}

/* ---------- Área Principal ---------- */
.main {
  flex: 1;
  min-width: 0;
  padding: 36px 48px 100px;
  max-width: 1160px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.title-h {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: #ffffff;
}

.title-sub {
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 4px;
}

/* Navegação por Data */
.datenav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  background: var(--canvas-surface);
  border: 1px solid var(--card-border);
  border-radius: 50%;
  color: var(--ink);
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.icon-btn:active {
  transform: var(--press);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

.date-pill {
  min-width: 180px;
  text-align: center;
  padding: 7px 18px;
  border-radius: var(--pill);
  background: var(--canvas-surface);
  border: 1px solid var(--card-border);
  font-size: 13.5px;
  color: var(--ink);
  font-weight: 500;
}

.date-pill b {
  color: #ffffff;
  font-weight: 700;
}

/* ---------- Cards Apple Clean ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-1);
  border-radius: var(--r);
  padding: 22px;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--card-border-hover);
}

.card-lg {
  padding: 26px 28px;
  border-radius: var(--r-lg);
}

.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.card-t {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #ffffff;
}

/* Grid System */
.grid {
  display: grid;
  gap: 16px;
}

.g-2 {
  grid-template-columns: 1.35fr 0.65fr;
}

.g-3 {
  grid-template-columns: repeat(3, 1fr);
}

.g-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* ---------- Botões Apple Human Interface ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  background: var(--primary);
  color: #ffffff;
  border: 0;
  transition: all 0.12s ease;
}

.btn:hover {
  background: var(--primary-hover);
}

.btn:active {
  transform: var(--press);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  border: 1px solid var(--card-border);
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.btn.sm {
  padding: 5px 12px;
  font-size: 12.5px;
  border-radius: 6px;
}

.btn svg {
  width: 14px;
  height: 14px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Formulários & Inputs ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.input {
  width: 100%;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: #ffffff;
  font-size: 14.5px;
  transition: border-color 0.15s ease;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.25);
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238e8e93' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-position: calc(100% - 14px) 50%;
  background-size: 12px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.hint {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

/* Utilitários */
.tabbar {
  display: none;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  font-size: 14px;
}

/* Toasts Apple Style */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1c1d22;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  padding: 10px 20px;
  border-radius: var(--pill);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  z-index: 1000;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.2s ease;
  pointer-events: none;
}

.toast.show,
.toast.on {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
}

.sheet {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 420px;
  max-width: 90vw;
  background: #16171b;
  border-left: 1px solid var(--line-strong);
  padding: 28px;
  z-index: 100;
  overflow-y: auto;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* Responsividade Mobile */
@media (max-width: 960px) {
  .sidebar {
    display: none;
  }
  .main {
    padding: 20px 16px 90px;
  }
  .g-2, .g-3, .g-4 {
    grid-template-columns: 1fr;
  }
  .tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #141519;
    border-top: 1px solid var(--line);
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
    z-index: 90;
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
  }
  .tabbar a.on {
    color: var(--primary);
  }
  .tabbar svg {
    width: 20px;
    height: 20px;
  }
}