:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1e21;
  --muted: #6b7280;
  --line: #e3e5e8;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --danger: #c62828;
  --warn-bg: #fff6e0;
  --warn-text: #7a5300;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --card: #1e2125;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --line: #33373d;
    --accent: #5b82ff;
    --danger: #ef6b6b;
    --warn-bg: #3a2f14;
    --warn-text: #f3d48a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 14px; }
[hidden] { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

/* ---------- Formulários */

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label > input:not([type=checkbox]):not([type=file]),
label > select,
.prefix {
  display: block;
  width: 100%;
  margin-top: 4px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.prefix { display: flex; align-items: center; padding: 0 0 0 11px; overflow: hidden; }
.prefix > span { white-space: nowrap; color: var(--muted); font-size: 14px; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.prefix input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; color: var(--text); padding: 9px 11px 9px 2px; outline: none; }

label.check { display: flex; gap: 8px; align-items: baseline; color: var(--text); font-size: 14px; }
label.check small { color: var(--muted); }

input[type=color] { display: block; width: 100%; height: 38px; margin-top: 4px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); cursor: pointer; }
input[type=range] { width: 100%; margin-top: 8px; accent-color: var(--accent); }
output { float: right; color: var(--text); font-variant-numeric: tabular-nums; }

fieldset { border: 0; border-top: 1px solid var(--line); padding: 14px 0 2px; margin: 0; }
legend { font-weight: 600; font-size: 13px; padding-right: 8px; }

.cols, .colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 14px; align-items: end; }
.colors label.check { margin-bottom: 20px; }

.file { position: relative; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file span {
  display: block; text-align: center; padding: 14px; color: var(--text);
  border: 1.5px dashed var(--line); border-radius: 8px;
}
.file:hover span { border-color: var(--accent); }

.needs-logo, .needs-gradient { display: none; }
.has-logo .needs-logo { display: block; }
.has-gradient .needs-gradient { display: block; }

/* ---------- Botões */

button, .btn {
  font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; display: inline-block;
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text);
}
button:hover, .btn:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.ghost { background: transparent; }
.small { padding: 5px 10px; font-size: 13px; }
.danger { color: var(--danger); }

.msg { min-height: 1.4em; margin: 10px 0 0; font-size: 14px; color: var(--muted); word-break: break-all; }
.msg.error, .error { color: var(--danger); }
.alert { background: var(--warn-bg); color: var(--warn-text); padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.muted { color: var(--muted); }

/* ---------- Layout */

.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}

.grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px;
  max-width: 1120px; margin: 24px auto; padding: 0 24px;
}
.panel { display: grid; gap: 20px; align-content: start; }
.sticky { position: sticky; top: 20px; }

.qr-box {
  aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  background: repeating-conic-gradient(#e9eaec 0 25%, #fff 0 50%) 0 0 / 20px 20px;
}
.qr-box svg { display: block; width: 100%; height: 100%; }
.qr-box.placeholder { opacity: .55; }
.qr-text { font-size: 13px; color: var(--muted); text-align: center; word-break: break-all; margin: 10px 0; }
.warn { background: var(--warn-bg); color: var(--warn-text); font-size: 13px; padding: 10px 12px; border-radius: 8px; margin: 0 0 12px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .primary { grid-column: 1 / -1; padding: 12px; }

.links { max-width: 1072px; margin: 0 auto 40px; }
.links-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.links-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td a { color: var(--accent); font-weight: 600; text-decoration: none; }
td.dest { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin-left: 4px; }

/* ---------- Login */

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.login label { margin: 0; }

/* ---------- Celular */

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; padding: 0 16px; margin: 16px auto; }
  .preview { order: -1; }
  .preview .card { position: static; }
  .top { padding: 12px 16px; }
  .links { margin: 0 16px 32px; }

  thead { display: none; }
  tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  td { display: block; border: 0; padding: 3px 0; }
  td.dest { max-width: none; white-space: normal; word-break: break-all; }
  td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
  .row-actions { text-align: left; white-space: normal; padding-top: 8px; }
  .row-actions .btn { margin: 0 4px 4px 0; }
}
