:root {
  color-scheme: light;
  font-family: "Yu Gothic UI", "Hiragino Sans", system-ui, sans-serif;
  --ink: #16233a;
  --muted: #6a768a;
  --line: #dfe6ef;
  --surface: #ffffff;
  --soft: #f4f7fb;
  --blue: #1f6feb;
  --navy: #143d7c;
  --green: #15825f;
  --green-soft: #e7f6f0;
  --shadow: 0 10px 28px rgba(22, 51, 90, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--soft); }
button, input { font: inherit; }
button { cursor: pointer; }
.topbar {
  min-height: 68px; padding: 0 28px; display: flex; align-items: center;
  justify-content: space-between; gap: 20px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong, .brand span { display: block; }
.brand span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.brand-mark {
  width: 54px; height: 54px; display: grid; place-items: center; border-radius: 15px;
  color: white; background: linear-gradient(135deg, #143d7c, #2386ef);
  font-size: 25px; font-weight: 800; box-shadow: var(--shadow);
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 10px; font-size: 17px; }
.page { max-width: 1360px; margin: 0 auto; padding: 30px; }
.heading-row, .panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 26px; }
h2 { margin: 0; font-size: 17px; }
.eyebrow { margin-bottom: 5px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.muted, .panel-heading p { color: var(--muted); }
.panel-heading p { margin: 5px 0 0; font-size: 12px; }
.sync, .safe-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px;
  color: var(--green); background: var(--green-soft); border-radius: 999px;
  font-size: 11px; font-weight: 800; white-space: nowrap;
}
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 24px 0; }
.stats article, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.stats article { padding: 18px; }
.stats span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.stats strong { display: block; margin-top: 5px; color: var(--navy); font-size: 28px; }
.panel { padding: 20px; }
.secondary {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 13px;
  color: var(--navy); background: var(--surface); font-weight: 700;
}
.secondary:hover { background: var(--soft); }
.worker-panel { margin-bottom: 16px; }
.worker-form { display: grid; gap: 8px; margin-top: 18px; }
.worker-form label { color: var(--muted); font-size: 12px; font-weight: 700; }
.worker-form > div { display: flex; gap: 10px; }
.worker-form input {
  flex: 1; min-width: 0; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--surface);
}
.primary-button {
  border: 0; border-radius: 9px; padding: 11px 16px; color: white;
  background: var(--blue); font-weight: 800;
}
.primary-button:disabled { cursor: wait; opacity: .55; }
.credential-box { margin-top: 14px; padding: 14px; border: 1px solid #a9d9c8; border-radius: 10px; background: var(--green-soft); }
.credential-box strong { color: var(--green); font-size: 12px; }
.credential-box p { margin: 5px 0 8px; color: var(--muted); font-size: 11px; }
.credential-box a { color: var(--navy); font-size: 12px; font-weight: 700; word-break: break-all; }
.compact-table { margin-top: 14px; }
.table-wrap { margin-top: 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 12px 10px; border-top: 1px solid #edf1f6; text-align: left; }
th { color: var(--muted); font-size: 11px; }
tbody tr[data-worker] { cursor: pointer; }
tbody tr[data-worker]:hover, tbody tr.is-selected { background: #edf5ff; }
.empty { padding: 26px; color: var(--muted); text-align: center; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 16px; margin-top: 16px; }
.meta { margin: 10px 0 15px; color: var(--muted); font-size: 11px; }
.transcript { display: grid; gap: 10px; max-height: 620px; overflow-y: auto; }
.event { padding: 12px 14px; border-radius: 10px; background: var(--soft); }
.event.assistant { background: #edf5ff; }
.event.tool { background: #f0f8f5; }
.event strong { display: block; margin-bottom: 5px; font-size: 11px; }
.event p { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.65; }
.empty-detail { padding: 24px; color: var(--muted); text-align: center; }
.signals { margin: 14px 0 0; }
.signals div { display: flex; justify-content: space-between; gap: 15px; padding: 12px 0; border-top: 1px solid #edf1f6; }
.signals dt { color: var(--muted); font-size: 12px; }
.signals dd { margin: 0; color: var(--navy); font-size: 12px; font-weight: 800; }
.notice { margin-top: 18px; padding: 14px; border-radius: 10px; background: #fff6df; }
.notice strong { color: #8a5d08; font-size: 12px; }
.notice p { margin: 5px 0 0; color: #755c31; font-size: 11px; line-height: 1.6; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #edf5ff, #f5f8fc); }
.login-card { width: min(430px, 100%); padding: 32px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 60px rgba(22, 51, 90, .15); }
.login-card .brand-mark { margin: 0 auto 16px; }
.login-card h1 { font-size: 22px; }
.login-form { display: grid; gap: 9px; margin-top: 22px; text-align: left; }
.login-form label { font-size: 12px; font-weight: 700; }
.login-form input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.login-form button {
  margin-top: 4px; padding: 12px; border: 0; border-radius: 9px;
  color: white; background: var(--blue); font-weight: 800;
}
.error-message { margin: 12px 0 0; color: #b53c45; font-size: 12px; }
.setup-body { min-height: 100vh; background: linear-gradient(180deg, #eef5ff 0, #f6f8fb 55%, #f4f7fb 100%); }
.setup-topbar {
  min-height: 68px; padding: 0 28px; display: flex; align-items: center;
  justify-content: space-between; gap: 18px; background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
}
.setup-page { width: min(1120px, 100%); margin: 0 auto; padding: 52px 28px 70px; }
.setup-hero { max-width: 760px; margin-bottom: 28px; }
.setup-hero h1 { font-size: clamp(27px, 4vw, 42px); line-height: 1.25; letter-spacing: -.03em; }
.setup-hero > p:last-child { color: var(--muted); line-height: 1.8; }
.setup-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .65fr); gap: 18px; align-items: start; }
.setup-consent { padding: 28px; }
.worker-chip {
  padding: 7px 10px; color: var(--navy); background: #edf5ff;
  border-radius: 999px; font-size: 11px; font-weight: 800;
}
.scope-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 24px 0; }
.scope-columns > div { padding: 18px; border-radius: 12px; background: var(--soft); }
.scope-columns h3 { margin: 0 0 12px; font-size: 13px; }
.scope-columns ul { margin: 0; padding: 0; list-style: none; }
.scope-columns li { position: relative; padding: 7px 0 7px 24px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.scope-columns li::before { position: absolute; left: 0; top: 7px; font-weight: 900; }
.check-list li::before { content: "✓"; color: var(--green); }
.no-list li::before { content: "—"; color: #9a6c12; }
.consent-check {
  display: flex; align-items: flex-start; gap: 11px; padding: 16px;
  border: 1px solid #b9cce5; border-radius: 11px; background: #f8fbff;
  font-size: 12px; font-weight: 700; line-height: 1.6;
}
.consent-check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--blue); }
.setup-actions { display: flex; gap: 10px; margin-top: 18px; }
.primary-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 11px 18px; border-radius: 10px; color: #fff; background: var(--blue);
  text-decoration: none; font-size: 13px; font-weight: 800;
  box-shadow: 0 8px 22px rgba(31, 111, 235, .24);
}
.primary-link.is-disabled { opacity: .4; pointer-events: none; box-shadow: none; }
.setup-actions .secondary:disabled { cursor: not-allowed; opacity: .45; }
.setup-note { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.setup-error { margin: 13px 0 0; color: #b53c45; font-size: 12px; font-weight: 700; }
.setup-steps { padding: 25px; }
.setup-steps ol { display: grid; gap: 4px; margin: 20px 0; padding: 0; list-style: none; }
.setup-steps li { display: flex; gap: 12px; padding: 13px 0; border-top: 1px solid #edf1f6; }
.setup-steps li > span {
  flex: 0 0 27px; width: 27px; height: 27px; display: grid; place-items: center;
  color: var(--blue); background: #edf5ff; border-radius: 50%; font-size: 11px; font-weight: 900;
}
.setup-steps li strong { font-size: 12px; }
.setup-steps li p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.setup-security { padding: 14px; border-radius: 10px; background: #fff6df; }
.setup-security strong { color: #8a5d08; font-size: 11px; }
.setup-security p { margin: 5px 0 0; color: #755c31; font-size: 11px; line-height: 1.55; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 15px);
  padding: 11px 15px; color: white; background: #173252; border-radius: 9px;
  opacity: 0; pointer-events: none; transition: .15s ease; font-size: 12px; font-weight: 700;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 850px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .detail-layout { grid-template-columns: 1fr; }
  .setup-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .page { padding: 20px 14px; }
  .heading-row { flex-direction: column; }
  .stats { grid-template-columns: 1fr 1fr; }
  .panel { padding: 15px; }
  .worker-form > div { flex-direction: column; }
  .setup-topbar { padding: 0 14px; }
  .setup-page { padding: 34px 14px 52px; }
  .setup-consent, .setup-steps { padding: 19px; }
  .scope-columns { grid-template-columns: 1fr; }
  .setup-actions { flex-direction: column; }
}
