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

:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --border: rgba(0,0,0,0.1);
  --border-med: rgba(0,0,0,0.18);
  --text: #1a1917;
  --text-2: #6b6963;
  --text-3: #9c9890;
  --accent: #4f46e5;
  --accent-bg: #eef2ff;
  --accent-text: #3730a3;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #86efac;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --warn-border: #fcd34d;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fca5a5;
  --radius: 8px;
  --radius-lg: 12px;
  --nav-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 16px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font); cursor: pointer; }
textarea, input { font-family: var(--font); }
h1 { font-size: 2rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.4rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.1rem; font-weight: 600; }

/* Nav */
.nav { height: var(--nav-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 1.5rem; gap: 1.5rem; position: sticky; top: 0; z-index: 100; }
.nav-logo { font-weight: 700; font-size: 1.1rem; color: var(--text); letter-spacing: -0.02em; }
.nav-logo span { color: var(--accent); }
.nav-links { display: flex; gap: 0.25rem; margin-left: auto; }
.nav-link { padding: 6px 12px; border-radius: var(--radius); font-size: 14px; color: var(--text-2); }
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-bg); }
.nav-btn { padding: 7px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500; background: var(--accent); color: white; border: none; }
.nav-btn:hover { opacity: 0.9; }

/* Page layout */
.page { max-width: 760px; margin: 0 auto; padding: 2rem 1.5rem; }
.page-wide { max-width: 1000px; margin: 0 auto; padding: 2rem 1.5rem; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; }
.card + .card { margin-top: 1rem; }

/* Forms */
.field { margin-bottom: 1.25rem; }
.field label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-med);
  border-radius: var(--radius); font-size: 15px; background: var(--surface);
  color: var(--text); transition: border-color 0.15s;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,0.08); }
.field textarea { resize: vertical; line-height: 1.6; }
.field-hint { font-size: 13px; color: var(--text-3); margin-top: 5px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 20px; border-radius: var(--radius); font-size: 15px; font-weight: 500; border: 1px solid transparent; transition: all 0.15s; line-height: 1; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-med); }
.btn-secondary:hover { background: var(--bg); }
.btn-secondary.active { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-lg { padding: 13px 28px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Tags/badges */
.tag { display: inline-block; font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 20px; letter-spacing: 0.02em; }
.tag-def { background: var(--bg); color: var(--text-2); border: 1px solid var(--border); }
.tag-app { background: var(--accent-bg); color: var(--accent-text); }
.tag-mech { background: #f0f9ff; color: #0369a1; }
.tag-analysis { background: #fdf4ff; color: #7e22ce; }

/* Metric cards */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 1.5rem; }
.metric { background: var(--bg); border-radius: var(--radius); padding: 1rem; }
.metric-label { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.metric-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }

/* Progress bar */
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s; }

/* Alert */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 1rem; }
.alert-err { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.alert-ok { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* Empty state */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-3); }
.empty h3 { color: var(--text-2); margin-bottom: 0.5rem; }

/* Loading */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Dot */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--success); }
.dot-yellow { background: var(--warn); }
.dot-red { background: var(--danger); }
.dot-gray { background: var(--text-3); }

/* Responsive */
@media (max-width: 600px) {
  h1 { font-size: 1.6rem; }
  .page, .page-wide { padding: 1.25rem 1rem; }
  .nav { padding: 0 1rem; }
}
