/* Signalpost dashboard — design system
   Palette: spruce (brand), signal amber (accent), warm neutrals. */
:root {
  --spruce-900: #0b2b2c;
  --spruce-800: #0f3d3e;
  --spruce-700: #155254;
  --spruce-600: #1c6b6d;
  --spruce-100: #e3f0ef;
  --amber-500: #f0a03c;
  --amber-600: #d9831a;
  --amber-100: #fdf1e1;
  --amber-700: #8a5210;
  --green-700: #1e6b38;
  --red-700: #9e2f1c;
  --blue-700: #1f4f94;
  --red-600: #c2412d;
  --red-100: #fbe7e3;
  --green-600: #2f8a4c;
  --green-100: #e4f4e8;
  --blue-600: #2c64b5;
  --blue-100: #e6eefa;
  --ink: #1d2424;
  --ink-2: #4d5757;
  --ink-3: #5d6767;
  --line: #e2e6e5;
  --surface: #ffffff;
  --canvas: #f5f6f4;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 32, 32, .06), 0 4px 16px rgba(16, 32, 32, .05);
  --focus: 0 0 0 3px rgba(240, 160, 60, .55);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e7ecec; --ink-2: #b4bebe; --ink-3: #8a9696; --line: #2c3838;
    --surface: #172021; --canvas: #101718; --spruce-100: #183536; --amber-100: #3a2c17;
    --red-100: #3d1e19; --green-100: #173322; --blue-100: #1a2a42;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
    --amber-700: #f3c37e; --green-700: #8fd3a5; --red-700: #f2a99b; --blue-700: #a9c6f0;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased; }
a { color: var(--spruce-600); }
@media (prefers-color-scheme: dark) { a { color: #6cc2c2; } }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: none; box-shadow: var(--focus); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h2 { font-size: 1.1rem; }
code { font-family: var(--mono); font-size: .85em; background: var(--canvas); padding: 1px 5px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--amber-500); color: #000; padding: 8px 12px; z-index: 100; border-radius: 6px; }
.skip-link:focus { left: 8px; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.text-warn { color: var(--amber-700); }
.empty { color: var(--ink-3); padding: 18px 0; text-align: center; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; color: inherit; text-decoration: none; font-size: 1.05rem; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px 8px 8px 2px; background: linear-gradient(135deg, var(--amber-500) 0 45%, transparent 45%), var(--spruce-600); box-shadow: inset 0 0 0 2px rgba(255,255,255,.18); }
.brand-lg { font-size: 1.35rem; margin-bottom: 18px; color: var(--ink); }

/* Shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--spruce-900); color: #d5e4e3; display: flex; flex-direction: column; padding: 16px 12px; gap: 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { color: #fff; padding: 4px 8px; }
.ws-switch select { width: 100%; background: var(--spruce-800); color: #fff; border: 1px solid var(--spruce-700); border-radius: var(--radius-sm); padding: 8px; font: inherit; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: #c7dbda; text-decoration: none; font-size: .93rem; }
.nav-item:hover { background: var(--spruce-800); color: #fff; }
.nav-item.active { background: var(--spruce-700); color: #fff; box-shadow: inset 3px 0 0 var(--amber-500); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--spruce-800); padding-top: 10px; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 1.2rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb { font-size: .78rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-link { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--spruce-100); color: var(--spruce-700); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.content { padding: 24px; max-width: 1280px; width: 100%; }
.menu-btn { display: none; }

/* Icons (CSS-drawn, no external assets) */
.ico { width: 16px; height: 16px; display: inline-block; flex: none; border: 2px solid currentColor; border-radius: 4px; opacity: .85; }
.ico-inbox { border-radius: 2px 2px 5px 5px; }
.ico-pulse { border-radius: 50%; }
.ico-people { border-radius: 50% 50% 4px 4px; }
.ico-shield { border-radius: 2px 2px 8px 8px; }
.ico-globe { border-radius: 50%; border-style: dotted; }
.ico-team { border-radius: 50%; box-shadow: 5px 0 0 -2px currentColor; }
.ico-lock { border-radius: 3px; border-top-width: 5px; }
.ico-list { border-width: 2px 0; }
.ico-gear { border-radius: 50%; border-style: dashed; }
.ico-plus, .ico-menu { border: 0; position: relative; }
.ico-plus::before, .ico-plus::after, .ico-menu::before, .ico-menu::after { content: ""; position: absolute; background: currentColor; }
.ico-plus::before { left: 7px; top: 1px; width: 2px; height: 14px; }
.ico-plus::after { top: 7px; left: 1px; height: 2px; width: 14px; }
.ico-menu { border-top: 2px solid; border-bottom: 2px solid; height: 14px; }
.ico-menu::before { top: 4px; left: 0; right: 0; height: 2px; }
.ico-server { border-radius: 2px; border-width: 2px 2px 5px; }

/* Cards & layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card.narrow { max-width: 560px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.two-col > .card { margin-bottom: 0; }
.two-col + .card, .two-col + .two-col { margin-top: 20px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.row-form .grow { flex: 1; min-width: 200px; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: .8rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.stat-note { font-size: .78rem; color: var(--ink-3); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.list li:first-child { border-top: 0; }
.list li > a, .list li > span { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 2px; color: inherit; text-decoration: none; flex: 1; }
.list li > a:hover { background: var(--canvas); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab { padding: 8px 14px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--ink); border-bottom-color: var(--amber-500); font-weight: 600; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-weight: 600; font-size: .9rem; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check label { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], input[type=color], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #c9d0cf; border-radius: var(--radius-sm); padding: 9px 11px; width: 100%; }
input[type=color] { padding: 2px; height: 40px; width: 80px; }
textarea { resize: vertical; }
.has-error input, .has-error textarea, .has-error select { border-color: var(--red-600); }
.field-error { color: var(--red-600); font-size: .85rem; margin: 0; }
.hint { color: var(--ink-3); font-size: .83rem; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
.copy-row { display: flex; gap: 8px; margin-top: 8px; }
.copy-row input { font-family: var(--mono); font-size: .85rem; }
.secret-box { font-family: var(--mono); font-size: 1.25rem; letter-spacing: .06em; padding: 12px 14px; background: var(--canvas); border: 1px dashed var(--amber-600); border-radius: var(--radius-sm); user-select: all; word-break: break-all; }

/* Buttons */
.btn { font: inherit; font-weight: 600; font-size: .9rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid #c9d0cf; background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--canvas); }
.btn-primary { background: var(--spruce-700); border-color: var(--spruce-700); color: #fff; }
.btn-primary:hover { background: var(--spruce-800); }
.btn-danger { color: var(--red-600); border-color: #e3b5ad; }
.btn-danger:hover { background: var(--red-100); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { background: transparent; border: 0; padding: 6px; cursor: pointer; color: var(--ink); border-radius: var(--radius-sm); }

/* Notices & pills */
.notice { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; }
.notice p { margin: 0 0 6px; }
.notice-ok { background: var(--green-100); border-color: #b9dfc4; }
.notice-error { background: var(--red-100); border-color: #ecc0b8; }
.notice-info { background: var(--blue-100); border-color: #c4d6f1; }
.notice-warn { background: var(--amber-100); border-color: #f0d3a8; }
.pill { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--canvas); color: var(--ink-2); border: 1px solid var(--line); text-transform: none; white-space: nowrap; }
.pill-open, .pill-active, .pill-connected, .pill-ok { background: var(--green-100); color: var(--green-700); border-color: transparent; }
.pill-pending, .pill-warn, .pill-unverified { background: var(--amber-100); color: var(--amber-700); border-color: transparent; }
.pill-closed, .pill-revoked, .pill-disconnected { background: var(--canvas); color: var(--ink-3); }
.pill-suspended, .pill-blocked, .pill-danger { background: var(--red-100); color: var(--red-700); border-color: transparent; }
.pill-mode { background: var(--blue-100); color: var(--blue-700); border-color: transparent; }
.pill-observed { background: var(--blue-100); color: var(--blue-700); border-color: transparent; }
.pill-submitted { background: var(--green-100); color: var(--green-700); border-color: transparent; }
.pill-inferred { background: var(--amber-100); color: var(--amber-700); border-color: transparent; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; }

/* Plain (auth) layout */
.plain-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; background: radial-gradient(circle at 20% 0%, var(--spruce-100), transparent 55%), var(--canvas); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card.wide { max-width: 560px; }
.auth-links { text-align: center; font-size: .9rem; margin: 14px 0 0; }

/* Inbox */
.inbox { display: grid; grid-template-columns: 330px 1fr 300px; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); height: calc(100vh - 120px); min-height: 520px; overflow: hidden; }
.inbox-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.inbox-filters { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.inbox-filters .row { display: flex; gap: 6px; }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv { display: block; width: 100%; text-align: left; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; font: inherit; color: inherit; }
.conv:hover { background: var(--canvas); }
.conv[aria-current="true"] { background: var(--spruce-100); box-shadow: inset 3px 0 0 var(--spruce-600); }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-meta { font-size: .78rem; color: var(--ink-3); display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.unread-dot { width: 9px; height: 9px; background: var(--amber-500); border-radius: 50%; display: inline-block; flex: none; margin-top: 6px; }
.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.thread-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.thread-head h2 { margin: 0; font-size: 1rem; flex: 1; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--canvas); }
.msg { max-width: 78%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg-visitor { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-operator { align-self: flex-end; background: var(--spruce-700); color: #fff; border-bottom-right-radius: 4px; }
.msg-system { align-self: center; background: transparent; color: var(--ink-3); font-size: .82rem; font-style: italic; }
.msg-meta { display: block; font-size: .72rem; opacity: .75; margin-top: 4px; }
.msg-failed { box-shadow: 0 0 0 2px var(--red-600); }
.composer { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 160px; }
.profile-panel { border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; font-size: .9rem; }
.profile-panel h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin: 16px 0 6px; }
.profile-panel dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
.profile-panel dt { color: var(--ink-3); }
.profile-panel dd { margin: 0; overflow-wrap: anywhere; }
.state { padding: 30px 16px; text-align: center; color: var(--ink-3); }
.state-error { color: var(--red-600); }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 4px 0 8px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--spruce-600); }
.legend { display: flex; gap: 8px; flex-wrap: wrap; font-size: .8rem; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--green-600); box-shadow: 0 0 0 3px var(--green-100); }
.recent-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }
.preview-box { border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px; background: var(--canvas); }

/* Responsive */
@media (max-width: 1100px) {
  .inbox { grid-template-columns: 290px 1fr; }
  .profile-panel { display: none; }
  .inbox.show-profile .profile-panel { display: block; position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 90vw); background: var(--surface); z-index: 30; box-shadow: var(--shadow); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 40; }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .two-col { grid-template-columns: 1fr; }
  .two-col > .card { margin-bottom: 20px; }
  .content { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .user-name { display: none; }
  .inbox { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .inbox .thread { display: none; height: 75vh; }
  .inbox.show-thread .thread { display: flex; }
  .inbox.show-thread .inbox-list { display: none; }
  .msg { max-width: 90%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.two-col.spaced { margin-top: 14px; }
.thread-head select { width: auto; }
.thread-head [data-back] { display: none; }
@media (max-width: 860px) { .thread-head [data-back] { display: inline-flex; } }
.thread-head .pill { text-transform: capitalize; }
.narrow-form { max-width: 460px; }
.nav-button { background: transparent; border: 0; width: 100%; text-align: left; font: inherit; cursor: pointer; }
.recovery-codes { font-family: var(--mono); background: var(--surface); padding: 10px 14px; border-radius: var(--radius-sm); columns: 2; }
