/* Helpdesk UI. No build step: plain CSS with light/dark tokens. */
:root {
  /* Cryptic Vector brand: blue #1A70C7, slate #505B75, deep blue #1E273C, light gray #EAECF1 */
  --bg: #EAECF1;
  --surface: #ffffff;
  --surface-2: #f4f5f8;
  --border: #d6dae3;
  --text: #1E273C;
  --text-2: #505B75;
  --text-3: #7d879c;
  --accent: #1A70C7;
  --accent-ink: #ffffff;
  --accent-soft: #e2edf8;
  --fill: #1A70C7;
  --ok: #157f3d;
  --ok-soft: #e3f4ea;
  --warn: #a35a00;
  --warn-soft: #fdf0dc;
  --bad: #c0262d;
  --bad-soft: #fde7e8;
  --info-soft: #e2edf8;
  --shadow: 0 1px 2px rgba(30, 39, 60, .06), 0 1px 3px rgba(30, 39, 60, .08);
  --show-light: inline-block;
  --show-dark: none;
  --radius: 10px;
  --sidebar: 232px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
/* dark: chosen with the toggle, or following the device setting until someone picks */
:root[data-theme="dark"] {
  --bg: #1E273C;
  --surface: #263049;
  --surface-2: #2d3853;
  --border: #3a4661;
  --text: #EAECF1;
  --text-2: #b4bbcb;
  --text-3: #8892a9;
  --accent: #5fa1ea;
  --accent-ink: #ffffff;
  --accent-soft: #233b5c;
  --fill: #1A70C7;
  --ok: #5cc98a;
  --ok-soft: #1f3d3a;
  --warn: #f2b25c;
  --warn-soft: #443823;
  --bad: #f27a80;
  --bad-soft: #4a2a37;
  --info-soft: #233b5c;
  --shadow: none;
  --show-light: none;
  --show-dark: inline-block;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1E273C;
    --surface: #263049;
    --surface-2: #2d3853;
    --border: #3a4661;
    --text: #EAECF1;
    --text-2: #b4bbcb;
    --text-3: #8892a9;
    --accent: #5fa1ea;
    --accent-ink: #ffffff;
    --accent-soft: #233b5c;
    --fill: #1A70C7;
    --ok: #5cc98a;
    --ok-soft: #1f3d3a;
    --warn: #f2b25c;
    --warn-soft: #443823;
    --bad: #f27a80;
    --bad-soft: #4a2a37;
    --info-soft: #233b5c;
    --shadow: none;
    --show-light: none;
    --show-dark: inline-block;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 620; }
p { margin: 0 0 .75em; }
code, kbd, pre, .mono { font-family: var(--mono); font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; padding: 4px 8px 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--fill); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 14px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 7px;
  color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .count { font-size: 11.5px; background: var(--surface-2); color: var(--text-2); border-radius: 99px; padding: 0 7px; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 5;
}
.topbar form.search { flex: 1; max-width: 520px; }
.topbar .spacer { flex: 1; }
.content { padding: 24px; max-width: 1400px; }
.content.narrow { max-width: 860px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.menu-btn { display: none; }

/* requester (portal) layout: top nav, no sidebar */
.portal-nav { display: flex; align-items: center; gap: 4px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.portal-nav .brand { padding: 0 16px 0 0; }
.portal-nav a.link { padding: 6px 12px; border-radius: 7px; color: var(--text-2); font-weight: 500; }
.portal-nav a.link:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.portal-nav a.link.active { color: var(--accent); background: var(--accent-soft); }
.portal-nav .spacer { flex: 1; }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 8px; }
.card-head h2, .card-head h3 { margin: 0; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .split > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--fill); border-color: var(--fill); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.block { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger { color: var(--bad); }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url],
input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font: inherit; min-height: 34px;
}
textarea { resize: vertical; line-height: 1.5; }
select[multiple] { padding: 4px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=color] { width: 60px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -3px; }
label { font-weight: 550; font-size: 13px; }

/* Django's form.as_div output */
.form > div, .field { margin-bottom: 14px; }
.form > div > label, .field > label { display: block; margin-bottom: 5px; }
.form .helptext, .help { display: block; color: var(--text-3); font-size: 12px; margin-top: 4px; }
.form > div:has(> input[type=checkbox]) { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form > div:has(> input[type=checkbox]) > label { margin: 0; order: 2; }
.form > div:has(> input[type=checkbox]) > input { order: 1; }
.form > div:has(> input[type=checkbox]) > .helptext { order: 3; width: 100%; margin-left: 24px; }
.form div[id$="permissions"], .form div[id$="members"], .form div[id$="roles"], .form div[id$="teams"],
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.form div[id$="permissions"] label, .form div[id$="members"] label, .form div[id$="roles"] label,
.form div[id$="teams"] label, .checks label { font-weight: 450; display: flex; gap: 8px; align-items: center; }
.form div[id$="kind"] { display: flex; gap: 16px; }
.form div[id$="kind"] label { font-weight: 500; display: flex; gap: 6px; align-items: center; }
ul.errorlist { list-style: none; margin: 4px 0; padding: 0; color: var(--bad); font-size: 12.5px; }
ul.errorlist.nonfield { background: var(--bad-soft); padding: 8px 12px; border-radius: 8px; margin-bottom: 14px; }
.form-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.flash.success { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.flash.warning { background: var(--warn-soft); color: var(--warn); }
.flash.info { background: var(--info-soft); color: var(--text); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 12px;
  font-weight: 560; background: var(--surface-2); color: var(--text-2); white-space: nowrap; line-height: 1.6;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-new { background: var(--accent-soft); color: var(--accent); }
.st-open { background: var(--info-soft); color: var(--accent); }
.st-in_progress { background: var(--warn-soft); color: var(--warn); }
.st-pending, .st-approval, .st-on_hold { background: var(--surface-2); color: var(--text-2); }
.st-resolved { background: var(--ok-soft); color: var(--ok); }
.st-closed { background: var(--surface-2); color: var(--text-3); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.tag { display: inline-block; padding: 0 7px; border-radius: 5px; background: var(--surface-2); color: var(--text-2); font-size: 12px; border: 1px solid var(--border); }
.due-over { color: var(--bad); font-weight: 600; }
.due-soon { color: var(--warn); font-weight: 600; }

.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.avatar.lg { width: 34px; height: 34px; font-size: 13px; }

table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .t-title { font-weight: 560; color: var(--text); }
.table .t-num { color: var(--text-3); font-family: var(--mono); font-size: 12px; }
.table-wrap { overflow-x: auto; }
.empty { padding: 32px; text-align: center; color: var(--text-2); }

.stat { padding: 16px 18px; }
.stat .k { font-size: 12.5px; color: var(--text-2); font-weight: 550; }
.stat .v { font-size: 26px; font-weight: 680; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v.bad { color: var(--bad); }
.stat .v.warn { color: var(--warn); }
.stat a.v { color: inherit; display: block; }
.stat a.v:hover { text-decoration: none; color: var(--accent); }

.bars .bar-row { display: grid; grid-template-columns: 140px 1fr 40px; gap: 10px; align-items: center; padding: 4px 0; }
.bars .bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bars .track { display: block; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bars .fill { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bars .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.chart { display: flex; align-items: flex-end; gap: 2px; height: 140px; padding-top: 8px; }
.chart .col { flex: 1; display: flex; gap: 1px; align-items: flex-end; height: 100%; position: relative; }
.chart .col span { display: block; flex: 1; border-radius: 3px 3px 0 0; min-height: 1px; }
.chart .c1 { background: var(--accent); }
.chart .c2 { background: var(--ok); opacity: .8; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.filters select, .filters input { width: auto; min-width: 130px; height: 32px; min-height: 32px; padding: 4px 8px; font-size: 13px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tabs a { padding: 10px 12px; color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.bulkbar { display: none; gap: 8px; align-items: center; padding: 10px 14px; background: var(--accent-soft); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.bulkbar.on { display: flex; }
.bulkbar select { width: auto; height: 30px; min-height: 30px; padding: 2px 8px; font-size: 13px; }
.pager { display: flex; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid var(--border); }

/* ticket conversation */
.ticket-title { font-size: 21px; font-weight: 650; margin: 2px 0 6px; }
.meta-line { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; color: var(--text-2); font-size: 13px; }
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.msg-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.msg-head .who { font-weight: 600; }
.msg-head .when { color: var(--text-3); font-size: 12.5px; margin-left: auto; }
.msg-body { padding: 14px; overflow-wrap: anywhere; }
.msg-body > :last-child { margin-bottom: 0; }
.msg.internal { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.msg.internal .msg-head { background: var(--warn-soft); }
.msg.requester .msg-head { background: var(--info-soft); }
.msg .files { padding: 0 14px 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.file-chip { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--border); border-radius: 7px; padding: 4px 9px; font-size: 12.5px; background: var(--surface); color: var(--text); }
.composer { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.composer .tabs { padding: 0 10px; }
.composer textarea { border: 0; border-radius: 0; min-height: 130px; padding: 12px 14px; }
.composer textarea:focus { outline: none; }
.composer.internal-mode { border-color: var(--warn); }
.composer.internal-mode textarea { background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.composer-foot { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.composer-foot select { width: auto; height: 32px; min-height: 32px; padding: 2px 8px; }
.presence { display: none; padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-weight: 550; margin-bottom: 12px; }
.presence.on { display: block; }

.side-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.side-section:last-child { border-bottom: 0; }
.side-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: 10px; display: flex; justify-content: space-between; }
.props label { font-size: 12px; color: var(--text-2); font-weight: 550; display: block; margin: 8px 0 3px; }
.props select { height: 32px; min-height: 32px; padding: 3px 8px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.linklist { list-style: none; padding: 0; margin: 0; }
.linklist li { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.linklist li:last-child { border-bottom: 0; }
.inline-form { display: flex; gap: 6px; margin-top: 8px; }
.inline-form input { height: 30px; min-height: 30px; font-size: 13px; padding: 3px 8px; }
.suggest { position: relative; }
.suggest-list { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); margin-top: 4px; max-height: 260px; overflow-y: auto; }
.suggest-list button { display: block; width: 100%; text-align: left; padding: 7px 10px; background: none; border: 0; font: inherit; color: var(--text); cursor: pointer; }
.suggest-list button:hover { background: var(--surface-2); }
.suggest-list small { color: var(--text-3); display: block; }

.timeline { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.timeline li { padding: 5px 0 5px 14px; border-left: 2px solid var(--border); position: relative; color: var(--text-2); }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.timeline b { color: var(--text); font-weight: 600; }

details.more summary { cursor: pointer; color: var(--accent); font-weight: 550; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }

.intake { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; }
.intake h3 { margin-bottom: 10px; }
.kb-suggest { border: 1px solid var(--border); background: var(--info-soft); border-radius: 8px; padding: 10px 14px; margin: -4px 0 14px; }
.kb-suggest ul { margin: 6px 0 0; padding-left: 18px; }

/* knowledge base article */
.article-body { font-size: 15px; line-height: 1.65; }
.article-body h2 { margin-top: 1.4em; }
.article-body pre { background: var(--surface-2); padding: 12px 14px; border-radius: 8px; overflow-x: auto; border: 1px solid var(--border); }
.article-body code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.article-body pre code { background: none; padding: 0; }
.article-body table { border-collapse: collapse; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 6px 10px; }
.article-body blockquote { border-left: 3px solid var(--border); margin: 0 0 1em; padding: 4px 14px; color: var(--text-2); }
.article-body img { max-width: 100%; border-radius: 8px; }
.kb-item { display: block; padding: 14px 18px; border-bottom: 1px solid var(--border); color: inherit; }
.kb-item:hover { background: var(--surface-2); text-decoration: none; }
.kb-item:last-child { border-bottom: 0; }
.kb-item .t { font-weight: 600; color: var(--text); }

/* sign-in pages */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; font-size: 18px; padding-bottom: 20px; }
.auth-card .card { padding: 28px; }
.auth-card h1 { font-size: 19px; text-align: center; margin-bottom: 18px; }
.auth-foot { text-align: center; margin-top: 16px; color: var(--text-2); font-size: 13px; }
.qr svg { display: block; width: 220px; height: 220px; max-width: 100%; background: #fff; border-radius: 8px; }
.code-input { font-size: 22px !important; letter-spacing: .35em; text-align: center; font-family: var(--mono); }
.code-input::placeholder { font-size: 14px; letter-spacing: normal; font-family: var(--font, inherit); }

.rating { display: flex; gap: 6px; flex-wrap: wrap; }
.rating label { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 500; display: flex; gap: 6px; align-items: center; }
.rating label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .topbar form.search { min-width: 0; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-cols { grid-template-columns: 1fr; }
  .bars .bar-row { grid-template-columns: 100px 1fr 32px; }
  .hide-sm { display: none; }
  .portal-nav { padding: 10px 16px; }
}
@media (max-width: 520px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 95px 1fr; }
}

/* ---------- workflows ---------- */
.bell { position: relative; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: var(--text-2); }
.bell:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.bell.has { color: var(--accent); }
.bell-n { position: absolute; top: 1px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
.portal-nav .bell { margin-right: 4px; }
.wf-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.wf-tiles .card + .card { margin-top: 0; }
.wf-tile { display: flex; gap: 14px; align-items: flex-start; padding: 16px; color: inherit; }
.wf-tile:hover { border-color: var(--accent); text-decoration: none; }
.wf-tile b { display: block; color: var(--text); font-size: 15px; margin-bottom: 2px; }
.wf-tile > span:last-child { display: flex; flex-direction: column; gap: 4px; }
.wf-icon { font-size: 26px; line-height: 1; width: 44px; height: 44px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.badge.wfs-pending_approval { background: var(--warn-soft); color: var(--warn); }
.badge.wfs-approved, .badge.wfs-completed { background: var(--ok-soft); color: var(--ok); }
.badge.wfs-denied { background: var(--bad-soft); color: var(--bad); }
.badge.wfs-in_progress { background: var(--accent-soft); color: var(--accent); }
.badge.wfs-cancelled { background: var(--surface-2); color: var(--text-3); }
.bars .fill.wfs-fill-pending_approval { background: var(--warn); }
.bars .fill.wfs-fill-approved, .bars .fill.wfs-fill-completed { background: var(--ok); }
.bars .fill.wfs-fill-denied { background: var(--bad); }
.bars .fill.wfs-fill-cancelled { background: var(--text-3); }
.badge.tks-todo { background: var(--surface-2); color: var(--text-2); }
.badge.tks-in_progress { background: var(--accent-soft); color: var(--accent); }
.badge.tks-blocked { background: var(--bad-soft); color: var(--bad); }
.badge.tks-done { background: var(--ok-soft); color: var(--ok); }
.badge.tks-na { background: var(--surface-2); color: var(--text-3); }
.mini-track { display: inline-block; width: 60px; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; vertical-align: middle; border: 1px solid var(--border); }
.mini-track.wide { width: 120px; }
.mini-track > span { display: block; height: 100%; background: var(--ok); }
.dep-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dep-chip { font-size: 12px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); }
.dep-chip.done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.wf-active + .wf-active { padding-top: 12px; border-top: 1px dashed var(--border); }
.notif { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; margin: 0 -10px; border-radius: 8px; color: inherit; border-left: 3px solid transparent; }
.notif:hover { background: var(--surface-2); text-decoration: none; }
.notif.unread { border-left-color: var(--accent); }
.notif b { color: var(--text); font-weight: 600; }
.notif:not(.unread) b { font-weight: 500; }
.row-notif { margin: 0; border-radius: 0; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.row-notif:last-child { border-bottom: 0; }
.decision { border-color: var(--warn); }
.dep-section { border-top: 1px solid var(--border); }
.dep-section:first-of-type { margin-top: 12px; }
.dep-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px 6px; }
.dep-head h3 { margin: 0; display: flex; gap: 8px; align-items: center; }
.ok-text { color: var(--ok); font-weight: 600; }
.task { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; padding: 9px 18px; align-items: start; }
.task + .task { border-top: 1px dashed var(--border); }
.task.closed .task-title { color: var(--text-3); text-decoration: line-through; }
.task:target { background: var(--accent-soft); }
.checkbox { width: 22px; height: 22px; margin-top: 1px; border-radius: 6px; border: 2px solid var(--text-3); background: var(--surface); color: #fff; font-weight: 800; font-size: 13px; line-height: 1; display: grid; place-items: center; cursor: pointer; padding: 0; }
.checkbox:hover { border-color: var(--ok); }
.checkbox.on { background: var(--ok); border-color: var(--ok); }
.checkbox.ro { cursor: default; opacity: .75; }
.task-title { font-weight: 550; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 1px; }
.task-edit { display: grid; grid-template-columns: 130px 170px minmax(0, 1fr); gap: 6px; margin-top: 6px; }
.task-edit select, .task-edit input { height: 30px; min-height: 30px; padding: 3px 8px; font-size: 12.5px; }
.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.avatar.xs { width: 18px; height: 18px; font-size: 8.5px; vertical-align: -4px; }
.wf-timeline li.ev-comment { color: var(--text); }
.wf-timeline li.ev-approved::before { background: var(--ok); }
.wf-timeline li.ev-denied::before { background: var(--bad); }
.wf-timeline li.ev-comment::before { background: var(--accent); }
.comment-body { margin-top: 3px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font-size: 13.5px; }
.kv.wide { grid-template-columns: 1fr; gap: 0; }
.kv.wide dt { font-size: 12px; margin-top: 8px; }
.kv.wide dt:first-child { margin-top: 0; }
.kv.wide dd { font-size: 14px; }
.money { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.steps { padding-left: 18px; margin: 0; }
.steps li + li { margin-top: 6px; }
.tabs.plain { border: 0; padding: 0; }
.table.matrix td.center, .table.matrix th.center, .table td.center { text-align: center; }
.cell { display: inline-block; min-width: 42px; padding: 2px 6px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); text-align: center; }
.cell:hover { text-decoration: none; filter: brightness(.97); }
.cell.done { background: var(--ok-soft); color: var(--ok); }
.cell.part { background: var(--accent-soft); color: var(--accent); }
.cell.late { background: var(--bad-soft); color: var(--bad); }
.legend-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--border); padding: 10px 18px; }
.legend-row .cell { min-width: 30px; margin-left: 8px; }
.wf-chart { display: flex; align-items: flex-end; gap: 4px; height: 170px; }
.wf-chart .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; min-width: 0; }
.wf-chart .b { width: 100%; max-width: 28px; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.wf-chart .cv { font-size: 11px; color: var(--text-2); font-weight: 600; }
.wf-chart .cl { font-size: 10px; color: var(--text-3); white-space: nowrap; overflow: hidden; max-width: 100%; }
.table.formset td { vertical-align: top; padding: 6px 8px; }
.table.formset input[type=text], .table.formset select, .table.formset input[type=number] { min-height: 30px; padding: 4px 8px; font-size: 13px; }
.wf-type-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.wf-type-form > div:has(textarea), .wf-type-form > div:has(#id_submit_departments), .wf-type-form > div:has(#id_notify_departments), .wf-type-form > div:has(#id_submit_access) { grid-column: 1 / -1; }
.form div[id$="departments"] { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.form div[id$="departments"] label, .form div[id$="submit_access"] label { font-weight: 450; display: flex; gap: 8px; align-items: center; }
.form div[id$="submit_access"] { display: flex; gap: 16px; flex-wrap: wrap; }
@media (max-width: 820px) {
  .task { grid-template-columns: 28px minmax(0, 1fr); }
  .task-side { grid-column: 2; flex-direction: row; align-items: center; text-align: left; }
  .task-edit { grid-template-columns: 1fr 1fr; }
  .task-edit input { grid-column: 1 / -1; }
  .wf-type-form { grid-template-columns: 1fr; }
}
.wf-type-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.wf-type-form legend { font-weight: 550; font-size: 13px; padding: 0; margin-bottom: 5px; }
.viewas-bar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 7px 16px; background: var(--warn-soft); color: var(--warn); font-weight: 550; font-size: 13px; border-bottom: 1px solid var(--border); }
.viewas-bar form { margin: 0; }

/* ---------- brand and theme toggle ---------- */
.logo { display: block; height: auto; }
.logo-light { display: var(--show-light); }
.logo-dark { display: var(--show-dark); }
.brand.has-logo { flex-direction: column; align-items: flex-start; gap: 3px; padding: 6px 8px 18px; }
.brand.has-logo .logo { width: 176px; }
.brand-sub { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); padding-left: 2px; }
.portal-nav .brand.has-logo { flex-direction: row; align-items: center; padding: 0 16px 0 0; gap: 10px; }
.portal-nav .brand.has-logo .logo { width: 150px; }
.auth-card .brand.has-logo { align-items: center; padding-bottom: 22px; }
.auth-card .brand.has-logo .logo { width: 240px; }
.theme-toggle { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; padding: 0; }
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle .i-moon { display: var(--show-light); }
.theme-toggle .i-sun { display: var(--show-dark); }
.auth-theme { position: fixed; top: 12px; right: 12px; }

/* ---- Labels ---- */
.label-chip { --lc: var(--accent); display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 550;
  color: color-mix(in srgb, var(--lc) 75%, var(--text)); background: color-mix(in srgb, var(--lc) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--lc) 35%, transparent); white-space: nowrap; }
a.label-chip:hover { text-decoration: none; filter: brightness(.95); }
.label-chip.sm { font-size: 11px; padding: 0 6px; }
.label-chip button { border: 0; background: none; color: inherit; padding: 0 0 0 2px; cursor: pointer; font-size: 11px; opacity: .7; }
.label-chip button:hover { opacity: 1; }
.label-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.meta-line .label-chip { margin-left: 2px; }

/* ---- Ticket list ---- */
.locked-filter { display: inline-flex; align-items: center; height: 32px; padding: 0 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }

/* ---- Reply composer: public reply options and @mentions ---- */
.composer { position: relative; }
.composer-public { display: none; padding: 8px 14px 10px; border-top: 1px dashed var(--border); gap: 6px; flex-direction: column; }
.composer.public-mode .composer-public { display: flex; }
.composer-public label.check { display: flex; gap: 8px; align-items: center; font-weight: 550; cursor: pointer; }
.composer-public label.check input { width: auto; min-height: 0; }
.composer-cc { display: none; align-items: center; gap: 8px; flex-wrap: wrap; }
.composer.emailing .composer-cc { display: flex; }
.composer-cc label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.composer-cc input { flex: 1; min-width: 220px; height: 32px; min-height: 32px; padding: 4px 8px; font-size: 13px; }
.mention-list { left: 12px; right: auto; top: auto; min-width: 240px; max-width: 360px; }
.mention-list button.on { background: var(--accent-soft); }
.msg-cc { padding: 6px 14px; font-size: 12.5px; color: var(--text-2); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.msg-cc b { color: var(--text-3); font-weight: 600; margin-right: 4px; }

/* ---- Manage ---- */
.manage-group { margin: 22px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.manage-group:first-of-type { margin-top: 4px; }
.check-cols > div { columns: 3 200px; column-gap: 18px; }
.check-cols > div > div { break-inside: avoid; margin-bottom: 4px; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; word-break: break-all; }

/* IT assistant */
.ai-wrap { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.ai-wrap > * { min-width: 0; }
.ai-chats nav { display: flex; flex-direction: column; padding: 6px; max-height: 70vh; overflow-y: auto; }
.ai-chats nav a { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 8px; color: inherit; }
.ai-chats nav a:hover { background: var(--surface-2); text-decoration: none; }
.ai-chats nav a.active { background: var(--accent-soft); }
.ai-chat-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-main { display: flex; flex-direction: column; min-height: 60vh; max-height: calc(100vh - 190px); }
.ai-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.ai-user { align-self: flex-end; background: var(--fill); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.ai-bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-bot > :first-child { margin-top: 0; } .ai-bot > :last-child { margin-bottom: 0; }
.ai-bot pre { background: var(--surface); padding: 10px 12px; border-radius: 8px; overflow-x: auto; border: 1px solid var(--border); }
.ai-bot code { background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.ai-bot pre code { padding: 0; }
.ai-bot table { border-collapse: collapse; } .ai-bot th, .ai-bot td { border: 1px solid var(--border); padding: 4px 8px; }
.ai-error { align-self: flex-start; background: var(--bad-soft); color: var(--bad); }
.ai-step { align-self: flex-start; font-size: 12.5px; color: var(--text-3); padding-left: 4px; }
.ai-step::before { content: "↳ "; }
.ai-working::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 50%;
  border: 2px solid var(--text-3); border-top-color: transparent; animation: ai-spin .8s linear infinite; vertical-align: -1px; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-empty { margin: auto; text-align: center; max-width: 560px; }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ai-suggest .btn { white-space: normal; text-align: left; height: auto; }
.ai-form { border-top: 1px solid var(--border); padding: 12px; }
.ai-form textarea { width: 100%; resize: vertical; }
.ai-form-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
@media (max-width: 900px) { .ai-wrap { grid-template-columns: 1fr; } .ai-chats nav { max-height: 180px; } .ai-main { max-height: none; } }
.ai-sources { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.ai-sources ol { margin: 4px 0 0; padding-left: 20px; font-size: 13px; }
.ai-sources a { overflow-wrap: anywhere; }

/* Manage › Access control */
.acc-wrap { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.acc-wrap > * { min-width: 0; }
.acc-tree { position: sticky; top: 16px; max-height: calc(100vh - 100px); overflow: auto; }
.acc-tree nav { padding: 6px 0; }
.acc-tree a { display: flex; justify-content: space-between; gap: 8px; padding: 6px 14px 6px 26px; color: var(--text); text-decoration: none; font-size: 14px; }
.acc-tree a:hover { background: var(--surface-2); }
.acc-tree a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.acc-tree a.acc-overview { padding-left: 14px; font-weight: 600; margin-bottom: 4px; }
.acc-tree a.acc-add { color: var(--accent); font-size: 13px; }
.acc-tree .acc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-tree .acc-none { padding: 4px 26px; }
.acc-tree details { border-top: 1px solid var(--border); }
.acc-tree summary { display: flex; justify-content: space-between; padding: 9px 14px; cursor: pointer; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); list-style: none; }
.acc-tree summary::-webkit-details-marker { display: none; }
.acc-tree summary::before { content: "▾"; margin-right: 6px; }
.acc-tree details:not([open]) summary::before { content: "▸"; }
.acc-tree summary span:first-child { flex: 1; }
.acc-matrix-wrap { overflow: auto; max-height: 75vh; }
.acc-matrix { border-collapse: separate; border-spacing: 0; }
.acc-matrix th, .acc-matrix td { padding: 6px 8px; }
.acc-matrix thead th { position: sticky; top: 0; z-index: 2; }
.acc-matrix thead tr:nth-child(2) th { top: 31px; }
.acc-matrix .acc-sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 200px; border-right: 1px solid var(--border); }
.acc-matrix thead .acc-sticky { z-index: 3; background: var(--surface-2); }
.acc-matrix .acc-group { text-align: center; border-left: 1px solid var(--border); }
.acc-matrix .acc-col { vertical-align: bottom; height: 120px; min-width: 34px; }
.acc-matrix .acc-col a { display: block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; max-height: 112px; overflow: hidden; text-overflow: ellipsis; color: var(--text); margin: 0 auto; }
.acc-matrix .acc-col a:hover { color: var(--accent); }
.acc-matrix tr.acc-area td { background: var(--surface-2); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.acc-matrix tbody tr:hover td.acc-sticky { background: var(--surface-2); }
.acc-dot { display: inline-block; min-width: 14px; text-align: center; font-weight: 700; }
.acc-dot.on { color: var(--ok); }
.acc-dot.implied { color: var(--text-3); font-size: 10px; }
.acc-features fieldset { border: 0; padding: 0; margin: 0 0 16px; }
.acc-features legend { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin-bottom: 6px; }
.acc-features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
.acc-feature { display: flex; gap: 10px; align-items: flex-start; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.acc-feature:hover { background: var(--surface-2); }
.acc-feature input { margin-top: 3px; }
.acc-feature > span { display: flex; flex-direction: column; gap: 1px; }
.acc-feature b { font-weight: 560; }
.acc-full-note { display: none; grid-column: 1 / -1; margin: 0; }
.acc-features.full .acc-full-note { display: block; }
.acc-features.full .acc-feature:not(:has([data-full])) { opacity: .55; }
.acc-filter { max-width: 220px; }
.acc-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 16px; max-height: 360px; overflow: auto; }
.acc-people label { display: flex; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.acc-people label:hover { background: var(--surface-2); }
.acc-people label[hidden] { display: none; }
.acc-person { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 24px; }
.acc-person h4 { margin: 8px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.acc-person ul { list-style: none; padding: 0; margin: 0; }
.acc-person li { display: flex; gap: 8px; padding: 3px 0; }
.acc-person li.off { color: var(--text-3); }
.acc-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; }
@media (max-width: 900px) {
  .acc-wrap { grid-template-columns: 1fr; }
  .acc-tree { position: static; max-height: 260px; }
  .acc-features { grid-template-columns: 1fr; }
}

/* Notes & to-dos */
.notes-side { overflow: hidden; }
.notes-search { padding: 10px 10px 0; }
.notes-tabs { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.notes-tabs a { padding: 3px 9px; border-radius: 999px; font-size: 13px; color: var(--text-2); }
.notes-tabs a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.notes-tabs a:hover { text-decoration: none; background: var(--surface-2); }
.notes-side nav { display: flex; flex-direction: column; padding: 6px; max-height: 70vh; overflow-y: auto; }
.notes-side nav a { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 8px; color: inherit; }
.notes-side nav a:hover { background: var(--surface-2); text-decoration: none; }
.notes-side nav a.active { background: var(--accent-soft); }
.notes-title { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-main { min-height: 50vh; }
.notes-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin: 6px 0 12px; font-size: 14px; }
.notes-preview { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-top: 10px; }
.notes-check { border-top: 1px solid var(--border); }
.notes-check h3 { margin: 0 0 8px; display: flex; gap: 10px; align-items: baseline; }
.notes-items { list-style: none; margin: 0 0 10px; padding: 0; }
.notes-items li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.notes-items li:hover { background: var(--surface-2); }
.notes-items label { display: flex; gap: 10px; align-items: flex-start; flex: 1; cursor: pointer; min-width: 0; }
.notes-items label input { margin-top: 3px; }
.notes-item-text { overflow-wrap: anywhere; }
.notes-items li.done .notes-item-text { text-decoration: line-through; color: var(--text-3); }
.notes-del { opacity: 0; }
.notes-items li:hover .notes-del, .notes-del:focus { opacity: 1; }
.notes-add { display: flex; gap: 8px; }
.notes-danger { border-top: 1px solid var(--border); padding-top: 12px; padding-bottom: 12px; }
.notes-group + .notes-group { margin-top: 16px; }
.notes-group-title { font-weight: 600; margin-right: 6px; }
@media (hover: none) { .notes-del { opacity: 1; } }
.acc-search { position: relative; margin-bottom: 12px; max-width: 520px; }
.acc-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); max-height: 320px; overflow: auto; padding: 4px; }
.acc-results button { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; border-radius: 6px; color: var(--text); cursor: pointer; font: inherit; }
.acc-results button:hover:not([disabled]) { background: var(--accent-soft); }
.acc-results button[disabled] { opacity: .55; cursor: default; }
.acc-members { list-style: none; margin: 0; padding: 0; }
.acc-members li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.acc-members li:last-child { border-bottom: 0; }
.acc-members li > span { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.acc-members.auto li { color: var(--text-2); }
.tag.new { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.acc-members li[hidden] { display: none; }
.notes-form input.notes-title-input { font-size: 20px; font-weight: 650; border: 0; padding: 4px 0; background: transparent; box-shadow: none; }
.label-filter { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; padding: 10px 16px 12px; }
.label-chip.toggle { opacity: .75; }
.label-chip.toggle:hover { opacity: 1; }
.label-chip.toggle.on { opacity: 1; background: color-mix(in srgb, var(--lc) 30%, var(--surface)); border-color: var(--lc); box-shadow: 0 0 0 1px var(--lc); }
.label-match a { color: var(--text-2); }
.label-match a.active { color: var(--accent); font-weight: 600; }
.label-add { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.label-add select { height: 30px; min-height: 30px; padding: 2px 6px; font-size: 13px; }
.label-new { display: flex; gap: 6px; }
.label-new[hidden] { display: none; }
.label-hint { margin: 4px 0 0; }
.label-list .label-chip button { line-height: 1; }
.label-check label { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; cursor: pointer; }
.label-check { display: flex; flex-wrap: wrap; gap: 4px 14px; }
/* IT projects */
.proj-tabs { padding: 0 0 12px; border: 0; }
.proj-grid { margin-bottom: 8px; }
.proj-tile { color: inherit; display: flex; flex-direction: column; gap: 8px; }
.proj-tile:hover { text-decoration: none; border-color: var(--accent); }
.proj-tile h2 { margin: 0; font-size: 17px; }
.proj-desc { margin: 0; }
.proj-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.proj-bar { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.proj-bar span { display: block; height: 100%; background: var(--ok); }
.proj-overdue { color: var(--bad); font-weight: 600; }
.proj-filter { padding: 0; border: 0; align-items: center; }
.proj-board-desc { margin: 4px 0 0; max-width: 720px; }
.proj-sharing { margin: -8px 0 14px; }
.board { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; }
.board-col { flex: 0 0 280px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.board-col > header { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px 6px; }
.board-col h3 { margin: 0; font-size: 14px; }
.board-cards { list-style: none; margin: 0; padding: 4px 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 40px; flex: 1; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow); cursor: grab; }
.board-card a { color: var(--text); display: block; overflow-wrap: anywhere; }
.board-card a:hover { text-decoration: none; color: var(--accent); }
.board-card.active { border-color: var(--accent); }
.board-card.dragging { opacity: .45; }
.board-card-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--text-2); }
.board-card-meta .avatar { margin-left: auto; }
.board-cards.drop { outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: 8px; }
.board-drop-mark { height: 3px; background: var(--accent); border-radius: 2px; list-style: none; }
.board-add { padding: 6px 8px 10px; }
.board-add input { background: var(--surface); }
.proj-modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: start center; padding: 6vh 16px; overflow-y: auto; }
.proj-modal-backdrop { position: fixed; inset: 0; background: rgba(15, 20, 32, .45); }
.proj-modal-body { position: relative; width: 100%; max-width: 640px; }
.proj-modal-body label, .proj-settings section > label { display: block; margin-bottom: 12px; font-weight: 500; }
.proj-modal-body label > input, .proj-modal-body label > select, .proj-modal-body label > textarea,
.proj-settings section > label > input, .proj-settings section > label > textarea { margin-top: 5px; font-weight: 400; }
.proj-modal-body .grid { gap: 0 14px; }
.proj-settings > section { margin-bottom: 16px; }
.proj-cols { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.proj-cols li { display: flex; gap: 8px; align-items: center; }
.proj-cols li > input[name=col_name] { max-width: 320px; }
.proj-cols li > span { min-width: 64px; }
.proj-teams { display: flex; flex-wrap: wrap; gap: 8px 18px; }
@media (max-width: 720px) { .board-col { flex-basis: 82vw; } }

/* Sign-in: system use notice, Microsoft sign-in, recovery codes */
.auth-card { max-width: 460px; }
.use-notice { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--border); border-left: 4px solid var(--warn);
  border-radius: 8px; background: var(--surface); font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
.use-notice h2 { font-size: 13px; margin: 0 0 6px; color: var(--text); text-transform: uppercase; letter-spacing: .04em; }
.use-notice p { margin: 0 0 8px; }
.use-notice p:last-child { margin-bottom: 0; color: var(--text); }
.auth-or { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--text-3); font-size: 12.5px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.sso-btn { justify-content: center; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; list-style: none; padding: 0; margin: 16px 0 0; }
.recovery-codes code { display: block; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2);
  font-family: var(--mono); font-size: 14px; text-align: center; letter-spacing: .05em; }

/* Idle sign-out warning */
.idle-warning { position: fixed; right: 20px; bottom: 20px; z-index: 1000; max-width: 380px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--warn); border-left-width: 4px; border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.idle-warning p { margin: 0 0 12px; font-size: 13.5px; }
.idle-warning [data-left] { display: block; margin-top: 4px; color: var(--warn); font-weight: 600; }

/* Formatting toolbar (Markdown) */
.md-toolbar { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 6px 8px;
  border: 1px solid var(--border); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--surface-2); }
.md-toolbar + textarea { border-top-left-radius: 0; border-top-right-radius: 0; }
.composer .md-toolbar { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.md-group { display: inline-flex; gap: 2px; }
.md-toolbar button { min-height: 28px; padding: 2px 8px; border: 1px solid transparent; border-radius: 6px; background: none;
  color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer; }
.md-toolbar button:hover, .md-toolbar button:focus-visible { background: var(--surface); border-color: var(--border); color: var(--text); }
.md-toolbar .md-b { font-weight: 800; }
.md-toolbar .md-i { font-style: italic; font-family: Georgia, serif; }
.md-toolbar .md-s { text-decoration: line-through; }
.md-toolbar .md-code { font-family: var(--mono); }
.md-toolbar .md-preview-btn { margin-left: auto; border-color: var(--border); background: var(--surface); }
.md-toolbar .md-preview-btn[aria-pressed=true] { color: var(--accent); border-color: var(--accent); }
.md-preview { min-height: 120px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 0 0 8px 8px; background: var(--surface); overflow: auto; }
.composer .md-preview { border: 0; border-radius: 0; }
.md table, .msg-body table, .article-body table { border-collapse: collapse; margin: 8px 0; }
.md th, .md td, .msg-body th, .msg-body td, .article-body th, .article-body td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; }
.md th, .msg-body th, .article-body th { background: var(--surface-2); }
.md pre, .msg-body pre, .article-body pre { padding: 10px 12px; border-radius: 6px; background: var(--surface-2); overflow-x: auto; font-family: var(--mono); font-size: 12.5px; }
.md blockquote, .msg-body blockquote, .article-body blockquote { margin: 8px 0; padding: 2px 12px; border-left: 3px solid var(--border); color: var(--text-2); }

/* Audit portal */
.audit-nav { border-bottom: 3px solid var(--warn); }
.audit-mark { padding: 3px 10px; margin-right: 12px; border-radius: 999px; background: var(--warn-soft); color: var(--warn);
  font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.audit-main { max-width: 1400px; margin: 0 auto; padding: 24px; }
.audit-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.audit-filters input, .audit-filters select { width: auto; min-width: 140px; flex: 1 1 140px; }
.audit-filters label.row { gap: 6px; flex: 0 0 auto; }
.audit-table td { vertical-align: top; font-size: 13px; }
.audit-outcome { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.audit-outcome.success { background: var(--ok-soft); color: var(--ok); }
.audit-outcome.failure { background: var(--warn-soft); color: var(--warn); }
.audit-outcome.denied { background: var(--bad-soft); color: var(--bad); }
.audit-pre { margin: 0; padding: 12px 14px; border-radius: 6px; background: var(--surface-2); font-family: var(--mono); font-size: 12.5px;
  white-space: pre-wrap; word-break: break-word; max-height: 480px; overflow: auto; }
.audit-perms { display: grid; gap: 10px; }
@media (max-width: 720px) { .audit-main { padding: 16px; } .recovery-codes { grid-template-columns: 1fr; } }

/* Sign-in captcha */
.captcha { display: grid; gap: 6px; }
.captcha img { border: 1px solid var(--border); border-radius: 6px; background: #f6f7fa; }
.captcha .row { gap: 8px; }
.captcha input { text-transform: uppercase; letter-spacing: .15em; font-family: var(--mono); }

/* Team directory */
.team-members { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.team-members li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.team-members li > .muted { flex-basis: 100%; padding-left: 36px; }
.team-dir { align-items: start; }
.team-dir .tag { margin: 2px 4px 2px 0; }

/* Dashboard tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.tiles > .card + .card { margin-top: 0; }
.tiles > * { min-width: 0; }
.tiles .tile-half { grid-column: span 2; }
.tiles .tile-wide { grid-column: 1 / -1; }
.tiles .stat .muted.small { margin-top: 2px; }
.trend { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; align-items: end; height: 130px; }
.trend-day { display: flex; flex-direction: column; height: 100%; }
.trend-bars { flex: 1; display: flex; gap: 2px; align-items: flex-end; }
.trend-bars span { flex: 1; min-height: 2px; border-radius: 3px 3px 0 0; }
.trend-bars .created, .legend.created { background: var(--accent); }
.trend-bars .resolved, .legend.resolved { background: var(--ok); }
.trend-lbl { text-align: center; font-size: 11px; color: var(--text-3, var(--text-2)); margin-top: 4px; }
.legend { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 4px 0 8px; }
.tile-list { list-style: none; margin: 0; padding: 0; }
.tile-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 10px 16px; border-top: 1px solid var(--border); }
.tile-list li:first-child { border-top: 0; }
.tile-order { display: flex; gap: 2px; }
.tile-edit { display: grid; gap: 8px; margin-top: 8px; max-width: 360px; }
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) { .tiles .tile-half { grid-column: 1 / -1; } }
