:root {
	--primary: #064887;
	--primary-ink: #ffffff;
	--accent: #74bbff;
	--bg: #f4f6f9;
	--surface: #ffffff;
	--surface-2: #f0f3f7;
	--text: #1f2933;
	--muted: #66717f;
	--border: #dde3ea;
	--danger: #b42318;
	--ok: #1a7f4b;
	--warn: #9a6700;
	--radius: 10px;
	--shadow: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
	font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
	color-scheme: light;
}

* { box-sizing: border-box; }
/* Garante que [hidden] vença regras como display: flex */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: .1rem 0; }
h2 { font-size: 1.15rem; margin: 0; }
code { background: var(--surface-2); padding: .1rem .35rem; border-radius: 4px; font-size: .85em; }
.muted { color: var(--muted); }
small { font-size: .82em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Layout */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh; }
.logo { font-weight: 800; font-size: 1.3rem; text-decoration: none; color: var(--primary); }
.logo span, .login-card h1 span { color: var(--muted); font-weight: 500; }
.sidebar nav { display: flex; flex-direction: column; gap: .15rem; }
.sidebar nav a { padding: .55rem .75rem; border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 500; }
.sidebar nav a:hover { background: var(--surface-2); }
.sidebar nav a[aria-current=page] { background: var(--primary); color: var(--primary-ink); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; }
.who { text-decoration: none; color: var(--text); display: flex; flex-direction: column; font-weight: 600; }
.who small { color: var(--muted); font-weight: 400; }
.content { padding: 1.5rem 2rem 4rem; max-width: 1100px; width: 100%; min-width: 0; }
@media (max-width: 800px) {
	.layout { grid-template-columns: minmax(0, 1fr); }
	.sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .75rem 16px; }
	.sidebar nav { flex-direction: row; flex-wrap: wrap; }
	.sidebar-foot { margin: 0; flex-direction: row; align-items: center; }
	.content { padding: 1rem 16px 3rem; }
}

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head.sticky { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: .75rem 0; margin-top: -.75rem; border-bottom: 1px solid var(--border); }
.page-head a.muted { text-decoration: none; font-size: .9rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

/* Botões */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.1); background: var(--primary); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: currentColor; background: transparent; }
.btn-small { padding: .3rem .65rem; font-size: .88rem; }
.btn-block { width: 100%; justify-content: center; }
.link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link.danger, .danger { color: var(--danger); }

/* Formulários */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.field { grid-column: 1 / -1; display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field.half { grid-column: span 1; }
@media (max-width: 640px) { .field.half { grid-column: 1 / -1; } }
.label, .field > span:first-child { font-weight: 600; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input:not([type]), select, textarea {
	width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
textarea.code, .code { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: .85rem; }
.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: 1.1rem; height: 1.1rem; }
.prefix { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.prefix > span { padding-left: .7rem; color: var(--muted); }
.prefix input { border: 0; padding-left: .2rem; }
.segmented { display: flex; flex-wrap: wrap; gap: .5rem; }
.segmented label { display: flex; gap: .4rem; align-items: center; padding: .45rem .8rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.segmented label:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.colors { flex-direction: row; gap: 1.5rem; }
.colors label { display: flex; flex-direction: column; gap: .35rem; }
input[type=color] { width: 4rem; height: 2.4rem; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface); }
.inline { display: inline-flex; gap: .35rem; align-items: center; }
.filter { margin-bottom: 1rem; max-width: 320px; }

/* Mensagens e selos */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-ok { color: var(--ok); border-color: currentColor; background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }
.flash-error { color: var(--danger); border-color: currentColor; background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.flash-info { color: var(--muted); border-color: var(--border); background: var(--surface-2); }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge-ok { color: var(--ok); border-color: currentColor; }
.badge-info { color: var(--primary); border-color: currentColor; }
.badge-warn { color: var(--warn); border-color: currentColor; }

/* Tabelas do painel */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .82rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.table tr.inactive td { opacity: .55; }
.card:has(> .table) { overflow-x: auto; }

/* Início */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--text); margin: 0; }
.stat strong { font-size: 1.8rem; }
.stat .ok { color: var(--ok); }
.stat .err { color: var(--danger); }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Seções da página */
.sections-title { margin: 1.5rem 0 .75rem; }
.sections { display: flex; flex-direction: column; gap: .75rem; }
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.section > summary { display: flex; align-items: center; gap: .6rem; padding: .75rem 1rem; cursor: pointer; list-style: none; }
.section > summary::-webkit-details-marker { display: none; }
.section[open] > summary { border-bottom: 1px solid var(--border); }
.section-icon { width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 6px; background: var(--surface-2); font-size: .85rem; font-weight: 700; color: var(--primary); }
.section-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.section-actions { margin-left: auto; display: flex; gap: .75rem; flex-shrink: 0; }
.section-actions .link { text-decoration: none; }
.section-body { padding: 1rem; }
.help { margin: 0 0 1rem; color: var(--muted); font-size: .9rem; }
.handle { cursor: grab; color: var(--muted); user-select: none; font-size: 1.1rem; }
.sortable-ghost { opacity: .4; }
.add-section { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1rem; }
.danger-zone { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* Listas repetíveis */
.repeater { display: flex; flex-direction: column; gap: .5rem; }
.repeater-row { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: start; padding: .75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.repeater-row .handle { padding-top: 1.7rem; }
.repeater-row [data-remove-row] { padding-top: 1.7rem; text-decoration: none; }
.repeater + .btn { align-self: flex-start; }

/* Campo de mídia */
.media-field { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.media-preview img { height: 56px; width: auto; max-width: 160px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: 4px; }
.media-preview:empty { display: none; }

/* Editor de texto */
.rte { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.rte-toolbar, .rte-subbar { display: flex; flex-wrap: wrap; gap: 2px; padding: .35rem; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: 8px 8px 0 0; position: sticky; top: 64px; z-index: 2; }
.rte-subbar { top: auto; position: static; border-radius: 0; background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.rte-subbar::before { content: attr(data-label); font-size: .82rem; color: var(--muted); align-self: center; margin: 0 .4rem; }
.rte-toolbar button, .rte-subbar button { min-width: 2rem; height: 2rem; padding: 0 .45rem; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.rte-subbar button { font-weight: 500; font-size: .85rem; border-color: var(--border); background: var(--surface); }
.rte-toolbar button:hover { background: var(--surface); border-color: var(--border); }
.rte-subbar button.active, .rte-toolbar button.active { background: var(--primary); color: var(--primary-ink); }
.rte-toolbar button:disabled { opacity: .35; cursor: default; }
.rte-toolbar button svg { vertical-align: middle; }
.rte-toolbar .sep, .rte-subbar .sep { width: 1px; background: var(--border); margin: 4px 4px; }
.rte-area .ProseMirror { min-height: 180px; padding: .9rem 1rem; outline: none; }
.rte-area .ProseMirror > :first-child { margin-top: 0; }
.rte-html { width: 100%; min-height: 260px; border: 0; border-radius: 0 0 8px 8px; padding: .9rem 1rem; }
.ProseMirror table { border-collapse: collapse; width: 100%; margin: .75rem 0; table-layout: fixed; }
.ProseMirror th, .ProseMirror td { border: 1px solid var(--border); padding: .35rem .5rem; vertical-align: top; position: relative; }
.ProseMirror th { background: var(--surface-2); font-weight: 600; }
.ProseMirror td p, .ProseMirror th p { margin: 0; }
.ProseMirror .selectedCell::after { content: ''; position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 30%, transparent); pointer-events: none; }
.ProseMirror img { max-width: 100%; height: auto; display: block; margin: .75rem auto; }
.ProseMirror img[data-align=left] { float: left; margin: .25rem 1.25rem .75rem 0; max-width: 50%; }
.ProseMirror img[data-align=right] { float: right; margin: .25rem 0 .75rem 1.25rem; max-width: 50%; }
.ProseMirror img[data-align=full] { width: 100%; }
.ProseMirror img[data-size=s] { width: 30%; }
.ProseMirror img[data-size=m] { width: 50%; }
.ProseMirror img[data-size=l] { width: 75%; max-width: 75%; }
.ProseMirror::after { content: ''; display: table; clear: both; }
.ProseMirror img.ProseMirror-selectednode { outline: 3px solid var(--accent); }
.ProseMirror blockquote { border-left: 4px solid var(--accent); margin: .75rem 0; padding: .25rem 1rem; background: var(--surface-2); }
.ProseMirror a { color: var(--primary); }

/* Menu */
.nav-tree, .nav-children { list-style: none; margin: 0; padding: 0; }
.nav-tree > li { margin-bottom: .5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.nav-children { margin: 0 .75rem .5rem 2.25rem; min-height: .75rem; border-left: 2px dashed var(--border); padding-left: .5rem; }
.nav-children > li { border: 1px solid var(--border); border-radius: 6px; margin-top: .4rem; background: var(--surface-2); }
.nav-row { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; flex-wrap: wrap; }
.nav-label { font-weight: 600; text-decoration: none; }
.nav-dest { font-size: .88rem; }
.hidden-item .nav-label { opacity: .55; }

/* Mídia */
.upload { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.dropzone { flex: 1; min-width: min(240px, 100%); display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; padding: 1rem; border: 2px dashed var(--border); border-radius: 8px; cursor: pointer; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 1.25rem; }
.media-card { padding: 1rem; margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.media-card img, .file-icon { width: 100%; height: 190px; object-fit: contain; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; border-radius: 6px; }
.file-icon { display: grid; place-items: center; font-weight: 800; color: var(--danger); }
.media-card figcaption { display: flex; flex-direction: column; gap: .5rem; }
.media-card figcaption .inline { display: flex; }
.media-card figcaption .inline input { flex: 1; min-width: 0; }
.media-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-card .row { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding-top: .5rem; border-top: 1px solid var(--border); }
.media-card input { padding: .4rem .6rem; }

/* Diálogo de imagens */
.dialog { width: min(900px, 94vw); max-height: 86vh; border: 1px solid var(--border); border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--text); }
.dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.dialog-body { padding: 1rem 1.25rem; }
.picker-upload { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.picker-item { display: flex; flex-direction: column; gap: .35rem; padding: .5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: .82rem; }
.picker-item:hover { border-color: var(--primary); }
.picker-item img { width: 100%; height: 90px; object-fit: contain; }
.picker-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 1rem; }
.login-card h1 { color: var(--primary); }
.login-card p { margin: -.75rem 0 0; }

/* Edição de imagem */
.editor-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.25rem; align-items: start; }
@media (max-width: 1000px) { .editor-layout { grid-template-columns: 1fr; } }
.aspect-buttons { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.cropper-box { max-height: 60vh; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.cropper-box img { display: block; max-width: 100%; }
.focal-box { position: relative; cursor: crosshair; line-height: 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.focal-box canvas { width: 100%; height: auto; }
.focal-marker { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px var(--primary), 0 2px 6px rgb(0 0 0 / .5); pointer-events: none; transition: left .1s, top .1s; }
.previews-title { font-size: .95rem; margin: 1.25rem 0 .5rem; }
.previews { display: grid; grid-template-columns: 2.4fr 1fr .7fr; gap: .75rem; align-items: end; }
.previews figure { margin: 0; }
.previews figcaption { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.frame { overflow: hidden; border-radius: 6px; background: var(--surface-2); }
.frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame-wide { aspect-ratio: 16 / 6; }
.frame-square { aspect-ratio: 1; }
.frame-tall { aspect-ratio: 9 / 16; }
.small { font-size: .85rem; }

.dropzone input[type=file] { max-width: 100%; }

/* Créditos */
.credit-card { margin-top: 1.25rem; }
.credit-preview { margin-top: 1rem; padding: .6rem .8rem; background: var(--surface-2); border-radius: 8px; font-size: .9rem; }
.credit-line { color: var(--ok); }
.media-card .badge { align-self: flex-start; text-decoration: none; }
