:root {
    --bg: #0f172a;
    --bg-soft: #111827;
    --panel: #1e293b;
    --panel-2: #243449;
    --panel-3: #334155;
    --border: #475569;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --success-hover: #15803d;
    --warning: #f59e0b;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
    --radius: 14px;
    --radius-sm: 10px;
    --cell-size: 40px;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font);
    background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
    color: var(--text);
}

body.sistemas-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
    border: 0;
}

.hidden {
    display: none !important;
}

/* layout base */
.sistemas-app-topbar {
    width: 100%;
    min-height: 46px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 6px 10px;
    background: rgba(7, 10, 15, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.30);
    z-index: 1000;
}

.sistemas-topbar-left,
.sistemas-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.sistemas-topbar-right {
    justify-content: flex-end;
}

.sistemas-topbar-center {
    color: rgba(255, 255, 255, 0.92);
    font-size: 16px;
    white-space: nowrap;
}

.sistemas-topbar-btn {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border-radius: 7px;
    background: #242424;
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid #444;
    text-decoration: none;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}

.sistemas-topbar-btn:hover {
    background: #333;
}

.sistemas-menu {
    position: relative;
}

.sistemas-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1200;
    min-width: 180px;
    padding: 6px;
    background: rgba(7, 10, 15, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.48);
}

.sistemas-menu-item {
    display: block;
    padding: 9px 10px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 13px;
}

.sistemas-menu-item:hover {
    background: rgba(255, 255, 255, 0.10);
}

.sistemas-shell {
    min-height: calc(100vh - 46px);
    display: grid;
    grid-template-columns: 340px minmax(640px, 1fr) 320px;
    gap: 18px;
    padding: 18px;
}

.sistemas-sidebar,
.sistemas-properties,
.sistemas-main {
    min-width: 0;
}

.sistemas-sidebar,
.sistemas-properties {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sistemas-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* utilitários */
.row {
    display: flex;
}

.gap8 {
    gap: 8px;
}

.top8 {
    margin-top: 8px;
}

.top16 {
    margin-top: 16px;
}

.flex1 {
    flex: 1;
    min-width: 0;
}

.between {
    justify-content: space-between;
}

.center {
    align-items: center;
}

/* cards */
.sidebar-card,
.ficha-wrap,
.main-toolbar {
    background: rgba(30, 41, 59, 0.94);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.sidebar-card {
    padding: 16px;
}

.sidebar-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #f8fafc;
    margin-bottom: 10px;
}

.sidebar-label,
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #cbd5e1;
    margin-bottom: 6px;
}

.sidebar-help {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--muted);
}

.catalogo-placeholder,
.properties-empty {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

/* inputs */
.input-dark,
.form-input {
    width: 100%;
    height: 40px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.88);
    color: var(--text);
    border-radius: 10px;
    padding: 0 12px;
    outline: none;
}

.input-dark:focus,
.form-input:focus {
    border-color: rgba(59, 130, 246, 0.8);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

select.input-dark,
select.form-input {
    appearance: none;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    color: #e2e8f0;
    font-size: 14px;
}

.check-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* botões */
.btn-mini,
.btn-primario,
.btn-secundario,
.mini-icon {
    height: 38px;
    border-radius: 10px;
    padding: 0 12px;
    transition: 0.18s ease;
    border: 1px solid transparent;
}

.btn-mini,
.btn-secundario {
    background: rgba(51, 65, 85, 0.95);
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.18);
}

.btn-mini:hover,
.btn-secundario:hover {
    background: rgba(71, 85, 105, 0.95);
}

.btn-primario {
    background: var(--primary);
    color: white;
}

.btn-primario:hover {
    background: var(--primary-hover);
}

.btn-danger {
    background: rgba(127, 29, 29, 0.95);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger);
}

.btn-green {
    background: rgba(21, 128, 61, 0.95);
    color: #fff;
}

.btn-green:hover {
    background: var(--success);
}

.mini-icon {
    width: 30px;
    min-width: 30px;
    padding: 0;
    background: rgba(51, 65, 85, 0.95);
    color: #fff;
    border-color: rgba(148, 163, 184, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mini-icon:hover {
    background: rgba(71, 85, 105, 0.95);
}

.mini-icon.danger:hover {
    background: rgba(127, 29, 29, 0.95);
}

/* toolbar principal */
.main-toolbar {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.editor-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #f8fafc;
}

.editor-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 14px;
}

/* listas */
.campo-lista {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.campo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.14);
    transition: 0.18s ease;
}

.campo-item:hover {
    border-color: rgba(59, 130, 246, 0.42);
    transform: translateY(-1px);
}

.campo-item.selected {
    border-color: rgba(59, 130, 246, 0.9);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.16);
}

.campo-handle {
    font-size: 18px;
    color: var(--muted);
    cursor: grab;
    user-select: none;
    line-height: 1;
}

.campo-body {
    flex: 1;
    min-width: 0;
}

.campo-titulo {
    font-size: 14px;
    font-weight: 700;
    color: #f8fafc;
    word-break: break-word;
}

.campo-meta {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}

.campo-uid {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.badge {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.15);
    color: #bfdbfe;
    border: 1px solid rgba(59, 130, 246, 0.24);
    font-weight: 600;
}

.layout-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ficha */
.ficha-wrap {
    padding: 18px;
    overflow: auto;
    min-height: 0;
}

.ficha-header {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
    margin-bottom: 16px;
}

#tituloFichaAtual {
    font-size: 16px;
    font-weight: 800;
    color: #f8fafc;
}

.ficha-meta {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    color: #cbd5e1;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.ficha-grid {
    display: grid;
    gap: 0;
    position: relative;
    align-content: start;
    background:
            linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
            linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px),
            rgba(15, 23, 42, 0.95);
    background-size: var(--cell-size) var(--cell-size);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    overflow: hidden;
}

.grid-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border-right: 1px solid rgba(148, 163, 184, 0.05);
    border-bottom: 1px solid rgba(148, 163, 184, 0.05);
}

/* campos no grid */
.campo-layout {
    position: relative;
    margin: 2px;
    border-radius: 10px;
    border: 2px solid rgba(59, 130, 246, 0.55);
    background: rgba(59, 130, 246, 0.14);
    color: #eff6ff;
    padding: 8px 10px 18px;
    overflow: hidden;
    cursor: move;
    user-select: none;
    min-width: 0;
}

.campo-layout:hover {
    border-color: rgba(96, 165, 250, 0.95);
    background: rgba(59, 130, 246, 0.2);
}

.campo-layout.selected {
    border-color: #f59e0b;
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.6), 0 0 0 2px rgba(245, 158, 11, 0.16);
}

.campo-layout.travado {
    cursor: default;
    border-style: dashed;
}

.campo-layout.is-hidden {
    opacity: 0.45;
}

.campo-layout.dragging,
.campo-layout.resizing {
    opacity: 0.88;
}

.layout-label {
    font-size: 13px;
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layout-sub {
    margin-top: 4px;
    font-size: 11px;
    color: #cbd5e1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layout-size {
    position: absolute;
    right: 8px;
    bottom: 4px;
    font-size: 10px;
    color: #dbeafe;
    opacity: 0.9;
}

.campo-resize-handle {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background:
            linear-gradient(135deg, transparent 0 45%, rgba(255,255,255,0.9) 45% 55%, transparent 55% 100%);
    cursor: nwse-resize;
    opacity: 0.95;
}

/* painel da direita */
.prop-line {
    padding: 10px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    font-size: 14px;
    color: #e2e8f0;
}

.prop-line:last-child {
    border-bottom: 0;
}

.prop-line strong {
    color: #f8fafc;
}

/* modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-box {
    width: 100%;
    max-width: 520px;
    background: #172233;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.modal-header,
.modal-footer {
    padding: 16px 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.modal-footer {
    border-bottom: 0;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: #f8fafc;
}

.modal-close {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(51, 65, 85, 0.95);
    color: #fff;
}

.modal-close:hover {
    background: rgba(71, 85, 105, 0.95);
}

.modal-body {
    padding: 18px;
}

.modal-body .form-input + .form-label,
.modal-body .form-label + .form-label {
    margin-top: 12px;
}

.form-status {
    min-height: 20px;
    margin-top: 10px;
    font-size: 13px;
    color: #fca5a5;
}

/* responsivo */
@media (max-width: 1480px) {
    .sistemas-shell {
        grid-template-columns: 320px minmax(560px, 1fr) 300px;
    }
}

@media (max-width: 1200px) {
    .sistemas-shell {
        grid-template-columns: 1fr;
    }

    .sistemas-sidebar,
    .sistemas-properties,
    .sistemas-main {
        width: 100%;
    }

    .ficha-wrap {
        overflow: auto;
    }
}

@media (max-width: 640px) {
    .sistemas-shell {
        padding: 12px;
        gap: 12px;
    }

    .main-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .row.gap8 {
        flex-wrap: wrap;
    }

    .btn-mini,
    .btn-primario,
    .btn-secundario {
        width: 100%;
    }

    .layout-actions {
        flex-wrap: wrap;
    }
}
/* catalogo */
.catalogo-lista {
    margin-top: 12px;
    max-height: 430px;
    overflow: auto;
    padding-right: 4px;
}

.catalogo-status {
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
}

.catalogo-lista::-webkit-scrollbar {
    width: 10px;
}

.catalogo-lista::-webkit-scrollbar-thumb {
    background: rgba(71, 85, 105, 0.9);
    border-radius: 999px;
}

.catalogo-lista::-webkit-scrollbar-track {
    background: transparent;
}

.catalogo-acoes-duplas {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.catalogo-acoes-duplas .btn-mini {
    width: 100%;
    min-width: 0;
}

#sistemaCatalogoSelect {
    width: 100%;
    margin-top: 6px;
}

.catalogo-lista.catalogo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-content: start;
}

.catalogo-item-card,
.catalogo-item {
    cursor: pointer;
    user-select: none;
}

.catalogo-item.selected,
.catalogo-item-card.selected {
    border-color: rgba(34, 197, 94, 0.9);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.16);
}

.catalogo-item-thumb,
.catalogo-item-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    max-height: 132px;
    object-fit: cover;
    border-radius: 10px;
    display: block;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.catalogo-item-thumb.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.catalogo-item-body {
    flex: 1;
    min-width: 0;
}

.catalogo-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}

/* drawer reutilizado do catalogo */
.sessao-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(3px);
    display: none;
    justify-content: flex-end;
    z-index: 1200;
}

.sessao-drawer-card {
    width: min(520px, 100%);
    height: 100%;
    background: #172233;
    border-left: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: -12px 0 30px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
}

.sessao-drawer-card-sm {
    width: min(440px, 100%);
}

.sessao-drawer-header {
    padding: 20px 18px 14px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.sessao-drawer-kicker {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}

.sessao-drawer-header h3 {
    margin: 0;
    font-size: 22px;
    color: #f8fafc;
}

.sessao-drawer-header p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.sessao-drawer-body {
    padding: 18px;
    overflow: auto;
    flex: 1;
}

.sessao-drawer-body label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #cbd5e1;
}

.sessao-drawer-body input[type="text"] {
    width: 100%;
    height: 42px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.88);
    color: var(--text);
    padding: 0 12px;
}

.sessao-drawer-actions {
    padding: 16px 18px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.sessao-drawer-actions button,
.sessao-drawer-file-btn {
    height: 40px;
    border: 0;
    border-radius: 10px;
    padding: 0 14px;
    background: rgba(51, 65, 85, 0.95);
    color: #fff;
    cursor: pointer;
}

.sessao-drawer-actions button:hover,
.sessao-drawer-file-btn:hover {
    background: rgba(71, 85, 105, 0.95);
}

.sessao-drawer-checks {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.sessao-drawer-check {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #e2e8f0;
    font-size: 14px;
}

.sessao-conversao-config {
    margin: 12px 0 16px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.sessao-conversao-config input[type="range"] {
    width: 100%;
    margin-bottom: 12px;
}

.sessao-preview-container {
    margin: 16px 0;
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(15, 23, 42, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.sessao-preview-container img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.sessao-preview-placeholder {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

/* arte no layout */
.campo-item.is-arte {
    border-color: rgba(168, 85, 247, 0.35);
}

.layout-item-badge-arte {
    background: rgba(168, 85, 247, 0.15);
    color: #e9d5ff;
    border: 1px solid rgba(168, 85, 247, 0.24);
}

.campo-layout.is-arte {
    border-style: solid;
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.08);
    padding: 0;
    overflow: hidden;
}

.campo-layout.is-arte .layout-label,
.campo-layout.is-arte .layout-sub,
.campo-layout.is-arte .layout-size {
    position: absolute;
    left: 8px;
    right: 8px;
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.campo-layout.is-arte .layout-label {
    top: 8px;
}

.campo-layout.is-arte .layout-sub {
    top: 26px;
}

.campo-layout.is-arte .layout-size {
    left: auto;
    right: 8px;
    bottom: 4px;
}

.layout-art-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0.96;
}

@media (max-width: 640px) {
    .catalogo-acoes-duplas {
        grid-template-columns: 1fr;
    }

    .catalogo-lista.catalogo-grid {
        grid-template-columns: 1fr;
    }
}
.layout-art-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layout-art-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0.96;
    transform-origin: center center;
    will-change: transform;
}

.prop-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
