/* =========================================================
   SeuQR — Painel (área logada)
   Usa os tokens de styles.css e os formulários de auth.css
   ========================================================= */

body.dash { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Barra lateral ---------- */
.dash-side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  background: var(--grad-navy);
  color: var(--on-navy-muted);
  overflow-y: auto;
}
.dash-logo { padding: 4px 8px; }
.dash-logo img { height: 28px; width: auto; }
.dash-nav { display: grid; gap: 4px; }
.dash-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--on-navy-muted);
  transition: background-color .2s, color .2s;
}
.dash-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.dash-nav a[aria-current="page"] { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.14); }
.dash-nav svg { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.dash-plan { margin-top: auto; padding: 18px; border-radius: 18px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); }
.dash-plan .eyebrow { font-size: 11px; color: #9fc2ff; }
.dash-plan strong { display: block; margin-top: 6px; font-size: 20px; color: #fff; letter-spacing: -.02em; }
.dash-plan__bar { height: 6px; margin-top: 12px; border-radius: 6px; background: rgba(255,255,255,.12); overflow: hidden; }
.dash-plan__bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #7fb0ff, #5897f7); transition: width .5s var(--ease); }
.dash-plan small { display: block; margin-top: 8px; font-size: 13px; }
.dash-plan p { margin-top: 8px; font-size: 13px; line-height: 1.45; }
.dash-plan__btn { width: 100%; height: 38px; margin-top: 14px; font-size: 14px; }

.dash-user { display: flex; align-items: center; gap: 10px; padding: 8px; }
.dash-user > div { min-width: 0; flex: 1; }
.dash-user strong { display: block; font-size: 14px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-user small { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-avatar { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--grad-blue); color: #fff; font-size: 13px; font-weight: 600; }
.dash-logout { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--on-navy-muted); cursor: pointer; }
.dash-logout:hover { background: rgba(255,255,255,.1); color: #fff; }
.dash-logout svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Conteúdo ---------- */
.dash-main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 64px; }
.dash-demo { margin-bottom: 20px; padding: 10px 14px; border-radius: 12px; background: #eaf1ff; color: #1d4aa8; font-size: 14px; }
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.dash-head h1 { margin-top: 6px; font-size: clamp(28px, 3.2vw, 36px); letter-spacing: -.035em; }
.dash-sub { margin-top: 6px; max-width: 560px; color: var(--muted); }
.dash-head .btn .ico { width: 18px; height: 18px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; font-size: 14px; font-weight: 500; color: var(--muted); }
.back-link:hover { color: var(--ink); }
.back-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Números */
.dash-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 28px 0 16px; }
.dash-stat { position: relative; padding: 20px; border-radius: 20px; background: #fff; box-shadow: var(--shadow-soft); }
.dash-stat__icon { position: absolute; top: 16px; right: 16px; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: #eef3ff; color: var(--blue-b); }
.dash-stat__icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dash-stat small { display: block; padding-right: 44px; font-size: 13px; color: var(--muted); }
.dash-stat strong { display: block; margin-top: 10px; font-size: 32px; font-weight: 600; letter-spacing: -.03em; color: var(--ink); font-variant-numeric: tabular-nums; }
.dash-stat em { display: block; margin-top: 2px; font-style: normal; font-size: 12.5px; color: var(--faint); }

/* Painéis */
.panel { padding: 24px; border-radius: 24px; background: #fff; box-shadow: var(--shadow-soft); }
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 19px; letter-spacing: -.02em; }
.panel > p, .panel-head p { margin-top: 4px; font-size: 14px; color: var(--muted); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.overview-grid .panel + .panel { margin-top: 0; }

/* Gráfico da semana */
.week-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 200px; margin-top: 22px; }
.week-chart div { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; height: 100%; }
.week-chart i { display: block; width: 100%; min-height: 4px; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, #cfdcff, #e9efff); transition: height .6s var(--ease); }
.week-chart div.is-today i { background: var(--grad-blue); }
.week-chart b { font-size: 12px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.week-chart span { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.week-total { margin-top: 14px; font-size: 14px; color: var(--muted); }

/* Recentes */
.recent-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 8px; }
.recent-list a { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px; border-radius: 14px; transition: background-color .2s; }
.recent-list a:hover { background: var(--tint); }
.recent-qr { width: 48px; height: 48px; padding: 4px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.recent-qr svg { width: 100%; height: 100%; }
.recent-list strong { display: block; font-size: 15px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-list small { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-list .scans { text-align: right; font-size: 13px; color: var(--muted); white-space: nowrap; }
.recent-list .scans b { display: block; font-size: 16px; color: var(--ink); }

/* Busca */
.dash-search { display: flex; align-items: center; gap: 8px; width: min(340px, 100%); height: 42px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2); background: #fff; }
.dash-search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(62,121,234,.14); }
.dash-search svg { flex: none; width: 17px; height: 17px; fill: none; stroke: var(--faint); stroke-width: 1.7; stroke-linecap: round; }
.dash-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: 15px var(--font); color: var(--ink); }

/* Tabela de QR Codes */
.table-wrap { margin-top: 18px; overflow-x: auto; }
.qr-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.qr-table th { padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); border-bottom: 1px solid var(--line); white-space: nowrap; }
.qr-table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.qr-table tr:last-child td { border-bottom: 0; }
.qr-table tbody tr { transition: background-color .2s; }
.qr-table tbody tr:hover { background: #fafbfd; }
.qr-cell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.qr-cell .recent-qr { flex: none; width: 44px; height: 44px; }
.qr-cell a { font-weight: 600; color: var(--ink); }
.qr-cell a:hover { color: var(--blue-b); }
.qr-cell small { display: block; max-width: 260px; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-table .mono { font-size: 13px; color: var(--text); white-space: nowrap; }
.qr-table .num { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.qr-table .date { white-space: nowrap; color: var(--muted); }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.qr-table td:nth-child(3) { white-space: nowrap; }
.qr-table td:nth-child(3) .switch { vertical-align: middle; margin-right: 6px; }
@media (max-width: 1240px) {
  .qr-table th:nth-child(5), .qr-table td:nth-child(5) { display: none; }
  .qr-table .status { display: none; }
}

.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.status i { width: 6px; height: 6px; border-radius: 50%; }
.status--on { background: rgba(137,236,176,.35); color: #135c35; }
.status--on i { background: #1f9d58; }
.status--off { background: #eef1f4; color: var(--muted); }
.status--off i { background: #a3aab4; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: border-color .2s, background-color .2s;
}
.icon-btn:hover { border-color: #b8c2c9; background: #f8fafc; }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn--danger { color: #c9353b; }
.icon-btn--danger:hover { border-color: #f0b4b6; background: #fdecec; }

/* Interruptor */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: relative; width: 38px; height: 22px; border-radius: 999px; background: #d6dde2; transition: background-color .25s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .25s var(--ease); }
.switch input:checked + span { background: #34c47a; }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--tint); font-size: 15px; font-weight: 500; color: var(--ink); cursor: pointer; }

/* Formulário do QR + prévia */
.qr-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; margin-top: 28px; align-items: start; }
.f-optional { font-weight: 400; color: var(--faint); }
.f-textarea { height: auto; min-height: 96px; padding-top: 14px; padding-bottom: 14px; line-height: 1.5; resize: vertical; }
select.f-input { appearance: none; padding-right: 40px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%238d949e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 14px center / 16px no-repeat; cursor: pointer; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.form-actions__delete { margin-left: auto; }
.form-actions [hidden] { display: none; }
.qr-preview { position: sticky; top: 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.qr-preview .eyebrow { align-self: flex-start; }
.qr-preview__code { width: 100%; max-width: 220px; aspect-ratio: 1; padding: 10px; border-radius: 18px; border: 1px solid var(--line); background: #fff; transition: opacity .3s, filter .3s; }
.qr-preview__code.is-paused { opacity: .4; filter: grayscale(1); }
.qr-preview__code svg { width: 100%; height: 100%; }
.qr-preview__url { font-size: 13px; color: var(--ink); word-break: break-all; }
.qr-preview__note { font-size: 13px; color: var(--muted); }
.qr-preview .btn { width: 100%; }

.dash-empty { margin-top: 18px; padding: 44px 24px; border-radius: 20px; border: 1.5px dashed var(--line-2); text-align: center; }
.dash-empty[hidden] { display: none; }
.dash-empty strong { font-size: 18px; color: var(--ink); }
.dash-empty p { margin: 6px 0 18px; color: var(--muted); }

/* Aviso flutuante */
.dash-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--navy-900);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 20px 40px -16px rgba(11,20,48,.6);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity .3s, transform .4s var(--ease);
}
.dash-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Billing e Configurações ---------- */
.panel-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; margin-top: 28px; align-items: start; }
.panel-grid .panel + .panel { margin-top: 0; }
.current-plan { position: relative; overflow: hidden; isolation: isolate; padding: 28px; border-radius: 24px; background: var(--grad-navy); color: var(--on-navy-muted); }
.current-plan::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(80% 60% at 50% 0%, rgba(88,151,247,.45), transparent 70%); }
.current-plan .eyebrow { color: #9fc2ff; }
.current-plan h2 { margin-top: 8px; color: #fff; font-size: 30px; letter-spacing: -.03em; }
.current-plan__price { margin-top: 4px; font-size: 16px; }
.current-plan .summary__list { margin-top: 20px; }
.current-plan__usage { margin-top: 22px; }
.current-plan__usage .dash-plan__bar { background: rgba(255,255,255,.14); }
.current-plan__usage small { display: block; margin-top: 8px; font-size: 13px; }

.plan-rows { display: grid; gap: 10px; margin-top: 18px; }
.plan-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); }
.plan-row.is-current { border-color: var(--blue); background: #f3f7ff; }
.plan-row b { display: block; font-size: 16px; color: var(--ink); }
.plan-row small { font-size: 13px; color: var(--muted); }
.plan-row .btn { height: 38px; font-size: 14px; }

.history { width: 100%; margin-top: 16px; border-collapse: collapse; font-size: 14px; }
.history th { padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); border-bottom: 1px solid var(--line); }
.history td { padding: 14px 12px; border-bottom: 1px solid var(--line); color: var(--text); }
.history tr:last-child td { border-bottom: 0; }
.history-empty { margin-top: 14px; padding: 20px; border-radius: 14px; background: var(--tint); font-size: 14px; color: var(--muted); }
.history-empty[hidden] { display: none; }

.settings-form { display: grid; gap: 18px; max-width: 520px; margin-top: 22px; }
.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn--danger { background: #fff; color: #c9353b; border-color: #f0b4b6; }
.btn--danger:hover { background: #fdecec; }

/* Página pública de planos */
.pricing-nav { display: flex; gap: 8px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .dash-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid, .overview-grid { grid-template-columns: 1fr; }
  .overview-grid .panel + .panel { margin-top: 0; }
}
@media (max-width: 960px) {
  .qr-form-grid { grid-template-columns: 1fr; }
  .qr-preview { position: static; order: -1; flex-direction: row; flex-wrap: wrap; justify-content: center; text-align: left; }
  .qr-preview__code { max-width: 140px; }
  .qr-preview .btn { width: auto; }
}
@media (max-width: 860px) {
  body.dash { grid-template-columns: 1fr; }
  .dash-side {
    position: sticky;
    z-index: 40;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    overflow: visible;
  }
  .dash-logo img { height: 24px; }
  .dash-nav { display: flex; gap: 2px; margin-left: auto; }
  .dash-nav a { height: 38px; padding: 0 9px; gap: 0; font-size: 0; }
  .dash-nav a svg { width: 21px; height: 21px; }
  .dash-plan { display: none; }
  .dash-user { padding: 0; }
  .dash-user > div, .dash-avatar { display: none; }
}
@media (max-width: 560px) {
  .dash-main { padding: 18px 16px 48px; }
  .dash-head .btn { width: 100%; }
  .dash-stats { gap: 10px; margin: 20px 0 16px; }
  .dash-stat { padding: 16px; }
  .dash-stat strong { font-size: 26px; }
  .dash-stat__icon { width: 32px; height: 32px; top: 12px; right: 12px; }
  .panel, .current-plan { padding: 20px; border-radius: 20px; }
  .week-chart { height: 160px; gap: 6px; }
  .qr-table th:nth-child(2), .qr-table td:nth-child(2),
  .qr-table th:nth-child(5), .qr-table td:nth-child(5) { display: none; }
  .qr-cell { min-width: 0; }
  .form-actions .btn { flex: 1; }
  .form-actions__delete { margin-left: 0; }
  .history th:nth-child(3), .history td:nth-child(3) { display: none; }
}

/* Campos lado a lado alinhados pelo topo */
.qr-form-grid .f-group { align-content: start; }

/* Planos dentro do painel */
.dash-plans { max-width: none; margin-top: 28px; }
.dash-plans .plan.is-current:not(.plan--featured) { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(62,121,234,.14); }
.dash-plans .plan--featured.is-current { box-shadow: 0 0 0 3px rgba(88,151,247,.45), 0 30px 60px -30px rgba(16,28,66,.65); }
.dash-plans [data-plan-cta].is-current { opacity: .6; cursor: default; pointer-events: none; }
.dash-plans__note { margin-top: 18px; font-size: 14px; color: var(--muted); }
@media (max-width: 1100px) { .dash-plans { grid-template-columns: 1fr; max-width: 520px; } }
