/*
 * Capaxero Cloud — Anodized Operations
 * Sistema visual operacional inspirado em instrumentos premium e salas de controle.
 */

:root {
  --bg: #070806;
  --surface: #0d0f0c;
  --surface-1: #11130f;
  --surface-2: #171914;
  --surface-hover: #1b1d17;
  --surface-elevated: #141611;
  --border: rgba(210, 176, 92, .16);
  --border-strong: rgba(210, 176, 92, .34);
  --border-soft: rgba(239, 229, 194, .08);
  --text: #f2eee3;
  --text-primary: #f2eee3;
  --text-soft: #c7c1b2;
  --text-muted: #8d8b82;
  --text-dim: #66675f;
  --brand-yellow: #d7ad4a;
  --brand-gold: #d7ad4a;
  --brand-green: #5ee39c;
  --brand-blue: #86a9ae;
  --brand-navy: #25383a;
  --status-green: #5ee39c;
  --status-blue: #86a9ae;
  --status-orange: #f0a64a;
  --status-red: #ff6b70;
  --font-display: 'Archivo', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --sidebar-w: 124px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --shadow-low: 0 18px 48px -34px rgba(0, 0, 0, .95);
  --shadow-high: 0 30px 90px -42px rgba(0, 0, 0, 1);
}

* { scrollbar-width: thin; scrollbar-color: rgba(215, 173, 74, .34) rgba(255,255,255,.035); }
*::selection { color: #090a08; background: #e0bb62; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: rgba(255,255,255,.025); }
*::-webkit-scrollbar-thumb { background: rgba(215,173,74,.3); border: 2px solid #0b0d0a; border-radius: 9px; }

html { background: var(--bg); }

body {
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 18% -8%, rgba(151, 112, 28, .13), transparent 72%),
    radial-gradient(680px 460px at 92% 14%, rgba(28, 85, 61, .09), transparent 75%),
    var(--bg);
  font-family: var(--font-body);
  letter-spacing: -.01em;
}

body::after {
  content: '';
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 0 48%, rgba(215,173,74,.018) 48.1% 48.3%, transparent 48.4% 100%);
}

a { color: var(--brand-gold); text-underline-offset: 3px; }
button, input, select, textarea { caret-color: var(--brand-gold); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid #e5bd5c;
  outline-offset: 3px;
}

/* Sidebar / command rail */
.navbar {
  position: fixed !important;
  z-index: 1000;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  height: 100vh;
  min-height: 100vh;
  max-height: 100vh;
  padding: 22px 12px 16px;
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  justify-content: flex-start;
  gap: 0;
  border: 0;
  border-right: 1px solid var(--border);
  background: rgba(8, 9, 7, .97);
  backdrop-filter: none;
  box-shadow: 22px 0 65px -50px rgba(215,173,74,.42);
  overflow-x: hidden;
  overflow-y: auto;
}

.navbar::after {
  content: '';
  position: absolute;
  top: 22px;
  right: -1px;
  width: 1px;
  height: 96px;
  background: linear-gradient(#e1bb60, transparent);
  pointer-events: none;
}

.navbar .brand {
  min-height: 74px;
  padding: 0 7px 18px;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  flex-grow: 0;
  order: 0 !important;
  width: 100%;
}

.navbar .brand img {
  width: 52px !important;
  height: 52px !important;
  object-fit: cover;
  border: 1px solid rgba(215,173,74,.35);
  border-radius: 12px !important;
  box-shadow: 0 14px 32px -18px rgba(215,173,74,.65);
}

.brand-lockup { display: grid; gap: 1px; text-align: center; margin-top: 6px; }
.brand-lockup b { color: #f2eee3; font-family: var(--font-body); font-size: 10px; letter-spacing: .12em; }
.brand-lockup small { color: var(--brand-gold); font-family: var(--font-mono); font-size: 8px; letter-spacing: .24em; }

.nav-tabs {
  width: 100% !important;
  height: auto !important;
  margin: 18px 0 auto !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  gap: 7px !important;
  border: 0 !important;
  overflow: visible !important;
  flex-shrink: 0;
  flex-grow: 0;
  order: 1 !important;
}

.nav-tab-btn {
  position: relative !important;
  width: 100% !important;
  min-height: 64px !important;
  height: auto !important;
  padding: 9px 7px !important;
  margin: 0 !important;
  display: flex;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
  color: #777970 !important;
  border: 1px solid transparent !important;
  border-radius: 12px !important;
  background: transparent !important;
  font-size: 9px !important;
  font-weight: 700 !important;
  letter-spacing: .02em !important;
  line-height: 1.15 !important;
  text-align: center !important;
  white-space: normal !important;
  overflow-wrap: anywhere;
  flex-shrink: 0;
  transform: none !important;
  box-sizing: border-box !important;
  transition: color 180ms ease, background 180ms ease, border-color 180ms ease !important;
}

/* Neutralize style.css residual pseudo-element */
.nav-tab-btn::after {
  content: none !important;
}

.nav-tab-btn .i { width: 19px !important; height: 19px !important; stroke-width: 1.6; }
.nav-tab-btn > span { display: block; max-width: 100%; }
.nav-tab-btn:hover { color: #d4cfbf !important; background: rgba(215,173,74,.045) !important; border-color: rgba(215,173,74,.1) !important; }
.nav-tab-btn.active {
  color: #e4bd61 !important;
  border-color: rgba(215,173,74,.3) !important;
  background: #15140f !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.018), 0 16px 36px -26px rgba(215,173,74,.78) !important;
}
.nav-tab-btn.active::after {
  content: '' !important;
  position: absolute !important;
  top: 14px !important;
  right: -13px !important;
  bottom: 14px !important;
  left: auto !important;
  width: 2px !important;
  height: auto !important;
  background: #e1b64e !important;
  box-shadow: 0 0 12px rgba(225,182,78,.8) !important;
  border-radius: 2px 0 0 2px !important;
  transform: none !important;
  opacity: 1 !important;
}

.navbar-search {
  position: fixed;
  z-index: 1002;
  top: 22px;
  right: 238px;
  width: min(390px, 31vw);
  height: 43px;
  margin: 0;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: #0d0f0c;
  box-shadow: var(--shadow-low);
}
.navbar-search:focus-within { border-color: var(--border-strong); box-shadow: 0 18px 48px -32px rgba(215,173,74,.35); }
.navbar-search input { color: var(--text); font-size: 12px; }
.navbar-search input::placeholder { color: #777970; }

.profile-wrap { position: fixed; z-index: 1003; top: 22px; right: 26px; margin: 0; }
.profile-btn {
  height: 43px;
  padding: 0 13px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: #0d0f0c;
  box-shadow: var(--shadow-low);
}
.profile-btn:hover { border-color: var(--border-strong); background: #151711; }
.profile-role { color: #0a0b08; background: var(--brand-gold); }
.profile-menu {
  top: 52px;
  right: 0;
  width: 370px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: #10120e;
  box-shadow: var(--shadow-high);
}

.ownership-bar {
  position: fixed;
  z-index: 990;
  top: 0;
  right: 0;
  left: var(--sidebar-w);
  height: 87px;
  padding: 23px 26px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(7,8,6,.92);
  backdrop-filter: blur(18px);
}
.ownership-bar-label { color: #777970; font-size: 9px; letter-spacing: .12em; }
.segmented { margin-left: 4px; padding: 3px; border-color: var(--border-soft); border-radius: 10px; background: #0c0e0b; }
.segmented button { min-height: 29px; padding: 0 11px; color: #888a80; border-radius: 7px; font-size: 10px; }
.segmented button.active { color: #0c0d0a; background: #d7ad4a; box-shadow: none; }

/* Restrições de perfil: ocultar elementos de administrador para não-admin */
body:not(.is-admin) .admin-only,
body:not(.is-admin) #tab-cadastros,
body:not(.is-admin) #tab-manutencao,
body:not(.is-admin) #ownership-bar,
body:not(.is-admin) .ownership-bar,
body:not(.is-admin) #page-cadastros,
body:not(.is-admin) #page-manutencao,
.nav-tab-btn[style*="display: none"],
.nav-tab-btn[style*="display:none"],
.ownership-bar[style*="display: none"],
.ownership-bar[style*="display:none"] {
  display: none !important;
}

body:not(.is-admin) .page {
  padding-top: 40px !important;
}

@media (max-width: 900px) {
  body:not(.is-admin) .page {
    padding-top: 24px !important;
  }
}

.dash-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 990px) {
  .dash-two-col {
    grid-template-columns: 1fr;
  }
}

/* Canvas and typography */
.page {
  width: auto;
  max-width: none;
  margin: 0 0 0 var(--sidebar-w);
  padding: 130px clamp(24px, 4vw, 64px) 56px;
}
.page > div { width: min(100%, 1560px); margin: 0 auto; }
.page.active > div { animation: cpxCommandIn 560ms var(--ease-out) both; }

.page-head { align-items: flex-end; margin-bottom: 36px; padding-bottom: 23px; border-bottom: 1px solid var(--border); }
.page-head h1 {
  max-width: 900px;
  margin: 0;
  color: #f2eee3;
  font-family: var(--font-display);
  font-size: clamp(32px, 3.8vw, 54px);
  font-style: italic;
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: .98;
  text-wrap: balance;
}
.page-head h1 .i { color: var(--brand-gold); vertical-align: .05em; font-style: normal; }
.page-head p { max-width: 68ch; margin-top: 12px; color: #969487; font-size: 12.5px; line-height: 1.65; }

h2, h3, .table-card-head h2, .panel-card h2, .chart-card h2, .station-group-head h2 {
  color: #eae5d8;
  font-family: var(--font-body);
  font-style: normal;
  font-weight: 700;
  letter-spacing: .02em;
}

/* Metrics and operational surfaces */
.kpi-grid { grid-template-columns: 1.25fr repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 30px; }
.kpi-card {
  min-height: 142px;
  padding: 22px 21px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: #10120e;
  box-shadow: var(--shadow-low);
  isolation: isolate;
}
.kpi-card::before { inset: 0; width: auto; height: 1px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 82%, #d7ad4a), transparent 68%); box-shadow: none; }
.kpi-card::after {
  content: '';
  position: absolute;
  z-index: -1;
  right: -40px;
  bottom: -72px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  filter: blur(24px);
}
.kpi-card:hover { transform: translateY(-2px); border-color: var(--border); box-shadow: 0 24px 54px -34px rgba(0,0,0,1); }
.kpi-label { color: #858479; font-size: 9.5px; letter-spacing: .12em; }
.kpi-value { margin-top: 17px; color: #f3eee0 !important; font-size: clamp(26px, 2.5vw, 36px); letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.kpi-card:first-child .kpi-value { color: #e3bd60 !important; font-size: clamp(30px, 3vw, 43px); }
.kpi-sub { margin-top: auto; padding-top: 15px; color: #7f8077 !important; font-size: 10px; }

.station-group { margin-top: 34px; }
.station-group-head { margin-bottom: 13px; padding: 0 2px 10px; border-bottom: 1px solid var(--border-soft); }
.station-group-head h2 { color: #aaa696; font-size: 10px; letter-spacing: .12em; }
.station-group-head .rev { color: var(--brand-green); }
.totem-grid { gap: 12px; }
.totem-card {
  position: relative;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: #10120e;
  box-shadow: var(--shadow-low);
}
.totem-card::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-top: 1px solid color-mix(in srgb, var(--status-color, #777) 38%, transparent);
}
.totem-card:hover { transform: translateY(-3px); border-color: var(--border); background: #131510; box-shadow: 0 28px 58px -38px rgba(0,0,0,1); }
.totem-card-top .name { color: #eee9dc; font-family: var(--font-body); font-style: normal; font-size: 14px; letter-spacing: -.015em; }
.totem-location { color: #858479; }
.cycle-box { border-color: rgba(215,173,74,.1); border-radius: 11px; background: #0b0d0a; }
.progress-track { background: rgba(255,255,255,.055); }

.table-card, .panel-card, .chart-card, .map-panel, .dashboard-card, .summary-card {
  border: 1px solid var(--border-soft) !important;
  border-radius: 14px;
  background: #10120e !important;
  box-shadow: var(--shadow-low);
}
.table-card { overflow: hidden; }
.table-card-head { min-height: 62px; padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.table-card-head h2, .panel-card h2, .chart-card h2 { font-size: 10.5px; letter-spacing: .11em; }
.table-card-head .count { color: var(--brand-gold); }
.panel-card, .chart-card { padding: 22px; }
.panel-card p { color: #8e8c81; line-height: 1.65; }

.data-table { background: transparent; }
.data-table thead th { padding: 13px 16px; color: #777970; border-bottom-color: var(--border-soft); background: #0b0d0a; font-size: 8.5px; letter-spacing: .1em; }
.data-table tbody td { padding: 15px 16px; color: #c9c4b6; border-bottom-color: rgba(255,255,255,.045); font-size: 11.5px; }
.data-table tbody tr:hover td { background: rgba(215,173,74,.035); color: #f0ebde; }
.data-table .mono { color: #aaa99f; font-variant-numeric: tabular-nums; }

/* Controls */
.btn {
  min-height: 40px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .015em;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary, .btn[style*="background:#FDCB24"], .btn[style*="background:var(--brand-yellow)"] {
  color: #0a0b08 !important;
  border-color: #d7ad4a !important;
  background: #d7ad4a !important;
  box-shadow: 0 16px 34px -24px rgba(215,173,74,.85);
}
.btn-primary:hover { background: #e2bd62 !important; }
.btn-outline { color: #bbb6a8; border-color: rgba(215,173,74,.18); background: #11130f; }
.btn-outline:hover { color: #e6bf63; border-color: rgba(215,173,74,.45); background: #171812; }
.btn-danger { color: #ff8588; border-color: rgba(255,107,112,.28); background: rgba(255,107,112,.045); }
.btn:disabled { transform: none; opacity: .48; cursor: not-allowed; }

.form-control, .map-search-box, .coupon-search-wrap {
  min-height: 43px;
  color: #e6e0d3;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: #0b0d0a;
}
.form-control::placeholder { color: #73746c; }
.form-control:focus { border-color: rgba(215,173,74,.52); box-shadow: 0 0 0 3px rgba(215,173,74,.08); }
.field-label { color: #8a887d; font-size: 9px; letter-spacing: .1em; }
select.form-control { color-scheme: dark; }
input[type='checkbox'], input[type='radio'] { accent-color: var(--brand-gold); }

/* Charts, ranking and telemetry */
.chart-card { overflow: hidden; }
.chart-head { padding-bottom: 15px; border-bottom: 1px solid var(--border-soft); }
.chart-head .total, .rank-val { color: var(--brand-green); }
.chart-gridline { border-color: rgba(255,255,255,.05); }
.rank-bar-bg { background: rgba(255,255,255,.045); }
.rank-bar-fill { background: linear-gradient(90deg, #6f571d, #d7ad4a); }
#dash-svg-chart path[stroke="#00C566"] { stroke: #5ee39c; }
#dash-svg-chart circle { stroke: #5ee39c; fill: #10120e; }
.station-cycle-chart { border-color: var(--border-soft); background: #0d0f0c; }

.gauge-card, .info-box, .cpf-summary-box, .admin-panel {
  border-color: var(--border-soft);
  border-radius: 12px;
  background: #10120e;
}
.gauge-ring { box-shadow: inset 0 0 0 1px rgba(255,255,255,.04); }
.stock-refresh-btn { background: transparent; }
.history-notice { border-radius: 11px; }
.history-notice.green { color: #8ce5b5; border-color: rgba(94,227,156,.25); background: rgba(94,227,156,.055); }
.history-notice.neutral { color: #b7b2a5; border-color: var(--border); background: rgba(215,173,74,.04); }

/* Modal system */
.modal-overlay { padding: 24px; background: rgba(2,3,2,.82); backdrop-filter: blur(10px); }
.modal-box {
  position: relative;
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: #0d0f0c;
  box-shadow: var(--shadow-high);
}
.modal-box .modal-sticky-head {
  padding: 22px 26px;
  background: #10120e;
  border-bottom: 1px solid var(--border-soft);
}
.modal-box .modal-body { padding: 22px 26px 28px; }
.modal-box .detail-loc { color: var(--text-muted); font-size: 11px; margin-top: 7px; }
.modal-box .info-box {
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: #11130f;
  box-shadow: none;
}
.modal-box .info-box .lbl { color: #858479; font-size: 9px; letter-spacing: .1em; }
.modal-box .info-box .val { color: #eee9dc; font-size: 13px; }
.modal-box .cycle-box.is-active {
  border-color: rgba(134,169,174,.5);
  background: #121a1b;
  box-shadow: inset 0 0 0 1px rgba(134,169,174,.05);
}
.modal-box .cycle-box:not(.is-active) { border-color: var(--border-soft); }
.modal-box #modal-cycle-stage { color: #f1ecdf !important; }
.modal-box #modal-cycle-sub { color: #8e9b99 !important; }
.modal-box #modal-cycle-pct { color: var(--brand-gold) !important; }
.modal-box #modal-cycle-bar { background: linear-gradient(90deg, #d7ad4a, #f0d287) !important; animation: none !important; }
.modal-box .stock-card {
  border-color: var(--border-soft);
  border-radius: 12px;
  background: #11130f;
}
.modal-box .gauge-title { color: #eee9dc; }
.modal-box .gauge-sub { color: #83c9a4; }
.modal-box .stock-updated-at { color: #777970; }
.modal-box .admin-panel {
  border-color: rgba(215,173,74,.22);
  border-radius: 12px;
  background: #11130f;
}
.modal-box .actions-row { gap: 9px; }
.modal-box .actions-row .btn { min-height: 38px; }
.modal {
  max-height: calc(100vh - 48px);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: #0d0f0c;
  box-shadow: var(--shadow-high);
}
.modal::before {
  content: '';
  position: absolute;
  z-index: 3;
  top: -1px;
  left: 28px;
  width: 110px;
  height: 1px;
  background: #e2b955;
}
.modal-header { padding: 22px 26px; border-bottom-color: var(--border-soft); background: #10120e; }
.detail-title h2, .modal-header h2 { color: #f1ecdf; font-family: var(--font-display); font-style: italic; font-weight: 900; letter-spacing: -.02em; }
.modal-body { padding: 24px 26px 28px; }
.modal-close { color: #8c8b82; border-color: var(--border-soft); border-radius: 9px; background: #151711; }
.modal-close:hover { color: #f0c667; border-color: var(--border-strong); }
.modal-tabs { gap: 20px; border-bottom-color: var(--border-soft); }
.modal-tab { min-height: 42px; color: #7f8077; font-size: 10.5px; }
.modal-tab.active { color: #dfb854; border-bottom-color: #dfb854; }

/* Auth is a complete entry experience */
.auth-backdrop {
  padding: 30px;
  background:
    radial-gradient(720px 520px at 24% 42%, rgba(160,116,24,.17), transparent 70%),
    radial-gradient(520px 400px at 82% 86%, rgba(26,91,62,.1), transparent 74%),
    #060705;
}
.auth-backdrop::before { inset: 0; border: 0; border-radius: 0; background: linear-gradient(90deg, transparent, rgba(215,173,74,.035), transparent); transform: skewX(-16deg); }
.auth-card {
  width: min(1040px, 94vw);
  min-height: 610px;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: #0d0f0c;
  box-shadow: 0 45px 130px -48px #000;
}
.auth-card::before { top: 0; bottom: auto; left: 42px; width: 150px; height: 1px; background: #d7ad4a; }
.auth-header {
  padding: 48px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  border-right: 1px solid var(--border-soft);
  background: radial-gradient(540px 420px at 70% 48%, rgba(215,173,74,.09), transparent 72%), #0a0c09;
}
.auth-brand { justify-content: flex-start; }
.auth-brand img { width: 56px !important; height: 56px !important; object-fit: cover; border: 1px solid var(--border-strong); border-radius: 12px !important; }
.auth-title { color: #efeadc; font-family: var(--font-display); font-size: 20px; font-style: italic; font-weight: 900; letter-spacing: .04em; }
.auth-sub { color: var(--brand-gold); font-family: var(--font-mono); font-size: 10px; letter-spacing: .2em; }
.auth-tagline { max-width: 38ch; color: #85857c; font-size: 11px; line-height: 1.6; }
.auth-manifesto { margin-top: auto; display: grid; gap: 20px; }
.auth-manifesto strong { color: #f2ede0; font-family: var(--font-display); font-size: clamp(39px, 4.2vw, 62px); font-weight: 900; font-style: italic; letter-spacing: -.03em; line-height: .96; }
.auth-manifesto span { max-width: 43ch; color: #99978b; font-size: 12px; line-height: 1.75; }
.auth-form { align-self: center; padding: 48px 42px; }
.auth-form::before { content: 'Acesso à central'; display: block; margin-bottom: 28px; color: #eee9dc; font-family: var(--font-display); font-size: 28px; font-weight: 900; font-style: italic; letter-spacing: -.02em; }
.auth-submit-btn { min-height: 48px; margin-top: 9px; }

/* Maps and utilities */
.leaflet-host { filter: saturate(.62) contrast(1.08); }
.leaflet-control-container { font-family: var(--font-body); }
.status-badge, .status-pill, .admin-badge, .badge { border-radius: 8px; }
.toast-msg { border-color: var(--border-strong); border-radius: 11px; background: #151711; box-shadow: var(--shadow-high); }

@keyframes cpxCommandIn {
  from { opacity: .01; filter: blur(8px); transform: translateY(12px); clip-path: inset(0 0 18px 0); }
  to { opacity: 1; filter: blur(0); transform: translateY(0); clip-path: inset(0); }
}

@media (max-width: 1180px) {
  :root { --sidebar-w: 104px; }
  .navbar { padding-inline: 9px !important; flex-direction: column !important; flex-wrap: nowrap !important; }
  .navbar .brand { order: 0 !important; flex: 0 0 auto !important; width: 100% !important; }
  .nav-tabs { order: 1 !important; flex: 0 0 auto !important; flex-direction: column !important; flex-wrap: nowrap !important; width: 100% !important; overflow: visible !important; }
  .nav-tab-btn { min-height: 58px !important; flex: 0 0 auto !important; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .navbar-search { right: 220px; width: min(340px, 34vw); }
  .ownership-bar { position: fixed !important; top: 0 !important; left: var(--sidebar-w) !important; }
  .page { margin-left: var(--sidebar-w) !important; }
}

@media (max-width: 1024px) {
  .navbar { padding: 22px 9px 16px !important; gap: 0 !important; }
  .page { margin-left: var(--sidebar-w) !important; padding: 130px 24px 56px !important; }
}

@media (max-width: 820px) {
  :root { --sidebar-w: 0px; }
  body { padding-bottom: 76px; }
  .navbar {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    width: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    height: 72px !important;
    padding: 7px 9px calc(7px + env(safe-area-inset-bottom)) !important;
    border: 0 !important;
    border-top: 1px solid var(--border) !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    background: rgba(8,9,7,.97) !important;
    overflow-y: hidden !important;
    overflow-x: auto !important;
  }
  .navbar::after, .navbar .brand, .navbar-search, .profile-wrap { display: none !important; }
  .nav-tabs {
    width: 100% !important;
    margin: 0 !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
    overflow-x: auto !important;
    align-items: center !important;
  }
  .nav-tab-btn {
    flex: 1 0 67px !important;
    min-height: 56px !important;
    padding: 6px 4px !important;
    border-radius: 9px !important;
    font-size: 8px !important;
  }
  .nav-tab-btn .i { width: 17px !important; height: 17px !important; }
  .nav-tab-btn.active::after {
    top: -8px !important;
    right: 18px !important;
    bottom: auto !important;
    left: 18px !important;
    width: auto !important;
    height: 2px !important;
    border-radius: 0 0 2px 2px !important;
  }
  .ownership-bar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
    height: 58px !important;
    padding: 10px 14px !important;
    overflow-x: auto !important;
    backdrop-filter: blur(12px) !important;
  }
  .ownership-bar-label { display: none !important; }
  .page { margin-left: 0 !important; padding: 88px 16px 30px !important; }
  .page-head { align-items: flex-start; gap: 18px; margin-bottom: 24px; padding-bottom: 18px; }
  .page-head h1 { font-size: clamp(32px, 10vw, 46px); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card { min-height: 124px; padding: 17px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal, .modal-box { width: 100% !important; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-header, .modal-sticky-head, .modal-body { padding-inline: 18px !important; }
  .auth-backdrop { padding: 16px; }
  .auth-card { min-height: 0; grid-template-columns: 1fr; }
  .auth-header { min-height: 290px; padding: 30px; border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .auth-manifesto strong { font-size: 38px; }
  .auth-manifesto span { display: none; }
  .auth-form { width: 100%; padding: 30px; }
}

@media (max-width: 540px) {
  .page { padding-inline: 12px; }
  .page-head h1 { font-size: 34px; }
  .page-head > div:last-child { width: 100%; }
  .page-head .btn { width: 100%; justify-content: center; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card, .kpi-card:first-child { min-height: 112px; }
  .kpi-value, .kpi-card:first-child .kpi-value { font-size: 30px; }
  .table-card, .panel-card, .chart-card, .map-panel { border-radius: 12px; }
  .auth-header { min-height: 250px; padding: 25px; }
  .auth-manifesto strong { font-size: 32px; }
  .auth-form { padding: 26px 24px 30px; }
  .profile-menu { right: 10px; left: 10px; width: auto; }
}

@media (max-width: 380px) {
  .navbar { height: 68px; padding-inline: 4px; }
  .nav-tabs { gap: 2px; }
  .nav-tab-btn { flex-basis: 58px; min-height: 54px; font-size: 9px; line-height: 1.15; }
  .nav-tab-btn .i { width: 16px; height: 16px; }
}

/* Modais acima da navbar (z-index 1000) — senão a barra inferior cobre o botão Salvar no celular */
.modal-overlay { z-index: 1100; }

@media (max-width: 820px) {
  .modal-overlay { overscroll-behavior: contain; }
  .modal-box { max-height: 92dvh; -webkit-overflow-scrolling: touch; }
  .modal-box .modal-body { padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important; }
  .modal-box .plans-config-grid,
  .modal-box .plan-fields,
  .modal-box .two-col { grid-template-columns: minmax(0, 1fr) !important; }
  .modal-box .plan-fields { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .modal-box form > div[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  .modal-box input, .modal-box select, .modal-box textarea { max-width: 100%; min-width: 0; font-size: 16px; }
  .modal-box .modal-actions-sticky {
    position: sticky; bottom: calc(-24px - env(safe-area-inset-bottom));
    margin: 18px -18px calc(-24px - env(safe-area-inset-bottom)) !important;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    background: #10120e; border-top: 1px solid var(--border-soft);
    z-index: 3;
  }
  .modal-box .modal-actions-sticky .btn { flex: 1; justify-content: center; }
}

@media (max-width: 420px) {
  .modal-box .plan-fields { grid-template-columns: minmax(0, 1fr) !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
