:root {
  --bg: #0d1117; --bg2: #161b22; --bg3: #1c2330; --line: #263041;
  --fg: #e6edf3; --muted: #8b98a9; --accent: #3fb950; --accent2: #58a6ff;
  --urgent: #f85149; --high: #ff9800; --medium: #58a6ff; --low: #8b98a9; --info: #6e7681;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.5 ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--bg3); color: var(--fg); border-radius: 8px; padding: 6px 12px; }
button:hover { border-color: var(--accent2); }
button.primary { background: var(--accent); color: #06210c; border-color: var(--accent); font-weight: 700; }
button.danger { color: var(--urgent); }
input, textarea, select { font: inherit; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
textarea { resize: vertical; min-height: 60px; }
a { color: var(--accent2); }

/* login gate */
#gate { position: fixed; inset: 0; background: var(--bg); display: flex;
  align-items: center; justify-content: center; z-index: 100; }
#gate .card { background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 32px; width: 380px; max-width: 90vw; }
#gate h1 { margin: 0 0 4px; font-size: 22px; }
#gate p { color: var(--muted); margin: 0 0 20px; }
.gate-err { color: var(--urgent); min-height: 20px; font-size: 13px; }

/* layout */
#app { display: grid; grid-template-columns: 300px 1fr; height: 100vh; }
#sidebar { background: var(--bg2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden; }
.brand { padding: 16px; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; justify-content: space-between; }
.brand b { font-size: 16px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--urgent);
  display: inline-block; }
.dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.side-scroll { overflow-y: auto; flex: 1; }
.side-h { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.side-h button { padding: 2px 8px; font-size: 12px; }
.room { padding: 10px 16px; border-left: 3px solid transparent; cursor: pointer; }
.room:hover { background: var(--bg3); }
.room.active { background: var(--bg3); border-left-color: var(--accent); }
.room .r-name { font-weight: 600; display: flex; justify-content: space-between; }
.room .r-meta { color: var(--muted); font-size: 12px; }
.badge-count { background: var(--bg); border: 1px solid var(--line); border-radius: 20px;
  padding: 0 7px; font-size: 11px; color: var(--accent); }
.inst { padding: 7px 16px; font-size: 12px; display: flex; align-items: center; gap: 8px; }
.inst .idot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.inst .idot.stale { background: var(--info); }
.inst .iname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst button { padding: 1px 6px; font-size: 11px; }

/* main */
#main { overflow-y: auto; padding: 0 24px 40px; }
.topbar { position: sticky; top: 0; background: var(--bg); padding: 16px 0;
  border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; z-index: 10; }
.topbar h2 { margin: 0; font-size: 18px; }
.topbar .sub { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; margin: 16px 0; flex-wrap: wrap; }
.tab { padding: 7px 14px; border-radius: 8px; color: var(--muted); border: 1px solid transparent; }
.tab:hover { background: var(--bg2); }
.tab.active { background: var(--bg3); color: var(--fg); border-color: var(--line); }
.tab .n { color: var(--accent); }

.empty { color: var(--muted); text-align: center; padding: 60px 0; }
.row-card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px; border-left: 3px solid var(--line); }
.row-card.p-urgent { border-left-color: var(--urgent); }
.row-card.p-high { border-left-color: var(--high); }
.row-card.p-medium { border-left-color: var(--medium); }
.row-card.p-low { border-left-color: var(--low); }
.row-card.done { opacity: .5; }
.row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.row-head .title { font-weight: 700; flex: 1; }
.chip { font-size: 11px; padding: 1px 8px; border-radius: 20px; border: 1px solid var(--line); }
.chip.urgent { color: var(--urgent); border-color: var(--urgent); }
.chip.high { color: var(--high); border-color: var(--high); }
.chip.medium { color: var(--medium); }
.chip.low { color: var(--low); }
.chip.info { color: var(--info); }
.row-body { white-space: pre-wrap; word-break: break-word; color: var(--fg); }
.row-body code, .mono { font-family: inherit; background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.row-meta { color: var(--muted); font-size: 12px; margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }
.row-actions { margin-left: auto; display: flex; gap: 6px; }
.row-actions button { padding: 2px 8px; font-size: 12px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 12px; }
.kv .k { color: var(--muted); }

/* add form */
.addbox { background: var(--bg2); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 18px; }
.addbox .grid { display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); }
.addbox .grid > .full { grid-column: 1 / -1; }
.addbox .actions { margin-top: 10px; display: flex; gap: 8px; align-items: center; }

/* token vault */
.tok { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 14px; }
.tok .tstate { width: 10px; height: 10px; border-radius: 50%; }
.tstate.valid { background: var(--accent); }
.tstate.warning { background: var(--high); box-shadow: 0 0 8px var(--high); }
.tstate.expired { background: var(--urgent); box-shadow: 0 0 8px var(--urgent); }
.tstate.unknown { background: var(--info); }
.tok .tinfo { flex: 1; }
.tok .tinfo .tmsg { color: var(--muted); font-size: 12px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--bg3);
  border: 1px solid var(--accent); border-radius: 8px; padding: 12px 16px; z-index: 200;
  max-width: 340px; }
/* modals (no native prompt/confirm anywhere) */
.modal-ov { position: fixed; inset: 0; background: rgba(3, 6, 12, .72);
  display: flex; align-items: center; justify-content: center; z-index: 300;
  animation: fade .12s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card { background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; width: 440px; max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.modal-body { color: var(--fg); }
.modal-field { margin-bottom: 12px; }
.modal-field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.hidden { display: none !important; }
@media (max-width: 720px) { #app { grid-template-columns: 1fr; } #sidebar { display: none; } }
