:root {
  --bg: #F8F7F4;
  --panel: #FFFFFF;
  --panel-2: #F1EFEA;
  --line: #E4E1DB;
  --text: #1B1E28;
  --muted: #6E6A63;
  --accent: #2E4F86;
  --accent-soft: #E7EDF7;
  --ok: #2F9E44;
  --ok-soft: #E6F6EA;
  --warn: #E8590C;
  --warn-soft: #FFF0E6;
  --err: #D6336C;
  --err-soft: #FDE8EF;
  --user-bubble: #2E4F86;
  --user-text: #FFFFFF;
  --shadow: 0 1px 2px rgba(20, 24, 50, .06), 0 4px 16px rgba(20, 24, 50, .05);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F111A; --panel: #171A26; --panel-2: #1E2232; --line: #2A2F42; --text: #ECEEF6;
    --muted: #9AA1BC; --accent: #7B86FF; --accent-soft: #23284A; --ok: #51CF66; --ok-soft: #173322;
    --warn: #FF922B; --warn-soft: #3A2516; --err: #F06595; --err-soft: #3A1826;
    --user-bubble: #5B67F5; --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #0F111A; --panel: #171A26; --panel-2: #1E2232; --line: #2A2F42; --text: #ECEEF6;
  --muted: #9AA1BC; --accent: #7B86FF; --accent-soft: #23284A; --ok: #51CF66; --ok-soft: #173322;
  --warn: #FF922B; --warn-soft: #3A2516; --err: #F06595; --err-soft: #3A1826;
  --user-bubble: #5B67F5; --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.6 "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.side {
  background: var(--panel); border-inline-end: 1px solid var(--line);
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; }
.modelsel { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }
.modelsel select { max-width: 100%; }
.brand img { width: 38px; height: 38px; border-radius: 10px; }
.brand b { display: block; font-size: 16px; }
.brand small { color: var(--muted); font-size: 12px; }
.nav a, .side-agents a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  color: var(--text); font-weight: 500;
}
.nav a:hover, .side-agents a:hover { background: var(--panel-2); }
.nav a.on, .side-agents a.on { background: var(--accent-soft); color: var(--accent); }
.ni { width: 22px; text-align: center; }
.badge {
  margin-inline-start: auto; background: var(--warn); color: #fff; font-style: normal;
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center;
}
.budget { display: block; margin: 10px 4px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); text-decoration: none; color: var(--text); font-size: 12.5px; }
.budget[hidden] { display: none; }
.budget .bh { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 6px; }
.budget .bw { margin-top: 7px; }
.connform { display: grid; gap: 8px; max-width: 520px; margin-top: 6px; }
.connform label { display: grid; gap: 3px; font-size: 13px; }
.connform label.switch { display: flex; gap: 6px; align-items: center; }
.connreq { margin: 6px 0; }
.checks { list-style: none; padding: 0 4px; margin: 6px 0; display: grid; gap: 4px; font-size: 13px; }
.checks li.done { color: var(--ok); }
.conns { list-style: none; margin: 0; padding: 0; }
.conns li { padding: 4px 0; }
.modelkey { padding-inline-start: 18px; margin: 0 0 12px; }
.budget-t .msel { font: inherit; font-size: 13px; padding: 2px 4px; max-width: 120px; }
.budget-t td.c { min-width: 70px; }
.budget-t tr.total th, .budget-t tr.total td { border-top: 2px solid var(--line); }
.budget { cursor: pointer; }
.budget .bl { display: flex; justify-content: space-between; color: var(--muted); }
.budget .bl b { color: var(--text); font-weight: 600; }
.budget .bar { height: 8px; border-radius: 6px; background: var(--panel-2); overflow: hidden; margin-top: 3px; }
.budget .bar i { display: block; height: 100%; border-radius: 6px; background: var(--ok); }
.budget .warn .bar i { background: var(--warn); }
.budget .hit .bar i { background: var(--err); }
.budget .unknown .bar i { width: 0 !important; }
.budget small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.side-agents { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.side-agents a { font-size: 14px; }
.side-agents .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: pulse 1.2s infinite; }
.sa-x { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; flex: none; }
.sa-n { color: var(--muted); font-size: 11.5px; font-weight: 500; background: var(--panel-2); border-radius: 999px; padding: 0 7px; min-width: 20px; text-align: center; line-height: 18px; }
.side-agents a.on .sa-n { background: var(--panel); color: var(--accent); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 18px 28px 6px;
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.topbar h1 { font-size: 22px; margin: 0; font-weight: 800; letter-spacing: -.2px; }
.back { border: 0; background: var(--panel); box-shadow: var(--shadow); width: 36px; height: 36px; border-radius: 10px; font-size: 18px; color: var(--text); }
.top-pending { margin-inline-start: auto; background: var(--warn-soft); color: var(--warn); font-weight: 600; padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.view { padding: 12px 28px 40px; max-width: 1100px; width: 100%; }
.tabbar { display: none; }

/* ---------- team ---------- */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat small { color: var(--muted); display: block; font-size: 12.5px; }
.stat b { font-size: 24px; font-weight: 800; }
.stat.hot { background: var(--warn-soft); }
.stat.hot b { color: var(--warn); }
a.stat { color: inherit; }

.live { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 18px; }
.live h3 { margin: 0 0 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.live-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; font-size: 14px; }
.live-row .ev { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  color: var(--text); display: flex; flex-direction: column; gap: 10px; border: 1px solid transparent;
  transition: transform .12s, border-color .12s;
}
.card:hover { transform: translateY(-2px); border-color: var(--line); }
.card-h { display: flex; gap: 12px; align-items: center; }
.av { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; flex: none; }
.card-h b { display: block; font-size: 16px; }
.card-h small { color: var(--muted); font-size: 13px; line-height: 1.35; display: block; }
.card-f { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12.5px; }
.pill { padding: 2px 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.pill.run { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.pill.pend { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.pill.learn { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.lessons { padding-inline-start: 20px; line-height: 1.7; }
.lessons small { color: var(--muted); }
.pill.err { background: var(--err-soft); color: var(--err); }

/* ---------- agent page ---------- */
.ahead { display: flex; gap: 14px; align-items: center; background: var(--panel); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); flex-wrap: wrap; }
.ahead .av { width: 56px; height: 56px; font-size: 30px; }
.ahead-t { flex: 1; min-width: 200px; }
.ahead-t b { font-size: 18px; }
.ahead-t p { margin: 2px 0 6px; color: var(--muted); font-size: 14px; }
.ahead-a { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 10px; padding: 8px 14px; font-weight: 600; background: var(--panel-2); color: var(--text); }
.btn.pri { background: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }

.tabs { display: flex; gap: 4px; margin: 16px 0 10px; background: var(--panel-2); padding: 4px; border-radius: 12px; width: fit-content; }
.tabs button { border: 0; background: transparent; padding: 6px 16px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

.chat { display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); overflow-wrap: anywhere; }
.msg.user { align-self: flex-start; background: var(--user-bubble); color: var(--user-text); border-end-start-radius: 4px; }
.msg.agent { align-self: flex-end; border-end-end-radius: 4px; }
.msg time { display: block; font-size: 11px; opacity: .6; margin-top: 4px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.thinking { align-self: flex-end; background: var(--panel); border-radius: 16px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 13.5px; color: var(--muted); min-width: 220px; }
.thinking .dots::after { content: "…"; animation: dots 1.2s steps(3) infinite; }
.thinking ul { margin: 6px 0 0; padding-inline-start: 18px; max-height: 160px; overflow-y: auto; }

.composer { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 calc(10px + var(--safe-b)); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 6px 12px; border-radius: 999px; font-size: 13.5px; }
.chips button:hover { border-color: var(--accent); color: var(--accent); }
.inrow { display: flex; gap: 8px; align-items: flex-end; }
.inrow textarea {
  flex: 1; resize: none; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 14px; padding: 10px 14px; font: inherit; max-height: 160px; min-height: 46px;
}
.inrow textarea:focus, .prop textarea:focus, .login input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.send { width: 46px; height: 46px; border-radius: 14px; border: 0; background: var(--accent); color: #fff; font-size: 20px; flex: none; }

.report { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px; }
.report summary { padding: 12px 16px; cursor: pointer; display: flex; gap: 10px; align-items: center; list-style: none; }
.report summary::-webkit-details-marker { display: none; }
.report .body { padding: 0 16px 14px; border-top: 1px solid var(--line); }

/* ---------- approvals ---------- */
.prop { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; border-inline-start: 4px solid var(--warn); }
.prop.executing { border-color: var(--accent); }
.prop.done { border-color: var(--ok); }
.prop.failed { border-color: var(--err); }
.prop.rejected { border-color: var(--line); opacity: .75; }
.prop.returned { border-color: var(--accent); }
.retbox { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.retbox textarea { min-height: 90px; background: var(--panel); }
.prop .res.note { background: var(--accent-soft); }
.prop a.btn { display: inline-block; margin-top: 10px; }
.prop-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.prop h3 { margin: 6px 0 2px; font-size: 16px; }
.prop .sum { color: var(--muted); margin: 0 0 8px; }
.prop textarea { width: 100%; min-height: 140px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel-2); color: var(--text); font: 14px/1.55 inherit; font-family: inherit; resize: vertical; }
.prop .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.prop .res { background: var(--panel-2); border-radius: 10px; padding: 8px 12px; margin-top: 8px; font-size: 14px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }
.filters a { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 4px 12px 4px 10px; border-radius: 999px; font-size: 13.5px; }
.filters a .face-xs { width: 22px; height: 22px; }
.filters a span { color: var(--muted); font-size: 12px; }
.filters a:hover { border-color: var(--accent); }
.filters a.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.filters a.on span { color: var(--accent); }
@media (max-width: 860px) { .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } .filters a { flex: none; } }
.kind { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- activity / guide ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: var(--panel-2); }
.guide { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 22px 18px; }
.guide h2 { font-size: 17px; margin: 18px 0 6px; }

/* ---------- markdown ---------- */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 12px 0 4px; line-height: 1.35; }
.md h1 { font-size: 18px; } .md h2 { font-size: 16.5px; } .md h3, .md h4 { font-size: 15px; }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-inline-start: 22px; }
.md code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-size: 13px; direction: ltr; unicode-bidi: embed; }
.md pre { background: var(--panel-2); padding: 10px; border-radius: 10px; overflow-x: auto; direction: ltr; text-align: left; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: 8px 0; font-size: 13.5px; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: start; }
.md th { background: var(--panel-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.md blockquote { margin: 6px 0; padding: 2px 12px; border-inline-start: 3px solid var(--line); color: var(--muted); }
.msg.user .md code { background: rgba(255,255,255,.18); }

/* ---------- login / toast ---------- */
.login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 50; padding: 16px; }
.login-card { background: var(--panel); border-radius: 22px; box-shadow: var(--shadow); padding: 28px; width: 100%; max-width: 380px; text-align: center; }
.login-card img { width: 64px; border-radius: 16px; }
.login-card h2 { margin: 10px 0 4px; }
.login-card p { color: var(--muted); font-size: 14px; }
.login input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; margin: 6px 0 10px; direction: ltr; text-align: center; }
.login button { width: 100%; padding: 12px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; }
.err { color: var(--err); min-height: 1em; }
.toast { position: fixed; bottom: calc(84px + var(--safe-b)); inset-inline: 0; margin: auto; width: fit-content; max-width: calc(100% - 32px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: 14px; }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes dots { 0% { content: ""; } 33% { content: "."; } 66% { content: ".."; } }

/* ---------- phone ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 6px; }
  .topbar h1 { font-size: 20px; }
  .view { padding: 8px 16px calc(90px + var(--safe-b)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; inset-inline: 0;
    background: var(--panel); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); z-index: 20;
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; font-size: 11.5px; color: var(--muted); position: relative; gap: 1px; }
  .tabbar a span { font-size: 20px; }
  .tabbar a.on { color: var(--accent); font-weight: 600; }
  .tabbar .badge { position: absolute; top: -2px; inset-inline-start: calc(50% + 6px); margin: 0; }
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .strip { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat b { font-size: 20px; }
  .composer { bottom: calc(62px + var(--safe-b)); padding-bottom: 8px; }
  .msg { max-width: 94%; }
  .table .hide-m { display: none; }
  .md td, .md th { min-width: 84px; }
}

/* ---------- people (team page look) ---------- */
.face { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; background: var(--panel-2); }
.face-xs { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; background: var(--panel-2); }
.face-lg { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; flex: none; background: var(--panel-2); }
.face-emoji { display: inline-grid; place-items: center; font-size: 60%; }
.sec { font-size: 17px; font-weight: 800; margin: 26px 0 12px; }
.sec:first-of-type { margin-top: 8px; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.tcard {
  display: flex; align-items: center; gap: 16px; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; min-height: 108px;
  transition: border-color .15s, box-shadow .15s;
}
.tcard:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.tcard.busy { border-color: var(--ok); }
.tc-b { flex: 1; min-width: 0; }
.tc-n { display: flex; align-items: baseline; gap: 8px; }
.tc-n b { font-size: 18px; font-weight: 800; }
.tc-n small { color: var(--muted); font-size: 12px; }
.tc-t { font-size: 14.5px; margin-top: 1px; }
.tc-s { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.st-run { color: var(--ok); font-weight: 600; }
.st-err { color: var(--err); }
.st-miss { color: var(--warn); }
.missed { background: var(--warn-soft); border-radius: 12px; padding: 8px 14px; margin-top: 12px; font-size: 13.5px; }
.missed summary { cursor: pointer; color: var(--warn); font-weight: 600; }
.missed ul { margin: 6px 0; padding-inline-start: 20px; }
.missed p { margin: 4px 0 2px; color: var(--muted); font-size: 12.5px; }
.count { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--text); }
.banner { display: block; text-align: center; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 9px 16px; color: var(--text); font-size: 14px; margin-bottom: 8px; }
.banner:hover { border-color: var(--accent); }
.foot { color: var(--muted); font-size: 13px; margin-top: 28px; max-width: 760px; }
.side-agents a { gap: 10px; padding: 7px 8px; }
.sa-t { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sa-t b { font-size: 14px; font-weight: 600; }
.sa-t small { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-agents a.on .sa-t small { color: var(--accent); }
.arow { display: flex; gap: 8px; align-items: flex-end; align-self: flex-end; max-width: 92%; }
.arow .msg { max-width: 100%; }
.arow .face-xs { margin-bottom: 2px; }
.empty .face-lg { display: block; margin: 0 auto 10px; }
.ahead .tc-t { color: var(--text); }
.ahead-t p { margin: 4px 0 8px; }
.prop-h .face-xs { width: 24px; height: 24px; }
.prop-h b { color: var(--text); }
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; }
.profile { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; }
.profile dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; margin: 0 0 8px; }
.profile dt { color: var(--muted); font-size: 13.5px; }
.profile dd { margin: 0; }
.pb-h { margin: 18px 0 8px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 16px; }
@media (max-width: 860px) {
  .tgrid { grid-template-columns: 1fr; gap: 10px; }
  .tcard { padding: 14px 16px; min-height: 0; }
  .face { width: 56px; height: 56px; }
  .profile dl { grid-template-columns: 1fr; gap: 2px; }
  .profile dt { margin-top: 8px; }
}
.profile dd code { direction: ltr; unicode-bidi: isolate; background: var(--panel-2); padding: 1px 6px; border-radius: 5px; font-size: 13px; }

/* ---------- account / users ---------- */
.login button.link { background: transparent; color: var(--muted); font-weight: 500; margin-top: 4px; }
.login input[type=email] { text-align: start; }
.ltr { direction: ltr; unicode-bidi: plaintext; }
.acct { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 18px; }
.acct > div { flex: 1; min-width: 160px; display: flex; flex-direction: column; }
.acct small { color: var(--muted); }
h3.sec { margin: 22px 0 10px; font-size: 15px; }
.table .acts { white-space: nowrap; text-align: end; }
.table .acts .btn { padding: 5px 10px; font-size: 13px; }
.adduser { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 16px 16px; }
.adduser h3, .adduser small, .adduser .btn { grid-column: 1 / -1; }
.adduser input, .adduser select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; }
@media (max-width: 640px) { .adduser { grid-template-columns: 1fr; } }
.todo { display: flex; flex-direction: column; gap: 4px; background: var(--warn-soft); color: var(--text); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: 14px; }
.todo b { color: var(--warn); }
.perm { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; font-size: 14px; margin: 6px 0; }
.perm label { display: flex; align-items: center; gap: 8px; }
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; padding: 8px 12px; background: var(--panel-2); border-radius: 10px; }
.perm:has(input[name=all]:checked) .perm-list { display: none; }
.permform { display: flex; flex-direction: column; gap: 6px; }
.permform .acts { text-align: start; }

/* ---------- attachments ---------- */
.attach { width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; flex: none; }
.attach:disabled { opacity: .5; }
.attached { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px; }
.file { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); color: var(--text); font-size: 13px; text-decoration: none; max-width: 100%; overflow-wrap: anywhere; }
.file button { border: 0; background: transparent; color: var(--muted); padding: 0 2px; }
.msg.user .file { background: rgba(255, 255, 255, .18); color: inherit; margin-top: 6px; margin-inline-end: 4px; }

/* ---------- shared folders ---------- */
.hint { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; }
.folder { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.folder header { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 8px; }
.folder h3 { margin: 0 0 2px; font-size: 16px; }
.folder p { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.folder small { color: var(--muted); }
.folder .table { box-shadow: none; }
.folderform { display: flex; flex-direction: column; gap: 8px; padding: 12px; margin: 8px 0; background: var(--panel-2); border-radius: 12px; }
.folderform input[type=text], .folderform input:not([type]) { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; }
.perm-list.always { display: grid !important; }

/* ---------- quiet hours ---------- */
.quiet { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 16px 16px; margin-bottom: 18px; display: flex; flex-direction: column; gap: 10px; }
.switch { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.qrule { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 12px; background: var(--panel-2); border-radius: 12px; }
.qdays { display: flex; gap: 4px; }
.day input { position: absolute; opacity: 0; pointer-events: none; }
.day span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-weight: 600; cursor: pointer; }
.day input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.day input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.qrule input[type=time], .qrule input[readonly] { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; width: 100px; }
.qrule .btn { margin-inline-start: auto; }

/* ---------- admin: permission matrix, activity log ---------- */
.adminlink { display: flex; flex-direction: column; gap: 2px; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; text-decoration: none; }
.adminlink span { color: var(--muted); font-size: 13.5px; }
.admintabs { margin-bottom: 14px; }
.matrix-wrap { overflow: auto; max-height: 70vh; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); }
.matrix { border-collapse: separate; border-spacing: 0; font-size: 13.5px; min-width: 100%; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line); padding: 6px 8px; background: var(--panel); }
.matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--panel-2); font-weight: 600; }
.matrix thead tr:nth-child(2) th { top: 31px; }
.matrix th.grp { text-align: center; border-inline-start: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.matrix th.who { position: sticky; inset-inline-start: 0; z-index: 3; min-width: 190px; text-align: start; font-weight: 400; background: var(--panel); }
.matrix thead th.who { background: var(--panel-2); }
.matrix th.who small { display: block; color: var(--muted); }
.matrix td.c, .matrix th.c { text-align: center; min-width: 38px; }
.matrix th.vert { vertical-align: bottom; }
.matrix th.vert > span { display: block; writing-mode: vertical-rl; transform: rotate(180deg); margin: 0 auto 6px; white-space: nowrap; max-height: 150px; overflow: hidden; text-overflow: ellipsis; }
.matrix .colall { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11.5px; color: var(--muted); }
.matrix .colall em { font-style: normal; }
.matrix tr.off td, .matrix tr.off th { opacity: .55; }
.matrix td.acts { white-space: nowrap; }
.matrix input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.matrix input:disabled { opacity: .5; cursor: default; }
.auditf { margin-bottom: 10px; }
.auditf select { padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; }

/* departments in the side list: a heading per department, collapsible */
.sg { margin-top: 6px; }
.sg-h { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 8px; cursor: pointer; color: var(--muted); font-size: 12.5px; border-radius: 8px; }
.sg-h:hover { background: var(--panel-2); }
.sg-h:focus-visible { outline: 2px solid var(--accent); }
.sg-h b { font-weight: 700; letter-spacing: .01em; }
.sg-h small { color: var(--muted); font-size: 11px; }
.sg-h .sa-n { margin-inline-start: auto; }
.sg-c { display: inline-block; transition: transform .15s; font-size: 14px; line-height: 1; }
.sg.closed .sg-c { transform: rotate(90deg); }
.sg.closed .sg-b { display: none; }
.lm { margin-inline-start: 4px; font-size: 11px; }
.sec small { color: var(--muted); font-weight: 500; font-size: 13px; margin-inline-start: 4px; }
.learnline { margin: 0 0 14px; padding: 8px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 13.5px; }
.learnbar { display: flex; flex-direction: column; gap: 3px; margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--warn); background: var(--warn-soft); color: var(--text); font-size: 13.5px; line-height: 1.5; }
.learnbar b { color: var(--warn); }
