:root {
  --bg-app: #09090b;
  --bg-sidebar: #101012;
  --bg-card: #141417;
  --bg-input: #09090b;
  --bg-topbar: rgba(9, 9, 11, 0.8);
  
  --bg-panel: rgba(0,0,0,0.14);
  --bg-panel-hover: rgba(34, 211, 238, 0.04);
  --bg-subtle: rgba(255,255,255,0.02);
  --bg-header: rgba(0,0,0,0.12);
  --bg-item: rgba(0,0,0,0.16);
  --bg-step: rgba(34, 211, 238, 0.06);
  --bg-chart: rgba(0,0,0,0.2);
  
  --border-subtle: #27272a;
  --border-focus: #3f3f46;
  
  --primary: #22d3ee;
  --primary-dim: rgba(34, 211, 238, 0.1);
  --primary-hover: #06b6d4;
  
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-faint: #52525b;
  
  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;
  
  --font-ui: 'Manrope', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-out: cubic-bezier(0.215, 0.61, 0.355, 1);
  --duration-fast: 0.15s;
  --duration-normal: 0.25s;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.4s var(--ease-out) forwards;
}

[data-theme="light"] {
  --bg-app: #f4f4f5;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-topbar: rgba(255, 255, 255, 0.8);
  
  --bg-panel: #ffffff;
  --bg-panel-hover: rgba(16, 185, 129, 0.05);
  --bg-subtle: transparent;
  --bg-header: #ffffff;
  --bg-item: #ffffff;
  --bg-step: rgba(16, 185, 129, 0.06);
  --bg-chart: #ffffff;
  
  --border-subtle: #e4e4e7;
  --border-focus: #a1a1aa;
  
  --primary: #10b981;
  --primary-dim: rgba(16, 185, 129, 0.1);
  --primary-hover: #059669;
  
  --text-main: #18181b;
  --text-muted: #71717a;
  --text-faint: #a1a1aa;
  
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
}

[data-theme="light"] .home-title {
  background: linear-gradient(135deg, #18181b 0%, #52525b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] #main {
  background-image: 
    linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px);
}

[data-theme="light"] .home-hero {
  background: linear-gradient(to bottom, #f4f4f5, #ffffff);
}

[data-theme="light"] .guide-pill {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .guide-pill:hover {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.15);
}

[data-theme="light"] .stat-card,
[data-theme="light"] .progress-wrap,
[data-theme="light"] .rowlist-item {
  border-color: var(--border-subtle);
}

[data-theme="light"] .upload-zone {
  border-color: rgba(0,0,0,0.16);
}

[data-theme="light"] .samp-stat-card {
  background: #ffffff;
}
[data-theme="light"] .samp-stat-baseline {
  border-color: rgba(16, 185, 129, 0.35);
}
[data-theme="light"] .samp-stat-variance {
  border-color: rgba(16, 185, 129, 0.35);
}
[data-theme="light"] .samp-stat-n {
  border-color: rgba(16, 185, 129, 0.35);
}

[data-theme="light"] .btn-primary {
  color: #ffffff;
}

[data-theme="light"] .btn-running {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.8), rgba(16, 185, 129, 1));
  border-color: rgba(16, 185, 129, 0.8);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.12), 0 0 18px rgba(16, 185, 129, 0.22);
  color: #ffffff;
}

[data-theme="light"] .progress-bar-inner {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.55), rgba(16, 185, 129, 1));
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.35);
}

* { box-sizing: border-box; outline: none; }
body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-ui);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
#layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  width: 240px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding: 0 8px;
}
.logo-img {
  width: 32px; height: 32px;
  border-radius: 6px;
}
.logo-text {
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: 14px;
  color: var(--text-main);
}

#nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  transition: all var(--duration-fast) var(--ease);
  font-weight: 500;
  position: relative;
  overflow: hidden;
}
.nav-item:hover {
  background: rgba(255,255,255,0.03);
  color: var(--text-main);
  transform: translateX(4px);
}
.nav-item:active {
  transform: translateX(4px) scale(0.98);
}
.nav-item.active {
  background: var(--primary-dim);
  color: var(--primary);
  transform: none;
}
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.4; transition: opacity 0.3s; }
.nav-item.active .nav-dot { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 8px;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  display: inline-block;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 8px rgba(52,211,153,0.4); }
.status-dot.offline { background: var(--error); }

.status-val { font-family: var(--font-mono); color: var(--text-main); }

.btn-icon-text {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 8px; border-radius: 6px;
  font-family: var(--font-ui); font-size: 13px;
  transition: all 0.2s;
}
.btn-icon-text:hover { color: var(--text-main); background: rgba(255,255,255,0.03); }
.icon {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid currentColor;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}

/* Main Area */
#main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image: 
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  min-width: 0;
}

#topbar {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-topbar);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  position: sticky;
  top: 0;
}
#page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-main);
}
#page-desc {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.link-subtle {
  color: var(--text-muted); text-decoration: none; font-size: 13px;
  border: 1px solid var(--border-subtle); padding: 6px 12px;
  border-radius: 6px; transition: all 0.2s;
}
.link-subtle:hover { border-color: var(--text-main); color: var(--text-main); }

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  padding-bottom: 80px;
}

/* Components */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
}
.grid-home {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.grid-2 > *, .grid-home > * {
  min-width: 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 24px;
  transition: all 0.3s var(--ease);
  display: flex; flex-direction: column;
  min-width: 0;
}
.card:hover { 
  border-color: var(--border-focus); 
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -8px rgba(0,0,0,0.3);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 600; color: var(--text-main); }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.card-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
  border: 1px solid transparent;
  font-size: 13px;
  font-family: var(--font-ui);
  text-decoration: none;
  user-select: none;
}
.btn:active {
  transform: scale(0.96);
}
.btn-primary {
  background: var(--primary);
  color: #000;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn-primary:hover { 
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(34, 211, 238, 0.25);
}

.btn-running{
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.8), rgba(34, 211, 238, 1));
  border: 1px solid rgba(34, 211, 238, 0.8);
  color: #000;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.12), 0 0 18px rgba(34, 211, 238, 0.22);
  position: relative;
  overflow: hidden;
}
.btn-running::after {
  content: "";
  position: absolute;
  top: 0; left: -100%;
  width: 200%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 1.5s infinite;
}

.btn-running[disabled]{
  opacity: 1;
  cursor: progress;
}

@keyframes shimmer {
  0% { transform: translateX(0); }
  100% { transform: translateX(100%); }
}

.btn[disabled]{
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}
.btn-ghost:hover { 
  border-color: var(--text-muted); 
  background: rgba(255,255,255,0.02);
  transform: translateY(-1px);
}
.btn-ghost:active {
  transform: translateY(0) scale(0.96);
}

.input-group { margin-bottom: 16px; }
.label { display: block; color: var(--text-muted); font-size: 12px; margin-bottom: 6px; font-weight: 500; }
.input, .textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 13px;
  transition: all var(--duration-fast) var(--ease);
}
.input:hover, .textarea:hover {
  border-color: var(--border-focus);
}
.input:focus, .textarea:focus { 
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}
.textarea { min-height: 140px; line-height: 1.5; }
.help-text { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

/* Table */
.table-container {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  overflow-x: auto;
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.table th {
  background: rgba(255,255,255,0.03);
  text-align: left;
  padding: 10px 16px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}
.table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}
.table tr:last-child td { border-bottom: none; }

/* Drawer */
#drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 40;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s var(--ease);
}
#drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 400px;
  background: var(--bg-card);
  border-left: 1px solid var(--border-subtle);
  z-index: 50;
  transform: translateX(100%);
  transition: transform 0.3s var(--ease);
  display: flex; flex-direction: column;
  box-shadow: -10px 0 40px rgba(0,0,0,0.5);
}
.drawer-open #drawer-backdrop { opacity: 1; pointer-events: auto; }
.drawer-open #drawer { transform: translateX(0); }

.drawer-header {
  padding: 24px; border-bottom: 1px solid var(--border-subtle);
  display: flex; justify-content: space-between; align-items: center;
}
.drawer-content { padding: 24px; overflow-y: auto; flex: 1; }
.btn-icon {
  background: transparent; border: 1px solid var(--border-subtle);
  color: var(--text-muted); width: 28px; height: 28px; border-radius: 6px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.btn-icon:hover { border-color: var(--text-main); color: var(--text-main); }

.doc-section { margin-bottom: 32px; }
.doc-section h3 { font-size: 12px; color: var(--primary); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 12px; font-weight: 700; }
.doc-section p { line-height: 1.6; color: var(--text-muted); margin: 0 0 12px; }
.doc-list { padding-left: 18px; margin: 0; }
.doc-list li { margin-bottom: 8px; color: var(--text-muted); line-height: 1.5; }
.doc-list strong { color: var(--text-main); }
code { background: rgba(255,255,255,0.05); padding: 2px 4px; border-radius: 4px; font-family: var(--font-mono); font-size: 12px; }

/* Toast */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex; align-items: center; gap: 12px;
  transform: translateY(20px); opacity: 0;
  animation: slideUp 0.3s var(--ease) forwards;
  pointer-events: auto;
  color: var(--text-main);
  font-size: 13px;
}
@keyframes slideUp { to { transform: translateY(0); opacity: 1; } }

/* Chart */
.chart-container {
  height: 320px; width: 100%;
  max-width: 100%;
  margin-top: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-chart);
}

/* Badges */
.badge {
  display: inline-flex; padding: 4px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; font-family: var(--font-mono);
}
.badge-ok { background: rgba(52,211,153,0.1); color: var(--success); }
.badge-warn { background: rgba(251,191,36,0.1); color: var(--warning); }
.badge-error { background: rgba(248,113,113,0.1); color: var(--error); }
.badge-neutral { background: rgba(255,255,255,0.05); color: var(--text-muted); border: 1px solid var(--border-subtle); }
.badge-mean { background: rgba(34,211,238,0.12); color: var(--primary); border: 1px solid rgba(34,211,238,0.22); text-transform: none; }
.badge-proportion { background: rgba(251,191,36,0.12); color: var(--warning); border: 1px solid rgba(251,191,36,0.22); text-transform: none; }
.badge-ratio { background: rgba(167,139,250,0.12); color: #a78bfa; border: 1px solid rgba(167,139,250,0.22); text-transform: none; }

.mde-val { font-family: var(--font-mono); font-weight: 800; color: var(--primary); }

.select{
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 10px 12px;
  padding-right: 34px;
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 13px;
  transition: all var(--duration-fast) var(--ease);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
}
.select:hover{ border-color: var(--border-focus); }
.select:focus{ 
  border-color: var(--primary); 
  box-shadow: 0 0 0 3px var(--primary-dim);
}

.btn-sm{ padding: 6px 10px; font-size: 12px; border-radius: 6px; }

.check{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  user-select: none;
}
.check input{ accent-color: var(--primary); }
.check span{ color: var(--text-main); font-weight: 500; }

.step{
  border: 1px solid rgba(34, 211, 238, 0.18);
  background: rgba(34, 211, 238, 0.06);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 14px 0 12px;
}
.step-title{
  font-weight: 700;
  color: var(--text-main);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.step-desc{
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.form-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.form-grid-3{
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.field{ min-width: 0; }
.field-wide{ grid-column: 1 / -1; }

.section{ margin-top: 14px; }
.section-head{ display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-title{ font-weight: 700; color: var(--text-main); font-size: 13px; }
.section-subtitle{ color: var(--text-muted); font-size: 12px; }

.upload-zone{
  border: 1px dashed rgba(255,255,255,0.16);
  background: var(--bg-panel);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
}
.upload-zone:hover{ border-color: rgba(34, 211, 238, 0.5); background: var(--bg-panel-hover); }
.upload-icon{
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  background: rgba(34, 211, 238, 0.08);
  color: var(--primary);
  font-weight: 800;
}
.upload-text{ color: var(--text-muted); font-size: 12px; text-align: center; }

.preview-box{ min-height: 120px; }

.progress-wrap{
  margin-top: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--bg-panel);
  border-radius: 12px;
  padding: 12px;
}
.progress-meta{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.progress-bar{
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}
.progress-bar-inner{
  height: 100%;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.55), rgba(34, 211, 238, 1));
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.35);
  transition: width 0.2s var(--ease);
}

/* Seed Hero Card */
.seed-hero {
  position: relative;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.08) 0%, rgba(34, 211, 238, 0.02) 100%);
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), inset 0 0 0 1px rgba(34, 211, 238, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.seed-hero-icon {
  width: 48px;
  height: 48px;
  background: rgba(34, 211, 238, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #22d3ee;
  margin-bottom: 4px;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.2);
}
.seed-hero-icon svg { width: 24px; height: 24px; }

.seed-hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.seed-hero-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

.seed-hero-seed {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: #22d3ee;
  letter-spacing: -0.5px;
  text-shadow: 0 0 20px rgba(34, 211, 238, 0.3);
  margin: 4px 0;
}

.seed-hero-sub {
  font-size: 13px;
  color: var(--text-faint);
  background: rgba(0,0,0,0.2);
  padding: 4px 10px;
  border-radius: 99px;
}

/* Light Mode Overrides for Seed Hero */
[data-theme="light"] .seed-hero {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.1), 0 1px 3px rgba(0,0,0,0.05);
}

[data-theme="light"] .seed-hero-icon {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.15);
}

[data-theme="light"] .seed-hero-seed {
  color: #10b981;
  text-shadow: none;
}

[data-theme="light"] .seed-hero-sub {
  background: rgba(16, 185, 129, 0.08);
  color: #059669;
}

.stat-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.stat-card{
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.14);
  border-radius: 12px;
  padding: 12px;
}
.stat-label{ color: var(--text-muted); font-size: 12px; }
.stat-value{ margin-top: 8px; font-family: var(--font-mono); font-size: 14px; color: var(--text-main); font-weight: 700; }

.btn-block{ width: 100%; margin-top: 14px; padding: 12px 16px; border-radius: 10px; }

#aa-summary { min-width: 0; }
#aa-summary .stat-card { min-width: 0; }
#aa-summary .stat-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.spinbox{ position: relative; }
.spinbox-input{ padding-right: 42px; }
.spinbox-input::-webkit-outer-spin-button,
.spinbox-input::-webkit-inner-spin-button{
  -webkit-appearance: none;
  margin: 0;
}
.spinbox-input{ -moz-appearance: textfield; }
.spinbox-btns{
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-subtle);
}
.spinbox-btn{
  width: 40px;
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.spinbox-btn:hover{ background: rgba(255,255,255,0.03); color: var(--text-main); }

.rowlist{
  margin-top: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255,255,255,0.02);
}
.rowlist-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-header);
}
.rowlist-title{ font-weight: 700; color: var(--text-main); }
.rowlist-body{ padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 10px; }

.rowlist-plain{
  border: none;
  background: transparent;
  border-radius: 0;
  overflow: visible;
}
.rowlist-plain .rowlist-body{ padding: 0; }

.rowlist-item{
  border: 1px solid rgba(255,255,255,0.06);
  background: var(--bg-item);
  border-radius: 10px;
  padding: 12px;
  transition: all var(--duration-fast) var(--ease);
}
.rowlist-item:hover{
  background: var(--bg-panel-hover);
  border-color: var(--border-focus);
}
.rowlist-grid{
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) minmax(220px, 1.6fr) minmax(180px, 1.1fr) minmax(180px, 1.1fr) auto;
  gap: 12px;
  align-items: end;
}
.rowlist-grid-2{ grid-template-columns: 1fr 1fr auto; }
.rowlist-grid-3{ grid-template-columns: 1fr 1fr 1fr auto; }
.rowlist-actions{ display: flex; justify-content: flex-end; }

.metric-row .rowlist-grid{
  grid-template-columns: minmax(160px, 1.2fr) minmax(220px, 1.6fr) auto;
}
.metric-row .rowlist-grid > .field{ min-width: 0; }
.metric-row .select{ max-width: 100%; }
.metric-row.is-ratio .rowlist-grid{
  grid-template-columns: minmax(140px, 1.1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
}
.rowlist-actions .btn{
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

.form-error{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, 0.25);
  background: rgba(248, 113, 113, 0.08);
  color: rgba(248, 113, 113, 0.95);
  font-size: 13px;
  line-height: 1.5;
}

/* Mobile Menu */
#mobile-menu-btn { display: none; margin-right: 16px; border: 1px solid var(--border-subtle); color: var(--text-muted); }
#mobile-menu-btn:hover { border-color: var(--text-main); color: var(--text-main); }

#sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ease);
}
body.sidebar-open #sidebar-backdrop { opacity: 1; pointer-events: auto; }

@keyframes slideRight { from { transform: translateX(-100%); } to { transform: translateX(0); } }

@media (max-width: 768px) {
  #layout { grid-template-columns: 1fr; }
  #sidebar { display: none; } 
  body.sidebar-open #sidebar {
    display: flex;
    position: fixed; top: 0; bottom: 0; left: 0;
    z-index: 50;
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    animation: slideRight 0.3s var(--ease) forwards;
    overflow-y: auto;
  }
  #mobile-menu-btn { display: flex; }
  #content { padding: 16px; padding-bottom: 96px; }
  .grid-2 { grid-template-columns: 1fr; gap: 16px; }
  .form-grid{ grid-template-columns: 1fr; gap: 12px; }
  .rowlist-grid{ grid-template-columns: 1fr; }
  .rowlist-grid-2{ grid-template-columns: 1fr; }
  .rowlist-grid-3{ grid-template-columns: 1fr; }
  .metric-row .rowlist-grid{ grid-template-columns: 1fr; }
  .metric-row.is-ratio .rowlist-grid{ grid-template-columns: 1fr; }
  .rowlist-actions{ justify-content: flex-start; width: 100%; }
  .rowlist-actions .btn{ width: 100%; }

  /* Compact Mode for Mobile */
  .card { padding: 16px; }
  .chart-container { height: 240px; }
  #topbar { padding: 12px 16px; }
  #page-title { font-size: 20px; }
}

@media (max-width: 1100px) {
  .metric-row.is-ratio .rowlist-grid{
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}


/* Theme Toggle (Capsule) */
.theme-switch {
  position: relative;
  width: 56px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.theme-switch:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--text-muted);
}
[data-theme="light"] .theme-switch {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .theme-switch:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.2);
}

.theme-switch-track {
  position: relative;
  width: 100%;
  height: 100%;
}

.theme-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  z-index: 3;
  transition: color 0.2s;
}
.theme-icon svg { width: 14px; height: 14px; }
.theme-icon.sun { left: 4px; }
.theme-icon.moon { right: 4px; }

[data-theme="light"] .theme-icon.sun { color: var(--text-main); }
[data-theme="dark"] .theme-icon.moon { color: var(--text-main); }

.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: var(--bg-card);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
  z-index: 2;
}
[data-theme="light"] .theme-switch-thumb {
  background: #ffffff;
  transform: translateX(0);
}
[data-theme="dark"] .theme-switch-thumb {
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transform: translateX(28px);
}

/* Home Mode Overrides */
.home-mode #sidebar { display: none; }
.home-mode { overflow-x: hidden; overflow-y: auto; }
.home-mode #layout { display: flex; flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
.home-mode #topbar { display: none; }
.home-mode #main { width: 100%; height: auto; min-height: 100vh; flex: 1; overflow: visible; }
.home-mode .content-area { overflow: visible; padding: 0; }

/* Home Landing Page Styles */
.home-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.home-page-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: clamp(0px, 1.2vh, 12px) 0 clamp(18px, 3vh, 30px);
}
.home-page-bottom {
  margin-top: clamp(8px, 1.6vh, 20px);
}

.home-hero {
  text-align: center;
  min-height: clamp(300px, 38vh, 500px);
  padding: clamp(100px, 12vh, 180px) 20px clamp(18px, 3.6vh, 44px);
  width: 100%;
  background: linear-gradient(to bottom, var(--bg-app), var(--bg-card));
  border-bottom: 1px solid var(--border-subtle);
  margin: 0;
}

.home-guide {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 24px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.guide-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: default;
}

.pill-dot {
  color: var(--primary);
  font-weight: 800;
  font-size: 26px;
  line-height: 0.8;
  vertical-align: middle;
  margin-right: 4px;
}

.guide-pill:hover {
  border-color: var(--text-muted);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.home-title {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0 0 34px;
  line-height: 1.1;
}

.home-subtitle {
  font-size: 18px;
  color: var(--text-muted);
  line-height: 1.95;
  max-width: 760px;
  margin: 0 auto;
}

.home-section-title {
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 64px;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.home-section-desc {
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
  max-width: 600px;
  margin: 0 auto 56px;
  line-height: 1.6;
}

@media (max-width: 768px) {
  .home-hero { padding: 92px 16px 38px; }
  .home-title { font-size: 38px; margin-bottom: 26px; }
  .home-subtitle { font-size: 16px; line-height: 1.75; }
  .home-guide { margin-top: 20px; gap: 12px; }
  .home-section-title { margin-top: 0; margin-bottom: 24px; font-size: 26px; }
}

.home-features {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 32px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 40px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 32px;
  transition: all 0.3s var(--ease);
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 20px 40px -10px rgba(0,0,0,0.5);
}

.feature-card:hover .feature-icon {
  background: var(--primary);
  color: #000;
}

.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 24px;
  transition: all 0.3s var(--ease);
  border: 1px solid var(--border-subtle);
}

.feature-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 2px;
}

.feature-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 12px;
}

.feature-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
  flex: 1;
}

.feature-link {
  margin-top: 24px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.home-contact {
  text-align: center;
  padding: 0 20px;
  margin: 0 auto 14px;
  max-width: 760px;
}
.home-contact-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.home-contact-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}
.home-contact-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.home-contact-btn {
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
}
.home-contact-icon {
  font-size: 16px;
  line-height: 1;
}
.home-contact-reveal {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-faint);
}
.home-contact-mail {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s;
}
.home-contact-mail:hover {
  color: var(--text-main);
  border-bottom-color: var(--border-focus);
}

.home-footer {
  text-align: center;
  padding: clamp(16px, 2.2vh, 24px) 20px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-faint);
  font-size: 11px;
}
.home-footer-meta {
  margin-bottom: 6px;
  line-height: 1.5;
  color: var(--text-faint);
}
.home-footer-copy {
  color: var(--text-faint);
}

@media (max-width: 768px) {
  .home-page-main { padding: 16px 0 40px; }
  .home-contact { margin-bottom: 12px; }
  .home-contact-title { font-size: 20px; }
}

@media (max-width: 1100px) {
  .home-features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .home-features { grid-template-columns: 1fr; }
}

/* Contact Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  opacity: 1; pointer-events: auto;
  transition: opacity 0.3s var(--ease);
}
.modal-backdrop[hidden] {
  opacity: 0; pointer-events: none; display: flex; 
  visibility: hidden;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  width: 90%; max-width: 440px;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  transform: scale(1);
  transition: transform 0.3s var(--ease);
  overflow: hidden;
}
.modal-backdrop[hidden] .modal-content {
  transform: scale(0.95);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-title {
  font-weight: 700; color: var(--text-main); font-size: 15px;
  display: flex; align-items: center; gap: 8px;
}
.modal-icon { font-size: 16px; }

.modal-close-icon {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 4px;
  border-radius: 4px; transition: all 0.2s;
}
.modal-close-icon:hover { color: var(--text-main); background: rgba(255,255,255,0.05); }

.modal-body { padding: 20px; }
.modal-desc { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; line-height: 1.5; }

.email-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 12px;
  padding: 16px;
  display: flex; align-items: center; gap: 16px;
}
.email-box-icon {
  width: 36px; height: 36px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.email-box-info { display: flex; flex-direction: column; gap: 2px; }
.email-box-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.email-box-addr { font-family: var(--font-mono); font-size: 14px; color: var(--text-main); font-weight: 600; }

.modal-actions {
  padding: 16px 20px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-subtle);
  display: flex; justify-content: flex-end; gap: 12px;
}
