/* ==========================================================================
   Painel administrativo
   ========================================================================== */
body.admin { font-size: 14.5px; }
body.admin .btn:not(.btn-sm):not(.btn-lg) { font-size: .9rem; padding: .45rem .9rem; }
.panel-head h2 { white-space: nowrap; }
.shell { display: flex; min-height: 100vh; }

/* ---------- Barra lateral ---------- */
.sidebar {
  width: 256px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040;
}
.sidebar-brand { display: flex; gap: .7rem; align-items: center; padding: 1.1rem 1rem 1rem; border-bottom: 1px solid var(--line); }
.brand-mark { width: 40px; height: 40px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex-shrink: 0; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-text strong { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: .74rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { padding: .5rem .6rem 1rem; flex: 1; }
.nav-section { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 1rem .65rem .35rem; }
.nav-item { display: flex; align-items: center; gap: .7rem; padding: .5rem .65rem; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 520; font-size: .9rem; position: relative; }
.nav-item i { width: 18px; text-align: center; color: var(--ink-3); font-size: .92rem; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 620; }
.nav-item.active i { color: var(--brand); }
.nav-item.active::before { content: ""; position: absolute; left: -.6rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav-badge { margin-left: auto; font-style: normal; font-size: .7rem; font-weight: 700; background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 7px; }
.sidebar-foot { border-top: 1px solid var(--line); padding: .8rem 1rem; display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: var(--ink-3); }
.sidebar-foot a { color: var(--ink-2); text-decoration: none; }
.sidebar-foot a:hover { color: var(--brand); }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(15, 20, 25, .4); z-index: 1030; }
}

/* ---------- Topo ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem; position: sticky; top: 0; z-index: 1020; }
.icon-btn { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink-2); }
.crumbs { display: flex; align-items: center; gap: .5rem; font-size: .86rem; color: var(--ink-3); min-width: 0; overflow: hidden; white-space: nowrap; }
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--brand); }
.crumbs span { color: var(--ink); font-weight: 560; overflow: hidden; text-overflow: ellipsis; }
.crumbs .sep { font-size: .6rem; opacity: .6; }
.topbar-user { margin-left: auto; }
.user-chip { display: flex; align-items: center; gap: .6rem; border: 0; background: transparent; padding: 4px 6px; border-radius: 8px; color: var(--ink-2); }
.user-chip:hover { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.user-meta { flex-direction: column; align-items: flex-start; line-height: 1.2; }
.user-meta strong { font-size: .86rem; color: var(--ink); }
.user-meta small { font-size: .74rem; color: var(--ink-3); }
.dropdown-item { display: flex; gap: .55rem; align-items: center; font-size: .9rem; }

.content { padding: 1.5rem; max-width: 1400px; width: 100%; }
@media (max-width: 575.98px) { .content { padding: 1rem; } .topbar { padding: 0 1rem; } }

/* ---------- Cabeçalho da página ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.page-head p { margin: .2rem 0 0; color: var(--ink-3); }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Painéis ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 1rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1.15rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: .98rem; font-weight: 650; margin: 0; display: flex; align-items: center; gap: .5rem; }
.panel-head h2 i { color: var(--ink-3); font-size: .9rem; }
.panel-body { padding: 1.15rem; }
.panel-foot { padding: .8rem 1.15rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.panel-note { font-size: .86rem; color: var(--ink-3); }

/* ---------- Indicadores ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; gap: .9rem; align-items: center; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--brand-line); }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex-shrink: 0; }
.stat-icon.warn { background: var(--warn-soft); color: var(--warn); }
.stat-icon.ok { background: var(--ok-soft); color: var(--ok); }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .82rem; color: var(--ink-3); }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.tbl th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 650; padding: .65rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface-2); text-align: left; white-space: nowrap; }
.tbl td { padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fafbfc; }
.tbl .t-main { font-weight: 600; color: var(--ink); text-decoration: none; display: block; }
.tbl a.t-main:hover { color: var(--brand); }
.tbl .t-sub { font-size: .82rem; color: var(--ink-3); }
.tbl .t-actions { white-space: nowrap; text-align: right; width: 1%; }
.tbl .num { font-variant-numeric: tabular-nums; }
.row-actions { display: inline-flex; gap: 4px; }
.row-actions form { display: inline; }

/* ---------- Filtros / abas ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .85rem 1.15rem; border-bottom: 1px solid var(--line); }
.toolbar .form-control, .toolbar .form-select { height: 38px; font-size: .9rem; }
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 360px; }
.toolbar .search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: .85rem; }
.toolbar .search input { padding-left: 34px; }
.toolbar .count { margin-left: auto; font-size: .84rem; color: var(--ink-3); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); padding: 0 .75rem; overflow-x: auto; }
.tabs a, .tabs button { border: 0; background: none; padding: .8rem .75rem; font-weight: 560; font-size: .9rem; color: var(--ink-3); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: .45rem; align-items: center; }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs a.active, .tabs button.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.tabs .tab-count { font-size: .72rem; background: #eef0f2; color: var(--ink-2); padding: 0 6px; border-radius: 999px; font-weight: 650; }
.tabs .active .tab-count { background: var(--brand-soft); color: var(--brand-ink); }

/* ---------- Formulário em seções ---------- */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.form-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 1rem; }
@media (max-width: 1199.98px) { .form-grid { grid-template-columns: 1fr; } .form-side { position: static; } }
.field-row { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; }
.field-row > * { grid-column: span 12; }
@media (min-width: 768px) {
  .span-2 { grid-column: span 2 !important; } .span-3 { grid-column: span 3 !important; } .span-4 { grid-column: span 4 !important; }
  .span-5 { grid-column: span 5 !important; } .span-6 { grid-column: span 6 !important; } .span-7 { grid-column: span 7 !important; }
  .span-8 { grid-column: span 8 !important; } .span-9 { grid-column: span 9 !important; }
}
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-nav button { text-align: left; border: 0; background: none; padding: .6rem .8rem; border-radius: 8px; color: var(--ink-2); font-weight: 540; display: flex; gap: .6rem; align-items: center; }
.settings-nav button i { width: 18px; color: var(--ink-3); }
.settings-nav button:hover { background: var(--surface-2); }
.settings-nav button.active { background: var(--brand-soft); color: var(--brand-ink); }
.settings-nav button.active i { color: var(--brand); }
.settings-pane { display: none; }
.settings-pane.active { display: block; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: .35rem .75rem; font-size: .88rem; margin: 0; }
.kv dt { color: var(--ink-3); font-weight: 500; }
.kv dd { margin: 0; word-break: break-word; }

.hash { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .76rem; word-break: break-all; color: var(--ink-2); background: var(--surface-2); padding: .5rem .6rem; border-radius: 6px; border: 1px solid var(--line); }
.codigo { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 650; letter-spacing: .04em; }

/* ---------- Montagem da edição ---------- */
.sortable { list-style: none; margin: 0; padding: 0; }
.sortable li { display: flex; gap: .75rem; align-items: center; padding: .7rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.sortable li:last-child { border-bottom: 0; }
.sortable li.dragging { opacity: .5; background: var(--brand-soft); }
.sortable .handle { cursor: grab; color: var(--ink-3); padding: 4px; }
.sortable .pos { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: var(--ink-2); flex-shrink: 0; }
.sortable .grow { flex: 1; min-width: 0; }
.sortable .grow strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sortable .grow small { color: var(--ink-3); }
.pick-list { max-height: 420px; overflow-y: auto; }
.pick-list label { display: flex; gap: .7rem; padding: .65rem 1rem; border-bottom: 1px solid var(--line); cursor: pointer; align-items: flex-start; }
.pick-list label:hover { background: var(--surface-2); }
.pick-list input { margin-top: .25rem; }

.locked-banner { display: flex; gap: .9rem; align-items: flex-start; background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 25%, #fff); color: #0f5b2b; border-radius: var(--radius); padding: .9rem 1.1rem; margin-bottom: 1.25rem; }
.locked-banner.warn { background: var(--warn-soft); color: #6b3f00; border-color: color-mix(in srgb, var(--warn) 25%, #fff); }
.locked-banner i { font-size: 1.15rem; margin-top: 2px; }

.preview-doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 2.5rem clamp(1rem, 5vw, 3.5rem); max-width: 860px; }

/* ---------- Login ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.auth-side { background: var(--brand); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px; border-radius: 50%; border: 60px solid rgba(255, 255, 255, .06); }
.auth-side .seal { width: 72px; height: 72px; border-radius: 14px; background: rgba(255, 255, 255, .12); display: grid; place-items: center; font-size: 1.8rem; overflow: hidden; }
.auth-side .seal img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 6px; }
.auth-side h1 { font-family: var(--font-serif); font-size: 2.1rem; font-weight: 700; margin: 1.5rem 0 .5rem; line-height: 1.15; }
.auth-side p { opacity: .82; max-width: 420px; }
.auth-side small { opacity: .7; }
.auth-form { display: grid; place-items: center; padding: 2rem; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: .25rem; }
.auth-box .lead { color: var(--ink-3); font-size: .95rem; margin-bottom: 1.75rem; }
.auth-box .form-control { height: 46px; }
.auth-box .btn { height: 46px; width: 100%; }
@media (max-width: 860px) { .auth-page { grid-template-columns: 1fr; } .auth-side { padding: 2rem; min-height: auto; } .auth-side h1 { font-size: 1.5rem; } }

/* ---------- Diversos ---------- */
.tox-tinymce { border-radius: 8px !important; border-color: var(--line-strong) !important; }
.color-field { display: flex; gap: .5rem; align-items: center; }
.color-field input[type=color] { width: 48px; height: 38px; padding: 3px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; }
.logo-preview { width: 120px; height: 120px; border: 1px dashed var(--line-strong); border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: .75rem; padding: .55rem 0; border-bottom: 1px dashed var(--line); font-size: .88rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 92px; }
.chart-box { position: relative; height: 240px; }
.text-muted-2 { color: var(--ink-3) !important; }
.w-fit { width: fit-content; }
