:root {
  --bg: #eef2f8;
  --bg2: #f9fbff;
  --card: #ffffff;
  --ink: #111b2a;
  --muted: #5a6a81;
  --border: rgba(14, 25, 42, 0.12);
  --shadow: 0 8px 20px rgba(14, 25, 42, 0.08);
  --accent: #2d6cdf;
  --danger: #b3261e;
}
* { box-sizing: border-box; }
body {
  font-family: "Segoe UI", "Noto Sans", ui-sans-serif, system-ui, -apple-system, Roboto, Ubuntu, Cantarell, sans-serif;
  margin: 0;
  background: radial-gradient(1200px 500px at 10% -10%, #dfe9ff 0%, transparent 65%), linear-gradient(180deg, var(--bg2) 0%, var(--bg) 100%);
  color: var(--ink);
  line-height: 1.45;
}
.wrap { max-width: 1360px; margin: 0 auto; padding: 18px 18px 48px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #1f8f57;
}
.brand-text {
  font-weight: 600;
  letter-spacing: 0.2px;
}
.topbar-actions { display: inline-flex; gap: 8px; }
.ui-mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}
body.ui-compact .wrap { padding: 12px 12px 28px; }
body.ui-compact h2 { margin: 12px 0 4px 0; font-size: 20px; }
body.ui-compact .card { padding: 9px; border-radius: 12px; }
body.ui-compact nav { padding: 8px 10px; gap: 6px; }
body.ui-compact nav a { padding: 5px 8px; }
body.ui-compact th,
body.ui-compact td { padding: 6px 8px; font-size: 13px; }
body.ui-compact .btn,
body.ui-compact button { padding: 6px 8px; }
body.ui-compact .pill,
body.ui-compact .pill2 { padding: 4px 8px; }
body.ui-compact .muted2 { font-size: 12px; }

.toast-host {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 2200;
  display: grid;
  gap: 8px;
  max-width: min(420px, calc(100vw - 20px));
}
.toast {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 10px 22px rgba(10, 16, 26, 0.18);
  padding: 8px 10px;
  font-size: 13px;
  animation: toast-in .16s ease-out;
}
.toast.info { border-left-color: var(--accent); }
.toast.success { border-left-color: #1f8f57; }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.role-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: #fff;
}
.role-pill.admin {
  color: #166d43;
  border-color: rgba(22, 109, 67, 0.25);
  background: rgba(22, 109, 67, 0.08);
}
.role-pill.moderator {
  color: #8a5c00;
  border-color: rgba(138, 92, 0, 0.25);
  background: rgba(138, 92, 0, 0.10);
}
.global-search {
  position: relative;
  min-width: 340px;
}
#global-search-input {
  width: 100%;
  padding: 8px 10px;
}
.global-search-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 80;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 34px rgba(10, 16, 26, 0.20);
  overflow: hidden;
  max-height: min(58vh, 460px);
  overflow-y: auto;
}
.global-search-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 10px;
  color: var(--ink);
  border-bottom: 1px solid rgba(15, 25, 40, 0.07);
  cursor: pointer;
}
.global-search-item:last-child {
  border-bottom: none;
}
.global-search-item:hover,
.global-search-item.is-active {
  background: rgba(45, 108, 223, 0.08);
}
.global-search-kind {
  flex: 0 0 auto;
  align-self: flex-start;
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
}
.global-search-main {
  min-width: 0;
  flex: 1 1 auto;
}
.global-search-title-link {
  text-decoration: none;
  color: inherit;
}
.global-search-title {
  font-size: 13px;
  color: var(--ink);
}
.global-search-subtitle {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.global-search-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}
.global-search-actions {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.global-search-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 12px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.global-search-act:hover {
  background: rgba(45, 108, 223, 0.08);
  border-color: rgba(45, 108, 223, 0.35);
}
.global-search-act.danger {
  color: var(--danger);
}
.instance-bar { padding:12px 14px; margin:0 0 12px 0; background:#f2f6ff; border:1px solid #c8d7ff; border-radius: 16px; box-shadow: 0 8px 18px rgba(45,108,223,0.08); }
.instance-switch { margin-top:8px; display:flex; gap:8px; flex-wrap:wrap; }
.pill { display:inline-flex; align-items:center; padding:5px 11px; border-radius:999px; border: 1px solid var(--border); background: #fff; color: var(--ink); text-decoration: none; font-size: 13px; }
.pill:hover { background: rgba(45, 108, 223, 0.08); border-color: rgba(45, 108, 223, 0.35); }
.pill.active { background: rgba(45, 108, 223, 0.12); border-color: rgba(45, 108, 223, 0.55); color: var(--accent); font-weight: 600; }
nav { position: sticky; top: 8px; z-index: 25; display:flex; flex-wrap:nowrap; overflow-x:auto; gap:8px; padding: 10px 12px; background: rgba(255,255,255,0.88); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }
nav::-webkit-scrollbar { height: 10px; }
nav::-webkit-scrollbar-thumb { background: rgba(15, 25, 40, 0.18); border-radius: 999px; }
nav a { flex: 0 0 auto; color: var(--ink); text-decoration: none; padding: 6px 10px; border-radius: 10px; }
nav a:hover { background: rgba(45, 108, 223, 0.10); }
nav a.active { background: rgba(45, 108, 223, 0.14); color: var(--accent); font-weight: 600; }
.main-nav .nav-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-right: 10px;
  border-right: 1px solid rgba(14, 25, 42, 0.12);
}
.main-nav .nav-group:last-child {
  border-right: none;
  padding-right: 0;
}
.nav-group-title {
  display: inline-flex;
  align-items: center;
  padding: 4px 7px;
  border-radius: 8px;
  border: 1px solid rgba(14, 25, 42, 0.12);
  background: rgba(15, 25, 40, 0.04);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
body.ui-simple nav a[data-simple="0"] { display: none; }
body.ui-simple nav a.active[data-simple="0"] {
  display: inline-flex;
  border: 1px dashed rgba(45, 108, 223, 0.45);
}
h2 { margin: 16px 0 6px 0; font-size: 24px; letter-spacing: 0.1px; }
table { border-collapse: collapse; margin-top: 12px; width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
th, td { border-bottom: 1px solid var(--border); padding: 9px 11px; vertical-align: top; }
th { text-align: left; font-size: 13px; color: var(--muted); background: rgba(15, 25, 40, 0.03); position: sticky; top: 0; z-index: 1; }
tr:nth-child(even) td { background: rgba(15, 25, 40, 0.012); }
tr:hover td { background: rgba(45, 108, 223, 0.05); }
.error { color: var(--danger); }
.muted { color: var(--muted); }
.hint { display:inline-flex; align-items:center; justify-content:center; width:18px; height:18px; margin-left:6px; border-radius:999px; border: 1px solid var(--border); color: var(--muted); font-size: 12px; line-height: 1; cursor: help; user-select: none; }
.hint:hover { background: rgba(45, 108, 223, 0.10); border-color: rgba(45, 108, 223, 0.4); color: var(--accent); }
.row { display:flex; gap:12px; flex-wrap:wrap; align-items:flex-start; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 12px; }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:7px 10px; border-radius:10px; border:1px solid var(--border); background:#fff; color: var(--ink); text-decoration:none; cursor:pointer; transition: all .14s ease; }
.btn:hover { border-color: rgba(45, 108, 223, 0.4); background: rgba(45, 108, 223, 0.06); }
.btn.danger { color: var(--danger); }
.btn.primary { background: rgba(45,108,223,0.10); border-color: rgba(45,108,223,0.35); }
.btn.mini { padding:6px 8px; font-size:12px; }
.pill2 { display:inline-flex; align-items:center; gap:6px; padding:5px 10px; border-radius:999px; border:1px solid var(--border); background:#fff; color: var(--ink); }
.pill2.active { background: rgba(45, 108, 223, 0.12); border-color: rgba(45, 108, 223, 0.45); color: var(--accent); font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.muted2 { color: var(--muted); font-size: 13px; }
button { cursor: pointer; border-radius: 10px; border: 1px solid var(--border); background: #fff; padding: 7px 10px; transition: all .14s ease; }
button:hover { border-color: rgba(45, 108, 223, 0.4); background: rgba(45,108,223,0.06); }
input, select, textarea { border-radius: 10px; border: 1px solid var(--border); padding: 8px 11px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: rgba(45,108,223,0.55); box-shadow: 0 0 0 3px rgba(45,108,223,0.14); }
details { border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,0.72); padding: 8px 10px; }
details + details { margin-top: 8px; }
summary { cursor: pointer; user-select: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; background: rgba(15,25,40,0.06); border:1px solid rgba(15,25,40,0.12); border-radius: 8px; padding: 1px 5px; }
pre { background: #f4f7fc; border:1px solid var(--border); border-radius: 10px; padding: 10px; overflow: auto; }
ul.flash-list { list-style: none; margin: 10px 0 0 0; padding: 0; display: grid; gap: 8px; }
ul.flash-list li { border: 1px solid var(--border); border-left: 4px solid #6b7a90; border-radius: 10px; background: #fff; padding: 8px 10px; }
ul.flash-list li.info { border-left-color: var(--accent); }
ul.flash-list li.error { border-left-color: var(--danger); color: var(--ink); }
ul.flash-list li.success { border-left-color: #1f8f57; }
a { color: var(--accent); }

.quick-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}
.quick-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 16, 26, 0.35);
  backdrop-filter: blur(2px);
}
.quick-panel {
  position: relative;
  width: min(760px, calc(100vw - 20px));
  margin: 9vh auto 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 28px 50px rgba(10, 16, 26, 0.28);
  overflow: hidden;
}
.quick-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
#quick-open-input {
  flex: 1;
  font-size: 15px;
}
.quick-list {
  max-height: 55vh;
  overflow: auto;
  padding: 8px;
}
.quick-item {
  display: block;
  text-decoration: none;
  color: var(--ink);
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
}
.quick-item:hover,
.quick-item.active {
  background: rgba(45, 108, 223, 0.08);
  border-color: rgba(45, 108, 223, 0.22);
}
.quick-foot {
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 12px;
}
.user-drawer {
  position: fixed;
  inset: 0;
  z-index: 1100;
}
.user-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 16, 26, 0.35);
  backdrop-filter: blur(2px);
}
.user-drawer-panel {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(460px, calc(100vw - 14px));
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(10, 16, 26, 0.22);
  display: flex;
  flex-direction: column;
}
.user-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.user-drawer-body {
  padding: 12px;
  overflow: auto;
}
.user-drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.user-drawer-grid > div {
  background: rgba(15, 25, 40, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}
.user-drawer-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 900px) {
  .wrap { padding: 12px 10px 32px; }
  h2 { font-size: 21px; }
  nav { top: 4px; }
  .main-nav .nav-group { padding-right: 8px; }
  .nav-group-title { font-size: 10px; padding: 3px 6px; }
  .topbar { margin-bottom: 10px; }
  .brand-text { font-size: 14px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .ui-mode-badge { order: 5; }
  .global-search { min-width: 220px; }
}

.dash-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.dash-widget-config {
  margin-top: 12px;
}
.dash-widget-head {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.dash-widget-panel {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.dash-widget-panel label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}
.kpi {
  min-width: 0;
}
.kpi-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.dash-block {
  flex: 1;
  min-width: 320px;
}
.dash-title {
  margin: 0 0 8px 0;
}
.dash-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 4px;
}
.dash-lines p,
.dash-block p {
  margin: 6px 0;
}
.dash-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
#dash-quick-action-result {
  min-height: 18px;
  margin-bottom: 8px;
}
.inline-form {
  display: inline-block;
  margin-right: 8px;
}
.dash-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}
.compact-table {
  margin-top: 8px;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 25, 40, 0.04);
  font-size: 12px;
  font-weight: 600;
}
.badge.ok {
  color: #166d43;
  border-color: rgba(22, 109, 67, 0.25);
  background: rgba(22, 109, 67, 0.1);
}
.badge.warn {
  color: #8a5c00;
  border-color: rgba(138, 92, 0, 0.25);
  background: rgba(138, 92, 0, 0.1);
}
.mod-layout {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(560px, 1.55fr) minmax(320px, 1fr);
  gap: 12px;
  align-items: start;
}
.mod-list {
  min-width: 0;
}
.mod-table {
  margin-top: 0;
}
.js-mod-row {
  cursor: pointer;
}
.js-mod-row.is-selected td {
  background: rgba(45, 108, 223, 0.11) !important;
}
.mod-side {
  position: sticky;
  top: 86px;
}
.mod-side-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.mod-meta-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mod-meta-grid > div {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(15, 25, 40, 0.03);
  padding: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.mod-reason-block {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(15, 25, 40, 0.03);
  padding: 8px;
}
.mod-side-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mod-empty {
  min-height: 120px;
  display: flex;
  align-items: center;
}
[data-live-root-page].is-loading {
  opacity: 0.62;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
@media (max-width: 1200px) {
  .dash-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mod-layout {
    grid-template-columns: 1fr;
  }
  .mod-side {
    position: static;
  }
}
@media (max-width: 680px) {
  .dash-kpis {
    grid-template-columns: 1fr;
  }
  .mod-meta-grid {
    grid-template-columns: 1fr;
  }
}
