:root {
  color-scheme: light;
  --bg: #f6f8fd;
  --card: #ffffff;
  --ink: #1b2236;
  --muted: #667089;
  --line: #e4e8f3;
  --accent: #5b5fc7;
  --accent-ink: #ffffff;
  --accent-soft: #eceeff;
  --ok: #0f7a55;
  --ok-bg: #e2f6ee;
  --warn: #8f5d00;
  --warn-bg: #fff2cc;
  --bad: #bd3328;
  --bad-bg: #fde7e4;
  --info: #1f62b8;
  --info-bg: #e5f0ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 34, 54, 0.04), 0 6px 18px rgba(27, 34, 54, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: linear-gradient(180deg, #eef1ff 0, var(--bg) 220px) var(--bg);
  color: var(--ink);
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 18px; }
h3 { font-size: 15px; margin-bottom: 10px; }
p { margin: 0 0 10px; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; }

.app { display: flex; height: 100vh; }

/* Left rail: light, like the rest of the page */
.rail {
  width: 84px;
  flex: none;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 0;
  overflow-y: auto;
}
.brand {
  width: 40px; height: 40px; border-radius: 12px; margin-bottom: 10px;
  display: grid; place-items: center; color: #fff; font-weight: 700; letter-spacing: 0.5px;
  background: linear-gradient(135deg, #6a6ee0, #8a5fd6);
}
.rail a {
  position: relative;
  width: 68px;
  padding: 8px 0 6px;
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}
.rail a:hover { background: var(--bg); color: var(--ink); }
.rail a.active { background: var(--accent-soft); color: var(--accent); }
.rail svg { width: 22px; height: 22px; display: block; margin: 0 auto 3px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.count-dot {
  position: absolute; top: 3px; right: 10px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; font-weight: 700;
}

.column { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 28px; }
.topbar h1 { font-size: 20px; }
.top-right { display: flex; gap: 8px; align-items: center; }
main { flex: 1; overflow: auto; padding: 4px 28px 32px; max-width: 1180px; width: 100%; }
/* Teams problems and the waiting banner sit outside main, so they stay current on every page */
#status-slot { flex: none; padding: 0 28px; max-width: 1180px; width: 100%; }
#status-slot:empty { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: #fff; border: 1px solid var(--line); white-space: nowrap;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.ok { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.chip.ok::before { background: var(--ok); }
.chip.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.chip.warn::before { background: #e0a100; }
.chip.info { background: var(--info-bg); border-color: transparent; color: var(--info); }
.chip.info::before { display: none; }
.chip.bad { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.chip.bad::before { background: var(--bad); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card h2 .sec, .sec { color: var(--accent); margin-left: 4px; font-weight: 400; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.card-head > * { min-width: 0; }
.card-head strong { overflow-wrap: anywhere; }

.hero { font-size: 22px; font-weight: 500; margin: 6px 0 4px; }
.hero b { color: var(--accent); font-weight: 700; }
.sub { color: var(--muted); margin-bottom: 18px; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-value { font-size: 26px; font-weight: 700; overflow-wrap: anywhere; }
.stat.hot .stat-value { color: var(--bad); }
.stat.good .stat-value { color: var(--ok); }

.alert, .banner, .error, .toast { overflow-wrap: anywhere; }
.alert { background: var(--bad-bg); border: 1px solid #f3c0ba; color: #8a231a; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; }
.banner {
  background: var(--accent-soft); border: 1px solid #d7dbff; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px;
  display: flex; gap: 16px; justify-content: space-between; align-items: center; flex-wrap: wrap;
}

.btn {
  appearance: none; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  border-radius: 10px; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.secondary { background: #fff; color: var(--accent); }
.btn.secondary:hover { background: var(--accent-soft); filter: none; }
.btn.danger { background: #fff; border-color: #efb5af; color: var(--bad); }
.btn.small { padding: 4px 11px; font-size: 13px; border-radius: 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

input[type="text"], input[type="number"], input[type="search"], input[type="url"], input[type="time"], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #d5daea; border-radius: 10px; padding: 8px 11px; width: 100%;
}
textarea { min-height: 84px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
select { width: auto; }

.form label { display: block; font-weight: 600; margin-bottom: 12px; }
.form label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 6px; }
.form input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.form fieldset { border: 0; padding: 0; margin: 0 0 14px; }
.form legend { font-weight: 600; margin-bottom: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; display: block; margin-top: 3px; }
.days { display: flex; flex-wrap: wrap; gap: 4px 14px; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: #c3c9dc; transition: background 0.15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform 0.15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; }
.switch-row + .switch-row { border-top: 1px solid var(--line); }

.seg { display: inline-flex; border: 1px solid #d5daea; border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid #d5daea; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.seg button[aria-pressed="true"].auto { background: var(--ok); }
.seg button[aria-pressed="true"].off { background: #8b93aa; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f7; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); }
.pad { padding: 18px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.toolbar input { max-width: 340px; }

.list { padding: 0; overflow: hidden; }
.row-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.row-item:last-child { border-bottom: 0; }
a.row-item:hover { background: #f8f9ff; }
.grow { flex: 1; min-width: 0; }
.name { font-weight: 700; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
a.name:hover { text-decoration: underline; }
.line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; text-align: right; }
.count { font-weight: 700; font-size: 13px; }
.more { color: var(--accent); font-size: 13px; font-weight: 600; }

.avatar { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; }

.back { display: inline-block; margin: 6px 0 12px; text-decoration: none; font-size: 14px; }
.person { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.person h2 { font-size: 24px; overflow-wrap: anywhere; }
.person > div { min-width: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 9px 16px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

.message-text { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; margin: 0; }
.reply-text { font-style: italic; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 22px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 10px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.plain li:last-child { border-bottom: 0; }

.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.msg.mine { border-left-color: #b9c0d8; background: #fafbff; margin-left: 28px; }
.msg.hot { border-left-color: var(--bad); }
.msg header { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.msg footer { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 14px; }

.draft textarea { margin: 8px 0 10px; }
textarea:disabled { background: #f6f7fb; color: var(--muted); }
.quote { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; color: var(--muted); font-size: 14px; margin: 6px 0; overflow-wrap: anywhere; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
tr.done td { color: var(--muted); text-decoration: line-through; }

.bars { display: flex; gap: 10px; align-items: flex-end; height: 120px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 12px; color: var(--muted); }
.bar .col { width: 100%; max-width: 44px; background: #dfe3f7; border-radius: 8px 8px 3px 3px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; min-height: 3px; }
.bar .col i { display: block; background: var(--accent); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-size: 12px; flex: none; width: 64px; }
.feed .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.checks { list-style: none; margin: 0 0 10px; padding: 0; }
.checks li { padding: 6px 0; display: flex; gap: 10px; align-items: center; }
.tick { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; background: var(--ok); flex: none; }
.tick.no { background: var(--bad); }
.snap { max-height: 360px; overflow: auto; font: 12px/1.4 ui-monospace, Menlo, monospace; background: #f8f9fd; border: 1px solid var(--line); border-radius: 10px; padding: 10px; white-space: pre-wrap; }
.empty { text-align: center; padding: 44px 16px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1b2236; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); max-width: calc(100vw - 32px); z-index: 10; }
.toast.error { background: var(--bad); }
.toast.warn { background: var(--warn); }
[hidden] { display: none !important; }

@media (max-width: 860px) {
  .cols, .grid2, .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .app { flex-direction: column; height: auto; min-height: 100vh; }
  .rail { width: 100%; flex-direction: row; justify-content: space-between; padding: 6px 8px; position: sticky; top: 0; z-index: 5; gap: 0; overflow-x: auto; }
  .rail .brand { display: none; }
  .rail a { width: auto; flex: 1; min-width: 40px; padding: 6px 0 4px; }
  .rail a span { display: none; }
  .rail svg { margin-bottom: 0; }
  .count-dot { right: 2px; }
  .topbar { padding: 10px 16px; height: auto; flex-wrap: wrap; }
  main { padding: 4px 16px 28px; }
  #status-slot { padding: 0 16px; }
  .toolbar input { max-width: none; }
  .row-item { flex-wrap: wrap; }
  .hero { font-size: 19px; }
  .msg.mine { margin-left: 0; }
  table { display: block; overflow-x: auto; }
}

/* Messages drawn the way Teams draws them */
.chatpane { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 22px; box-shadow: var(--shadow); max-width: 900px; }
.day { display: flex; align-items: center; gap: 14px; margin: 18px 0 10px; color: var(--muted); font-size: 12px; font-weight: 600; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.day:first-child { margin-top: 0; }
.trow { display: flex; gap: 10px; margin-top: 3px; }
.trow.head { margin-top: 14px; }
.trow.mine { justify-content: flex-end; }
.mini { width: 34px; flex: none; }
.mini .avatar { width: 32px; height: 32px; font-size: 12px; }
.tcol { display: flex; flex-direction: column; align-items: flex-start; max-width: min(72%, 640px); min-width: 0; }
.trow.mine .tcol { align-items: flex-end; }
.tmeta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.tmeta .who { font-weight: 600; }
.tbubble { background: #f1f2f6; border-radius: 6px; padding: 8px 12px; max-width: 100%; overflow-wrap: anywhere; }
.trow.mine .tbubble { background: #e6e8fb; }
.tbubble.flag { box-shadow: inset 3px 0 0 var(--bad); }
.tbubble .message-text { font-size: 14.5px; line-height: 1.45; }
.reacts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 4px; }
.react { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 1px solid #d5daea; border-radius: 12px; padding: 0 8px; height: 24px; font-size: 13px; }
.react.you { background: var(--accent-soft); border-color: #c4c8f5; }
.react .emo { font-size: 15px; line-height: 1; }
.react .n { font-weight: 600; }
.react-by { color: var(--muted); font-size: 12px; margin-right: 6px; overflow-wrap: anywhere; }
.pilot { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin-top: 5px; font-size: 12px; max-width: 100%; overflow-wrap: anywhere; }

@media (max-width: 700px) {
  .chatpane { padding: 12px; }
  .tcol { max-width: 86%; }
}
.quote-in { border-left: 3px solid var(--accent); background: rgba(255, 255, 255, 0.75); padding: 4px 10px; margin-bottom: 6px; font-size: 13px; color: var(--muted); border-radius: 3px; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.quote-in strong { display: block; color: var(--ink); font-weight: 600; }

/* People rows keep a readable name column at phone width: the controls wrap underneath it. */
.row-item > .grow { flex: 1 1 150px; }

/* Model picker */
.model-list { border: 1px solid var(--line); border-radius: 12px; max-height: 440px; overflow-y: auto; background: #fff; margin-top: 10px; }
.form .model-row, .model-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; font-weight: 400; margin: 0; }
.form .model-row:last-child, .model-row:last-child { border-bottom: 0; }
.model-row:hover { background: #f8f9ff; }
.model-row.off { opacity: 0.6; cursor: default; }
.model-row.off:hover { background: transparent; }
.form .model-row input[type="radio"], .model-row input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; }
.model-row .rank { width: 24px; flex: none; text-align: right; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.model-row .grow > span { display: block; }
.model-row .line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
@media (max-width: 700px) { .model-row { flex-wrap: wrap; } .model-row .badge { margin-left: 52px; } }
th { overflow-wrap: normal; white-space: nowrap; }

/* Areas: posts from your teams' channels */
.areas-bar { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.areas-card { padding: 0; overflow: hidden; overflow-wrap: break-word; }
.areas-pad { padding: 10px 18px; }
.areas-team { border-bottom: 1px solid var(--line); padding: 4px 0; }
.areas-team:last-child { border-bottom: 0; }
.areas-team > summary { cursor: pointer; padding: 12px 18px; }
.areas-channel { padding: 6px 18px 0; color: var(--accent); }
.areas-post { padding: 10px 18px; border-top: 1px solid var(--line); }
.areas-post-head { display: flex; align-items: center; gap: 10px; }
.areas-post-subject { font-weight: 700; margin-top: 4px; }
.areas-post .message-text { white-space: pre-wrap; margin: 4px 0 0; }
.areas-post.is-reply { border-top: 0; border-left: 3px solid var(--accent-soft); margin: 4px 0 0 18px; padding: 6px 12px; }
.areas-replies { margin-top: 6px; }
ul.areas-list { margin: 0; padding: 10px 18px 10px 36px; }
nav.tabs[aria-label="Areas"] { overflow-x: auto; overflow-y: hidden; white-space: nowrap; }
@media (max-width: 700px) { .rail a { min-width: 32px; } }
