:root {
  --bg: #F4F3EE;
  --card: #FFFFFF;
  --text: #1A1B1C;
  --muted: #6B7280;
  --border: #E4E3DD;
  --accent: #0D9488;
  --accent-dark: #0F766E;
  --accent-soft: rgba(13, 148, 136, 0.12);
  --danger: #EA6668;
  --success: #2E9E5B;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Roboto', 'PingFang SC', 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Navbar ===== */
.nav {
  background: #0F2A43;
  color: #fff;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  min-height: 60px;
  gap: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.brand:hover { text-decoration: none; }
.brand svg { display: block; }
.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.lang-switch { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.lang-switch a { color: #BFDBFE; }
.lang-switch a:hover { color: #fff; text-decoration: none; }
.lang-switch .divider { color: rgba(255, 255, 255, 0.4); }
.nav-home { color: #BFDBFE; font-size: 14px; font-weight: 600; }
.nav-home:hover { color: #fff; text-decoration: none; }
.nav-actions { display: flex; gap: 10px; align-items: center; }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, transform 0.05s ease;
  text-align: center;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, 0.55); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }
.btn-dark-ghost { background: transparent; border-color: var(--accent); color: var(--accent-dark); }
.btn-dark-ghost:hover { background: var(--accent-soft); }
.btn-lg { padding: 13px 26px; font-size: 16px; border-radius: 12px; }

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 72px 24px 48px;
  background: linear-gradient(180deg, #EAF7F4 0%, var(--bg) 100%);
}
.hero-tagline {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.hero h1 {
  font-size: 42px;
  font-weight: 800;
  max-width: 760px;
  margin: 0 auto 18px;
  color: #0F2A43;
  line-height: 1.25;
}
.hero .subtitle {
  font-size: 17px;
  color: #374151;
  max-width: 680px;
  margin: 0 auto 30px;
}
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ===== Features ===== */
.features {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 24px 48px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.card {
  flex: 1 1 280px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.card h3 { font-size: 17px; margin-bottom: 8px; color: #0F2A43; }
.card p { font-size: 14px; color: var(--muted); }
.card-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}

/* ===== Auth / Panel layout ===== */
.auth-wrap, .panel-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 20px;
}
.auth-card, .panel-card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}
.panel-card { max-width: 680px; }

/* ===== Form ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.form-actions { margin-top: 22px; }
.form-actions .btn { width: 100%; }

.alert {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 18px;
}
.alert-error { background: rgba(234, 102, 104, 0.12); color: #B42318; border: 1px solid rgba(234, 102, 104, 0.35); }
.alert-success { background: rgba(46, 158, 91, 0.12); color: #1E7A46; border: 1px solid rgba(46, 158, 91, 0.35); }

.auth-links { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }

/* ===== Panel ===== */
.panel-header {
  width: 100%;
  max-width: 680px;
  margin-bottom: 22px;
}
.panel-header h1 { font-size: 26px; color: #0F2A43; }
.panel-header .welcome { color: var(--muted); font-size: 14px; margin-top: 4px; }
.panel-params .panel-title { font-size: 18px; color: #0F2A43; margin-bottom: 6px; }
.panel-params .panel-desc { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.param-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.param-item { flex: 1 1 300px; min-width: 0; }
.param-item .form-control { font-family: 'SFMono-Regular', Consolas, Menlo, monospace; }
.param-current {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  word-break: break-all;
}
.param-current b { color: #0F2A43; font-weight: 600; }
.param-value-mono { font-family: Consolas, Menlo, monospace; }
.btn-save { margin-top: 6px; }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 26px 16px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .hero h1 { font-size: 30px; }
  .nav-inner { padding: 10px 0; }
}

/* ===== Loading spinner (HTMX hx-indicator) ===== */
.spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: #2D8CF0;
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 8px;
  animation: spinner-rotate 0.7s linear infinite;
}
.spinner.htmx-request { display: inline-block; }
@keyframes spinner-rotate { to { transform: rotate(360deg); } }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}
.tabs a {
  padding: 10px 18px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tabs a:hover { color: var(--text); }
.tabs a.active {
  color: var(--accent, #0F2A43);
  border-bottom-color: var(--accent, #2D8CF0);
  font-weight: 600;
}

/* ===== Data table ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.data-table .mono { font-family: Consolas, Menlo, monospace; font-size: 12.5px; }
.data-table .err-cell {
  color: #c0392b;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-ok { background: #e6f7ed; color: #1e8449; }
.badge-fail { background: #fdecea; color: #c0392b; }

/* ===== Data toolbar links ===== */
.data-link {
  display: inline-block;
  padding: 2px 8px;
  margin: 0 2px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--muted);
}
.data-link:hover { background: #f0f2f5; }
.data-link.active {
  background: #2D8CF0;
  color: #fff;
  font-weight: 600;
}

/* ===== Data table tweaks ===== */
.data-table .col-time { min-width: 165px; width: 175px; }
.data-table .err-cell {
  max-width: none;
  white-space: normal;
  word-break: break-all;
  line-height: 1.4;
}
.pager-info {
  padding: 2px 10px;
  color: var(--muted);
}

/* ===== Data tab: shrink-wrap to table content ===== */
.panel-card-auto {
  width: fit-content;
  max-width: none;
}
.panel-card-auto .data-table { width: auto; }

/* ===== Error detail row under FAILED record ===== */
.err-detail {
  background: #fef5f5;
  color: #c0392b;
  font-size: 12px;
  padding: 6px 10px 8px 32px !important;
  line-height: 1.5;
  word-break: break-all;
}
.err-detail .err-label {
  font-weight: 600;
  margin-right: 4px;
}

/* ===== Data toolbar: select + sort toggle ===== */
.page-size-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}
.sort-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  background: #fff;
}
.sort-toggle:hover { background: #f0f2f5; }
.sort-arrow { font-weight: 700; }

/* ===== Panel welcome username ===== */
.welcome-user {
  color: #2D8CF0;
  font-weight: 700;
  font-size: 1.05em;
  margin-left: 4px;
}

@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
