:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e5e9f0;
  --border-strong: #d5dce6;
  --text: #111827;
  --muted: #64748b;
  --brand: #16a34a;
  --brand-dark: #15803d;
  --brand-soft: #ecfdf3;
  --meta-blue: #1877f2;
  --meta-blue-dark: #1463cc;
  --warn-soft: #fff7ed;
  --warn-text: #b45309;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
  font-size: 16px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.top-links { display: flex; align-items: center; gap: 16px; font-size: 13px; }

.container {
  width: 100%;
  max-width: 1080px;
  margin: 24px auto;
  padding: 0 20px 48px;
  flex: 1;
}
.legal-page { max-width: 820px; margin: 28px auto; padding: 0 20px 48px; width: 100%; }
.legal-card h1 { margin-top: 0; font-size: 24px; }
.legal-card h2 { margin-top: 22px; font-size: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card h2 { margin: 0 0 8px; font-size: 17px; }
.card h3 { margin: 0 0 8px; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.auth-wrap { max-width: 440px; margin: 40px auto; }
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tab.active {
  color: var(--brand-dark);
  border-bottom-color: var(--brand);
}

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: 13px; }
.field input, .field select, .field textarea {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  background: #fff;
}
.field textarea { min-height: 84px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 220px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 11px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff;
  font-weight: 600;
  cursor: pointer;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-meta { background: var(--meta-blue); border-color: var(--meta-blue); color: #fff; }
.btn-meta:hover:not(:disabled) { background: var(--meta-blue-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eef2f7;
  color: #334155;
}
.pill-ok { background: var(--brand-soft); color: var(--brand-dark); }
.pill-warn { background: var(--warn-soft); color: var(--warn-text); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }

.notice {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #f8fafc;
  margin-top: 10px;
  font-size: 13px;
}
.notice-ok { background: var(--brand-soft); border-color: #bbf7d0; color: var(--brand-dark); }
.notice-warn { background: var(--warn-soft); border-color: #fed7aa; color: var(--warn-text); }
.notice-danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  overflow-x: auto;
  white-space: pre;
}

.msg-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.msg-item {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.msg-item.outbound {
  align-self: flex-end;
  background: #dcfce7;
  border-color: #bbf7d0;
}
.msg-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.footer {
  padding: 14px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--panel);
}
