:root {
  color-scheme: dark;
  --bg: #101218;
  --panel: #181c25;
  --panel-2: #202633;
  --line: #31384a;
  --text: #e8ebf2;
  --muted: #a3abbd;
  --accent: #9eb0ff;
  --accent-ink: #1b2140;
  --ok: #8fd0a8;
  --warn: #e2c27a;
  --danger: #ef8d8d;
  --shadow: none;
  font-family: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { min-height: 100%; }

.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.brand { font-weight: 750; letter-spacing: .04em; font-size: 28px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 22px; }
label { display: block; margin: 0 0 12px; color: var(--muted); font-size: 14px; }
input, select, textarea {
  width: 100%; margin-top: 6px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
textarea { min-height: 120px; resize: vertical; }
.btn {
  border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 700;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.warn { background: var(--warn); color: #2b2414; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.err { color: var(--danger); min-height: 1.2em; }
.ok { color: var(--ok); }

.shell { min-height: 100%; display: grid; grid-template-rows: 60px 1fr; }
.top { display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.top nav { display: flex; gap: 8px; }
.top .spacer { flex: 1; }
.who { color: var(--muted); font-size: 14px; }
.link { text-decoration: none; }
.link.on { background: var(--text); color: var(--bg); }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 0; }
.rail { border-right: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 6px; background: #141820; }
.rail button { text-align: left; background: transparent; border: 0; color: var(--text); border-radius: 8px; padding: 10px; }
.rail button.on { background: var(--panel-2); }
.main { padding: 18px; overflow: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat b { display: block; font-size: 28px; }
.stat span { color: var(--muted); }
.list { display: grid; gap: 10px; }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 18px 0 8px; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; font-size: 12px; color: var(--muted); }
.pill.run { color: var(--ok); border-color: var(--ok); }
.pill.soft { color: var(--warn); border-color: var(--warn); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.checks { display: flex; gap: 12px; flex-wrap: wrap; }
.checks label { display: flex; gap: 6px; align-items: center; }
.checks input { width: auto; margin: 0; }

.panel-view { display: grid; grid-template-columns: 240px 280px 1fr; min-height: calc(100vh - 60px); }
.col { border-right: 1px solid var(--line); overflow: auto; }
.col h2 { margin: 12px; }
.person, .cust { width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
.person.on, .cust.on { background: var(--panel-2); }
.thread { display: grid; grid-template-rows: auto 1fr auto auto; min-height: calc(100vh - 60px); }
.msgs { overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 70%; padding: 8px 10px; border-radius: 12px; background: var(--panel-2); }
.bubble.out { align-self: flex-end; background: #2a3358; }
.bubble small { display: block; color: var(--muted); }
.composer, .notebox { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.composer textarea, .notebox textarea { min-height: 52px; }
.secret { font-family: ui-monospace, monospace; background: var(--bg); padding: 8px; border-radius: 8px; word-break: break-all; }

@media (max-width: 900px) {
  .layout, .panel-view { grid-template-columns: 1fr; }
  .rail { flex-direction: row; overflow: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .thread { min-height: auto; }
}
