:root {
  --bg: #f8fafc;
  --surface: #fff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --danger: #dc2626;
  --radius: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
html, body { margin: 0; padding: 0; font-family: var(--font); color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.app-header h1 { font-size: 16px; font-weight: 600; margin: 0; }
.nav-links { display: flex; gap: 8px; }
.nav-links a {
  padding: 6px 12px; border-radius: 8px; font-size: 13px; color: var(--muted);
  text-decoration: none;
}
.nav-links a.active, .nav-links a:hover { background: #eff6ff; color: var(--brand); }

.btn {
  padding: 8px 14px; border-radius: 8px; border: none; font-size: 13px;
  font-weight: 500; cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.input, .select, textarea {
  font-family: inherit; font-size: 13px; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; background: var(--surface);
}
textarea { resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.zone-row {
  display: grid; grid-template-columns: 36px 1fr auto auto; gap: 8px;
  align-items: center; font-size: 12px; margin-bottom: 4px;
}
.zone-tag {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  font-weight: 600; font-size: 11px; color: #1e293b; text-align: center;
}
.zone-bar-wrap { height: 8px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.zone-bar { height: 100%; border-radius: 4px; min-width: 2px; }
.zone-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.zone-pct { color: var(--muted); font-variant-numeric: tabular-nums; }

.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px;
  font-size: 12px; margin-top: 12px;
}
.stats-grid dt { color: var(--muted); }
.stats-grid dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.chart-wrap {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.chart-wrap canvas { display: block; width: 100%; height: 220px; }
.chart-hover {
  font-size: 12px; color: var(--muted); padding: 8px 12px;
  border-top: 1px solid var(--border); min-height: 32px;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 16px;
}
.modal {
  background: var(--surface); border-radius: var(--radius); width: 100%;
  max-width: 480px; max-height: 90vh; overflow: auto; padding: 20px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.12);
}
.modal h2 { margin: 0 0 16px; font-size: 16px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field-row { display: flex; gap: 8px; }
.field-row .input, .field-row .select { flex: 1; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; z-index: 200; animation: fadeUp 0.2s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translate(-50%, 8px); } }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge-A { background: #dcfce7; color: #166534; }
.badge-B { background: #fee2e2; color: #991b1b; }
.badge-C { background: #ffedd5; color: #9a3412; }
.badge-D { background: #ede9fe; color: #5b21b6; }

@media (max-width: 900px) {
  .studio-layout { flex-direction: column !important; }
  .studio-sidebar { width: 100% !important; max-height: 200px; }
}
