/* ============ Base / utilitarios ============ */
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
h1, h2, h3, h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: var(--stack-gap); }

/* ============ Botoes ============ */
.btn {
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
}
.btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--accent);
  color: #04130f;
  border-color: var(--accent);
  box-shadow: 0 6px 20px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 8px 26px var(--accent-glow); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: var(--danger-dim); }
.btn-sm { padding: 6px 10px; font-size: var(--fs-xs); }
.btn-icon {
  padding: 7px;
  background: transparent;
  border-color: var(--border);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }
.btn-accent-outline {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}
.btn-accent-outline:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ============ Inputs ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: var(--fs-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
input, select, textarea {
  font-family: inherit;
  font-size: var(--fs-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}
input.invalid { border-color: var(--danger); }
input.valid { border-color: var(--accent); }

/* ============ Select customizado ============ */
.select-wrap {
  position: relative;
  width: 100%;
}
select.select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  text-align: left;
}
.select-trigger:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-3);
}
.select-wrap.open .select-trigger,
.select-trigger:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}
.select-wrap.open .select-trigger {
  background: var(--surface-3);
}
.select-trigger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.select-value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.select-chevron {
  display: flex;
  flex-shrink: 0;
  color: var(--muted);
  transition: transform var(--transition), color var(--transition);
}
.select-chevron svg { width: 16px; height: 16px; }
.select-wrap.open .select-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}
.select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
  padding: 6px;
  max-height: 240px;
  overflow-y: auto;
  animation: rise var(--transition);
}
.select-menu[hidden] { display: none; }
.select-option {
  padding: 9px 12px;
  font-size: var(--fs-sm);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  outline: none;
}
.select-option:hover,
.select-option:focus-visible {
  background: var(--surface-2);
}
.select-option.selected {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.select-option.selected:hover,
.select-option.selected:focus-visible {
  background: var(--accent-dim);
  color: var(--accent);
}
.modal .select-menu { z-index: 110; }
.toolbar .select-wrap { width: auto; min-width: 150px; }

/* E-mail com dominio fixo (@financeiro.com.br) */
.email-field {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.email-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.email-field input.email-local {
  flex: 1;
  border: none;
  border-radius: 0;
  box-shadow: none;
  min-width: 0;
  background: transparent;
}
.email-field input.email-local:focus {
  border: none;
  box-shadow: none;
  outline: none;
}
.email-suffix {
  display: flex;
  align-items: center;
  padding: 0 13px 0 4px;
  color: var(--muted);
  font-size: var(--fs-md);
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}
.email-field.valid { border-color: var(--accent); }
.email-field.invalid { border-color: var(--danger); }
textarea { resize: vertical; min-height: 70px; }
.hint { font-size: var(--fs-xs); color: var(--muted); }
.hint.error { color: var(--danger); }
.hint.ok { color: var(--accent); }

/* Medidor de forca de senha */
.strength { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.strength > span {
  display: block; height: 100%; width: 0;
  transition: width var(--transition), background var(--transition);
}

/* ============ Cards ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--card-pad);
}

/* ============ Auth layout ============ */
.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  padding-top: max(28px, env(safe-area-inset-top));
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}
.auth-wrap--login::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(520px 320px at 50% 18%, rgba(79, 255, 214, 0.09), transparent 70%),
    radial-gradient(400px 280px at 80% 90%, rgba(79, 255, 214, 0.05), transparent 65%);
  pointer-events: none;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px 32px;
  box-shadow: var(--shadow);
  animation: authCardIn 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes authCardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.auth-hero {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--accent);
  color: #04130f;
  display: grid;
  place-items: center;
  box-shadow: 0 0 28px var(--accent-glow), 0 8px 24px rgba(0, 0, 0, 0.35);
}
.auth-logo svg { width: 26px; height: 26px; }
.auth-wordmark {
  font-family: "Orbitron", var(--font-sans);
  font-size: clamp(1.35rem, 5vw, 1.65rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
  line-height: 1.1;
  text-shadow:
    0 0 20px var(--accent-glow),
    0 0 40px rgba(79, 255, 214, 0.18);
}
.auth-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}
.auth-tabs-indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  border-radius: 9px;
  background: var(--accent-dim);
  border: 1px solid rgba(79, 255, 214, 0.35);
  box-shadow: 0 0 18px var(--accent-glow);
  transition: transform 340ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}
.auth-tabs[data-active="register"] .auth-tabs-indicator {
  transform: translateX(100%);
}
.auth-tabs button {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 11px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-sm);
  font-family: inherit;
  transition: color 280ms cubic-bezier(0.22, 1, 0.36, 1);
}
.auth-tabs button.active { color: var(--accent); }
.auth-panels {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  overflow: hidden;
}
.auth-panel {
  grid-area: 1 / 1;
  width: 100%;
  min-width: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 320ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 360ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 320ms;
}
.auth-panel[hidden] {
  display: none !important;
}
.auth-panels[data-direction="right"] .auth-panel:not(.auth-panel--active) {
  transform: translateX(18px);
}
.auth-panels[data-direction="left"] .auth-panel:not(.auth-panel--active) {
  transform: translateX(-18px);
}
.auth-panels .auth-panel.auth-panel--active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  pointer-events: auto;
  z-index: 1;
}
.auth-submit { width: 100%; justify-content: center; margin-top: 4px; }
.auth-link { margin: 4px 0 0; }
.auth-checkbox {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--muted);
  user-select: none;
  margin: 2px 0 4px;
}
.auth-checkbox input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.auth-checkbox-box {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--bg);
  transition:
    background var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}
.auth-checkbox input:checked + .auth-checkbox-box {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim), 0 0 12px var(--accent-glow);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2304130f' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
}
.auth-checkbox input:focus-visible + .auth-checkbox-box {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.auth-checkbox:hover .auth-checkbox-box {
  border-color: var(--accent);
}

/* ============ Boot loading (pos-login) ============ */
.boot-loading {
  --boot-accent: var(--accent);
  --boot-accent-dim: var(--accent-dim);
  --boot-accent-glow: var(--accent-glow);
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  background: var(--bg);
  opacity: 0;
  transition: opacity 320ms cubic-bezier(0.22, 1, 0.36, 1);
}
.boot-loading--visible { opacity: 1; }
.boot-loading--out { opacity: 0; pointer-events: none; }
.boot-loading__inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.boot-loading__glow {
  position: absolute;
  width: min(420px, 88vw);
  height: min(420px, 88vw);
  border-radius: 50%;
  background: radial-gradient(circle, var(--boot-accent-dim) 0%, transparent 68%);
  pointer-events: none;
}
.boot-loading__logo {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 15px;
  background: var(--boot-accent);
  color: #04130f;
  display: grid;
  place-items: center;
  box-shadow: 0 0 32px var(--boot-accent-glow), 0 10px 28px rgba(0, 0, 0, 0.35);
}
.boot-loading__logo svg { width: 28px; height: 28px; }
.boot-loading__spinner {
  position: relative;
  width: 34px;
  height: 34px;
  margin-top: 22px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--boot-accent);
  border-radius: 50%;
  animation: bootSpin 760ms linear infinite;
}
.boot-loading__label {
  position: relative;
  margin: 16px 0 0;
  font-size: var(--fs-sm);
  color: var(--muted);
  letter-spacing: 0.04em;
}
@keyframes bootSpin {
  to { transform: rotate(360deg); }
}
#boot-loading-static {
  display: none;
}
html.boot-loading-pending .app {
  visibility: hidden !important;
}
html.boot-loading-pending #boot-loading-static {
  display: grid !important;
}

/* Auth legado (outras paginas) */
.brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: #04130f;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px var(--accent-glow);
}
.brand .logo svg { width: 20px; height: 20px; }
.brand strong { font-size: var(--fs-lg); letter-spacing: -0.02em; }
.auth-sub { color: var(--muted); font-size: var(--fs-sm); margin: 2px 0 22px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; margin-bottom: 22px; }
.tabs button {
  flex: 1; border: none; background: transparent; color: var(--muted);
  padding: 9px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: var(--fs-sm);
  transition: background var(--transition), color var(--transition);
}
.tabs button.active { background: var(--surface-3); color: var(--text); }

/* ============ App shell ============ */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  color: var(--text);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: 0; height: 100vh;
  overflow: hidden;
}
.sidebar .brand { padding: 0 8px 18px; flex-shrink: 0; }
.nav {
  display: flex; flex-direction: column; gap: 2px;
  flex: 1; min-height: 0; overflow-y: auto;
  padding-right: 2px; scrollbar-gutter: stable;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 9px; color: var(--muted);
  font-weight: 550; font-size: var(--fs-sm);
  transition: background var(--transition), color var(--transition);
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-dim); color: var(--accent); }
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-icon { display: flex; align-items: center; justify-content: center; width: 18px; flex-shrink: 0; }
.nav-link { position: relative; user-select: none; -webkit-user-select: none; }
.nav-link--holding { background: var(--surface-3); transform: scale(0.98); }
.nav-marker { width: 18px; height: 18px; display: grid; place-items: center; flex-shrink: 0; color: var(--muted); }
.nav a.active .nav-marker { color: var(--accent); }
.nav-marker--bullet::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.nav-marker--square::before {
  content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor;
}
.nav-marker--circle::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  border: 2px solid currentColor; background: transparent;
}
.nav-marker--diamond::before {
  content: ""; width: 7px; height: 7px; background: currentColor;
  transform: rotate(45deg); border-radius: 1px;
}
.nav-marker--arrow svg { width: 14px; height: 14px; }
.nav-marker--none { width: 18px; }
.nav-item--shift-up { animation: nav-shift-up 420ms cubic-bezier(0.22, 1, 0.36, 1); }
.nav-item--shift-down { animation: nav-shift-down 420ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes nav-shift-up {
  0% { transform: translateY(6px); opacity: 0.55; }
  100% { transform: translateY(0); opacity: 1; }
}
@keyframes nav-shift-down {
  0% { transform: translateY(-6px); opacity: 0.55; }
  100% { transform: translateY(0); opacity: 1; }
}
.nav-reorder-menu {
  position: fixed; z-index: 1200; min-width: 196px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-soft);
  padding: 8px; display: flex; flex-direction: column; gap: 4px;
}
.nav-reorder-menu__title {
  margin: 0 8px 4px; font-size: var(--fs-xs); color: var(--muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.nav-reorder-menu button {
  display: flex; align-items: center; gap: 8px;
  border: none; background: transparent; color: var(--text);
  padding: 9px 10px; border-radius: 7px; cursor: pointer;
  font-size: var(--fs-sm); font-weight: 550; text-align: left;
  transition: background var(--transition);
}
.nav-reorder-menu button:hover:not(:disabled) { background: var(--surface-3); }
.nav-reorder-menu button:disabled { opacity: 0.35; cursor: not-allowed; }
.nav-reorder-menu button svg { width: 16px; height: 16px; flex-shrink: 0; }
.icon-flip-y { display: inline-flex; transform: rotate(180deg); }
.icon-flip-y svg { width: 16px; height: 16px; }
.nav .badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 0.65rem; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 99px; display: grid; place-items: center; padding: 0 5px;
}
.sidebar-footer { margin-top: auto; flex-shrink: 0; }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 10px 8px;
  border-top: 1px solid var(--border); margin-top: 8px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3);
  display: grid; place-items: center; font-weight: 700; color: var(--accent);
  border: 1px solid var(--border-strong); flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-chip .meta { overflow: hidden; }
.user-chip .meta b { font-size: var(--fs-sm); display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.user-chip .meta span { font-size: var(--fs-xs); color: var(--muted); }

.content { padding: var(--page-y) var(--page-x); max-width: 1280px; }
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: var(--section-gap); gap: 20px; flex-wrap: wrap;
}
.page-head-text { min-width: 0; flex: 1; }
.page-title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text);
}
.page-title::after {
  content: "";
  display: block;
  width: 36px;
  height: 3px;
  margin-top: 10px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), transparent);
  box-shadow: 0 0 14px var(--accent-glow);
}
.page-head h1 { font-size: var(--fs-xl); }
.page-head-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; flex-shrink: 0; align-items: center; }

/* ============ Cards de metrica ============ */
.metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: var(--section-gap);
}
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; cursor: pointer;
  position: relative; overflow: hidden;
  transition: transform var(--transition), border-color var(--transition);
}
.metric:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.metric .m-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.metric .m-top svg { width: 18px; height: 18px; opacity: 0.7; }
.metric .m-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.07em; }
.metric .m-value { font-size: var(--fs-2xl); font-weight: 700; margin-top: 12px; letter-spacing: -0.02em; }
.metric.pulse { animation: pulse 520ms ease-out; }
.metric .m-value.counting { color: var(--accent); text-shadow: 0 0 18px var(--accent-glow); }
.metric.metric-static { cursor: default; }
.metric.metric-static:hover { transform: none; border-color: var(--border); }
.metrics-single { grid-template-columns: repeat(auto-fit, minmax(200px, 280px)); margin-bottom: 20px; }
.metric.metric-sum-temp {
  background: var(--accent-dim);
  border-color: var(--accent);
  box-shadow: 0 6px 24px var(--accent-glow);
  cursor: default;
  padding-top: 22px;
}
.metric.metric-sum-temp:hover { transform: none; border-color: var(--accent); }
.metric.metric-sum-temp .m-label { color: var(--accent); }
.metric.metric-sum-temp .m-value { color: var(--accent); text-shadow: 0 0 18px var(--accent-glow); }
.metric-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  opacity: 0.45;
  cursor: pointer;
  transition: opacity var(--transition), background var(--transition);
}
.metric-dismiss:hover { opacity: 1; background: rgba(79, 255, 214, 0.12); }
.metric-dismiss svg { width: 14px; height: 14px; }

/* ============ Toolbar / filtros ============ */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar select, .toolbar input { width: auto; min-width: 150px; }
.spacer { flex: 1; }

/* ============ Tabelas / listas ============ */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: auto; -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 16px; font-size: var(--fs-sm); }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: var(--fs-xs); letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
td { border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--surface-2); }
.actions-cell {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.actions-cell .btn {
  flex: 0 0 auto;
  width: auto;
}
.table-wrap th:last-child,
.table-wrap td:last-child {
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
}

/* ============ Tags / chips ============ */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); font-weight: 600; padding: 3px 9px; border-radius: 99px;
  background: var(--surface-3); color: var(--muted); border: 1px solid var(--border);
}
.tag.accent { background: var(--accent-dim); color: var(--accent); border-color: transparent; }
.tag.warn { background: var(--warning-dim); color: var(--warning); border-color: transparent; }
.tag.danger { background: var(--danger-dim); color: var(--danger); border-color: transparent; }
.tag.info { background: rgba(106,168,255,0.14); color: var(--info); border-color: transparent; }
.tag.alta { background: var(--danger-dim); color: var(--danger); }
.tag.media { background: var(--warning-dim); color: var(--warning); }
.tag.baixa { background: var(--surface-3); color: var(--muted); }

/* Origem (gastos) — texto accent neon, sem fundo */
.origem-text {
  color: var(--accent);
  font-weight: 600;
  font-size: var(--fs-sm);
  text-transform: capitalize;
  text-shadow: 0 0 14px var(--accent-glow);
}

/* ============ Empty / skeleton ============ */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; opacity: 0.4; margin-bottom: 10px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
.sk-line { height: 14px; margin: 8px 0; }
.sk-card { height: 110px; border-radius: var(--radius); }

/* ============ Tabs de conteudo ============ */
.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 10px; gap: 4px; }
.seg button {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  padding: 8px 14px; border-radius: 7px; font-weight: 600; font-size: var(--fs-sm);
  transition: background var(--transition), color var(--transition);
}
.seg button.active { background: var(--surface-3); color: var(--text); }
.seg .badge { margin-left: 6px; font-size: 0.65rem; color: var(--accent); }

/* ============ Grafico de barras ============ */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 90px; gap: 12px; align-items: center; }
.bar-track { background: var(--surface-3); border-radius: 99px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width 600ms cubic-bezier(0.22,1,0.36,1); }
.bar-row .val { text-align: right; font-size: var(--fs-sm); }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.66);
  backdrop-filter: blur(3px); display: grid; place-items: center;
  z-index: 100; padding: 20px; animation: fade var(--transition);
  overflow: hidden; overscroll-behavior: none;
}
.modal {
  width: 100%; max-width: 480px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: 26px; box-shadow: var(--shadow); animation: rise var(--transition);
}
.modal h3 { font-size: var(--fs-lg); margin-bottom: 6px; }
.modal .modal-body { color: var(--muted); font-size: var(--fs-sm); margin-bottom: 20px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-pick {
  max-width: 520px;
  display: flex;
  flex-direction: column;
  max-height: min(640px, calc(100vh - 40px));
  overflow: hidden;
}
.modal-pick h3,
.modal-pick .modal-body,
.modal-pick .modal-actions { flex-shrink: 0; }
.pick-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
  max-height: 360px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-bottom: 20px;
  padding-right: 2px;
  scrollbar-gutter: stable;
}
.pick-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity var(--transition), border-color var(--transition), background var(--transition);
}
.pick-item:hover:not(:has(input:checked)) {
  opacity: 0.72;
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.pick-item:has(input:checked) {
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent-dim);
}
.pick-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.pick-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2304130f' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
}
.pick-name { flex: 1; font-size: var(--fs-sm); font-weight: 550; min-width: 0; color: var(--muted); }
.pick-price { font-size: var(--fs-sm); color: var(--muted-2); flex-shrink: 0; }
.pick-item:has(input:checked) .pick-name { color: var(--text); font-weight: 600; }
.pick-item:has(input:checked) .pick-price { color: var(--accent); }
.modal .warn-box {
  background: var(--warning-dim); border: 1px solid transparent; color: var(--warning);
  padding: 12px; border-radius: var(--radius-sm); font-size: var(--fs-sm); margin-bottom: 18px;
}

/* ============ Toasts ============ */
.toasts { position: fixed; top: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--muted); border-radius: var(--radius-sm);
  padding: 13px 16px; min-width: 260px; max-width: 360px;
  box-shadow: var(--shadow-soft); animation: slideIn var(--transition);
  display: flex; gap: 10px; align-items: flex-start;
}
.toast.success { border-left-color: var(--accent); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.toast.success svg { color: var(--accent); }
.toast.error svg { color: var(--danger); }
.toast.warning svg { color: var(--warning); }
.toast .t-msg { font-size: var(--fs-sm); }
.toast.out { animation: slideOut var(--transition) forwards; }

/* ============ Drawer (detalhe de metrica) ============ */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px); z-index: 90; animation: fade var(--transition);
  overscroll-behavior: none;
}
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 100%; max-width: 520px;
  background: var(--surface); color: var(--text);
  border-left: 1px solid var(--border-strong);
  z-index: 91; padding: 24px; box-shadow: var(--shadow);
  animation: slideDrawer var(--transition);
  display: flex; flex-direction: column; overflow: hidden;
}
.drawer h3 { font-size: var(--fs-lg); margin-bottom: 0; }
.drawer > .row.between { flex-shrink: 0; margin-bottom: 16px !important; }
.drawer-content {
  flex: 1; min-height: 0; overflow-y: auto;
  padding-right: 4px; scrollbar-gutter: stable;
}
.detail-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px;
}
.detail-item-link {
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.detail-item-link:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
  transform: translateX(-2px);
}
.detail-item-link:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}
.detail-item .di-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.detail-item .di-name { font-weight: 600; }
.detail-item .di-meta { color: var(--muted); font-size: var(--fs-xs); margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }

tbody tr.row-highlight { background: var(--accent-dim) !important; }
tbody tr.row-highlight td { color: var(--text); }
tbody tr.row-highlight .hint { color: var(--muted); }

/* ============ Scrollbars — sidebars e paineis rolaveis ============ */
.sidebar,
.nav,
.drawer,
.drawer-content,
.pick-list,
.select-menu {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) var(--surface);
}
.sidebar::-webkit-scrollbar,
.nav::-webkit-scrollbar,
.drawer::-webkit-scrollbar,
.drawer-content::-webkit-scrollbar,
.pick-list::-webkit-scrollbar,
.select-menu::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.sidebar::-webkit-scrollbar-track,
.nav::-webkit-scrollbar-track,
.drawer::-webkit-scrollbar-track,
.drawer-content::-webkit-scrollbar-track,
.pick-list::-webkit-scrollbar-track,
.select-menu::-webkit-scrollbar-track {
  background: var(--surface);
}
.sidebar::-webkit-scrollbar-thumb,
.nav::-webkit-scrollbar-thumb,
.drawer::-webkit-scrollbar-thumb,
.drawer-content::-webkit-scrollbar-thumb,
.pick-list::-webkit-scrollbar-thumb,
.select-menu::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 2px solid var(--surface);
}
.sidebar::-webkit-scrollbar-thumb:hover,
.nav::-webkit-scrollbar-thumb:hover,
.drawer::-webkit-scrollbar-thumb:hover,
.drawer-content::-webkit-scrollbar-thumb:hover,
.pick-list::-webkit-scrollbar-thumb:hover,
.select-menu::-webkit-scrollbar-thumb:hover {
  background: var(--muted-2);
}

/* ============ Pagina de configuracoes ============ */
.settings-page {
  display: grid;
  grid-template-columns: minmax(160px, 200px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 28px;
}
.settings-nav button {
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  cursor: pointer;
  font-weight: 550;
  font-size: var(--fs-sm);
  font-family: inherit;
  transition: background var(--transition), color var(--transition);
}
.settings-nav button:hover { background: var(--surface-2); color: var(--text); }
.settings-nav button.active { background: var(--accent-dim); color: var(--accent); }
.settings-panels { min-width: 0; }
.settings-panel { display: none; }
.settings-panel.active { display: block; }
.settings-panel-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 640px;
}
.settings-block {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.settings-block--tip {
  background: var(--surface-2);
  border-style: dashed;
}
.settings-block-title {
  margin: 0 0 4px;
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: -0.01em;
}
.settings-block-desc {
  margin: 0 0 16px;
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.5;
}
.settings-panel-actions {
  display: flex;
  justify-content: flex-start;
  padding-top: 4px;
}
.field-hint {
  margin: 6px 0 0;
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.45;
}
.nav-icon-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.nav-icon-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.nav-icon-row__label {
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--text);
  padding-top: 8px;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-head h3 { font-size: var(--fs-lg); }
.card-head .hint { margin: 0; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.card-actions { margin-top: 2px; }
.color-picker-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.color-picker-divider {
  width: 1px;
  height: 22px;
  background: var(--border-strong);
  flex-shrink: 0;
  margin: 0 2px;
}
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border);
  background: var(--swatch); cursor: pointer; padding: 0;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.color-swatch:hover { transform: scale(1.08); }
.color-swatch.is-selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--swatch);
}
.color-custom {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px dashed var(--border-strong);
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--surface-3);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.color-custom:hover {
  transform: scale(1.08);
  border-color: var(--muted);
}
.color-custom:focus-within {
  border-style: solid;
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent-dim);
}
.color-custom input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.color-custom input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
.color-custom input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}
.color-custom input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}
.icon-pickers-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px;
}
.icon-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-picker--single-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 2px 2px 8px;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.icon-picker--single-row::-webkit-scrollbar { height: 5px; }
.icon-picker--single-row::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
}
.icon-picker--balanced {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 10px;
  min-width: 0;
  width: 100%;
}
.icon-picker-row-line {
  display: grid;
  grid-template-columns: repeat(var(--icon-cols, 8), 34px);
  gap: 8px;
  justify-content: start;
}
.icon-pick {
  width: 34px; height: 34px; display: grid; place-items: center; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-3);
  color: var(--muted); cursor: pointer; padding: 0;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.icon-pick svg { width: 16px; height: 16px; }
.icon-pick:hover { border-color: var(--border-strong); color: var(--text); }
.icon-pick.is-selected {
  border-color: var(--accent); color: var(--accent); background: var(--accent-dim);
}
.pref-hint { margin: 0; }
.pref-hint strong { color: var(--text); font-weight: 600; }

/* ============ Status / aprovacao ============ */
.status-card { max-width: 460px; text-align: center; }
.status-icon {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 18px;
  background: var(--accent-dim); display: grid; place-items: center;
}
.status-icon svg { width: 30px; height: 30px; color: var(--accent); }

/* ============ Mobile shell (header + drawer) ============ */
.mobile-header,
.sidebar-backdrop { display: none; }

/* ============ Animacoes ============ */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0% { transform: scale(1); } 45% { transform: scale(1.03); } 100% { transform: scale(1); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOut { to { opacity: 0; transform: translateX(20px); } }
@keyframes slideDrawer { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============ Responsivo ============ */
@media (max-width: 1024px) {
  .app { grid-template-columns: 220px 1fr; }
  .content { padding: var(--page-y) 24px; }
}

@media (max-width: 768px) {
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 80;
    padding: 14px var(--page-x);
    padding-top: max(14px, env(safe-area-inset-top));
    background: rgba(17, 17, 17, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .mobile-header-title {
    font-size: var(--fs-md);
    font-weight: 650;
    letter-spacing: -0.02em;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-menu-btn {
    flex-shrink: 0;
    width: var(--touch-min);
    height: var(--touch-min);
    padding: 0;
    justify-content: center;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.58);
    opacity: 0;
    pointer-events: none;
    transition: opacity 280ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .app.nav-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .app {
    display: block;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 88vw);
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    transform: translateX(-105%);
    transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
    border-right: 1px solid var(--border);
    border-bottom: none;
    padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
    box-shadow: var(--shadow);
    overflow-y: auto;
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .sidebar .brand { padding: 4px 8px 22px; margin-bottom: 4px; }
  .nav {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 4px;
    overflow: visible;
  }
  .nav a {
    min-height: var(--touch-min);
    padding: 12px 14px;
    gap: 12px;
  }
  .nav a span.label { display: inline; }
  .sidebar-footer {
    margin-top: 20px;
    margin-left: 0;
    padding-top: 8px;
  }
  .sidebar-footer .btn { min-height: var(--touch-min); margin-bottom: 12px; }
  .user-chip {
    padding: 14px 8px 4px;
    margin-top: 12px;
    border-top: 1px solid var(--border);
  }

  .content {
    padding: var(--page-y) var(--page-x);
    padding-bottom: max(var(--page-y), env(safe-area-inset-bottom));
    max-width: none;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    margin-bottom: var(--section-gap);
  }
  .page-head-actions {
    justify-content: stretch;
    gap: 10px;
  }
  .page-head-actions .btn { flex: 1 1 calc(50% - 5px); justify-content: center; min-height: var(--touch-min); }

  .metrics { grid-template-columns: 1fr; gap: 14px; }
  .metrics-single { grid-template-columns: 1fr; }
  .metric { padding: 20px 18px; }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 20px;
  }
  .toolbar .select-wrap,
  .toolbar select,
  .toolbar input { width: 100%; min-width: 0; }
  .toolbar .btn { width: 100%; justify-content: center; min-height: var(--touch-min); }
  .toolbar .spacer { display: none; }

  .table-wrap { border-radius: var(--radius-sm); }
  .table-wrap table { min-width: 640px; }
  th, td { padding: 14px 16px; }
  .table-wrap th:last-child,
  .table-wrap td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--surface);
    padding-left: 12px;
    padding-right: 12px;
    box-shadow: -6px 0 14px rgba(0, 0, 0, 0.28);
  }
  tbody tr:hover td:last-child { background: var(--surface-2); }
  .actions-cell {
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 6px;
  }
  .actions-cell .btn {
    min-height: 36px;
    min-width: 36px;
    padding: 6px;
  }

  .bar-row { grid-template-columns: 1fr; gap: 10px; }
  .bar-row .val { text-align: left; }

  .modal-overlay { padding: 16px; align-items: flex-end; }
  .modal {
    max-width: none;
    padding: 22px 20px;
    padding-bottom: max(22px, env(safe-area-inset-bottom));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
  }
  .modal-actions {
    flex-direction: column-reverse;
    gap: 10px;
    margin-top: 8px;
  }
  .modal-actions .btn { width: 100%; justify-content: center; min-height: var(--touch-min); }

  .drawer {
    max-width: 100%;
    width: 100%;
    padding: 20px var(--page-x);
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  .toasts {
    top: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
    left: var(--page-x);
    right: var(--page-x);
  }
  .toast { padding: 14px 16px; }

  .auth-wrap {
    padding: max(20px, env(safe-area-inset-top)) var(--page-x) max(20px, env(safe-area-inset-bottom));
    align-items: center;
    justify-content: center;
  }
  .auth-card {
    padding: 28px 22px 26px;
    margin: 0 auto;
  }
  .auth-hero { margin-bottom: 24px; }
  .auth-tabs button { min-height: var(--touch-min); padding: 12px; }

  .settings-page { grid-template-columns: 1fr; gap: 20px; }
  .settings-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    position: static;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav button {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 12px 18px;
    min-height: var(--touch-min);
  }
  .settings-panel-stack { max-width: none; gap: 18px; }
  .settings-block { padding: var(--card-pad); }
  .settings-panel-actions .btn { width: 100%; justify-content: center; min-height: var(--touch-min); }
  .nav-icon-row {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
  }
  .nav-icon-row__label { padding-top: 0; margin-bottom: 2px; }
  .icon-picker-row-line {
    grid-template-columns: repeat(var(--icon-cols, 8), minmax(0, 1fr));
    gap: 10px;
  }
  .icon-pick { width: 100%; max-width: 42px; height: auto; aspect-ratio: 1; }
  .icon-picker--single-row .icon-pick,
  .icon-picker--balanced .icon-pick { width: 100%; max-width: 42px; }
  .form-row { grid-template-columns: 1fr; gap: var(--stack-gap); }

  .nav-reorder-menu {
    left: var(--page-x) !important;
    right: var(--page-x);
    width: auto;
    min-width: 0;
  }

  .seg { width: 100%; }
  .seg button { flex: 1; min-height: var(--touch-min); }

  .empty { padding: 40px 20px; }
}

@media (max-width: 480px) {
  .page-head-actions .btn { flex: 1 1 100%; }
  .card-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .icon-picker--single-row .icon-pick { width: 36px; height: 36px; }
}

@media (pointer: coarse) {
  .btn { min-height: var(--touch-min); }
  .btn-sm { min-height: 38px; }
  .btn-icon { min-width: var(--touch-min); min-height: var(--touch-min); }
  .actions-cell .btn,
  .actions-cell .btn-icon,
  .actions-cell .btn-sm {
    min-width: 36px;
    min-height: 36px;
    width: auto;
  }
  .icon-picker--single-row .icon-pick { width: 38px; height: 38px; flex-shrink: 0; }
  .icon-picker--balanced .icon-pick { width: 100%; max-width: 42px; height: auto; aspect-ratio: 1; }
  .color-swatch, .color-custom { width: 32px; height: 32px; }
}
