:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1e2230;
  --border: #2a2f3f;
  --text: #eef0f5;
  --muted: #9aa1b4;
  --accent: #7c5cff;
  --accent-2: #4fd1c5;
  --danger: #ff6b6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15,17,23,0.9);
  backdrop-filter: blur(6px);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 16px;
}

nav { display: flex; align-items: center; gap: 18px; }
nav a:not(.btn) { color: var(--muted); font-weight: 500; }
nav a.active:not(.btn) { color: var(--text); }

main { max-width: 1100px; margin: 0 auto; padding: 32px; }

.page-head h1 { margin: 0 0 6px; font-size: 26px; }
.subtitle { color: var(--muted); margin: 0 0 28px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: transform .08s ease, background .15s ease;
}
.btn:hover { background: #262b3b; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6a4bff);
  border: none;
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.card {
  display: flex;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card-qr img {
  width: 84px;
  height: 84px;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}

.card-body { flex: 1; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head h3 { margin: 0; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  letter-spacing: .03em;
}
.badge-link { background: rgba(124,92,255,0.18); color: #b6a4ff; }
.badge-pdf { background: rgba(79,209,197,0.18); color: #7fe3d8; }

.card-url a { font-size: 12px; color: var(--accent-2); word-break: break-all; }
.card-dest { font-size: 12.5px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state p { margin-bottom: 16px; }

.create-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  align-items: start;
}

.create-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--muted); }
.field input[type=text], .field input[type=url] {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
}
.field input[type=file] {
  width: 100%;
  padding: 9px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
}
.field input[type=color] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 4px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

.tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.tab {
  flex: 1;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.tab.active { background: rgba(124,92,255,0.16); color: var(--text); border-color: var(--accent); }

.style-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.style-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}
.style-card.active { border-color: var(--accent); color: var(--text); background: rgba(124,92,255,0.14); }
.style-preview {
  width: 40px; height: 40px; border-radius: 8px; background: #fff;
}
.shape-classico {
  background-image:
    linear-gradient(45deg, #111 25%, transparent 25%, transparent 75%, #111 75%),
    linear-gradient(45deg, #111 25%, transparent 25%, transparent 75%, #111 75%);
  background-size: 10px 10px;
  background-position: 0 0, 5px 5px;
}
.shape-arredondado {
  background-image: radial-gradient(circle, #111 42%, transparent 44%);
  background-size: 11px 11px;
  border-radius: 12px;
}
.shape-pontos {
  background-image: radial-gradient(circle, #111 30%, transparent 32%);
  background-size: 9px 9px;
}
.shape-elegante {
  background-image: repeating-linear-gradient(45deg, #111 0 4px, transparent 4px 8px);
}

.preview-pane { position: sticky; top: 90px; }
.preview-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 220px;
}
.preview-box img { width: 100%; max-width: 260px; display: block; }
.preview-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.7); color: #333; font-size: 13px; border-radius: var(--radius);
}
.muted { color: var(--muted); }
.small { font-size: 12px; text-align: center; margin-top: 10px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; width: 380px; max-width: 90vw;
}
.modal h3 { margin: 0 0 6px; }
.modal input { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); margin-top: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------- Medidor de legibilidade ---------- */

.meter-wrap {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-top: 14px;
}
.meter-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.meter-title { font-size: 13px; font-weight: 600; color: var(--muted); }
.meter-verdict { font-size: 13px; font-weight: 700; }
.meter-track { height: 8px; border-radius: 100px; background: var(--panel-2); overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: 100px; transition: width .3s ease, background .3s ease; }

.field input[type=range] {
  width: 100%; margin-top: 8px; accent-color: var(--accent);
}

/* ---------- Analises ---------- */

.an-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.back-link { display: inline-block; margin-bottom: 10px; font-size: 13px; }
.an-qr { width: 96px; height: 96px; border-radius: 10px; background: #fff; padding: 5px; }

.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-tile {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 4px;
}
.stat-num { font-size: 28px; font-weight: 700; }
.stat-num.small { font-size: 18px; }
.stat-label { font-size: 12px; color: var(--muted); }

.an-section {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px;
}
.an-section h2 { margin: 0 0 16px; font-size: 15px; }

.chart { display: flex; align-items: flex-end; gap: 3px; height: 130px; }
.chart-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.chart-bar {
  width: 100%; min-height: 2px; border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--accent), #4634a8);
}

.an-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-label { width: 110px; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 8px; background: var(--panel-2); border-radius: 100px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 100px; }
.bar-count { width: 34px; text-align: right; font-size: 13px; font-weight: 600; }

.an-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.an-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.an-table td { padding: 8px; border-bottom: 1px solid var(--border); }
.an-table tr:last-child td { border-bottom: none; }

@media (max-width: 800px) {
  .create-layout { grid-template-columns: 1fr; }
  .preview-pane { position: static; }
  .an-grid { grid-template-columns: 1fr; }
  .stat-tiles { grid-template-columns: 1fr; }
}
