:root {
  --brand: #d71920;
  --brand-2: #dc2626;
  --brand-dark: #b51218;
  --night: #0b1220;
  --charcoal: #111827;
  --slate: #1f2937;
  --steel: #374151;
  --gray: #6b7280;
  --pale: #e5e7eb;
  --white: #ffffff;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --warning: #f59e0b;
  --success: #10b981;
  --bg: #f7f8fa;
  --surface: var(--white);
  --surface-2: #f1f3f5;
  --ink: var(--charcoal);
  --muted: var(--gray);
  --line: var(--pale);
  --green: var(--accent);
  --green-dark: var(--accent-dark);
  --red: var(--brand);
  --amber: var(--warning);
  --blue: var(--accent);
  --shadow: 0 18px 40px rgba(35, 39, 47, 0.08);
  --font-brand: Montserrat, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-support: Inter, Montserrat, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-support);
  padding-bottom: env(safe-area-inset-bottom);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: none;
}

.main {
  margin: 0 auto;
  max-width: 1320px;
  width: 100%;
}

.dashboard-mode .metrics,
.dashboard-mode .client-tabs {
  display: none;
}

body:not(.dashboard-mode) #dashboard {
  display: none;
}

.sidebar {
  background: var(--night);
  color: var(--white);
  padding: 22px;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
}

.brand > div > strong,
.brand > div > span {
  display: block;
}

.brand > div > strong {
  color: var(--white);
  font-family: var(--font-brand);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
}

.brand > div > strong span {
  color: var(--brand);
}

.brand > div > span {
  color: #c8cdd5;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-top: 4px;
  text-transform: uppercase;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 auto;
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--brand);
  clip-path: polygon(50% 0, 90% 24%, 90% 76%, 50% 100%, 10% 76%, 10% 24%);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 6px;
  background: var(--night);
  clip-path: polygon(50% 0, 90% 24%, 90% 76%, 50% 100%, 10% 76%, 10% 24%);
}

.brand-letter {
  color: var(--white);
  font-family: var(--font-brand);
  font-size: 1.75rem;
  font-weight: 900;
  font-style: italic;
  line-height: 1;
  position: relative;
  z-index: 1;
  transform: skew(-8deg);
}

.brand-signal {
  position: absolute;
  right: 3px;
  top: 8px;
  width: 11px;
  height: 11px;
  z-index: 1;
  border-top: 2px solid var(--brand);
  border-right: 2px solid var(--brand);
  border-radius: 0 9px 0 0;
}

.brand-signal::after {
  content: "";
  position: absolute;
  right: -6px;
  top: -6px;
  width: 17px;
  height: 17px;
  border-top: 2px solid var(--brand);
  border-right: 2px solid var(--brand);
  border-radius: 0 14px 0 0;
}

.search span,
label {
  color: var(--muted);
  display: grid;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 700;
}

label small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.sidebar .search span {
  color: #c8cdd5;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  min-height: 42px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.sidebar input {
  background: #2c323d;
  color: var(--white);
  border-color: #454c59;
}

.sidebar-actions {
  display: grid;
  gap: 10px;
}

button,
.file-button {
  border: 0;
  border-radius: 7px;
  min-height: 42px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  font-family: var(--font-brand);
}

.primary {
  background: var(--brand);
  color: var(--white);
}

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

.ghost {
  background: var(--pale);
  color: var(--ink);
}

.danger {
  background: #fdebec;
  color: var(--red);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 36px;
  background:
    radial-gradient(circle at 18% 18%, rgba(215, 25, 32, 0.18), transparent 30%),
    linear-gradient(135deg, #050913 0%, var(--night) 48%, #151c27 100%);
}

.auth-page {
  width: min(1080px, 100%);
  min-height: min(680px, calc(100vh - 72px));
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.72fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(11, 18, 32, 0.88);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
}

.auth-hero {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: space-between;
  gap: 38px;
  padding: 48px;
  position: relative;
  color: var(--white);
}

.auth-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.28;
  background:
    linear-gradient(120deg, transparent 0 46%, rgba(215, 25, 32, 0.5) 46% 46.4%, transparent 46.4% 100%),
    linear-gradient(28deg, transparent 0 58%, rgba(255, 255, 255, 0.18) 58% 58.2%, transparent 58.2% 100%);
  pointer-events: none;
}

.auth-brand,
.auth-hero-copy,
.auth-badges {
  position: relative;
  z-index: 1;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-brand .brand-mark {
  width: 58px;
  height: 58px;
}

.auth-brand .brand-letter {
  font-size: 2.15rem;
}

.auth-brand > div > strong,
.auth-brand > div > span {
  display: block;
}

.auth-brand strong {
  color: var(--white);
  font-family: var(--font-brand);
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.auth-brand strong span {
  color: var(--brand);
  display: inline;
}

.auth-brand div > span {
  color: #d6dbe3;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-top: 5px;
  text-transform: uppercase;
}

.auth-hero-copy {
  max-width: 620px;
}

.auth-hero-copy .eyebrow {
  color: var(--brand);
}

.auth-hero-copy h1 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: clamp(2.3rem, 5vw, 4.2rem);
  line-height: 1.02;
}

.auth-hero-copy p:not(.eyebrow) {
  max-width: 560px;
  margin: 18px 0 0;
  color: #d6dbe3;
  font-size: 1.04rem;
  font-weight: 650;
  line-height: 1.5;
}

.auth-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-badges span {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #edf0f4;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.03em;
  padding: 9px 13px;
  text-transform: uppercase;
}

.auth-box {
  align-self: stretch;
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 48px;
  border-left: 1px solid var(--line);
  background: var(--white);
}

.auth-box h2 {
  margin: 0;
  font-size: 2rem;
  font-family: var(--font-brand);
}

.auth-box label {
  display: grid;
  gap: 6px;
  font-weight: 800;
  color: var(--muted);
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

.auth-box .primary {
  min-height: 48px;
}

.fvision-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 9, 19, 0.78);
}

.fvision-dialog {
  width: min(460px, 100%);
  display: grid;
  gap: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

.fvision-dialog-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background:
    linear-gradient(120deg, rgba(215, 25, 32, 0.22), transparent 38%),
    var(--night);
  color: var(--white);
}

.fvision-dialog-brand .brand-mark {
  width: 42px;
  height: 42px;
}

.fvision-dialog-brand .brand-letter {
  font-size: 1.55rem;
}

.fvision-dialog-brand strong,
.fvision-dialog-brand span {
  display: block;
}

.fvision-dialog-brand strong {
  color: var(--white);
  font-family: var(--font-brand);
  font-size: 1.15rem;
  font-weight: 850;
  line-height: 1;
}

.fvision-dialog-brand strong span {
  color: var(--brand);
  display: inline;
}

.fvision-dialog-brand div > span {
  color: #d6dbe3;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-top: 4px;
  text-transform: uppercase;
}

.fvision-dialog-body {
  display: grid;
  gap: 8px;
  padding: 4px 22px 0;
}

.fvision-dialog-body .eyebrow {
  color: var(--brand);
}

.fvision-dialog-body h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-brand);
  font-size: 1.55rem;
  line-height: 1.15;
}

.fvision-dialog-message {
  color: var(--steel);
  font-weight: 650;
  line-height: 1.45;
}

.fvision-dialog-message p {
  margin: 0 0 8px;
}

.fvision-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 4px 22px 22px;
}

.fvision-dialog-actions button {
  min-height: 42px;
}

.fvision-dialog-danger .fvision-dialog-body .eyebrow,
.fvision-dialog-danger .fvision-dialog-body h2 {
  color: var(--brand);
}

.plan-picker-dialog {
  width: min(560px, 100%);
}

.plan-picker-help,
.plan-picker-empty {
  margin: 0;
  color: var(--steel);
  font-weight: 650;
  line-height: 1.4;
}

.plan-picker-search,
.plan-picker-select {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.plan-picker-select select {
  min-height: 210px;
  padding: 4px;
}

.plan-picker-select option {
  padding: 10px;
  border-radius: 5px;
  white-space: normal;
}

.fvision-progress-dialog {
  width: min(520px, 100%);
}

.fvision-progress-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--mist);
  border: 1px solid var(--line);
}

.fvision-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width 160ms ease;
}

.fvision-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.fvision-progress-meta strong {
  color: var(--brand);
  font-family: var(--font-brand);
}

.file-button {
  background: var(--brand);
  color: var(--white);
  position: relative;
  overflow: hidden;
}

.file-button:hover {
  background: var(--brand-dark);
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.client-list {
  display: grid;
  gap: 6px;
  overflow: auto;
  padding-right: 2px;
}

.client-item {
  text-align: left;
  background: transparent;
  border: 1px solid #454c59;
  color: var(--white);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  justify-items: stretch;
  min-height: 54px;
  padding: 8px 10px;
}

.client-item.active {
  background: #303743;
  border-color: var(--brand);
}

.client-item-main {
  display: grid;
  min-width: 0;
}

.client-item-main strong,
.client-item-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-item span,
.client-item small {
  color: #c8cdd5;
  font-size: 0.78rem;
  font-weight: 700;
}

.client-item-main strong {
  color: var(--white);
  font-size: 0.88rem;
}

.client-item-counts {
  align-content: center;
  display: grid;
  gap: 3px;
  justify-items: end;
}

.client-item-counts small {
  background: rgba(215, 25, 32, 0.14);
  border-radius: 999px;
  color: #ffe3e4;
  padding: 2px 7px;
}

.main {
  padding: 28px;
  display: grid;
  gap: 20px;
  align-content: start;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: flex-start;
}

.eyebrow {
  color: var(--brand);
  margin: 0 0 4px;
  font-weight: 900;
  font-size: 0.78rem;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  letter-spacing: 0;
  font-family: var(--font-brand);
  font-weight: 800;
}

h2 {
  font-size: 1rem;
  margin-bottom: 0;
  font-family: var(--font-brand);
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.contextual-actions {
  grid-column: 2;
  display: flex;
  min-height: 42px;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.metrics article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  box-shadow: var(--shadow);
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  font-size: 1.7rem;
  margin-top: 4px;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  background: transparent;
  color: var(--muted);
  border-radius: 7px 7px 0 0;
  border-bottom: 3px solid transparent;
  min-height: 44px;
  white-space: nowrap;
}

.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  background: #fdebec;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.start-hero {
  align-items: center;
  background:
    radial-gradient(circle at 78% 28%, rgba(215, 25, 32, 0.24), transparent 18%),
    linear-gradient(135deg, var(--night), var(--charcoal));
  border-radius: 8px;
  color: var(--white);
  margin-bottom: 12px;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.start-hero::after {
  content: "";
  position: absolute;
  inset: auto -40px -62px auto;
  width: 220px;
  height: 140px;
  border-top: 2px solid rgba(215, 25, 32, 0.5);
  transform: rotate(-32deg);
}

.start-hero h2 {
  font-size: clamp(1.55rem, 3vw, 2.2rem);
  line-height: 1.15;
  margin: 0 0 8px;
  max-width: 780px;
  text-transform: uppercase;
}

.start-hero p:not(.eyebrow) {
  color: #d4d8df;
  margin-bottom: 0;
  max-width: 720px;
}

.start-actions {
  display: grid;
  gap: 10px;
  min-width: 240px;
}

.dashboard-toolbar {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 280px) minmax(180px, 220px);
  margin-bottom: 18px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
}

.admin-user-list {
  display: grid;
  gap: 8px;
}

.admin-user-row {
  width: 100%;
  display: grid;
  gap: 3px;
  justify-items: start;
  min-height: auto;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
}

.admin-user-row.active {
  border-color: var(--brand);
  background: #fdebec;
}

.admin-user-row span,
.admin-user-row small {
  color: var(--muted);
  font-weight: 800;
}

.permission-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
  color: var(--muted);
}

.permission-head strong {
  color: var(--ink);
}

.permissions-grid {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.permission-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(4, minmax(112px, max-content));
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.permission-row:last-child {
  border-bottom: 0;
}

.permission-row span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.permission-row label,
.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  color: var(--ink);
}

.permission-row label {
  justify-content: flex-start;
  min-width: 112px;
  white-space: nowrap;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--brand);
}

.checkbox-line input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
}

.admin-audit-panel {
  margin-top: 16px;
}

.admin-danger-panel {
  margin-top: 16px;
}

.asset-storage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-weight: 600;
}

.inventory-load-more {
  width: calc(100% - 24px);
  margin: 12px;
}

.audit-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.audit-row {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.audit-row span,
.audit-row small,
.audit-row em {
  color: var(--muted);
  font-size: 0.85rem;
  font-style: normal;
  font-weight: 800;
}

.dashboard-toolbar .primary,
.dashboard-toolbar .file-button {
  width: 100%;
}

.dashboard-import {
  background: var(--brand);
  color: var(--white);
}

.dashboard-import:hover {
  background: var(--brand-dark);
}

.dashboard-panel-tools {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  min-width: min(560px, 100%);
}

.dashboard-panel-tools input {
  max-width: 320px;
  min-width: 220px;
}

.dashboard-panel-tools span {
  white-space: nowrap;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
}

.dashboard-main,
.dashboard-side {
  min-width: 0;
}

.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-kpis article {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.dashboard-kpis span {
  color: var(--muted);
  display: block;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.dashboard-kpis strong {
  display: block;
  font-size: 1.75rem;
  margin-top: 4px;
}

.dashboard-table-wrap {
  overflow: auto;
}

.dashboard-table {
  border-collapse: collapse;
  min-width: 720px;
  width: 100%;
}

.dashboard-table th,
.dashboard-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 9px;
  text-align: left;
}

.dashboard-table th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.dashboard-table tr {
  cursor: pointer;
}

.dashboard-table tr:hover {
  background: #f8f9fb;
}

.client-summary {
  display: grid;
  gap: 10px;
  margin: 0;
}

.client-summary dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.client-summary dd {
  border-bottom: 1px solid var(--line);
  margin: 0;
  padding-bottom: 9px;
}

.dashboard-actions {
  justify-content: stretch;
}

.dashboard-actions button {
  width: 100%;
}

.two-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 18px;
}

.cadastro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.panel-head span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.panel-title-row {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.panel-title-row span,
#amplifierCount {
  background: rgba(37, 99, 235, 0.08);
  border-radius: 999px;
  color: var(--blue);
  padding: 4px 9px;
  white-space: nowrap;
}

.panel-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-head-actions input[type="search"] {
  max-width: 280px;
  min-width: 220px;
}

.small-file-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.8rem;
}

.import-actions {
  justify-content: flex-start;
}

.import-actions .small-file-button {
  min-height: 40px;
  padding: 10px 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.form-grid.one {
  grid-template-columns: 1fr;
}

.full {
  grid-column: 1 / -1;
}

.form-section-title {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
}

.form-section-title strong {
  color: var(--ink);
}

.form-section-title span {
  color: var(--muted);
  font-size: 0.86rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.component-layout {
  display: grid;
  grid-template-columns: 310px 310px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.perifericos-layout {
  grid-template-columns: minmax(0, 1fr) 330px;
}

.amplifier-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.compact {
  padding: 16px;
}

.table-panel {
  min-width: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-width: min(500px, 100%);
}

.filters .file-button {
  white-space: nowrap;
}

.perifericos-layout .filters {
  justify-content: flex-end;
}

.table-wrap {
  overflow: auto;
  max-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.perifericos-layout .table-wrap {
  max-height: clamp(720px, calc(100vh - 160px), 940px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 790px;
  background: #fff;
}

.device-table {
  min-width: 780px;
  table-layout: fixed;
}

.device-table th,
.device-table td {
  padding: 8px 7px;
  vertical-align: middle;
}

.device-table th:nth-child(3),
.device-table td:nth-child(3) {
  width: 62px;
}

.device-table th:nth-child(4),
.device-table td:nth-child(4) {
  width: 142px;
}

.device-table th:nth-child(5),
.device-table td:nth-child(5) {
  width: 180px;
}

.device-table th:nth-child(6),
.device-table td:nth-child(6) {
  width: 54px;
  text-align: center;
}

.device-table th:nth-child(8),
.device-table td:nth-child(8) {
  width: 112px;
}

.device-location-cell,
.device-type-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #f1f3f5;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  z-index: 1;
}

td {
  font-size: 0.9rem;
}

tbody tr {
  cursor: pointer;
}

tbody tr.has-plan-link {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected-row {
  background: #eef2ff;
}

tbody tr.selected-row {
  box-shadow: inset 3px 0 0 var(--brand);
}

.plan-status-header,
.plan-link-cell {
  width: 18px;
  min-width: 18px;
  max-width: 18px;
  padding-left: 8px;
  padding-right: 4px;
  text-align: center;
}

.device-photo-header,
.device-photo-cell {
  width: 54px;
  min-width: 54px;
  max-width: 54px;
  padding-left: 6px !important;
  padding-right: 4px !important;
}

.device-list-photo {
  width: 44px;
  height: 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f1f3f5;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 0.61rem;
  font-weight: 800;
  line-height: 1.05;
  text-align: center;
}

.device-list-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.device-photo-open,
.device-plan-open {
  cursor: pointer;
}

.device-photo-open:hover .device-list-photo {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(215, 25, 32, 0.12);
}

.device-plan-open:hover {
  color: var(--brand);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.plan-link-dot {
  display: inline-block;
  width: 8px;
  height: 28px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  vertical-align: middle;
}

.plan-link-dot.linked {
  background: #119b62;
}

.plan-link-dot.missing {
  background: var(--brand);
}

.status-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eaf0ff;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 900;
}

.status-pill.warn {
  background: #fff5df;
  color: var(--amber);
}

.status-pill.off {
  background: #f1f3f5;
  color: var(--gray);
}

.hidden {
  display: none !important;
}

.amplifier-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  max-height: clamp(720px, calc(100vh - 160px), 940px);
  overflow: auto;
  overscroll-behavior: contain;
}

.amplifier-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 54px 10px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  justify-content: stretch;
  min-height: 70px;
  text-align: left;
}

.amplifier-row.has-plan-link {
  cursor: pointer;
}

.amplifier-row:last-child {
  border-bottom: 0;
}

.amplifier-row:hover,
.amplifier-row.active {
  background: #eef2ff;
}

.amplifier-row.active {
  box-shadow: inset 3px 0 0 var(--brand);
}

.amplifier-row-main {
  min-width: 0;
}

.amplifier-row strong,
.amplifier-row span {
  display: block;
}

.amplifier-row-main span {
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.amplifier-row .status-pill {
  color: var(--accent-dark);
  justify-self: end;
  white-space: nowrap;
}

.amplifier-row .status-pill.off {
  color: var(--gray);
}

.amplifier-photo {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f1f3f5;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.amplifier-photo-open,
.amplifier-plan-open {
  cursor: pointer;
}

.amplifier-photo-open:hover {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(215, 25, 32, 0.12);
}

.amplifier-plan-open:hover {
  color: var(--brand);
  text-decoration: underline;
}

.photo-preview-box {
  margin: 0;
  display: grid;
  gap: 7px;
}

.photo-preview-box figcaption {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.photo-gallery {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcff;
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  align-content: start;
  padding: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.photo-gallery > span {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  min-height: 180px;
  display: grid;
  place-items: center;
}

.manual-plan-button {
  justify-self: stretch;
  width: 100%;
}

.manual-plan-actions {
  grid-column: 1 / -1;
  width: 100%;
  display: grid;
  gap: 8px;
}

.photo-gallery-item {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f1f3f5;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.76rem;
}

.floorplan-gallery {
  grid-template-columns: 1fr;
  min-height: 180px;
}

.floorplan-item {
  aspect-ratio: 4 / 3;
}

.floorplan-caption {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
}

.photo-view-button {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.photo-remove-button {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-height: 28px;
  border-radius: 6px;
  padding: 4px 8px;
  background: rgba(255, 240, 238, 0.95);
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 900;
}

.photo-remove-button:hover {
  background: #ffe0dc;
}

.amplifier-photo img,
.photo-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 28px;
}

.photo-modal-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 0;
  background: rgba(9, 18, 16, 0.76);
}

.photo-modal-content {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  justify-items: stretch;
  width: min(1180px, 94vw);
  max-height: 92vh;
}

.photo-modal-toolbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.photo-modal-close {
  background: #fff;
  color: var(--ink);
  min-height: 36px;
  padding: 7px 12px;
}

.photo-nav-btn,
.photo-zoom-btn,
.photo-zoom-level,
.photo-recenter-btn,
.photo-mark-btn {
  background: #fff;
  color: var(--ink);
  min-height: 36px;
  padding: 7px 12px;
}

.photo-zoom-btn {
  width: 42px;
}

.photo-nav-btn:disabled,
.photo-zoom-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.photo-recenter-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.photo-mark-btn.active {
  background: var(--brand);
  color: var(--white);
}

.photo-zoom-level {
  min-width: 76px;
}

.photo-nav-count {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-weight: 900;
}

.photo-modal-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: calc(92vh - 66px);
  max-height: calc(92vh - 66px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}

.photo-modal-stage.is-draggable {
  cursor: grab;
}

.photo-modal-stage.is-dragging {
  cursor: grabbing;
}

.photo-modal-stage.is-marking {
  cursor: crosshair;
}

.photo-modal-info {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(35, 39, 47, 0.92);
  color: var(--white);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.photo-modal-info span {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.86rem;
  font-weight: 800;
}

.photo-modal-info strong {
  color: #c7d6ff;
  font-size: 0.74rem;
  text-transform: uppercase;
}

.photo-modal-stage img {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  max-width: none;
  max-height: none;
  object-fit: fill;
  transform-origin: 0 0;
  transition: transform 180ms ease;
  user-select: none;
  will-change: transform, width, height;
}

.photo-modal-stage.is-dragging img {
  transition: none;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.model-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.model-card p {
  color: var(--muted);
  line-height: 1.45;
  min-height: 66px;
}

.model-card ul {
  margin: 0;
  padding-left: 18px;
  color: #343a46;
  line-height: 1.55;
}

.import-log {
  display: grid;
  gap: 12px;
}

.import-entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcff;
}

.import-entry strong {
  display: block;
  margin-bottom: 6px;
}

.import-entry span {
  color: var(--muted);
  display: block;
  font-size: 0.86rem;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #fbfcff;
  display: grid;
  gap: 4px;
}

@media (max-width: 1180px) {
  .component-layout,
  .amplifier-layout,
  .model-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .import-actions {
    width: 100%;
  }

  .import-actions .small-file-button {
    width: 100%;
    justify-content: center;
  }

  .client-list {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .topbar,
  .panel-head,
  .start-hero {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .contextual-actions {
    grid-column: 1;
    justify-content: flex-start;
  }

  .start-actions {
    min-width: 0;
  }

  .dashboard-toolbar {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .permission-row {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-panel-tools {
    align-items: stretch;
    flex-direction: column;
    min-width: 0;
  }

  .dashboard-panel-tools input {
    max-width: none;
    min-width: 0;
  }

  .metrics,
  .two-columns,
  .cadastro-grid,
  .dashboard-layout,
  .dashboard-kpis,
  .component-layout,
  .amplifier-layout,
  .model-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    flex-direction: column;
  }

  .main {
    padding: 20px;
  }
}

.table-panel .panel-head {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: auto minmax(0, 1fr);
}

.table-panel .filters {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(240px, 1fr) minmax(170px, 230px) auto;
  min-width: 0;
}

.table-panel .filters input,
.table-panel .filters select {
  min-width: 0;
}

.table-panel .filters .file-button {
  min-height: 42px;
}

@media (max-width: 720px) {
  .photo-modal {
    place-items: stretch;
    padding: 0;
  }

  .photo-modal-content {
    width: 100vw;
    max-height: none;
    height: 100vh;
    height: 100dvh;
    gap: 0;
  }

  .photo-modal-stage {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    touch-action: none;
  }

  .photo-modal-toolbar {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: calc(env(safe-area-inset-bottom) + 8px);
    z-index: 5;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    padding: 7px;
    border-radius: 12px;
    background: rgba(11, 18, 32, 0.74);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
    -webkit-overflow-scrolling: touch;
  }

  .photo-modal-toolbar button,
  .photo-nav-count {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 7px 10px;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .photo-zoom-btn {
    width: 40px;
  }

  .photo-zoom-level {
    min-width: 70px;
  }

  .photo-modal-info {
    top: max(8px, env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    gap: 5px;
    padding: 7px;
    border-radius: 10px;
    background: rgba(35, 39, 47, 0.84);
  }

  .photo-modal-info span {
    padding: 3px 6px;
    font-size: 0.74rem;
  }

  .photo-modal-info strong {
    font-size: 0.64rem;
  }

  .auth-overlay {
    padding: 0;
  }

  .auth-page {
    min-height: 100vh;
    grid-template-columns: 1fr;
    border-radius: 0;
  }

  .auth-hero {
    min-height: 360px;
    padding: 30px 22px;
  }

  .auth-hero-copy h1 {
    font-size: 2.15rem;
  }

  .auth-box {
    border-left: 0;
    padding: 28px 22px 34px;
  }

  .table-panel .panel-head,
  .table-panel .filters {
    grid-template-columns: 1fr;
  }
}
body.app-booting .app-shell {
  visibility: hidden;
}
