:root {
  --black: #0B0B0B;
  --black-2: #1C1C1C;
  --yellow: #FFD400;
  --yellow-soft: #FFF6CC;
  --ink: #0B0B0B;
  --muted: #4B5563;
  --line: #E4E6EB;
  --bg: #F4F5F7;
  --red: #B91C1C;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, sans-serif; color: var(--ink); background: var(--bg); }
button, input, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* ---------- layout ---------- */
.app { display: flex; height: 100vh; }
.sidebar { width: 248px; flex: none; background: var(--black); color: #E5E7EB; padding: 20px 14px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.panes { flex: 1; display: flex; min-height: 0; }
.pane-list { width: 340px; flex: none; background: #fff; border-right: 1px solid var(--line); overflow-y: auto; }
.pane-chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.pane-details { width: 300px; flex: none; background: #fff; border-left: 1px solid var(--line); overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- sidebar ---------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 700; font-size: 17px; color: #fff; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--yellow); display: inline-flex; align-items: center; justify-content: center; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #9CA3AF; padding: 8px 10px 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 10px; border: 0; border-radius: 8px; text-align: left; background: transparent; color: #D1D5DB; font-size: 14px; }
.nav-item:hover { background: var(--black-2); }
.nav-item.active { background: var(--yellow); color: var(--black); }
.nav-item.parent-active { color: #fff; font-weight: 700; }
.nav-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.nav-item .label { flex: 1; }
.nav-item .demo { font-size: 10px; color: #9CA3AF; border: 1px solid #3A3A3A; border-radius: 4px; padding: 0 4px; }
.nav-item.active .demo { color: var(--black); border-color: var(--black); }
.nav-item .chev { transition: transform .15s; flex: none; }
.nav-item[aria-expanded="true"] .chev { transform: rotate(180deg); }
.subnav { display: flex; flex-direction: column; gap: 2px; margin: 0 0 6px 15px; padding-left: 10px; border-left: 1px solid #333; }
.subnav .nav-item { min-height: 40px; font-size: 13px; font-weight: 500; }
.badge { min-width: 20px; padding: 2px 7px; border-radius: 10px; font-size: 12px; font-weight: 600; text-align: center; background: var(--yellow); color: var(--black); }
.nav-item.active .badge { background: var(--black); color: var(--yellow); }
.badge.red, .nav-item.active .badge.red { background: #DC2626; color: #fff; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid #262626; display: flex; flex-direction: column; gap: 4px; }
.foot-btn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: #D1D5DB; font-size: 14px; font-weight: 500; text-decoration: none; text-align: left; }
.foot-btn:hover { background: var(--black-2); color: #fff; }
.foot-btn-accent { border: 1px solid #3A3A3A; color: var(--yellow); }
.foot-btn-accent:hover { color: var(--yellow); border-color: var(--yellow); }

/* ---------- top bar ---------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 14px 24px; background: var(--black); border-bottom: 3px solid var(--yellow); }
.search { flex: 1 1 280px; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 10px; background: #F9FAFB; }
.search input { flex: 1; border: 0; outline: none; background: transparent; font-size: 14px; }
.top-stats { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.chip { padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.chip-yellow { background: var(--yellow); color: var(--black); }
.chip-orange { background: #FFF1E6; color: #9A3412; }
.btn-dark { min-height: 36px; padding: 0 14px; border: 1px solid #3A3A3A; border-radius: 8px; background: var(--black-2); color: #fff; font-weight: 600; font-size: 13px; }
.btn-primary { min-height: 46px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--yellow); color: var(--black); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-outline { min-height: 44px; padding: 0 14px; border: 1px solid #D5D8DE; border-radius: 10px; background: #fff; font-weight: 500; color: var(--ink); }
.btn-black { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--black); color: var(--yellow); font-weight: 600; }
button:disabled { opacity: .55; cursor: default; }

/* ---------- list ---------- */
.list-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; background: #fff; border-bottom: 1px solid var(--line); }
.list-head h2 { margin: 0; font-size: 15px; }
.list-head span { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 12px; width: 100%; padding: 14px 18px; border: 0; border-bottom: 1px solid #EEF0F3; text-align: left; background: #fff; }
.row:hover { background: #FAFAFA; }
.row.selected { background: var(--yellow-soft); }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-top { display: flex; gap: 6px; align-items: center; }
.row-name { flex: 1; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.unread .row-name { font-weight: 700; }
.row-time { font-size: 12px; color: #6B7280; }
.row-meta { font-size: 12px; color: var(--muted); }
.row-preview { font-size: 13px; color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.tag-incident { background: #FEE2E2; color: #991B1B; font-weight: 700; }
.tag-due { background: #FFF1E6; color: #9A3412; }
.tag-new { background: var(--yellow); color: var(--black); }
.tag-done { background: #ECFDF3; color: #14532D; }
.empty { padding: 32px 20px; font-size: 14px; color: var(--muted); text-align: center; }

/* ---------- chat ---------- */
.empty-state { margin: auto; color: var(--muted); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 22px; background: #fff; border-bottom: 1px solid var(--line); }
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .name { font-size: 16px; font-weight: 600; }
.chat-head .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-btn { display: none; width: 44px; height: 44px; border: 0; background: transparent; }
.incident-box { margin: 16px 22px 0; padding: 14px 16px; border-radius: 12px; background: #FEF2F2; border: 1px solid #FCA5A5; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.incident-box .txt { flex: 1 1 240px; min-width: 0; }
.incident-box .ttl { font-size: 14px; font-weight: 700; color: #7F1D1D; }
.incident-box .meta { font-size: 12px; color: #7F1D1D; margin-top: 2px; }
.incident-box .hint { font-size: 12px; color: #374151; margin-top: 4px; }
.incident-box.closed { background: #ECFDF3; border-color: #A7E3BE; }
.incident-box.closed .ttl, .incident-box.closed .meta { color: #14532D; }
.messages { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; flex-direction: column; gap: 4px; max-width: 72%; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 11px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); background: #fff; }
.msg.out .bubble { background: var(--yellow); border-color: #E6BF00; }
.msg.failed .bubble { background: #FEF2F2; border-color: #FCA5A5; }
.msg-meta { font-size: 11px; color: #6B7280; }
.msg.failed .msg-meta { color: var(--red); font-weight: 600; }
.composer { padding: 12px 22px 18px; background: #fff; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick button { min-height: 32px; padding: 6px 12px; border: 1px solid #D5D8DE; border-radius: 16px; background: #fff; font-size: 12px; color: #374151; }
.compose-row { display: flex; gap: 10px; align-items: flex-end; }
.compose-row textarea { flex: 1; min-height: 46px; max-height: 160px; resize: vertical; padding: 12px 14px; border: 1px solid #D5D8DE; border-radius: 10px; font-size: 14px; outline: none; }
.compose-row textarea:focus { border-color: var(--black); }
.compose-foot { font-size: 12px; color: var(--muted); }
.no-reply { padding: 16px 22px; background: #FFF8EB; border-top: 1px solid #F3D9A4; font-size: 13px; color: #78350F; }

/* ---------- details ---------- */
.sec-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #6B7280; margin-bottom: 10px; }
.item-name { font-size: 15px; font-weight: 600; line-height: 1.35; }
.item-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; font-size: 13px; }
.facts dt { color: #6B7280; }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.actions { display: flex; flex-direction: column; gap: 8px; }
.note textarea { width: 100%; min-height: 80px; padding: 10px 12px; border: 1px solid #D5D8DE; border-radius: 10px; font-size: 13px; resize: vertical; background: var(--bg); }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--black); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
.toast.show { opacity: 1; }
.toast.error { background: var(--red); }

/* ---------- login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--black); }
.login-card { width: min(380px, 92vw); background: #fff; border-radius: 16px; padding: 28px; border-top: 6px solid var(--yellow); }
.login-card .brand { color: var(--black); padding: 0; }
.login-card h1 { font-size: 22px; margin: 20px 0 16px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.login-card input { width: 100%; height: 46px; padding: 0 14px; border: 1px solid #D5D8DE; border-radius: 10px; }
.login-card .btn-primary { width: 100%; margin-top: 8px; }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* ---------- smaller screens ---------- */
@media (max-width: 1200px) { .pane-details { display: none; } }
@media (max-width: 860px) {
  .app { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: 100%; max-height: none; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav > div { flex: 1 1 160px; }
  .sidebar-foot { margin-top: 0; }
  .panes { flex-direction: column; }
  .pane-list { width: 100%; max-height: none; }
  .pane-chat { display: none; min-height: 80vh; }
  body.show-chat .pane-list, body.show-chat .sidebar, body.show-chat .topbar { display: none; }
  body.show-chat .pane-chat { display: flex; }
  .back-btn { display: inline-flex; align-items: center; justify-content: center; }
  .msg { max-width: 88%; }
}

/* ---------- accounts page ---------- */
.accounts-page { background: var(--bg); min-height: 100vh; }
.accounts-page .topbar { justify-content: space-between; }
.accounts-page .brand { text-decoration: none; }
.btn-link { text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.accounts-main { max-width: 1040px; margin: 0 auto; padding: 32px 24px 64px; display: flex; flex-direction: column; gap: 28px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.section-title { margin: 0 0 12px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #6B7280; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.card-head .grow { flex: 1 1 220px; min-width: 0; }
.card-head h3 { margin: 0; font-size: 18px; }
.card-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.logo { width: 44px; height: 44px; border-radius: 12px; flex: none; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-live { background: #ECFDF3; color: #15803D; }
.pill-demo { background: #F3F4F6; color: #4B5563; }
.pill-soon { background: #FFF6CC; color: #6B5300; }
.pill-err { background: #FEF2F2; color: var(--red); }
.callout { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: #FFFBEB; border: 1px solid #FCE7A6; font-size: 14px; color: #5C4A00; }
.callout ol { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.callout code, .card code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: rgba(0, 0, 0, .06); padding: 1px 6px; border-radius: 5px; }
.acc-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.acc { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: #FCFCFD; }
.acc .initials { width: 38px; height: 38px; border-radius: 50%; background: var(--black); color: var(--yellow); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.acc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.acc-info strong { font-size: 15px; }
.acc-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.acc-empty { padding: 18px; border: 1px dashed #D5D8DE; border-radius: 12px; text-align: center; color: var(--muted); font-size: 14px; }
.tip { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.mini { display: flex; flex-direction: column; gap: 12px; }
.mini .row1 { display: flex; align-items: center; gap: 12px; }
.mini-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.mini h4 { margin: 0; font-size: 16px; }
.mini p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.mini.soon { opacity: .75; }
.btn-danger-ghost { min-height: 38px; padding: 0 14px; border: 1px solid #E5E7EB; border-radius: 10px; background: #fff; color: #374151; font-weight: 500; font-size: 13px; }
.btn-danger-ghost:hover, .btn-danger-ghost.armed { border-color: #FCA5A5; color: var(--red); background: #FEF2F2; }
.flash { padding: 14px 16px; border-radius: 12px; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.flash[hidden] { display: none; }
.flash.ok { background: #ECFDF3; color: #14532D; border: 1px solid #A7E3BE; }
.flash.err { background: #FEF2F2; color: var(--red); border: 1px solid #FCA5A5; }
@media (max-width: 640px) { .accounts-main { padding: 20px 14px 48px; } .page-head h1 { font-size: 24px; } }
