:root {
  --bg: #f4f5f6;
  --surface: #ffffff;
  --line: #e0e3e7;
  --text: #15181c;
  --muted: #57606b;
  --accent: #0e6b66;
  --accent-soft: #dcf0ee;
  --sidebar: #12191c;
  --on-sidebar: #e7ecee;
  --on-sidebar-muted: #94a1a8;
  --sidebar-active: #223035;
  --warning: #8f5309;
  --warning-soft: #fbebd3;
  --danger: #b0303f;
  --danger-soft: #f8e3e2;
  --gold: #7a5714;
  --gold-soft: #f3e7ce;
  --neutral: #57606b;
  --neutral-soft: #eceef0;
  --font: "IBM Plex Sans JP", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 14px/1.6 var(--font); }
h1 { margin: 0; font-size: 20px; font-weight: 700; }
h2 { margin: 0 0 12px; font-size: 14px; font-weight: 700; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.logo { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-family: var(--mono); font-size: 16px; font-weight: 500; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: 500 13px/1.4 var(--font);
  text-decoration: none;
  cursor: pointer;
}
.button:hover { border-color: var(--muted); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button.wide { width: 100%; margin-top: 8px; min-height: 42px; }
.link-button { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.link-button.danger { color: var(--danger); }
.link-button.on-dark { color: var(--on-sidebar-muted); font-size: 12px; }

label { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
input, select {
  display: block;
  width: 100%;
  min-height: 38px;
  margin-top: 4px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: 400 14px/1.4 var(--font);
}
input.mono { font-family: var(--mono); }
input.code { letter-spacing: .2em; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-tight { margin: 12px 0; }
.row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.row-actions { display: flex; gap: 12px; }

.auth { display: grid; place-items: center; min-height: 100%; padding: 32px 16px; }
.auth-card { width: min(360px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.auth-card h1 { margin-top: 16px; font-size: 18px; }
.auth-card > p { margin-top: 6px; }
.auth-card form { margin-top: 12px; }
.qr { display: block; width: 176px; height: 176px; margin: 12px auto; }
.recovery-codes { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 12px 0; padding: 12px; border-radius: 8px; background: var(--neutral-soft); list-style: none; font-size: 13px; }

.alert { padding: 8px 12px; border-radius: 6px; font-size: 13px; }
.alert.danger { background: var(--danger-soft); color: var(--danger); }

.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100%; }
.sidebar { display: flex; flex-direction: column; gap: 12px; padding: 16px 12px; background: var(--sidebar); color: var(--on-sidebar); }
.brand { padding: 4px 8px; text-decoration: none; }
.brand .logo { color: var(--on-sidebar); }
.tenant-box { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 6px; background: var(--sidebar-active); }
.tenant-label { color: var(--on-sidebar-muted); font-size: 11px; }
.tenant-slug { font-family: var(--mono); font-size: 13px; }
.env-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.env-switch button { min-height: 28px; border: 1px solid var(--sidebar-active); border-radius: 6px; background: none; color: var(--on-sidebar-muted); font: 500 12px/1 var(--font); cursor: pointer; }
.env-switch button.active { background: var(--sidebar-active); color: var(--on-sidebar); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--on-sidebar-muted); font-size: 13px; text-decoration: none; }
.nav-item:hover { color: var(--on-sidebar); }
.nav-item.active { background: var(--sidebar-active); color: var(--on-sidebar); }
.sidebar-foot { display: flex; flex-direction: column; gap: 8px; margin-top: auto; padding-top: 12px; }
.member { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--on-sidebar); text-decoration: none; }
.member.active { background: var(--sidebar-active); }
.member strong { display: block; font-size: 13px; }
.member small { display: block; color: var(--on-sidebar-muted); font-size: 11px; }
.sidebar-foot form { padding: 0 10px; }

.content { min-width: 0; padding: 24px 32px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.page-actions { display: flex; gap: 8px; }
.section-title { margin: 24px 0 8px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stat-label, .stat-note { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.4; }

.table-card { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th { padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
tr:last-child td { border-bottom: 0; }
td.mono { white-space: nowrap; }
.notes { display: flex; flex-wrap: wrap; gap: 4px; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip.success { background: var(--accent-soft); color: var(--accent); }
.chip.warning { background: var(--warning-soft); color: var(--warning); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.gold { background: var(--gold-soft); color: var(--gold); }
.chip.neutral { background: var(--neutral-soft); color: var(--neutral); }

.note { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.filters input, .filters select { width: auto; margin: 0; }
.filters .grow { flex: 1; min-width: 220px; }

.card { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.card.narrow { max-width: 480px; margin-bottom: 16px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; align-items: start; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; align-items: start; }
.webhook { margin-bottom: 12px; }
.code-card { padding: 16px; border-radius: 8px; background: var(--sidebar); color: var(--on-sidebar); }
.code-card pre { margin: 0; overflow-x: auto; font: 400 12px/1.7 var(--mono); }

.timeline { display: block; width: 100%; height: 34px; border-radius: 6px; }
.timeline-chat { fill: var(--neutral-soft); }
.timeline-voice { fill: var(--accent); }
.timeline-axis { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.legend { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.swatch.chat { background: var(--neutral-soft); border: 1px solid var(--line); }
.swatch.voice { margin-left: 8px; background: var(--accent); }
.events { margin: 0; padding: 0; list-style: none; }
.events li { display: flex; gap: 12px; padding: 3px 0; font-size: 13px; }
.events time { flex: none; color: var(--muted); font-size: 12px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }
.plain { margin: 0; padding: 0; list-style: none; font-size: 13px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar-foot { margin-top: 0; }
  .stats, .two-col, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 16px; }
}
