:root {
  --bg: #f2f4f7;
  --sidebar-width: 280px;
  --sidebar: #20262e;
  --sidebar-border: #343c46;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --border: #d7deea;
  --border-strong: #c0cad8;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --green: #16a34a;
  --yellow: #d97706;
  --red: #dc2626;
  --shadow: 0 8px 28px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Arial, "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  height: 100vh;
  overflow: auto;
  padding: 18px 14px;
  color: #e5e7eb;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
}
.brand {
  padding: 10px 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  margin-bottom: 14px;
}
.brand-kicker { font-size: 13px; color: #c7d2fe; font-weight: 700; }
.brand-title { margin-top: 6px; font-size: 28px; font-weight: 800; }
.brand-sub { margin-top: 6px; color: #94a3b8; font-size: 13px; line-height: 1.45; }
.menu { display: flex; flex-direction: column; gap: 10px; }
.menu-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  color: #e5e7eb;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .03);
  border-radius: 8px;
  transition: .18s ease;
}
.menu-item span { font-size: 16px; font-weight: 700; }
.menu-item small { color: #94a3b8; font-size: 12px; }
.menu-item:hover,
.menu-item.active {
  background: #29384b;
  border-color: #4c78a8;
}
.main-panel { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 54px;
  padding: 8px 18px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .04);
}
.topbar-group { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.inline-form { display: inline-flex; margin: 0; }
.inline-form button,
.control-form button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.inline-form button:disabled,
.control-form button:disabled {
  color: #e2e8f0;
  background: #64748b;
  border-color: #94a3b8;
  cursor: not-allowed;
  opacity: .72;
}
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  color: #334155;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
}
.pill.ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.pill.version { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }
.pill.warn { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.pill.protect { background: #ffedd5; border-color: #fdba74; color: #9a3412; }
.container { max-width: 1780px; margin: 0 auto; padding: 14px 18px 24px; }
.hero-panel,
.summary-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.hero-panel {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 22px 24px;
  margin-bottom: 16px;
}
.hero-panel h1 { margin: 0 0 6px; font-size: 22px; }
.hero-panel p { margin: 0; color: var(--muted); line-height: 1.5; }
.metric-strip { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.metric-item {
  min-width: 132px;
  padding: 10px 12px;
  background: #f8fbff;
  border: 1px solid #d6e4ff;
  border-radius: 8px;
}
.metric-item span { display: block; color: var(--muted); font-size: 12px; }
.metric-item strong { display: block; margin-top: 4px; font-size: 16px; }
.metric-item strong,
.summary-list strong,
.status-caption,
.status-note {
  overflow-wrap: anywhere;
}
.summary-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.summary-grid.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.summary-grid.three-up { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.summary-grid.four-up { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.summary-panel { padding: 18px 20px; }
.analysis-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.analysis-tab {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  color: #334155;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
}
.analysis-tab:hover,
.analysis-tab.active {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}
.policy-panel {
  min-height: 148px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 { margin: 0; font-size: 18px; }
.summary-list,
.feed-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.summary-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #edf2f7;
}
.summary-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.summary-list span { color: var(--muted); }
.feed-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.feed-item.ok { background: #f0fdf4; border-color: #bbf7d0; }
.feed-item.warn { background: #fff7ed; border-color: #fed7aa; }
.feed-item.danger { background: #fff1f1; border-color: #fecaca; }
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.pass { background: #dcfce7; color: #166534; }
.badge.review { background: #fef3c7; color: #92400e; }
.badge.block { background: #fee2e2; color: #991b1b; }
.badge.info { background: #dbeafe; color: #1d4ed8; }
.badge.subtle { background: #eef2f7; color: #475569; }
.panel-action { margin: 16px 0 0; }
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.action-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  font-weight: 700;
}
.notice {
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-weight: 700;
}
.status-card { min-height: 154px; }
.status-number {
  margin-top: 8px;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.05;
}
.status-number.small { font-size: 25px; }
.status-caption,
.status-note {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}
.control-form {
  display: grid;
  gap: 12px;
}
.control-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.control-form input,
.control-form select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
.center-control-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 16px;
}
.center-control-form { margin: 0; }
.engine-control-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  background: #1d4ed8;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
.engine-control-button.analysis_stop,
.engine-control-button.artifact_output_stop {
  background: #991b1b;
  border-color: #fecaca;
}
.engine-control-button.artifact_output_stop {
  background: #92400e;
  border-color: #fed7aa;
}
.engine-control-button.current_round_request {
  background: #0f766e;
  border-color: #99f6e4;
}
.engine-control-button.paused,
.engine-control-button:disabled {
  background: #64748b;
  border-color: #cbd5e1;
  color: #f8fafc;
  cursor: not-allowed;
  opacity: 0.72;
}
.center-control-state {
  margin-top: 4px;
}
.control-form .checkbox-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.control-form .checkbox-row input {
  width: auto;
  min-height: auto;
}
.account-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.account-table th,
.account-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
}
.account-table th {
  color: var(--muted);
  background: #f8fafc;
}
.table-panel { margin-bottom: 16px; }
.table-scroll {
  width: 100%;
  overflow-x: auto;
}
.table-scroll .account-table { min-width: 680px; }
.empty-cell {
  padding: 28px 12px !important;
  color: var(--muted);
  text-align: center !important;
}
.full-span { grid-column: 1 / -1; }
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.login-shell { width: min(460px, 100%); }
.login-panel {
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.login-panel h1 { margin: 6px 0 8px; }
.login-panel p { color: var(--muted); line-height: 1.5; }
.login-message {
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f1;
  color: #991b1b;
}

@media (min-width: 768px) and (max-width: 1100px) {
  :root { --sidebar-width: 240px; }
  .sidebar { padding: 14px 10px; }
  .brand { padding: 8px 10px 14px; }
  .brand-title { font-size: 24px; }
  .brand-sub { font-size: 12px; }
  .menu-item { padding: 10px 12px; }
  .container { padding: 12px 14px 22px; }
  .hero-panel { padding: 18px 20px; }
  .summary-panel { padding: 16px 18px; }
}

@media (max-width: 767px) {
  body { overflow-x: hidden; }
  .sidebar { position: static; width: auto; height: auto; }
  .main-panel { width: 100%; min-width: 0; margin-left: 0; }
  .summary-grid.two-up,
  .summary-grid.three-up,
  .summary-grid.four-up { grid-template-columns: 1fr; }
  .topbar {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
    padding: 8px 12px;
    overflow: hidden;
  }
  .topbar-group {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
  }
  .pill {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .container {
    width: 100%;
    min-width: 0;
    padding: 12px;
  }
  .hero-panel,
  .summary-panel {
    width: 100%;
    min-width: 0;
  }
  .hero-panel { flex-direction: column; padding: 18px; }
  .metric-strip {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
  }
  .metric-item {
    flex: 1 1 140px;
    min-width: 0;
  }
  .summary-list li {
    align-items: flex-start;
    flex-direction: column;
  }
  .table-scroll { max-width: 100%; }
}
