/* myp7 desktop — NovoDacha brand palette
   Primary black #131313, accent red-orange #E84619, warm off-white surfaces. */
:root {
  --brand: #131313;
  --accent: #E84619;
  --accent-dark: #C23612;
  --accent-light: #FFE9E2;
  --muted: #6b7280;
  --bg: #ffffff;
  --bg-alt: #faf8f5;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --warn: #a16207;
  --warn-bg: #fef3c7;
  --info: #1e40af;
  --info-bg: #dbeafe;
  --ok: #166534;
  --ok-bg: #dcfce7;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--brand);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 0.88em; }

/* Top bar */
.topbar {
  background: var(--brand);
  color: white;
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid var(--accent);
}
.topbar .brand {
  color: white;
  font-weight: 700;
  text-decoration: none;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.02em;
}
.topbar .brand img { height: 32px; width: auto; filter: brightness(0) invert(1); }
.topbar nav {
  display: flex;
  align-items: center;
  gap: 22px;
}
.topbar nav a {
  color: rgba(255,255,255,0.92);
  text-decoration: none;
  font-size: 0.95em;
  transition: color 0.15s;
}
.topbar nav a:hover { color: var(--accent); text-decoration: none; }
.topbar nav .user-name {
  color: rgba(255,255,255,0.75);
  font-weight: 500;
  padding-right: 22px;
  border-right: 1px solid rgba(255,255,255,0.18);
}
.topbar nav .device-toggle {
  font-size: 1.5em;
  padding-left: 22px;
  border-left: 1px solid rgba(255,255,255,0.18);
  line-height: 1;
  opacity: 0.9;
}
.topbar nav .device-toggle:hover { opacity: 1; }

.container { max-width: 1100px; margin: 0 auto; padding: 28px 24px; }

h1 { font-size: 1.9em; margin-top: 0; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.35em; font-weight: 600; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-top: 1.8em; }
h3 { font-size: 1.1em; font-weight: 600; color: var(--brand); }

/* Flashes */
.flash { padding: 12px 16px; margin-bottom: 16px; border-left: 4px solid var(--muted); background: var(--surface); border-radius: 4px; font-size: 0.95em; }
.flash-success { border-color: var(--ok); background: var(--ok-bg); }
.flash-danger  { border-color: var(--danger); background: var(--danger-bg); }
.flash-warning { border-color: var(--warn); background: var(--warn-bg); }
.flash-info    { border-color: var(--accent); background: var(--accent-light); }

/* Forms */
.form-narrow { max-width: 640px; }
.form-narrow .field { margin: 14px 0; }
.form-narrow label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 0.92em; }
.form-narrow input[type=text], .form-narrow input[type=email], .form-narrow input[type=password],
.form-narrow input[type=number], .form-narrow select, .form-narrow textarea,
.form-narrow input[type=file] {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px; font-size: 1em;
  font-family: inherit; width: 100%; max-width: 520px; background: white;
}
.form-narrow textarea { font-family: inherit; resize: vertical; min-height: 80px; }
.form-narrow input:focus, .form-narrow select:focus, .form-narrow textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light);
}
.form-narrow fieldset { border: 1px solid var(--border); padding: 12px 16px; border-radius: 6px; }
.form-narrow fieldset legend { padding: 0 6px; font-weight: 500; color: var(--brand); }

.btn-primary {
  background: var(--accent); color: white; border: none;
  padding: 10px 22px; border-radius: 4px; cursor: pointer;
  font-size: 0.95em; font-weight: 600; text-decoration: none;
  display: inline-block; transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-dark); color: white; text-decoration: none; }
.btn-secondary {
  background: transparent; color: var(--brand); border: 1.5px solid var(--brand);
  padding: 8px 18px; border-radius: 4px; cursor: pointer;
  font-size: 0.92em; font-weight: 500; text-decoration: none; display: inline-block;
}
.btn-secondary:hover { background: var(--brand); color: white; text-decoration: none; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: inherit; text-decoration: underline; font-family: inherit; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.data-table th, .data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.data-table th { background: var(--bg-alt); font-weight: 600; font-size: 0.9em; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: var(--bg-alt); }
.row-inactive { opacity: 0.55; }

.badge-ok { background: var(--ok-bg); color: var(--ok); padding: 3px 10px; border-radius: 12px; font-size: 0.82em; font-weight: 500; }
.badge-off { background: var(--danger-bg); color: var(--danger); padding: 3px 10px; border-radius: 12px; font-size: 0.82em; font-weight: 500; }

.filter-bar { margin: 14px 0; padding: 12px 16px; background: var(--bg-alt); border-radius: 6px; }
.filter-bar label { margin-right: 20px; font-size: 0.92em; }
.filter-bar select { padding: 4px 8px; font-size: 0.92em; border: 1px solid var(--border); border-radius: 3px; }

/* Dashboard stats */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 16px 0 24px; }
.admin-stats > div { background: var(--surface); padding: 16px; border: 1px solid var(--border); border-radius: 8px; transition: transform 0.15s, box-shadow 0.15s; }
.admin-stats > div:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); border-color: var(--accent); }
.admin-stats > div span { display: block; color: var(--muted); font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.03em; }
.admin-stats > div strong { display: block; font-size: 1.8em; margin-top: 4px; color: var(--brand); font-weight: 700; }

/* ==================================================================
   Unified rubric tree — the core navigation UI (task 2/3)
   ================================================================== */

.rubric-tree { list-style: none; padding: 0; margin: 0; }
.rubric-tree details { border: 1px solid var(--border); border-radius: 6px; background: var(--surface); margin-bottom: 6px; }
.rubric-tree details[open] { box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.rubric-tree details summary {
  list-style: none;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
  display: flex; align-items: center; gap: 10px;
  user-select: none;
  transition: background 0.1s;
}
.rubric-tree details summary:hover { background: var(--bg-alt); }
.rubric-tree details summary::-webkit-details-marker { display: none; }
.rubric-tree details summary::before {
  content: "+";
  display: inline-block;
  width: 22px; height: 22px;
  text-align: center; line-height: 20px;
  color: white; background: var(--accent);
  border-radius: 4px;
  font-weight: 700; font-size: 1.1em;
  flex-shrink: 0;
}
.rubric-tree details[open] > summary::before { content: "−"; }
.rubric-tree details > ul { list-style: none; padding: 0 10px 10px 26px; margin: 0; border-top: 1px solid var(--border); }
.rubric-tree details > ul > li { margin: 3px 0; }

/* Level-2 nested (smaller indicator) */
.rubric-tree details details summary::before { background: var(--brand); width: 18px; height: 18px; line-height: 16px; font-size: 0.95em; }
.rubric-tree details details { border-color: var(--border); margin-bottom: 4px; }

/* Level-3 leaf: no details wrapper, just a li with name */
.rubric-tree li.rubric-leaf { padding: 6px 10px 6px 28px; position: relative; border-radius: 4px; }
.rubric-tree li.rubric-leaf::before { content: "•"; position: absolute; left: 12px; color: var(--accent); font-weight: 700; }
.rubric-tree li.rubric-leaf:hover { background: var(--bg-alt); }

/* Article entries under a rubric */
.rubric-tree .article-item {
  padding: 6px 10px 6px 28px;
  position: relative;
  font-size: 0.95em;
  border-radius: 4px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.rubric-tree .article-item::before {
  content: "📄"; position: absolute; left: 4px; font-size: 0.9em; opacity: 0.6;
}
.rubric-tree .article-item:hover { background: var(--accent-light); }
.rubric-tree .article-item a { color: var(--brand); text-decoration: none; flex: 1; }
.rubric-tree .article-item a:hover { color: var(--accent); }
.rubric-tree .article-item .block-count { color: var(--muted); font-size: 0.82em; background: var(--bg-alt); padding: 1px 8px; border-radius: 10px; }

/* Rubric admin actions (shown only in admin mode) */
.rubric-tree .rubric-admin-actions { margin-left: auto; font-size: 0.82em; }
.rubric-tree .rubric-admin-actions a, .rubric-tree .rubric-admin-actions form { margin-left: 8px; }
.rubric-tree .summary-count { color: var(--muted); font-size: 0.82em; font-weight: 400; margin-left: 6px; }

/* Article view */
.breadcrumb { margin-bottom: 6px; font-size: 0.88em; }
.breadcrumb a { color: var(--muted); }
.article-meta { margin-bottom: 16px; font-size: 0.9em; }
.tag { background: var(--accent-light); color: var(--accent-dark); padding: 2px 10px; margin-right: 4px; border-radius: 12px; font-size: 0.82em; font-weight: 500; }

.alert-banner { padding: 14px 18px; margin: 16px 0; border-left: 5px solid var(--warn); background: var(--warn-bg); border-radius: 6px; display: flex; gap: 12px; align-items: flex-start; }
.alert-banner.alert-critical { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.alert-banner.alert-info { border-color: var(--info); background: var(--info-bg); }

.article-description { background: var(--bg-alt); padding: 14px 18px; border-radius: 6px; margin: 16px 0; font-size: 1.02em; line-height: 1.6; }

/* Content blocks */
.block { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; margin: 14px 0; }
.block-head { font-size: 0.82em; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.block-kind { font-weight: 600; color: var(--brand); text-transform: uppercase; letter-spacing: 0.03em; font-size: 0.85em; }
.block img { max-width: 100%; height: auto; border-radius: 6px; display: block; }
.block video { max-width: 100%; height: auto; border-radius: 6px; }
.block audio { width: 100%; }
.block .caption { font-size: 0.9em; color: var(--muted); margin-top: 8px; font-style: italic; }
.pdf-link { display: inline-block; padding: 12px 18px; background: var(--accent-light); color: var(--brand); border-radius: 6px; text-decoration: none; font-weight: 500; }
.pdf-link:hover { background: var(--accent); color: white; text-decoration: none; }

/* Task 6: side-by-side good/bad photo pair */
.photo-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.photo-pair .photo-col { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.photo-pair .photo-col.good { border-top: 4px solid var(--ok); }
.photo-pair .photo-col.bad { border-top: 4px solid var(--danger); }
.photo-pair .photo-col .label { font-size: 0.82em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 8px; display: inline-block; padding: 2px 8px; border-radius: 4px; }
.photo-pair .photo-col.good .label { background: var(--ok-bg); color: var(--ok); }
.photo-pair .photo-col.bad .label { background: var(--danger-bg); color: var(--danger); }
.photo-pair img { max-width: 100%; height: auto; border-radius: 4px; display: block; }
.photo-pair .caption { font-size: 0.88em; color: var(--muted); margin-top: 6px; font-style: italic; }
.photo-pair .block-head { font-size: 0.75em; margin-top: 8px; }
@media (max-width: 700px) { .photo-pair { grid-template-columns: 1fr; } }

/* Comments */
.comments { margin-top: 32px; padding-top: 18px; border-top: 2px solid var(--border); }
.comment-list { list-style: none; padding: 0; }
.comment-list li { padding: 12px 14px; background: var(--bg-alt); border-radius: 6px; margin: 8px 0; }
.comment-form { margin-top: 14px; }
.comment-form textarea { width: 100%; min-height: 70px; border: 1px solid var(--border); border-radius: 4px; padding: 10px; font-family: inherit; font-size: 0.95em; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

.search-form { display: flex; gap: 10px; margin: 16px 0 20px; }
.search-form input[type=search] { flex: 1; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 4px; font-size: 1em; }
.search-form input[type=search]:focus { outline: none; border-color: var(--accent); }

.footer { margin: 60px 24px 20px; text-align: center; font-size: 0.85em; color: var(--muted); }

.admin-row { padding: 12px 16px; background: var(--bg-alt); border-radius: 6px; margin: 14px 0; }
.admin-row form { display: inline; }

/* Dropzone — task 4 */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: 8px;
  padding: 32px 20px;
  text-align: center;
  background: var(--bg-alt);
  color: var(--muted);
  transition: all 0.15s;
  cursor: pointer;
  margin: 10px 0;
}
.dropzone.drag-over { border-color: var(--accent); background: var(--accent-light); color: var(--accent-dark); }
.dropzone .dz-icon { font-size: 2.5em; margin-bottom: 6px; }
.dropzone .dz-text { font-weight: 500; margin-bottom: 4px; }
.dropzone .dz-hint { font-size: 0.88em; }
.dropzone.has-file { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); border-style: solid; }
.dropzone input[type=file] { display: none; }

/* Lightbox — click any content image to enlarge */
main img:not(.no-zoom) { cursor: zoom-in; transition: opacity 0.15s; }
main img:not(.no-zoom):hover { opacity: 0.92; }
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 24px;
  animation: lb-fade 0.15s ease-out;
}
.lightbox[hidden] { display: none; }
.lightbox-img {
  max-width: 95vw; max-height: 95vh;
  object-fit: contain; border-radius: 4px;
  box-shadow: 0 10px 60px rgba(0, 0, 0, 0.6);
  cursor: zoom-out;
}
.lightbox-close {
  position: absolute; top: 16px; right: 20px;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.15); color: white; border: none;
  font-size: 1.8em; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.28); }
@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }

/* PDF block */
.pdf-block { display: block; }
.pdf-actions { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.pdf-link, .pdf-download {
  display: inline-flex; align-items: center;
  padding: 10px 16px; background: var(--accent-light); color: var(--brand);
  border-radius: 6px; text-decoration: none; font-weight: 500;
  transition: background 0.15s;
}
.pdf-link:hover, .pdf-download:hover { background: var(--accent); color: white; text-decoration: none; }
.pdf-download { background: var(--bg-alt); }
.pdf-viewer {
  display: block; width: 100%;
  height: 640px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-alt);
}

/* ──────────────────────────────────────────────────
   Reusable utility classes (extracted from browse_*)
   ────────────────────────────────────────────────── */

/* Thumbnails — square image tile, fixed size */
.thumb-sm { width: 72px; height: 72px; object-fit: cover; border-radius: 4px; display: block; }
.thumb-xs { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; display: block; }

/* Emoji-as-icon, sized for table cells */
.emoji-icon { font-size: 2em; line-height: 1; display: inline-block; }

/* Kind-colored tags (articles / content blocks) */
.tag-good     { background: var(--ok-bg);      color: var(--ok); }
.tag-bad      { background: var(--danger-bg);  color: var(--danger); }
.tag-neutral  { background: var(--accent-light); color: var(--accent-dark); }
.tag-warn     { background: var(--warn-bg);    color: var(--warn); }
.tag-info     { background: var(--info-bg);    color: var(--info); }
.tag-critical { background: var(--danger-bg);  color: var(--danger); }

/* Row of inline actions with subtle separators */
.action-row { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.action-row > * + *::before { content: "·"; margin-right: 8px; color: var(--muted); }
.action-row form { display: inline; }

/* Max-width text cell inside data tables */
.cell-limit-narrow { max-width: 280px; }
.cell-limit-wide   { max-width: 360px; }

/* Browse-table column helper */
.col-thumb { width: 88px; }
