* { box-sizing: border-box; }
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; margin: 0; color: #222; background: #f5f6f8; }
a { color: #0b6cff; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { display: flex; align-items: center; gap: 1.5rem; padding: 0.75rem 1.25rem; background: #1f2937; color: #fff; }
.topbar .brand { color: #fff; font-weight: 700; }
.topbar nav { display: flex; gap: 1rem; }
.topbar nav a { color: #d1d5db; }
.topbar .user { margin-left: auto; display: flex; gap: 1rem; align-items: center; color: #d1d5db; }
.topbar .user a { color: #fff; }

main { padding: 1.5rem 2rem; max-width: 1400px; margin: 0 auto; }
h1 { margin-top: 0; }

.btn { display: inline-block; padding: 0.4rem 0.85rem; border-radius: 4px; border: 1px solid #d0d4da; background: #fff; cursor: pointer; font: inherit; }
.btn:hover { background: #f0f2f5; }
.btn.primary { background: #0b6cff; color: #fff; border-color: #0b6cff; }
.btn.primary:hover { background: #0a5ad9; }
.btn.danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn.danger:hover { background: #b91c1c; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1rem; color: #222; }
.card h3 { margin: 0 0 0.5rem 0; }
.card p { margin: 0; font-size: 1.5rem; font-weight: 700; }
.card small { color: #6b7280; }

.panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
.panel form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.panel label { display: flex; flex-direction: column; font-size: 0.85rem; gap: 0.25rem; }
input[type=text], input[type=number], input[type=search], input[name=title], input[name=description], input[name=title_prefix], select { padding: 0.4rem; border-radius: 4px; border: 1px solid #d0d4da; min-width: 200px; }

.data-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }
.data-table th, .data-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid #f1f3f5; text-align: left; }
.data-table th { background: #f9fafb; font-size: 0.85rem; }
.data-table tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: 0.4rem; }
.tag { background: #e0f2fe; color: #075985; padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.75rem; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #1f2937; }
.login-card { background: #fff; padding: 2rem; border-radius: 12px; max-width: 420px; width: 90%; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }

/* Editor */
#st-meta { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; background: #fff; padding: 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid #e5e7eb; }
.wysiwyg { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; }
.wysiwyg > * { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1rem; min-height: 500px; }
.wysiwyg h2 { font-size: 1rem; margin-top: 0; }

/* OnlyOffice editor: full-bleed iframe canvas (palette lives inside as a plugin) */
.oo-canvas { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 0; overflow: hidden; height: 80vh; min-height: 700px; }
#onlyoffice-placeholder { width: 100%; height: 100%; }
#onlyoffice-placeholder iframe { width: 100% !important; height: 100% !important; border: 0; display: block; }
.sit-chip-item { display: flex; flex-direction: column; }
.sit-chip-item .sit-name { font-weight: 500; }
.sit-chip-item .sit-cat { font-size: 0.7rem; color: #6b7280; margin-top: 2px; }
.sit-palette input, .sit-palette select { width: 100%; margin-bottom: 0.5rem; }
.sit-list { list-style: none; padding: 0; max-height: 65vh; overflow-y: auto; margin: 0; }
.sit-list li { padding: 0.4rem 0.5rem; border: 1px solid #e5e7eb; border-radius: 4px; margin-bottom: 0.3rem; cursor: pointer; background: #f9fafb; font-size: 0.85rem; }
.sit-list li:hover { background: #eef2ff; }
.sit-list .cat { font-size: 0.7rem; color: #6b7280; margin-top: 2px; }
.sit-list code { font-size: 0.7rem; }

.canvas { display: flex; flex-direction: column; padding: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.25rem; padding: 0.5rem; border-bottom: 1px solid #e5e7eb; background: #f9fafb; border-top-left-radius: 8px; border-top-right-radius: 8px; }
.toolbar button { padding: 0.3rem 0.6rem; border: 1px solid #d0d4da; background: #fff; border-radius: 4px; cursor: pointer; font-size: 0.85rem; }
.toolbar button:hover { background: #eef2ff; }
.toolbar .sep { width: 1px; background: #d0d4da; margin: 0 0.25rem; }

.prose { padding: 1rem 1.5rem; min-height: 60vh; outline: none; }
.prose .ProseMirror { outline: none; min-height: 60vh; }
.prose .ProseMirror p { margin: 0 0 0.75rem 0; }
.prose .ProseMirror h1 { font-size: 1.6rem; margin: 1rem 0 0.5rem; }
.prose .ProseMirror h2 { font-size: 1.3rem; margin: 0.9rem 0 0.5rem; }
.prose .ProseMirror h3 { font-size: 1.1rem; margin: 0.8rem 0 0.4rem; }
.prose .ProseMirror table { border-collapse: collapse; margin: 0.5rem 0; }
.prose .ProseMirror table td, .prose .ProseMirror table th { border: 1px solid #d0d4da; padding: 0.3rem 0.5rem; min-width: 60px; }
.prose .ProseMirror img { max-width: 100%; }

.sit-chip {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  margin: 0 1px;
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #7dd3fc;
  border-radius: 999px;
  font-size: 0.85em;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  white-space: nowrap;
  user-select: none;
  cursor: grab;
}
.sit-chip.ProseMirror-selectednode { outline: 2px solid #0b6cff; }

.page-break {
  page-break-before: always;
  border-top: 2px dashed #c0c4cc !important;
  margin: 1rem 0 !important;
  height: 0;
}
.page-break.ProseMirror-selectednode { border-top-color: #0b6cff !important; }

.hint { font-size: 0.8rem; color: #6b7280; }
