:root {
  --navy-950: #071b3d;
  --navy-900: #0c2d60;
  --navy-800: #153b73;
  --navy-700: #1b4d91;
  --blue: #2d7ef7;
  --blue-soft: #eaf2ff;
  --red: #e31e24;
  --red-soft: #fff0f1;
  --green: #198754;
  --green-soft: #eaf8f0;
  --amber: #b56a00;
  --amber-soft: #fff5df;
  --ink: #10213f;
  --muted: #6f7d94;
  --muted-soft: #94a0b2;
  --canvas: #f5f7fb;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --line: #e5eaf2;
  --line-strong: #d8e0ec;
  --shadow-sm: 0 4px 12px rgba(12, 45, 96, 0.06);
  --shadow: 0 16px 36px rgba(12, 45, 96, 0.10);
  --shadow-lg: 0 24px 64px rgba(7, 27, 61, 0.24);
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-height: 100%;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button { -webkit-tap-highlight-color: transparent; }
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.table-scroll:focus-visible { outline: 3px solid rgba(45, 126, 247, 0.26); outline-offset: 2px; }

#authGate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  color: var(--muted);
  background:
    radial-gradient(circle at 8% 6%, rgba(45, 126, 247, 0.10), transparent 34rem),
    var(--canvas);
}

.auth-gate-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  color: var(--navy-800);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  font-weight: 700;
}

.loading-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 6px rgba(45, 126, 247, 0.12);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% { transform: scale(0.72); opacity: 0.5; }
}

#adminApp { display: none; min-height: 100dvh; }
#adminApp.ready {
  display: grid;
  grid-template-columns: 278px minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  min-width: 230px;
  max-width: 560px;
  flex-direction: column;
  overflow: hidden;
  color: #f7faff;
  background:
    radial-gradient(circle at 2% 0%, rgba(45, 126, 247, 0.34), transparent 25rem),
    linear-gradient(160deg, var(--navy-950) 0%, var(--navy-900) 54%, #133f7d 130%);
  border-right: 1px solid rgba(255, 255, 255, 0.10);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 23px 18px 17px;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #397ff0, #1b5fcd);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 14px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.20);
}

.brand-mark svg { width: 23px; height: 23px; }
.brand-copy { min-width: 0; }
.brand-copy strong {
  display: block;
  color: #fff;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand-copy span {
  display: block;
  margin-top: 2px;
  color: rgba(235, 243, 255, 0.66);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.icon-button:hover { background: rgba(255, 255, 255, 0.10); border-color: rgba(255, 255, 255, 0.16); }
.icon-button:active { transform: scale(0.94); }
.icon-button svg { width: 19px; height: 19px; }
.sidebar-close { display: none; }

.account-card {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  margin: 0 14px 18px;
  padding: 11px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 15px;
}

.account-avatar {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  place-items: center;
  color: #fff;
  background: rgba(45, 126, 247, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
}
.account-avatar svg { width: 17px; height: 17px; }
.account-copy { min-width: 0; flex: 1; }
.account-copy strong { display: block; color: #fff; font-size: 11px; font-weight: 750; }
.account-copy span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: rgba(235, 243, 255, 0.68);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sign-out {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  padding: 0;
  color: rgba(255, 255, 255, 0.84);
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
}
.sign-out:hover { color: #fff; background: rgba(227, 30, 36, 0.86); }
.sign-out svg { width: 16px; height: 16px; }

.tabs {
  display: grid;
  gap: 4px;
  padding: 0 12px;
}
.tabs button {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  color: rgba(235, 243, 255, 0.71);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.tabs button:hover { color: #fff; background: rgba(255, 255, 255, 0.075); }
.tabs button.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(45, 126, 247, 0.42), rgba(45, 126, 247, 0.16));
  border-color: rgba(125, 181, 255, 0.36);
  box-shadow: inset 3px 0 0 var(--red), 0 6px 18px rgba(0, 0, 0, 0.10);
}
.tabs button:active { transform: translateX(1px); }
.tab-icon { display: inline-grid; width: 20px; height: 20px; flex: 0 0 20px; place-items: center; }
.tab-icon svg { width: 18px; height: 18px; stroke-width: 1.9; }
.tabs button.active .tab-icon { color: #afceff; }

.workspace-nav {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  margin-top: 19px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
}
.workspace-heading {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 16px 20px 10px;
  color: rgba(235, 243, 255, 0.58);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.workspace-heading::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(227, 30, 36, 0.13);
  content: "";
}
.side-panel { min-height: 0; flex: 1; overflow: auto; padding: 0 12px 18px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.26) transparent; }
.side-panel::-webkit-scrollbar { width: 5px; }
.side-panel::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.26); border-radius: 10px; }
.side-panel .empty-state { min-height: 132px; padding: 18px 12px; color: rgba(235, 243, 255, 0.65); background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.15); font-size: 11.5px; }
.side-panel-notice { margin: 4px 2px; padding: 15px 13px; color: rgba(235, 243, 255, 0.71); background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; line-height: 1.55; }
.side-panel-notice strong { display: block; margin-bottom: 6px; color: #fff; font-size: 12px; }
.side-panel-notice p { margin: 0; font-size: 11px; }

.cat-block { margin-bottom: 8px; }
.cat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 9px 7px;
  color: rgba(172, 207, 255, 0.88);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}
.cat-title::after { height: 1px; flex: 1; background: rgba(255, 255, 255, 0.12); content: ""; }

.tree-node {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 4px;
  margin: 2px 0;
  padding: 8px 9px;
  color: rgba(235, 243, 255, 0.69);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12.5px;
  line-height: 1.25;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.tree-node:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.tree-node.active { color: #fff; background: rgba(45, 126, 247, 0.24); border-color: rgba(125, 181, 255, 0.24); }
.tree-node .node-title { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-node .qcount {
  flex: 0 0 auto;
  padding: 2px 6px;
  color: rgba(235, 243, 255, 0.66);
  background: rgba(255, 255, 255, 0.10);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 750;
}
.tree-node.active .qcount { color: #fff; background: rgba(45, 126, 247, 0.54); }
.toggle-icon,
.toggle-spacer { display: inline-grid; width: 17px; height: 17px; flex: 0 0 17px; place-items: center; }
.toggle-icon { color: rgba(235, 243, 255, 0.55); border-radius: 5px; font-size: 8px; transition: transform 0.2s ease, background 0.16s ease; }
.toggle-icon:hover { color: #fff; background: rgba(255, 255, 255, 0.10); }
.tree-node-wrapper.collapsed > .tree-children { display: none; }
.tree-node-wrapper.collapsed > .tree-node > .toggle-icon { transform: rotate(-90deg); }
.tree-node.depth-0 { padding-left: 8px; }
.tree-node.depth-1 { padding-left: 22px; }
.tree-node.depth-2 { padding-left: 36px; }
.tree-node.depth-3 { padding-left: 50px; }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 14px;
  padding: 12px 10px;
  color: rgba(235, 243, 255, 0.56);
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  font-size: 10.5px;
  font-weight: 600;
}
.sidebar-footer svg { width: 15px; height: 15px; color: #81b2ff; }

.sidebar-resize-handle { position: absolute; z-index: 35; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; }
.sidebar-resize-handle::after { position: absolute; top: 0; right: 3px; width: 2px; height: 100%; background: transparent; content: ""; transition: background 0.18s ease; }
.sidebar-resize-handle:hover::after,
.sidebar-resize-handle.dragging::after { background: var(--blue); }
body.sidebar-resizing,
body.sidebar-resizing * { cursor: col-resize !important; user-select: none; }

.sidebar-backdrop { display: none; }

/* Main workspace */
.main { display: flex; min-width: 0; min-height: 0; flex-direction: column; background: var(--canvas); }
.mobile-header { display: none; }
.main-header {
  position: relative;
  z-index: 5;
  display: flex;
  min-height: 102px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 21px clamp(22px, 3vw, 40px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(12, 45, 96, 0.025);
}
.main-heading { min-width: 0; }
.eyebrow { display: block; margin-bottom: 5px; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: 0.105em; text-transform: uppercase; }
.main-header h2 { margin: 0; color: var(--navy-950); font-size: clamp(20px, 2.2vw, 26px); font-weight: 760; letter-spacing: -0.035em; line-height: 1.15; }
.main-header .sub { min-height: 16px; margin-top: 5px; color: var(--muted); font-size: 12px; font-weight: 550; }
#mainActions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  color: #fff;
  background: var(--navy-800);
  border: 1px solid var(--navy-800);
  border-radius: 11px;
  box-shadow: 0 6px 14px rgba(21, 59, 115, 0.14);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 750;
  line-height: 1.1;
  text-align: center;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--navy-700); border-color: var(--navy-700); box-shadow: 0 9px 18px rgba(21, 59, 115, 0.18); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); box-shadow: none; }
.btn.secondary { color: var(--navy-800); background: var(--surface); border-color: var(--line-strong); box-shadow: none; }
.btn.secondary:hover:not(:disabled) { color: var(--navy-900); background: var(--blue-soft); border-color: #cfe0ff; box-shadow: none; }
.btn.danger { color: #fff; background: var(--red); border-color: var(--red); box-shadow: 0 6px 14px rgba(227, 30, 36, 0.14); }
.btn.danger:hover:not(:disabled) { background: #c9181d; border-color: #c9181d; }
.btn.small { min-height: 33px; padding: 7px 10px; border-radius: 9px; font-size: 11.5px; }
.btn:disabled { cursor: not-allowed; opacity: 0.48; box-shadow: none; }

.id-search-input {
  width: 210px;
  min-height: 40px;
  padding: 8px 12px;
  color: var(--ink);
  background: #fbfcff;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  font-size: 12.5px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.id-search-input::placeholder { color: var(--muted-soft); }
.id-search-input:focus { background: #fff; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(45, 126, 247, 0.12); outline: none; }

.content { min-width: 0; flex: 1; overflow: auto; padding: clamp(20px, 3vw, 34px) clamp(18px, 3vw, 40px) 44px; }
.empty-state {
  display: grid;
  min-height: 230px;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.66);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  font-weight: 560;
  line-height: 1.6;
  text-align: center;
}

/* Tables */
.table-scroll { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch; }
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: #cbd6e6; border-radius: 999px; }
table.q-table { width: 100%; min-width: 720px; border-collapse: separate; border-spacing: 0; background: var(--surface); }
table.q-table th {
  padding: 13px 16px;
  color: #63718a;
  background: #f8faff;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
table.q-table td { padding: 15px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.q-table tr:last-child td { border-bottom: 0; }
table.q-table tbody tr { transition: background 0.15s ease; }
table.q-table tbody tr:hover td { background: #fbfdff; }
table.q-table tr.selected td { background: var(--blue-soft); }
table.q-table td.q-check,
table.q-table th.q-check { width: 42px; padding-right: 0; padding-left: 14px; text-align: center; }
table.q-table input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.q-prompt { max-width: 470px; color: var(--navy-950); font-size: 13px; font-weight: 600; line-height: 1.55; }
.q-options { min-width: 210px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.q-options .correct { color: var(--green); font-weight: 750; }
.row-actions { min-width: 126px; white-space: nowrap; }
.row-actions button { padding: 5px 7px; color: var(--navy-800); background: transparent; border: 0; border-radius: 7px; cursor: pointer; font-size: 11.5px; font-weight: 750; }
.row-actions button:hover { color: var(--blue); background: var(--blue-soft); }
.row-actions button.del { color: var(--red); }
.row-actions button.del:hover { color: #c9181d; background: var(--red-soft); }
.badge { display: inline-flex; min-height: 23px; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; line-height: 1; white-space: nowrap; }
.badge.yes { color: var(--green); background: var(--green-soft); }
.badge.no { color: #62718a; background: #eff3f8; }

/* Bulk operations */
.bulk-bar { display: flex; align-items: center; gap: 10px 14px; margin-bottom: 16px; padding: 12px 14px; color: #fff; background: linear-gradient(110deg, var(--navy-900), var(--navy-800)); border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-md); box-shadow: var(--shadow); flex-wrap: wrap; }
.bulk-bar .bulk-count { color: rgba(255,255,255,0.74); font-size: 12px; font-weight: 700; }
.bulk-bar .bulk-sep { width: 1px; height: 18px; background: rgba(255,255,255,0.18); }
.bulk-bar-actions { display: flex; align-items: center; gap: 7px; margin-left: auto; flex-wrap: wrap; }
.bulk-bar button { min-height: 32px; padding: 6px 10px; color: #fff; background: rgba(255,255,255,0.09); border: 1px solid rgba(255,255,255,0.15); border-radius: 9px; cursor: pointer; font-size: 11.5px; font-weight: 750; }
.bulk-bar button:hover:not(:disabled) { background: rgba(255,255,255,0.17); }
.bulk-bar button.brass { color: var(--navy-950); background: #fff; border-color: #fff; }
.bulk-bar button.danger { background: var(--red); border-color: var(--red); }
.bulk-bar button:disabled { cursor: not-allowed; opacity: 0.48; }
.bulk-bar label.select-all { display: inline-flex; align-items: center; gap: 7px; color: rgba(255,255,255,0.82); cursor: pointer; font-size: 12px; font-weight: 650; }
.bulk-bar input[type="checkbox"] { accent-color: var(--blue); }

/* Modals and forms */
.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: none; align-items: center; justify-content: center; padding: 22px; background: rgba(7, 27, 61, 0.58); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal-backdrop.open { display: flex; }
.modal { position: relative; width: 590px; max-width: 100%; max-height: calc(100dvh - 44px); overflow: auto; padding: 26px 28px 28px; background: #fff; border: 1px solid rgba(255,255,255,0.55); border-radius: 22px; box-shadow: var(--shadow-lg); }
.modal h3 { margin: 0 38px 22px 0; color: var(--navy-950); font-size: 20px; font-weight: 760; letter-spacing: -0.025em; }
.modal-close { position: absolute; top: 18px; right: 18px; display: grid; width: 34px; height: 34px; place-items: center; padding: 0; color: var(--muted); background: #f3f6fa; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.modal-close:hover { color: var(--navy-800); background: var(--blue-soft); border-color: #d4e5ff; }
.modal-close svg { width: 17px; height: 17px; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 7px; color: #52617a; font-size: 10.5px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.field textarea,
.field input[type="text"],
.field input[type="number"],
.field input[type="file"],
.field input[type="email"],
.field input[type="password"],
.field select {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fbfcff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input[type="file"] { padding: 9px; }
.field input:focus,
.field textarea:focus,
.field select:focus { background: #fff; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(45, 126, 247, 0.12); outline: none; }
.field-row { display: flex; gap: 12px; }
.field-row .field { min-width: 0; flex: 1; }
.field-check { display: flex; align-items: center; gap: 8px; padding: 10px 11px; background: #f8faff; border: 1px solid var(--line); border-radius: 10px; }
.field-check label { margin: 0; font-size: 12px; letter-spacing: 0; text-transform: none; }
.field-check input,
.kadro-check-group input { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.option-row { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.option-row input[type="radio"] { width: 16px; height: 16px; flex: 0 0 auto; accent-color: var(--blue); cursor: pointer; }
.option-row input[type="text"] { min-width: 0; flex: 1; }
.option-row .opt-remove { display: grid; width: 32px; height: 32px; flex: 0 0 32px; place-items: center; padding: 0; color: var(--muted); background: #fff; border: 1px solid var(--line-strong); border-radius: 9px; cursor: pointer; font-size: 15px; }
.option-row .opt-remove:hover:not(:disabled) { color: #fff; background: var(--red); border-color: var(--red); }
.option-row .opt-remove:disabled { cursor: not-allowed; opacity: 0.4; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin-top: 23px; padding-top: 18px; border-top: 1px solid var(--line); }
.modal-actions.split { justify-content: space-between; }
.form-error { display: none; margin-top: 10px; padding: 10px 12px; color: #bf1f25; background: var(--red-soft); border: 1px solid #ffd2d4; border-radius: 10px; font-size: 12px; font-weight: 600; line-height: 1.45; }
.form-error.show { display: block; }
.form-hint { margin-top: 6px; color: var(--muted); font-size: 11.5px; line-height: 1.55; }
.form-hint a { color: var(--blue); font-weight: 750; text-decoration: none; }
.form-hint a:hover { text-decoration: underline; }
details { padding: 11px 12px; background: #f8faff; border: 1px solid var(--line); border-radius: 11px; }
details > summary { color: var(--navy-800); cursor: pointer; font-size: 12px; font-weight: 750; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 12px; }
.kadro-check-group { display: flex; gap: 8px 14px; flex-wrap: wrap; padding: 2px 0; }
.kadro-check-group label { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); cursor: pointer; font-size: 12px; font-weight: 600; text-transform: none; }

/* Topic management */
.breadcrumb { display: flex; align-items: center; gap: 4px; min-width: 0; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.breadcrumb a { color: var(--navy-800); cursor: pointer; font-weight: 750; text-decoration: none; }
.breadcrumb a:hover { color: var(--blue); text-decoration: underline; }
.manage-list { display: grid; gap: 9px; }
.manage-row { display: flex; min-height: 92px; flex-direction: column; gap: 7px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 3px 9px rgba(12, 45, 96, 0.035); cursor: pointer; transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease; }
.manage-row:hover { border-color: #bfd7ff; box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.mr-title { color: var(--navy-950); font-size: 14px; font-weight: 750; }
.mr-meta { color: var(--muted); font-size: 11.5px; font-weight: 550; }
.mr-actions { display: flex; gap: 4px; margin-top: 1px; }
.mr-actions button { padding: 5px 7px; color: var(--navy-800); background: transparent; border: 0; border-radius: 7px; cursor: pointer; font-size: 11.5px; font-weight: 750; }
.mr-actions button:hover { color: var(--blue); background: var(--blue-soft); }
.mr-actions button.del { color: var(--red); }
.mr-actions button.del:hover { background: var(--red-soft); }
.type-badge { display: inline-flex; align-items: center; margin-right: 6px; padding: 3px 6px; color: var(--blue); background: var(--blue-soft); border: 1px solid #d5e6ff; border-radius: 6px; font-size: 9px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: middle; }

/* Toast */
.admin-toast { position: fixed; z-index: 500; left: 50%; bottom: 24px; max-width: min(440px, calc(100vw - 32px)); padding: 12px 16px; color: #fff; background: var(--navy-950); border: 1px solid rgba(255,255,255,0.16); border-radius: 13px; box-shadow: var(--shadow-lg); font-size: 12.5px; font-weight: 650; line-height: 1.45; opacity: 0; pointer-events: none; transform: translate(-50%, 18px); transition: opacity 0.2s ease, transform 0.2s ease; white-space: pre-line; }
.admin-toast.show { opacity: 1; transform: translate(-50%, 0); }
.admin-toast.error { background: #991c24; }

/* Login */
body.login-page { display: grid; min-height: 100dvh; place-items: center; padding: 24px; overflow: auto; background: radial-gradient(circle at 9% 7%, rgba(45, 126, 247, 0.21), transparent 34rem), linear-gradient(145deg, #071b3d, #0e396f); }
.login-shell { display: grid; width: min(100%, 960px); grid-template-columns: minmax(0, 1.07fr) minmax(360px, 0.93fr); overflow: hidden; background: #fff; border: 1px solid rgba(255,255,255,0.28); border-radius: 26px; box-shadow: 0 30px 90px rgba(0,0,0,0.32); }
.login-intro { position: relative; min-height: 570px; overflow: hidden; padding: 48px; color: #fff; background: linear-gradient(150deg, var(--navy-950), var(--navy-800)); }
.login-intro::after { position: absolute; right: -88px; bottom: -104px; width: 330px; height: 330px; background: radial-gradient(circle, rgba(45, 126, 247, 0.78) 0 2px, transparent 3px) 0 0/22px 22px; border: 1px solid rgba(255,255,255,0.15); border-radius: 50%; content: ""; opacity: 0.46; }
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 11px; }
.login-brand .brand-mark { width: 43px; height: 43px; flex-basis: 43px; }
.login-brand strong { display: block; font-size: 17px; }
.login-brand span { display: block; margin-top: 3px; color: rgba(235,243,255,0.65); font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.login-intro-copy { position: relative; z-index: 1; max-width: 360px; margin-top: 125px; }
.login-intro-copy p { margin: 0 0 12px; color: #9ec5ff; font-size: 11px; font-weight: 800; letter-spacing: 0.105em; text-transform: uppercase; }
.login-intro-copy h1 { margin: 0; color: #fff; font-size: 34px; font-weight: 760; letter-spacing: -0.045em; line-height: 1.13; }
.login-intro-copy span { display: block; margin-top: 15px; color: rgba(235,243,255,0.73); font-size: 13px; line-height: 1.7; }
.login-card { display: flex; min-width: 0; flex-direction: column; justify-content: center; padding: 52px 44px; background: #fff; }
.login-card .mobile-login-brand { display: none; }
.login-card h2 { margin: 0 0 6px; color: var(--navy-950); font-size: 25px; font-weight: 760; letter-spacing: -0.035em; }
.login-card .sub { margin: 0 0 30px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.login-card label { display: block; margin-bottom: 7px; color: #52617a; font-size: 10.5px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.login-card input { width: 100%; min-height: 45px; margin-bottom: 17px; padding: 10px 12px; color: var(--ink); background: #fbfcff; border: 1px solid var(--line-strong); border-radius: 11px; font-size: 13px; }
.login-card input:focus { background: #fff; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(45,126,247,0.12); outline: none; }
.login-card .primary-login { width: 100%; min-height: 46px; margin-top: 2px; color: #fff; background: var(--navy-800); border: 1px solid var(--navy-800); border-radius: 11px; cursor: pointer; font-size: 13px; font-weight: 750; }
.login-card .primary-login:hover:not(:disabled) { background: var(--navy-700); }
.login-card button:disabled { cursor: not-allowed; opacity: 0.58; }
.login-card .error { min-height: 18px; margin: -7px 0 13px; color: var(--red); font-size: 12px; font-weight: 600; }
.login-card .divider { display: flex; align-items: center; gap: 11px; margin: 22px 0; color: var(--muted-soft); font-size: 11px; font-weight: 600; }
.login-card .divider::before,
.login-card .divider::after { height: 1px; flex: 1; background: var(--line); content: ""; }
.login-card .google-btn { display: inline-flex; width: 100%; min-height: 44px; align-items: center; justify-content: center; gap: 10px; color: var(--navy-800); background: #fff; border: 1px solid var(--line-strong); border-radius: 11px; cursor: pointer; font-size: 12.5px; font-weight: 750; }
.login-card .google-btn:hover { background: #f8faff; border-color: #c5d9f7; }
.login-card .google-btn svg { width: 18px; height: 18px; }

@media (max-width: 980px) {
  #adminApp.ready { grid-template-columns: 250px minmax(0, 1fr); }
  .main-header { padding-right: 24px; padding-left: 24px; }
  .content { padding-right: 24px; padding-left: 24px; }
  .tabs button { padding-right: 10px; padding-left: 10px; }
}

@media (max-width: 760px) {
  body.sidebar-open { overflow: hidden; }
  #adminApp.ready { display: block; height: 100dvh; overflow: hidden; }
  .sidebar {
    position: fixed;
    z-index: 80;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 320px) !important;
    min-width: 0;
    max-width: none;
    height: 100dvh;
    box-shadow: 18px 0 46px rgba(7, 27, 61, 0.28);
    transform: translateX(-104%);
    transition: transform 0.24s cubic-bezier(0.22, 0.75, 0.25, 1);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-close { display: inline-grid; }
  .sidebar-resize-handle { display: none; }
  .sidebar-backdrop { position: fixed; z-index: 70; inset: 0; display: block; visibility: hidden; background: rgba(7, 27, 61, 0.46); opacity: 0; pointer-events: none; transition: opacity 0.22s ease, visibility 0.22s ease; }
  body.sidebar-open .sidebar-backdrop { visibility: visible; opacity: 1; pointer-events: auto; }
  .main { height: 100dvh; }
  .mobile-header { display: flex; min-height: 60px; align-items: center; justify-content: space-between; padding: 10px 15px; color: var(--navy-950); background: #fff; border-bottom: 1px solid var(--line); }
  .mobile-brand { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 760; letter-spacing: -0.02em; }
  .mobile-brand .brand-mark { width: 31px; height: 31px; flex-basis: 31px; border-radius: 10px; }
  .mobile-brand .brand-mark svg { width: 18px; height: 18px; }
  .mobile-header .icon-button { color: var(--navy-800); border-color: var(--line); }
  .mobile-header .icon-button:hover { background: var(--blue-soft); border-color: #cfe0ff; }
  .main-header { min-height: auto; align-items: flex-start; padding: 17px 16px 16px; gap: 14px; flex-direction: column; }
  .main-header h2 { font-size: 21px; }
  .main-header .sub { font-size: 11.5px; }
  #mainActions { width: 100%; justify-content: flex-start; gap: 7px; }
  #mainActions .id-search-input { min-width: 0; flex: 1 1 170px; }
  #mainActions .btn { min-height: 38px; padding-right: 11px; padding-left: 11px; }
  .content { padding: 16px 14px 28px; }
  .empty-state { min-height: 200px; padding: 24px 18px; font-size: 12.5px; }
  .table-scroll { border-radius: 14px; }
  table.q-table { min-width: 650px; }
  table.q-table th { padding: 12px; }
  table.q-table td { padding: 13px 12px; }
  .bulk-bar { align-items: flex-start; padding: 11px; }
  .bulk-bar-actions { width: 100%; margin-left: 0; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { width: 100% !important; max-height: min(90dvh, 780px); padding: 24px 17px max(22px, env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; }
  .modal h3 { margin-bottom: 19px; font-size: 18px; }
  .modal-close { top: 14px; right: 14px; }
  .field-row { gap: 0; flex-direction: column; }
  .field-row .field { width: 100%; }
  .modal-actions { gap: 8px; flex-wrap: wrap; }
  .modal-actions.split { align-items: flex-start; flex-direction: column; }
  .modal-actions.split > div { display: flex !important; width: 100%; gap: 8px !important; }
  .modal-actions .btn { flex: 1; }
  .kadro-check-group { gap: 9px 13px; }
  .manage-row { min-height: 0; padding: 14px; }
  .admin-toast { bottom: max(18px, env(safe-area-inset-bottom)); font-size: 12px; }
  .login-page { padding: 0; }
  .login-shell { min-height: 100dvh; grid-template-columns: 1fr; border: 0; border-radius: 0; }
  .login-intro { display: none; }
  .login-card { padding: 34px 24px; }
  .login-card .mobile-login-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 52px; color: var(--navy-950); font-size: 15px; font-weight: 760; }
  .login-card .mobile-login-brand .brand-mark { width: 37px; height: 37px; flex-basis: 37px; border-radius: 12px; }
  .login-card .mobile-login-brand .brand-mark svg { width: 21px; height: 21px; }
}

@media (max-width: 390px) {
  #mainActions .btn { font-size: 11.5px; }
  .modal-actions .btn { min-width: calc(50% - 4px); }
  .login-card { padding-right: 20px; padding-left: 20px; }
}

@media (max-width: 600px) {
  .table-scroll { overflow: visible; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
  table.q-table { display: block; min-width: 0; background: transparent; }
  table.q-table thead { display: none; }
  table.q-table tbody { display: grid; gap: 10px; }
  table.q-table tr { display: block; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 3px 9px rgba(12, 45, 96, 0.035); }
  table.q-table tr.selected { border-color: #b9d5ff; }
  table.q-table td,
  table.q-table td.q-check { display: flex; width: 100%; min-width: 0; align-items: flex-start; gap: 11px; padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; }
  table.q-table tr:last-child td:last-child { border-bottom: 0; }
  table.q-table td::before { width: 78px; flex: 0 0 78px; padding-top: 1px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 0.055em; line-height: 1.35; text-align: left; text-transform: uppercase; content: attr(data-label); }
  table.q-table td.q-check::before { padding-top: 2px; }
  table.q-table .q-prompt { max-width: none; font-size: 12.5px; }
  table.q-table .q-options { min-width: 0; font-size: 11.5px; }
  table.q-table .row-actions { min-width: 0; align-items: center; flex-wrap: wrap; }
  table.q-table .row-actions button { padding: 6px 8px; background: #f7faff; border: 1px solid var(--line); }
  table.q-table .row-actions button.del { background: var(--red-soft); border-color: #ffd9dc; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
