:root {
  --bg: #f4f6fa; --panel: #ffffff; --border: #dde3ec; --text: #1a2333; --muted: #64748b;
  --accent: #2563eb; --accent-soft: #eff4ff; --accent-hover: #1d4fd8; --accent-deep: #101a2e;
  --danger: #dc2626; --ok: #16a34a; --warn: #d97706;
  --radius: 10px; --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}
* { box-sizing: border-box; }
body { margin:0; font-family:"Segoe UI", system-ui, -apple-system, sans-serif; background:var(--bg); color:var(--text); font-size:14px; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size:20px; margin:0 0 4px; } h2 { font-size:16px; margin:0; } h3 { font-size:14px; margin:0 0 6px; }
.loading-screen { display:flex; align-items:center; justify-content:center; height:100vh; color:var(--muted); }

/* buttons & inputs (shared with the other RA tools) */
button, .btn { font:inherit; border:1px solid var(--border); background:#fff; color:var(--text); padding:7px 13px; border-radius:8px; cursor:pointer; }
button:hover { border-color:#b8c4d6; }
button.primary { background:var(--accent); border-color:var(--accent); color:#fff; font-weight:600; }
button.primary:hover { background:var(--accent-hover); }
button.danger { color:var(--danger); border-color:#f3c1c1; }
button.small, .btn.small { padding:4px 9px; font-size:12.5px; border-radius:6px; }
button.ghost { border-color:transparent; background:transparent; color:var(--accent); }
button:disabled { opacity:.5; cursor:not-allowed; }
input, select, textarea { font:inherit; padding:7px 10px; border:1px solid var(--border); border-radius:8px; background:#fff; color:var(--text); width:100%; }
input:focus, select:focus, textarea:focus { outline:2px solid #bcd0f7; border-color:var(--accent); }
textarea { min-height:64px; resize:vertical; }
label.f { display:block; margin-bottom:11px; }
label.f > span { display:block; font-size:12px; font-weight:600; color:var(--muted); margin-bottom:4px; }
.row-flex { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

/* ---- gate (setup / login) ---- */
.gate { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px;
  background:radial-gradient(1100px 520px at 50% -10%, #1e3a6b 0%, transparent 60%), var(--accent-deep); }
.gate-card { background:#fff; border-radius:14px; box-shadow:0 20px 60px rgba(8,15,30,.35); padding:26px; width:100%; max-width:380px; }
.gate-card .logo { font-size:34px; line-height:1; margin-bottom:10px; }
.gate-card p.sub { color:var(--muted); font-size:13px; margin:0 0 18px; }
.gate-card .err { color:var(--danger); font-size:12.5px; min-height:17px; margin:6px 0 0; }

/* ---- shell ---- */
.topbar { background:var(--accent-deep); color:#fff; padding:14px 22px; display:flex; align-items:center; gap:14px; flex-wrap:wrap; position:sticky; top:0; z-index:40; }
.topbar .brand { display:flex; align-items:center; gap:10px; font-weight:700; font-size:16px; letter-spacing:.2px; }
.topbar .brand .mark { font-size:20px; }
.topbar .grow { flex:1; }
.topbar .search { max-width:280px; }
.topbar .search input { background:#1b2a47; border-color:#2c3f63; color:#fff; }
.topbar .search input::placeholder { color:#8fa0bd; }
.topbar button { background:#1b2a47; border-color:#2c3f63; color:#dbe4f3; }
.topbar button:hover { background:#25375c; border-color:#3d537f; }
.topbar button.primary { background:var(--accent); border-color:var(--accent); color:#fff; }
.topbar button.on { background:var(--accent); border-color:var(--accent); color:#fff; }
.main { padding:20px 22px 80px; max-width:1400px; margin:0 auto; }

.hint { background:#eef4ff; border:1px solid #d5e3fb; color:#1e3a6b; border-radius:8px; padding:8px 12px; font-size:12.5px; margin-bottom:14px; display:flex; gap:8px; align-items:center; }

/* ---- sections ---- */
.section { background:var(--panel); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); margin-bottom:14px; }
.section.drag-ghost { opacity:.4; }
.section-head { display:flex; align-items:center; gap:9px; padding:11px 14px; border-bottom:1px solid #eef1f6; }
.section-head .count { font-size:11px; color:var(--muted); background:#eef1f6; border-radius:99px; padding:1px 8px; font-weight:600; }
.section-head .grow { flex:1; }
.section-head .acts { display:flex; gap:5px; opacity:0; transition:opacity .12s; }
.section:hover .section-head .acts, .editing .section-head .acts { opacity:1; }
.handle { cursor:grab; color:#b6c0d0; font-size:15px; line-height:1; padding:2px 3px; user-select:none; display:none; }
.editing .handle { display:inline-block; }
.handle:active { cursor:grabbing; }
.section-body { padding:14px; min-height:56px; }
.section-body.grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); gap:11px; }
.section-body.list { display:flex; flex-direction:column; gap:7px; }
.section-body.dropping { background:var(--accent-soft); border-radius:8px; }
.empty-slot { color:var(--muted); font-size:12.5px; padding:10px 2px; grid-column:1 / -1; }

/* ---- tiles ---- */
.tile { position:relative; display:flex; gap:11px; align-items:flex-start; padding:12px; border:1px solid var(--border); border-radius:9px; background:#fff; text-decoration:none; color:inherit; transition:box-shadow .12s, transform .12s, border-color .12s; }
.tile:hover { border-color:#b8c4d6; box-shadow:0 4px 14px rgba(16,24,40,.10); transform:translateY(-1px); }
.tile.drag-ghost { opacity:.35; }
.tile .ico { width:34px; height:34px; flex:0 0 34px; border-radius:9px; display:flex; align-items:center; justify-content:center; font-size:18px; color:#fff; }
.tile .body { min-width:0; flex:1; }
.tile .t { font-weight:600; font-size:13.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tile .s { color:var(--muted); font-size:11.5px; margin-top:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tile .acts { position:absolute; top:6px; right:6px; display:none; gap:3px; background:#fff; border-radius:7px; padding:2px; box-shadow:var(--shadow); }
.editing .tile:hover .acts { display:flex; }
.tile .acts button { padding:2px 6px; font-size:11.5px; border-radius:5px; line-height:1.5; }
.section-body.list .tile { align-items:center; padding:9px 12px; }
.section-body.list .tile .ico { width:28px; height:28px; flex-basis:28px; font-size:15px; border-radius:7px; }
.section-body.list .tile .s { white-space:normal; }
.tile.hidden { display:none; }

/* ---- modal ---- */
.modal-back { position:fixed; inset:0; background:rgba(15,23,42,.45); display:flex; align-items:center; justify-content:center; z-index:200; padding:18px; }
.modal { background:#fff; border-radius:12px; box-shadow:0 20px 60px rgba(8,15,30,.3); width:100%; max-width:430px; max-height:90vh; overflow:auto; }
.modal .mh { padding:14px 18px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:10px; }
.modal .mh .grow { flex:1; }
.modal .mb { padding:18px; }
.modal .mf { padding:12px 18px; border-top:1px solid var(--border); display:flex; gap:9px; justify-content:flex-end; }
.icon-picks { display:flex; flex-wrap:wrap; gap:5px; margin-top:6px; }
.icon-picks button { padding:3px 7px; font-size:15px; line-height:1.4; }
.color-picks { display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
.swatch { width:24px; height:24px; border-radius:7px; border:2px solid transparent; cursor:pointer; padding:0; }
.swatch.on { border-color:#1a2333; }
.drop-zone { border:2px dashed var(--border); border-radius:10px; padding:22px; text-align:center; color:var(--muted); font-size:13px; cursor:pointer; }
.drop-zone.drag { border-color:var(--accent); background:var(--accent-soft); color:var(--accent); }

/* ---- toast ---- */
#toast-root { position:fixed; bottom:18px; left:50%; transform:translateX(-50%); z-index:400; display:flex; flex-direction:column; gap:7px; align-items:center; }
.toast { background:#1e293b; color:#fff; padding:8px 15px; border-radius:8px; font-size:13px; box-shadow:0 6px 20px rgba(0,0,0,.25); }
.toast.bad { background:var(--danger); }

/* ---- locked tiles (tool the user has no access to) ---- */
.tile.locked { opacity:.55; cursor:not-allowed; background:#fafbfd; }
.tile.locked:hover { transform:none; box-shadow:none; border-color:var(--border); }
.tile .lock { font-size:11px; }

.hint.warn { background:#fff7ed; border-color:#fed7aa; color:#9a3412; }
.hint button { margin-left:auto; }

/* ---- admin table ---- */
.tablewrap { overflow:auto; border:1px solid var(--border); border-radius:var(--radius); background:#fff; box-shadow:var(--shadow); }
table.data { border-collapse:collapse; width:100%; font-size:13px; }
table.data th, table.data td { padding:8px 11px; border-bottom:1px solid #eef1f6; text-align:left; vertical-align:middle; }
table.data th { position:sticky; top:0; background:#f8fafd; z-index:2; font-size:12px; white-space:nowrap; border-bottom:1px solid var(--border); }
table.data tr:hover td { background:#f7faff; }
table.data tr.inactive td { opacity:.5; }
table.data.plain { border:1px solid var(--border); border-radius:8px; }
table.data.plain th { position:static; }
.rowacts { white-space:nowrap; display:flex; gap:4px; }
.chips { min-width:180px; }
.chip { display:inline-flex; align-items:center; gap:4px; background:var(--accent-soft); color:#1e3a6b; border-radius:99px;
  padding:1px 8px; font-size:11.5px; font-weight:600; margin:1px 3px 1px 0; }
.chip i { font-style:normal; opacity:.65; font-weight:500; }
.muted { color:var(--muted); }
.pill { display:inline-block; padding:1px 8px; border-radius:99px; font-size:11px; font-weight:600; background:#eef1f6; color:var(--muted); }
.pill.warn { background:#fff7ed; color:#9a3412; }
.modal.wide { max-width:760px; }

/* ---- selecting several people at once ---- */
table.data th.pick, table.data td.pick { width:34px; padding-right:0; }
table.data .pick input { width:auto; margin:0; cursor:pointer; }
.bulkbar { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:12px; padding:9px 13px;
  background:var(--accent-soft); border:1px solid #d5e3fb; border-radius:8px; font-size:13px; color:#1e3a6b; }
/* An author `display` beats the browser's own [hidden] rule, so anything laid
   out with flex has to opt back out of it by hand. */
.bulkbar[hidden], .hint[hidden] { display:none; }
.bulkbar .grow { flex:1; }
.bulkbar .muted { font-size:12px; }
.namelist { max-height:96px; overflow:auto; margin-bottom:14px; }
.modes { display:grid; gap:7px; margin-bottom:14px; }
.mode { display:flex; align-items:flex-start; gap:9px; padding:8px 11px; border:1px solid var(--border);
  border-radius:8px; cursor:pointer; font-size:13px; }
.mode:hover { background:#f7faff; }
.mode input { width:auto; margin:2px 0 0; }
.mode b { display:block; font-weight:600; }
.mode i { display:block; font-style:normal; font-size:12px; color:var(--muted); margin-top:1px; }
.mode:has(input:checked) { border-color:var(--accent); background:var(--accent-soft); }

@media (max-width: 620px) {
  .topbar { padding:11px 13px; gap:8px; }
  .topbar .search { max-width:none; order:9; width:100%; }
  .main { padding:14px 12px 70px; }
  .section-body.grid { grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); }
}
