/* =====================================================================
   Painel de gestão
   Tinta escura + petróleo; amarelo-sinal só marca "onde você está".
   ===================================================================== */
:root {
  --ink: #16202B;
  --ink-2: #223041;
  --ink-text: #C9D3DE;
  --paper: #F4F6F8;
  --surface: #FFFFFF;
  --text: #1B2430;
  --muted: #5F6B7A;
  --line: #DFE4EA;
  --line-strong: #C8D0D9;
  --primary: #0E5A6B;
  --primary-hover: #0A4855;
  --primary-soft: #E3EFF1;
  --signal: #F2B705;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --success: #1F7A4D;
  --success-soft: #E5F4EC;
  --warning: #8A5A00;
  --warning-soft: #FFF5D6;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(22, 32, 43, .06);
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--text);
  font: 15px/1.5 var(--font); font-feature-settings: "tnum" 1;
}
a { color: var(--primary); }
img { max-width: 100%; height: auto; }
.icon { flex-shrink: 0; vertical-align: middle; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

/* ---------- Estrutura ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--ink) 248px, transparent 248px); }
.sidebar {
  background: var(--ink); color: var(--ink-text); padding: 18px 12px 24px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.brand-name { font-weight: 600; font-size: 15px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { display: block; font-size: 12px; font-weight: 400; color: #8D9AAA; }

.nav-group { margin-top: 14px; }
.nav-title { padding: 0 12px 6px; font-size: 12px; color: #7E8B9B; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 1px 0;
  color: var(--ink-text); text-decoration: none; border-radius: var(--radius-sm); position: relative;
}
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.is-active { background: var(--ink-2); color: #fff; font-weight: 600; }
.nav a.is-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: var(--signal);
}
.nav .count { margin-left: auto; background: var(--signal); color: var(--ink); font-size: 12px; font-weight: 700; border-radius: 999px; padding: 0 7px; }
.sidebar-foot { margin-top: auto; padding-top: 18px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.topbar .menu-toggle { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.content { padding: 28px; max-width: 1180px; width: 100%; }

/* ---------- Cabeçalho de página ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.01em; font-weight: 650; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 14px; color: var(--muted); text-decoration: none; display: inline-flex; gap: 4px; align-items: center; margin-bottom: 6px; }
.crumb:hover { color: var(--text); }

/* ---------- Superfícies ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.panel-body { padding: 20px; }
.panel-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: #FAFBFC; border-radius: 0 0 var(--radius) var(--radius); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-2 > .panel + .panel, .stack > .panel + .panel { margin-top: 0; }
.stack { display: grid; gap: 20px; }

/* Indicadores do painel inicial: uma faixa, não cartões soltos */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; }
.stat { padding: 18px 20px; border-left: 1px solid var(--line); text-decoration: none; color: inherit; }
.stat:first-child { border-left: 0; }
a.stat:hover { background: #FAFBFC; }
.stat-value { font-size: 28px; font-weight: 650; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); padding: 10px 20px; border-bottom: 1px solid var(--line); background: #FAFBFC; white-space: nowrap; }
.table td { padding: 13px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #FBFCFD; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline; }
.table .title-cell a { font-weight: 600; color: var(--text); text-decoration: none; }
.table .title-cell a:hover { color: var(--primary); }
.table .sub { display: block; color: var(--muted); font-size: 13px; }
.is-unread td { font-weight: 600; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 8px 15px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: 600 14px/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.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 { color: var(--danger); border-color: #F1C4BF; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--paper); color: var(--text); border-color: transparent; }
.btn-sm { min-height: 32px; padding: 6px 10px; font-size: 13px; }
.btn-icon { min-height: 32px; width: 32px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.sidebar .btn-ghost { color: var(--ink-text); width: 100%; justify-content: flex-start; padding: 9px 12px; }
.sidebar .btn-ghost:hover { background: var(--ink-2); color: #fff; }

/* ---------- Formulários ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-weight: 600; font-size: 14px; }
.field .hint { color: var(--muted); font-size: 13px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); font: 15px/1.4 var(--font);
}
textarea.input { min-height: 110px; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14, 90, 107, .18); }
.has-error .input { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 13px; }
.input-group { display: flex; }
.input-group .addon { display: flex; align-items: center; padding: 0 12px; background: var(--paper); border: 1px solid var(--line-strong); color: var(--muted); font-size: 14px; white-space: nowrap; }
.input-group .addon:first-child { border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .addon:last-child { border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group .input { border-radius: 0; }
.input-group .input:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .input:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); }
.section-title { font-size: 15px; font-weight: 650; margin: 8px 0 0; grid-column: 1 / -1; padding-top: 14px; border-top: 1px solid var(--line); }
.section-title:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

/* Editor de texto */
.editor-wrap .ql-toolbar.ql-snow { border-color: var(--line-strong); border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: #FAFBFC; font-family: var(--font); }
.editor-wrap .ql-container.ql-snow { border-color: var(--line-strong); border-radius: 0 0 var(--radius-sm) var(--radius-sm); min-height: 340px; font: 16px/1.6 var(--font); }
.editor-wrap .ql-editor { min-height: 340px; }

/* ---------- Avisos ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; border: 1px solid; }
.alert-success { background: var(--success-soft); border-color: #B8DFC9; color: #14532D; }
.alert-error { background: var(--danger-soft); border-color: #F4C7C2; color: #7A1A12; }
.alert-warning { background: var(--warning-soft); border-color: #F0DC9C; color: #5C3D00; }
.alert-info { background: var(--primary-soft); border-color: #BCD9DE; color: #0B3F4B; }
.alert .close { margin-left: auto; background: none; border: 0; cursor: pointer; color: inherit; opacity: .6; padding: 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--paper); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: #C3E3D1; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: #F0DC9C; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: #F4C7C2; }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: #BCD9DE; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 17px; }
.empty p { margin: 0 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.inline-form { display: inline; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.message-body { white-space: pre-wrap; line-height: 1.6; background: var(--paper); border-radius: var(--radius-sm); padding: 16px; margin-top: 16px; }

/* ---------- Biblioteca de mídia ---------- */
.dropzone {
  border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted);
  background: #FAFBFC; cursor: pointer;
}
.dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.dropzone strong { color: var(--text); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.media-item { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.media-thumb { aspect-ratio: 4 / 3; background: var(--paper) center / cover no-repeat; display: grid; place-items: center; color: var(--muted); }
.media-meta { padding: 8px 10px; font-size: 12.5px; color: var(--muted); }
.media-meta .name { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-actions { display: flex; gap: 2px; padding: 0 6px 8px; align-items: flex-start; flex-wrap: wrap; }

/* ---------- Aparência: layouts e paletas ---------- */
.choice-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card { display: block; position: relative; border: 2px solid var(--line); border-radius: var(--radius); padding: 12px; height: 100%; background: #fff; }
.choice-card:hover { border-color: var(--line-strong); }
.choice input:checked + .choice-card { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14, 90, 107, .15); }
.choice input:focus-visible + .choice-card { outline: 3px solid var(--signal); outline-offset: 2px; }
.choice-title { display: block; margin: 10px 0 2px; font-size: 15px; }
.choice-desc { display: block; color: var(--muted); font-size: 13px; }
.layout-sketch { aspect-ratio: 16 / 10; border-radius: 4px; background: var(--paper); padding: 8px; display: grid; gap: 5px; }
.layout-sketch i { display: block; background: #CDD5DE; border-radius: 2px; }
.choice .layout-sketch { display: grid; }
.swatches { display: flex; height: 44px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.swatches span { flex: 1; }
.swatches span:first-child { flex: 2; }
.current-tag { position: absolute; top: 8px; right: 8px; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 480px); }
.auth-side {
  background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background-image: linear-gradient(180deg, transparent 60%, rgba(14, 90, 107, .55));
}
.auth-side h2 { font-size: 34px; line-height: 1.15; letter-spacing: -.02em; max-width: 14ch; margin: 0; font-weight: 600; }
.auth-side p { color: var(--ink-text); max-width: 42ch; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 28px; background: var(--surface); }
.auth-box { width: 100%; max-width: 360px; }
.auth-box h1 { font-size: 24px; margin: 0 0 4px; }
.auth-box > p { color: var(--muted); margin: 0 0 24px; }
.auth-box .field { margin-bottom: 16px; }
.auth-links { margin-top: 18px; text-align: center; font-size: 14px; }

/* ---------- Página de erro ---------- */
.error-page { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.error-code { font-size: 64px; font-weight: 700; color: var(--line-strong); line-height: 1; }

/* ---------- Responsivo ---------- */
@media (max-width: 1080px) {
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar { position: fixed; left: 0; top: 0; width: 264px; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(22, 32, 43, .45); z-index: 40; }
  .topbar .menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 20px 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .table th, .table td { padding: 10px 14px; }
  .hide-sm { display: none; }
  .user-name { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
