:root {
  --ad-bg: #f5f2ea;
  --ad-surface: #ffffff;
  --ad-ink: #102440;
  --ad-muted: #5d6680;
  --ad-line: #e3ddd0;
  --ad-line-strong: #cfc7b6;
  --ad-navy: #162368;
  --ad-navy-deep: #0c1440;
  --ad-blue: #66b8e8;
  --ad-blue-soft: #e4f2fb;
  --ad-green: #1f8a4c;
  --ad-green-soft: #e3f4ea;
  --ad-amber: #9a6200;
  --ad-amber-soft: #fbefd6;
  --ad-red: #b42318;
  --ad-red-soft: #fde7e4;
  --ad-serif: "Fraunces", Georgia, serif;
  --ad-sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ad-radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ad-bg); color: var(--ad-ink); font-family: var(--ad-sans); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ad-navy); }
.ad-app { min-height: 100vh; }

/* topo */
.ad-header {
  background: var(--ad-navy-deep);
  color: #fbf6ea;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
}
.ad-header img { height: 24px; display: block; }
.ad-header-title { display: flex; align-items: center; gap: 14px; font-weight: 700; }
.ad-header-title span { opacity: 0.7; font-weight: 600; padding-left: 14px; border-left: 1px solid rgba(251, 246, 234, 0.3); }
.ad-header .ad-btn--quiet { color: #fbf6ea; }

.ad-main { max-width: 1180px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 40px) 80px; }
.ad-pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.ad-h1 { font-family: var(--ad-serif); font-weight: 600; font-size: clamp(28px, 4vw, 38px); line-height: 1.1; margin: 0 0 6px; letter-spacing: -0.01em; }
.ad-sub { color: var(--ad-muted); margin: 0; }

/* botoes */
.ad-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1.5px solid var(--ad-line-strong);
  background: var(--ad-surface);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ad-ink);
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.ad-btn:hover { border-color: var(--ad-navy); }
.ad-btn:focus-visible { outline: 2px solid var(--ad-blue); outline-offset: 2px; }
.ad-btn:disabled { opacity: 0.5; cursor: default; }
.ad-btn svg { width: 16px; height: 16px; flex: none; }
.ad-btn--primary { background: var(--ad-navy); border-color: var(--ad-navy); color: #fff; }
.ad-btn--primary:hover { background: var(--ad-navy-deep); border-color: var(--ad-navy-deep); }
.ad-btn--danger { color: var(--ad-red); }
.ad-btn--danger:hover { border-color: var(--ad-red); background: var(--ad-red-soft); }
.ad-btn--quiet { border-color: transparent; background: transparent; }
.ad-btn--quiet:hover { background: rgba(22, 35, 104, 0.08); border-color: transparent; }
.ad-btn--small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.ad-btn--big { min-height: 48px; padding: 0 22px; font-size: 16px; }

/* etiquetas */
.ad-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 800; letter-spacing: 0.02em; white-space: nowrap; }
.ad-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ad-pill--live { background: var(--ad-green-soft); color: var(--ad-green); }
.ad-pill--draft { background: #eceae4; color: var(--ad-muted); }
.ad-pill--changes { background: var(--ad-amber-soft); color: var(--ad-amber); }

/* cards da lista */
.ad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.ad-card {
  background: var(--ad-surface);
  border: 1.5px solid var(--ad-line);
  border-radius: var(--ad-radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.ad-card:hover { border-color: var(--ad-line-strong); box-shadow: 0 12px 30px rgba(16, 36, 64, 0.07); }
.ad-card-title { font-family: var(--ad-serif); font-size: 21px; font-weight: 600; margin: 0; line-height: 1.2; }
.ad-card-link { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ad-muted); min-width: 0; }
.ad-card-link code { font-family: inherit; font-weight: 700; color: var(--ad-navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-stats { display: flex; gap: 22px; padding: 12px 0; border-top: 1px solid var(--ad-line); border-bottom: 1px solid var(--ad-line); }
.ad-stat b { display: block; font-size: 26px; line-height: 1; font-weight: 800; letter-spacing: -0.02em; }
.ad-stat span { font-size: 13px; color: var(--ad-muted); }
.ad-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ad-card-actions .ad-btn--primary { flex: 1; }
.ad-archived { margin-top: 36px; }
.ad-archived summary { cursor: pointer; font-weight: 700; color: var(--ad-muted); margin-bottom: 14px; }
.ad-card--archived { opacity: 0.75; }

.ad-banner { display: flex; gap: 10px; align-items: flex-start; background: var(--ad-amber-soft); color: #5c3b00; border-radius: 10px; padding: 12px 14px; margin-bottom: 20px; font-size: 14px; }
.ad-empty { background: var(--ad-surface); border: 1.5px dashed var(--ad-line-strong); border-radius: var(--ad-radius); padding: 40px 24px; text-align: center; }
.ad-empty h2 { font-family: var(--ad-serif); font-weight: 600; margin: 0 0 8px; }
.ad-empty p { color: var(--ad-muted); margin: 0 0 20px; }

/* modelos */
.ad-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.ad-template {
  text-align: left;
  background: var(--ad-surface);
  border: 1.5px solid var(--ad-line);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s;
}
.ad-template:hover, .ad-template:focus-visible { border-color: var(--ad-navy); background: var(--ad-blue-soft); outline: none; }
.ad-template b { font-size: 16px; }
.ad-template span { color: var(--ad-muted); font-size: 13px; }
.ad-template small { color: var(--ad-navy); font-weight: 700; font-size: 12px; margin-top: auto; padding-top: 6px; }

/* dialogo */
.ad-dialog { border: 0; border-radius: 16px; padding: 0; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 30px 80px rgba(12, 20, 64, 0.35); color: var(--ad-ink); }
.ad-dialog::backdrop { background: rgba(12, 20, 64, 0.55); }
.ad-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--ad-line); position: sticky; top: 0; background: #fff; z-index: 1; }
.ad-dialog-head h2 { margin: 0; font-family: var(--ad-serif); font-weight: 600; font-size: 22px; }
.ad-dialog-body { padding: 20px 22px; }
.ad-dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--ad-line); }
.ad-dialog--small { width: min(460px, calc(100vw - 32px)); }

/* campos */
.ad-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.ad-label { font-weight: 700; font-size: 14px; }
.ad-help { font-size: 13px; color: var(--ad-muted); margin: 0; }
.ad-input, .ad-select, .ad-textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1.5px solid var(--ad-line-strong);
  border-radius: 9px;
  background: #fff;
  font-size: 15px;
}
.ad-textarea { resize: vertical; min-height: 70px; line-height: 1.4; }
.ad-input:focus, .ad-select:focus, .ad-textarea:focus { outline: none; border-color: var(--ad-navy); box-shadow: 0 0 0 3px rgba(102, 184, 232, 0.35); }
.ad-input--error { border-color: var(--ad-red); }
.ad-field-error { color: var(--ad-red); font-size: 13px; font-weight: 700; margin: 0; }
.ad-row { display: flex; gap: 10px; align-items: center; }
.ad-row > * { min-width: 0; }
.ad-prefix { display: flex; align-items: stretch; border: 1.5px solid var(--ad-line-strong); border-radius: 9px; overflow: hidden; background: #fff; }
.ad-prefix span { display: flex; align-items: center; padding: 0 10px; background: #f1ede4; color: var(--ad-muted); font-weight: 700; font-size: 14px; border-right: 1px solid var(--ad-line); }
.ad-prefix input { border: 0; min-height: 40px; padding: 0 10px; flex: 1; min-width: 0; font-size: 15px; }
.ad-prefix:focus-within { border-color: var(--ad-navy); box-shadow: 0 0 0 3px rgba(102, 184, 232, 0.35); }
.ad-prefix input:focus { outline: none; }

/* interruptor */
.ad-switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 700; font-size: 14px; margin-bottom: 16px; user-select: none; }
.ad-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ad-switch-track { position: relative; width: 42px; height: 24px; flex: none; border-radius: 99px; background: var(--ad-line-strong); transition: background 0.2s; }
.ad-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s; }
.ad-switch input:checked + .ad-switch-track { background: var(--ad-navy); }
.ad-switch input:checked + .ad-switch-track::after { transform: translateX(18px); }
.ad-switch input:focus-visible + .ad-switch-track { outline: 2px solid var(--ad-blue); outline-offset: 2px; }
.ad-switch small { display: block; font-weight: 500; color: var(--ad-muted); font-size: 13px; }

/* editor */
.ad-editor { display: flex; flex-direction: column; height: 100vh; }
.ad-edbar { display: flex; align-items: center; gap: 12px; padding: 10px clamp(12px, 2vw, 20px); background: #fff; border-bottom: 1px solid var(--ad-line); flex-wrap: wrap; }
.ad-edbar-title { flex: 1; min-width: 180px; display: flex; align-items: center; gap: 10px; }
.ad-edbar-title input { font-family: var(--ad-serif); font-weight: 600; font-size: 20px; border: 1.5px solid transparent; border-radius: 8px; padding: 4px 8px; min-width: 0; flex: 1; background: transparent; }
.ad-edbar-title input:hover { border-color: var(--ad-line); }
.ad-edbar-title input:focus { outline: none; border-color: var(--ad-navy); background: #fff; }
.ad-saved { font-size: 13px; color: var(--ad-muted); white-space: nowrap; }
.ad-saved--warn { color: var(--ad-amber); font-weight: 700; cursor: pointer; text-decoration: underline; background: none; border: 0; padding: 0; }
.ad-edbody { flex: 1; display: grid; grid-template-columns: 290px minmax(0, 1fr) 400px; grid-template-rows: minmax(0, 1fr); min-height: 0; }
.ad-edlist { border-right: 1px solid var(--ad-line); overflow-y: auto; padding: 14px 10px 40px; background: #faf8f3; }
.ad-edpanel { overflow-y: auto; padding: 24px clamp(16px, 3vw, 36px) 80px; }
.ad-edpanel-inner { max-width: 640px; }
.ad-edpreview { border-left: 1px solid var(--ad-line); background: #ece8de; display: flex; flex-direction: column; align-items: center; padding: 16px; gap: 10px; min-height: 0; }
.ad-edpreview-head { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 360px; font-size: 13px; font-weight: 700; color: var(--ad-muted); }
.ad-phone { width: 100%; max-width: 360px; flex: 1; min-height: 0; max-height: 720px; border-radius: 28px; overflow: hidden; border: 8px solid #1b1f2e; box-shadow: 0 20px 50px rgba(12, 20, 64, 0.3); }
.ad-phone > .wf-root { height: 100%; }

.ad-section-label { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ad-muted); padding: 14px 10px 6px; }
.ad-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px;
  border-radius: 9px;
  border: 1.5px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.3;
}
.ad-item:hover { background: #fff; border-color: var(--ad-line); }
.ad-item[aria-current="true"] { background: #fff; border-color: var(--ad-navy); box-shadow: 0 4px 14px rgba(16, 36, 64, 0.08); }
.ad-item-num { flex: none; display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 7px; background: var(--ad-blue-soft); color: var(--ad-navy); font-weight: 800; font-size: 12px; }
.ad-item-num--fixed { background: #ece8de; color: var(--ad-muted); }
.ad-item-text { flex: 1; min-width: 0; }
.ad-item-text b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ad-item-text small { color: var(--ad-muted); font-size: 12px; display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.ad-item-tag { background: var(--ad-amber-soft); color: var(--ad-amber); font-weight: 800; border-radius: 5px; padding: 0 5px; font-size: 11px; }
.ad-add { margin: 8px 10px 0; width: calc(100% - 20px); border-style: dashed; }

.ad-panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.ad-panel-title h2 { margin: 0; font-family: var(--ad-serif); font-weight: 600; font-size: 24px; }
.ad-box { border: 1.5px solid var(--ad-line); border-radius: var(--ad-radius); padding: 16px; background: #fff; margin: 8px 0 18px; }
.ad-box--logic { border-color: #f0d9a8; background: #fffaf0; }
.ad-box h3 { margin: 0 0 4px; font-size: 15px; }
.ad-checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ad-check { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1.5px solid var(--ad-line-strong); border-radius: 99px; cursor: pointer; font-weight: 600; font-size: 14px; background: #fff; }
.ad-check:has(input:checked) { border-color: var(--ad-navy); background: var(--ad-blue-soft); }
.ad-check input { accent-color: var(--ad-navy); }
.ad-option-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.ad-option-key { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; background: var(--ad-blue-soft); color: var(--ad-navy); font-weight: 800; font-size: 12px; }
.ad-tip { display: flex; gap: 10px; background: var(--ad-blue-soft); border-radius: 10px; padding: 12px 14px; font-size: 14px; margin: 4px 0 18px; }
.ad-tip svg { width: 18px; height: 18px; flex: none; color: var(--ad-navy); margin-top: 1px; }
.ad-tip code { font-family: inherit; font-weight: 800; background: #fff; padding: 1px 6px; border-radius: 5px; }
.ad-danger-zone { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--ad-line); display: flex; gap: 8px; flex-wrap: wrap; }

.ad-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.ad-menu button { text-align: left; padding: 12px; border: 1.5px solid var(--ad-line); border-radius: 10px; background: #fff; cursor: pointer; }
.ad-menu button:hover, .ad-menu button:focus-visible { border-color: var(--ad-navy); background: var(--ad-blue-soft); outline: none; }
.ad-menu b { display: block; }
.ad-menu span { font-size: 13px; color: var(--ad-muted); }

/* respostas */
.ad-tablewrap { background: #fff; border: 1.5px solid var(--ad-line); border-radius: var(--ad-radius); overflow: auto; }
.ad-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ad-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ad-muted); background: #faf8f3; padding: 10px 12px; border-bottom: 1px solid var(--ad-line); white-space: nowrap; position: sticky; top: 0; }
.ad-table td { padding: 11px 12px; border-bottom: 1px solid var(--ad-line); vertical-align: top; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-table tbody tr { cursor: pointer; }
.ad-table tbody tr:hover td { background: var(--ad-blue-soft); }
.ad-detail dt { font-weight: 700; font-size: 13px; color: var(--ad-muted); margin-top: 14px; }
.ad-detail dd { margin: 3px 0 0; font-size: 16px; white-space: pre-wrap; word-break: break-word; }
.ad-more { display: flex; justify-content: center; padding: 16px; }

/* login */
.ad-login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(120% 80% at 100% 0%, rgba(102, 184, 232, 0.22), transparent 55%), #0c1440; }
.ad-login form { width: min(400px, 100%); background: #fff; border-radius: 18px; padding: 32px 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35); }
.ad-login-logo { background: var(--ad-navy-deep); border-radius: 10px; padding: 14px; display: flex; justify-content: center; margin-bottom: 22px; }
.ad-login-logo img { height: 28px; }
.ad-login h1 { font-family: var(--ad-serif); font-weight: 600; font-size: 26px; margin: 0 0 6px; }
.ad-login p { color: var(--ad-muted); margin: 0 0 20px; }

/* avisos */
.ad-toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; width: min(520px, calc(100vw - 32px)); }
.ad-toast { background: var(--ad-navy-deep); color: #fbf6ea; padding: 12px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 14px 40px rgba(12, 20, 64, 0.35); display: flex; gap: 10px; align-items: center; animation: ad-toast-in 0.25s ease; }
.ad-toast--error { background: var(--ad-red); color: #fff; }
.ad-toast--ok { background: var(--ad-green); color: #fff; }
@keyframes ad-toast-in { from { transform: translateY(12px); } to { transform: none; } }
.ad-loading { padding: 80px 24px; text-align: center; color: var(--ad-muted); }

@media (max-width: 1180px) {
  .ad-edbody { grid-template-columns: 260px minmax(0, 1fr); }
  .ad-edpreview { display: none; }
}
@media (max-width: 760px) {
  .ad-editor { height: auto; min-height: 100vh; }
  .ad-edbody { display: block; overflow: visible; }
  .ad-edlist { border-right: 0; border-bottom: 1px solid var(--ad-line); max-height: 46vh; }
  .ad-edpanel { padding: 20px 16px 60px; }
  .ad-header-title span { display: none; }
  .ad-grid { grid-template-columns: 1fr; }
  .ad-edbar .ad-hide-mobile { display: none; }
}
