/* ==========================================================================
   Plaquinhas QR — folha de estilo unica do sistema
   ========================================================================== */

:root {
  --bg: #070b14;
  --bg-soft: #0d1421;
  --surface: #111a2b;
  --surface-2: #16203433;
  --border: #1e2b42;
  --border-soft: #182234;

  --text: #e6ecf7;
  --text-soft: #9aa9c2;
  --text-dim: #6b7c99;

  --primary: #6366f1;
  --primary-hover: #7c7ff5;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --sidebar-width: 248px;
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
ul { margin: 8px 0 0; padding-left: 18px; }
small { font-size: 11.5px; }

code, .mono, .error-trace {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: .01em;
}

code {
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 1px 5px;
}

.mono--lg { font-size: 15px; font-weight: 700; letter-spacing: .08em; }
.is-muted { color: var(--text-soft); }
.is-right { text-align: right; }
.link { color: var(--primary-hover); word-break: break-all; }
.link:hover { text-decoration: underline; }
.divider { border: 0; border-top: 1px solid var(--border-soft); margin: 20px 0; }
.section-note { color: var(--text-soft); margin-bottom: 14px; }

/* --------------------------------------------------------------------------
   Botoes
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}

.btn:hover { background: #1a2438; }
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn--danger {
  background: transparent;
  border-color: #4a2028;
  color: #f78d8d;
}
.btn--danger:hover { background: #2a1219; border-color: var(--danger); }

.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }

.btn--sm { padding: 7px 12px; font-size: 12.5px; }
.btn--xs { padding: 5px 9px; font-size: 11.5px; font-weight: 600; }
.btn--icon { padding: 7px 10px; }
.btn--block { display: flex; width: 100%; }

/* --------------------------------------------------------------------------
   Formularios
   -------------------------------------------------------------------------- */
.field { margin-bottom: 18px; }

.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.field__input,
.input,
.select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}

.field__input:focus,
.input:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}

.field__input::placeholder { color: var(--text-dim); }
.field__help { display: block; margin-top: 6px; font-size: 11.5px; color: var(--text-dim); }
.field__warning { display: block; margin-top: 6px; font-size: 11.5px; color: var(--warning); }

.select { cursor: pointer; appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--text-soft) 50%), linear-gradient(135deg, var(--text-soft) 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

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

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

.color-row { display: flex; gap: 10px; align-items: center; }

.color-row input[type="color"] {
  width: 46px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  cursor: pointer;
}

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch__track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #233047;
  transition: background .18s;
  flex-shrink: 0;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s;
}

.switch input:checked + .switch__track { background: var(--success); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px rgba(99, 102, 241, .3); }
.switch__label { font-size: 13.5px; }

/* --------------------------------------------------------------------------
   Avisos / flash
   -------------------------------------------------------------------------- */
.flash-stack { display: grid; gap: 8px; margin-bottom: 18px; }

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.flash p { flex: 1; font-size: 13px; }
.flash__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.flash--success { border-left-color: var(--success); }
.flash--success .flash__dot { background: var(--success); }
.flash--error { border-left-color: var(--danger); }
.flash--error .flash__dot { background: var(--danger); }

.flash__close {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.flash__close:hover { color: var(--text); }

.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 18px;
  font-size: 13px;
}
.alert--error { background: #2a1116; border-color: #57222c; color: #fbc3c3; }
.alert--error strong { display: block; margin-bottom: 4px; }
.alert--warn { background: #2a1f0b; border-color: #5c441a; color: #fbdfa8; }
.alert--warn strong { color: #fcd977; }

/* --------------------------------------------------------------------------
   Layout admin
   -------------------------------------------------------------------------- */
.layout-admin {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 16px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand { display: flex; align-items: center; gap: 11px; }
.sidebar__brand strong { display: block; font-size: 14.5px; }
.sidebar__brand small { color: var(--text-dim); }

.brand__mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--primary), #8b5cf6);
  color: #fff;
  font-size: 19px;
  flex-shrink: 0;
}
.brand__mark--lg { width: 54px; height: 54px; font-size: 28px; border-radius: 14px; }

.sidebar__nav { display: grid; gap: 4px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 550;
  transition: background .15s, color .15s;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: rgba(99, 102, 241, .16); color: #c7cbff; }
.nav-item__icon { font-size: 15px; opacity: .85; }

.sidebar__footer { display: grid; gap: 12px; border-top: 1px solid var(--border-soft); padding-top: 16px; }
.sidebar__user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar__user strong { display: block; font-size: 13px; }
.sidebar__user small { display: block; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; }
.sidebar__user div { min-width: 0; }

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.content { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(7, 11, 20, .82);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar__title { flex: 1; min-width: 0; }
.topbar__title h1 { font-size: 19px; }
.topbar__sub { font-size: 11.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__toggle { display: none; }

.page { padding: 24px 26px 60px; display: grid; gap: 20px; align-content: start; }

/* --------------------------------------------------------------------------
   Paines e tabelas
   -------------------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel--sticky { position: sticky; top: 92px; }

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: #131d2f66;
}
.panel__head h2 { font-size: 14.5px; }
.panel__head--wrap { flex-wrap: wrap; }
.panel__body { padding: 18px; }
.panel__body > *:last-child { margin-bottom: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; }
.toolbar .input { max-width: 300px; }
.toolbar .select { width: auto; min-width: 150px; }

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

.table { width: 100%; border-collapse: collapse; font-size: 13px; }

.table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

.table td { padding: 11px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #16203457; }
.table th.is-right, .table td.is-right { text-align: right; }

.table__title { font-weight: 600; color: var(--text); }
.table__title:hover { color: var(--primary-hover); }
.table__sub { display: block; color: var(--text-dim); margin-top: 2px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--on { background: rgba(34, 197, 94, .14); color: #6ee7a0; border-color: rgba(34, 197, 94, .3); }
.badge--off { background: rgba(148, 163, 184, .13); color: #b3c0d4; border-color: rgba(148, 163, 184, .25); }
.badge--neutral { background: rgba(99, 102, 241, .14); color: #b6baff; border-color: rgba(99, 102, 241, .3); }
.badge--warn { background: rgba(245, 158, 11, .14); color: #fbca7a; border-color: rgba(245, 158, 11, .32); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 11.5px;
  cursor: pointer;
}
.chip:hover { border-style: solid; border-color: var(--primary); color: var(--text); }
.chip.is-copied { border-color: var(--success); color: #6ee7a0; }

.row-actions { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.row-actions--wrap { flex-wrap: wrap; justify-content: flex-start; gap: 10px; }
.row-actions form { display: inline; }

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-top: 1px solid var(--border-soft);
  font-size: 12.5px;
  color: var(--text-soft);
}
.pagination__links { display: flex; gap: 4px; }

.pagination__link {
  min-width: 32px;
  padding: 6px 10px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--text-soft);
}
.pagination__link:hover { border-color: var(--primary); color: var(--text); }
.pagination__link.is-active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }

.empty { padding: 44px 20px; text-align: center; color: var(--text-soft); display: grid; gap: 14px; justify-items: center; }

/* --------------------------------------------------------------------------
   Estatisticas
   -------------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }

.stat {
  padding: 16px 18px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  gap: 4px;
}
.stat--highlight { border-color: rgba(99, 102, 241, .42); background: linear-gradient(150deg, #1a2340, var(--surface)); }
.stat__label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); font-weight: 650; }
.stat__value { font-size: 27px; font-weight: 700; line-height: 1.15; }
.stat__meta { font-size: 11.5px; color: var(--text-dim); }

/* --------------------------------------------------------------------------
   Detalhes / definicoes
   -------------------------------------------------------------------------- */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.detail-head h2 { font-size: 20px; margin-bottom: 4px; }
.detail-head__badges { display: flex; gap: 8px; flex-wrap: wrap; }

.definition { display: grid; gap: 14px; margin: 0; }
.definition > div { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; align-items: baseline; }
.definition dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); font-weight: 650; }
.definition dd { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; word-break: break-word; }

.color-dot { display: inline-block; width: 13px; height: 13px; border-radius: 50%; border: 1px solid var(--border); }

/* --------------------------------------------------------------------------
   Split form + previa
   -------------------------------------------------------------------------- */
.layout-split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.split__main { display: grid; gap: 20px; min-width: 0; }
.split__side { min-width: 0; }

.qr-preview {
  display: grid;
  place-items: center;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: #fff;
}
.qr-preview--bordered { border: 1px solid var(--border); }
.qr-preview__img { display: block; width: 100%; max-width: 230px; height: auto; image-rendering: pixelated; }

.qr-preview__note { margin-top: 12px; font-size: 11.5px; color: var(--text-dim); line-height: 1.6; }
.qr-preview__code { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-soft); display: grid; gap: 8px; }
.qr-preview__code .field__label { margin: 0; }

/* --------------------------------------------------------------------------
   Login / telas publicas
   -------------------------------------------------------------------------- */
.layout-public { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

.auth { width: 100%; display: grid; place-items: center; }

.auth__card {
  width: 100%;
  max-width: 380px;
  padding: 30px 26px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}
.auth__card--center { max-width: 440px; justify-items: center; text-align: center; }
.auth__card--center h1 { font-size: 20px; }
.auth__card--center .btn { margin-top: 4px; }

.auth__brand { text-align: center; display: grid; gap: 8px; justify-items: center; }
.auth__brand h1 { font-size: 20px; }
.auth__brand p { font-size: 11.5px; color: var(--text-dim); }

.auth__hint { font-size: 11.5px; color: var(--text-dim); text-align: center; line-height: 1.6; }

.status-mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
  background: rgba(99, 102, 241, .15);
  color: #b6baff;
  border: 1px solid rgba(99, 102, 241, .35);
}
.status-mark--warn { background: rgba(245, 158, 11, .15); color: #fbbf24; border-color: rgba(245, 158, 11, .35); }
.status-mark--error { background: rgba(239, 68, 68, .15); color: #f78d8d; border-color: rgba(239, 68, 68, .35); }

.error-trace {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-soft);
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --------------------------------------------------------------------------
   Impressao
   -------------------------------------------------------------------------- */
.layout-print { display: grid; justify-items: center; gap: 26px; padding: 30px 20px; background: #fff; color: #111; }

.print-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: #555;
}
.print-toolbar .btn { background: var(--primary); border-color: var(--primary); color: #fff; }

.print-sheet {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px dashed #bbb;
  border-radius: 10px;
  background: #fff;
  color: #111;
}

.print-sheet__qr { display: grid; place-items: center; }
.print-sheet__qr img { display: block; }
.print-sheet__label { font-size: 13px; font-weight: 700; text-align: center; }
.print-sheet__url { font-family: var(--mono); font-size: 10px; color: #666; text-align: center; word-break: break-all; }

@media print {
  .print-toolbar { display: none !important; }
  .layout-print { padding: 0; gap: 0; background: #fff; }
  .print-sheet { border: 0; border-radius: 0; padding: 0; page-break-inside: avoid; }
  @page { margin: 12mm; }
}

/* --------------------------------------------------------------------------
   Responsivo
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .layout-split { grid-template-columns: minmax(0, 1fr); }
  .panel--sticky { position: static; }
}

@media (max-width: 900px) {
  .layout-admin { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow); }
  .topbar__toggle { display: inline-flex; }
  .topbar { padding: 14px 16px; }
  .page { padding: 18px 16px 50px; }
}

@media (max-width: 640px) {
  .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
  .definition > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .toolbar .input, .toolbar .select { max-width: none; width: 100%; }
  .table th, .table td { padding: 9px 11px; }
}
