:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-alt: #f0f1f5;
  --border: #dfe2e8;
  --text: #1c2129;
  --text-muted: #5c6472;
  --primary: #3457d5;
  --primary-hover: #2941ab;
  --primary-text: #ffffff;
  --success: #1f9d55;
  --success-bg: #e8f8ee;
  --danger: #d64545;
  --danger-bg: #fdeaea;
  --warning: #a86b00;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 33, 0.06), 0 1px 8px rgba(20, 24, 33, 0.04);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1b1f26;
    --surface-alt: #21262f;
    --border: #2c323c;
    --text: #e7e9ee;
    --text-muted: #9aa2b1;
    --primary: #6d8bff;
    --primary-hover: #8aa1ff;
    --primary-text: #0d1117;
    --success: #3fcf7f;
    --success-bg: #103823;
    --danger: #ff6b6b;
    --danger-bg: #3a1414;
    --warning: #e0a840;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 8px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--primary);
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--text);
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
}

.main-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.main-nav a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 500;
}

.main-nav a:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.main-nav a.active {
  background: var(--primary);
  color: var(--primary-text);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.page-title {
  margin: 0 0 6px;
  font-size: 1.6rem;
}

.page-subtitle {
  color: var(--text-muted);
  margin: 0 0 28px;
  max-width: 70ch;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
  margin-top: 10px;
}

section.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

section.panel h2 {
  margin-top: 0;
  font-size: 1.15rem;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

section.panel .panel-desc {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: -4px 0 16px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
  flex: 1 1 220px;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="tel"],
input[type="url"],
textarea,
select {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

input[readonly] {
  background: var(--surface-alt);
  color: var(--text-muted);
}

input:disabled,
button:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 70px;
}

.btn {
  font: inherit;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 6px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-text);
  cursor: pointer;
  transition: background 0.12s ease;
}

.btn:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn.secondary:hover:not(:disabled) {
  background: var(--surface-alt);
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
}

.btn.small {
  padding: 5px 10px;
  font-size: 0.82rem;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.checkbox-row,
.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
}

.checkbox-group,
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.output {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-radius: 6px;
  font-size: 0.88rem;
  font-family: var(--mono);
  color: var(--text);
  min-height: 18px;
  word-break: break-word;
}

.output.empty {
  color: var(--text-muted);
  font-family: inherit;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: 0.15s;
}

.toggle .slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.15s;
}

.toggle input:checked + .slider {
  background: var(--primary);
}

.toggle input:checked + .slider::before {
  transform: translateX(20px);
}

.progress-bar {
  width: 100%;
  height: 14px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.2s ease;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: var(--surface-alt);
  color: var(--text);
}

.drag-item {
  display: inline-block;
  padding: 10px 16px;
  background: var(--primary);
  color: var(--primary-text);
  border-radius: 6px;
  cursor: grab;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 16px;
  user-select: none;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data-table th,
table.data-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}

table.data-table th {
  cursor: pointer;
  user-select: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

table.data-table th:hover {
  color: var(--text);
}

table.data-table th .arrow {
  opacity: 0.5;
  font-size: 0.75em;
}

.tooltip-wrap {
  position: relative;
  display: inline-block;
}

.tooltip-wrap .tooltip-bubble {
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.tooltip-wrap:hover .tooltip-bubble {
  opacity: 1;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
}

.modal-box h3 {
  margin-top: 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

.scroll-list {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.scroll-list div {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.scroll-list div:last-child {
  border-bottom: none;
}

.scroll-list div:hover {
  background: var(--surface-alt);
}

iframe.demo-frame {
  width: 100%;
  height: 140px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.alert-box {
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-top: 14px;
}

.alert-box.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success);
}

.alert-box.error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.login-wrap {
  max-width: 380px;
  margin: 40px auto;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 1.3rem;
}

.login-card .sub {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0 0 24px;
}

.login-card .field {
  margin-bottom: 16px;
}

.pw-wrap {
  position: relative;
}

.pw-wrap input {
  padding-right: 60px;
}

.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

.success-wrap {
  max-width: 460px;
  margin: 60px auto;
  text-align: center;
}

.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.id-tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 1px 6px;
  border-radius: 4px;
}

footer.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 30px 20px 50px;
}
