/* ═══════════════════════════════════════════════════════════════════
   笔迹 - Pen Tracker Styles
   A beautiful, elegant pen tracking application
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reset & Variables ─────────────────────────────────────────── */

:root {
  --bg: #f0f0f7;
  --bg-warm: #faf9fe;
  --surface: #ffffff;
  --surface-hover: #f8f7fc;
  --border: #e8e6f0;
  --border-light: #f0eef6;

  --text: #1a1a2e;
  --text-secondary: #64618c;
  --text-muted: #9e9bba;

  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #eef2ff;
  --accent: #8b5cf6;
  --accent-light: #ede9fe;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 1px 3px rgba(99, 102, 241, 0.08), 0 8px 32px rgba(99, 102, 241, 0.06);
  --shadow-lg: 0 4px 12px rgba(99, 102, 241, 0.1), 0 20px 60px rgba(99, 102, 241, 0.1);
  --shadow-xl: 0 8px 24px rgba(99, 102, 241, 0.15), 0 32px 80px rgba(99, 102, 241, 0.12);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; height: auto; }

/* ── Animations ────────────────────────────────────────────────── */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes confetti {
  0% { transform: translateY(0) rotateZ(0deg); opacity: 1; }
  100% { transform: translateY(600px) rotateZ(720deg); opacity: 0; }
}

.fade-in {
  animation: fadeInUp 0.5s var(--transition) both;
}

/* ── Typography ────────────────────────────────────────────────── */

.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-muted { color: var(--text-muted); font-size: 0.875rem; }

/* ── Navigation ────────────────────────────────────────────────── */

.top-nav {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 1rem;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.nav-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
}

.nav-brand:hover { color: var(--primary); }

.nav-links {
  display: flex;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-link svg { opacity: 0.7; }

/* ── Buttons ───────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
  color: #fff;
}

.btn-next {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
  padding: 0.8rem 2rem;
  font-size: 1rem;
}
.btn-next:hover { box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4); transform: translateY(-1px); color: #fff; }
.btn-next.disabled { opacity: 0.5; pointer-events: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--primary-light); color: var(--primary); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-back {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}
.btn-back:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger {
  background: transparent;
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-accent {
  background: var(--accent-light);
  color: var(--accent);
}
.btn-accent:hover { background: var(--accent); color: #fff; }

.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; }
.btn-lg { padding: 0.8rem 1.6rem; font-size: 1rem; }
.btn-finish { background: var(--success-bg); color: var(--success); }
.btn-finish:hover { background: var(--success); color: #fff; }

/* ── Inputs ────────────────────────────────────────────────────── */

.input-lg {
  flex: 1;
  padding: 0.8rem 1.2rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
  outline: none;
}

.input-lg:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.input-lg::placeholder { color: var(--text-muted); }

.input-md {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
  outline: none;
  min-width: 0;
}

.input-md:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.input-sm {
  padding: 0.3rem 0.6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
  outline: none;
  width: 100px;
}

.input-sm:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.select-lg {
  flex: 1;
  padding: 0.8rem 1.2rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364618c' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.select-lg:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.form-select {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364618c' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2rem;
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-textarea {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
  outline: none;
  resize: vertical;
  min-height: 80px;
}

.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ── Setup Page ────────────────────────────────────────────────── */

.setup-page {
  background: linear-gradient(135deg, #f0f0ff 0%, #faf9fe 40%, #f5f0ff 100%);
  min-height: 100vh;
  padding: 2rem 1rem;
}

.setup-container {
  max-width: 720px;
  margin: 0 auto;
}

.setup-hero {
  text-align: center;
  margin-bottom: 2.5rem;
  padding: 1rem 0;
}

.hero-icon {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  animation: pulse 2s infinite ease-in-out;
}

.setup-hero h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.hero-sub {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

/* Wizard Steps */
.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 2rem;
  padding: 0 1rem;
}

.step-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.step-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: all var(--transition-slow);
}

.step-indicator.active .step-num {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.step-indicator.done .step-num {
  background: var(--success);
  border-color: transparent;
  color: #fff;
}

.step-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: color var(--transition);
}

.step-indicator.active .step-label { color: var(--primary); }

.step-line {
  width: 80px;
  height: 2px;
  background: var(--border);
  margin: 0 0.5rem;
  margin-bottom: 1.5rem;
  transition: background var(--transition-slow);
}

.step-line.done {
  background: linear-gradient(90deg, var(--success), var(--primary));
}

/* Wizard Card */
.wizard-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

.card-header {
  margin-bottom: 1.5rem;
}

.card-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.card-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.input-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

/* Tags */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 40px;
  margin-bottom: 1.5rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 500;
  animation: fadeInUp 0.3s both;
}

.tag-remove {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity var(--transition);
  padding: 0;
  margin-left: 0.1rem;
}

.tag-remove:hover { opacity: 1; }

/* Model Grid */
.model-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.model-grid {
  margin-bottom: 1.5rem;
}

.model-brand-group {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.model-brand-group:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.model-brand-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.model-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Tape Grid */
.tape-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.tape-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tape-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  background: var(--bg-warm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  animation: fadeInUp 0.3s both;
}

.tape-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tape-brand { font-weight: 600; }
.tape-model { color: var(--text-secondary); }
.tape-meters {
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Wizard Actions */
.wizard-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  margin-top: 1.5rem;
}

.wizard-actions-right {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* ── Dashboard / Home Page ─────────────────────────────────────── */

.home-page { background: var(--bg); }

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Stats Section */
.stats-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  transition: all var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-icon { font-size: 1.8rem; margin-bottom: 0.4rem; }

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.2rem;
}

.stat-total .stat-icon { animation: pulse 3s infinite; }

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.card-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-title h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.card-pens { grid-column: 1 / -1; }
.card-activity { grid-column: 1 / -1; }
.card-chart { grid-column: 1 / -1; }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.empty-state p { margin-bottom: 0.75rem; }

/* Pen List */
.pen-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pen-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  color: var(--text);
  cursor: pointer;
  border: 1px solid transparent;
}

.pen-item:hover {
  background: var(--primary-light);
  border-color: rgba(99, 102, 241, 0.1);
  color: var(--text);
}

.pen-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.pen-info { flex: 1; min-width: 0; }

.pen-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pen-meta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.pen-type, .pen-ink, .pen-qty {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0.1rem 0.5rem;
  border-radius: 100px;
}

.pen-qty { color: var(--accent); background: var(--accent-light); }

.pen-action { flex-shrink: 0; }

.usage-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* Brand Bars */
.brand-bars {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.brand-bar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-bar-name {
  width: 60px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
}

.brand-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 100px;
  overflow: hidden;
}

.brand-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 100px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 4px;
}

.brand-bar-count {
  width: 30px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}

/* Tape Home */
.tape-list-home {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tape-item-home {
  padding: 0.75rem 1rem;
  background: var(--bg-warm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.tape-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.tape-item-brand { font-weight: 600; font-size: 0.9rem; }
.tape-item-pct { font-weight: 700; color: var(--accent); font-size: 0.9rem; }

.tape-progress {
  height: 6px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 0.3rem;
}

.tape-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 100px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.tape-item-detail { font-size: 0.75rem; color: var(--text-muted); }

/* Activity List */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-light);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-pen { font-weight: 600; font-size: 0.9rem; }
.activity-note {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}
.activity-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Bar Chart */
.chart-container {
  padding: 1rem 0;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  height: 180px;
  padding: 0 0.5rem;
}

.bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.bar-value {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.3rem;
}

.bar {
  width: 100%;
  background: linear-gradient(180deg, var(--primary), var(--accent));
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  min-height: 4px;
  transition: height 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* ── Add Page ──────────────────────────────────────────────────── */

.page-container {
  max-width: 800px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.form-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  margin-top: 1.5rem;
}

/* Type Chips */
.type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  padding: 0.35rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
}

.chip input { display: none; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* Color Chips */
.color-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
}

.color-chip input { display: none; }

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chip-color);
}

.color-chip:hover { border-color: var(--chip-color); }
.color-chip.active {
  border-color: var(--chip-color);
  background: color-mix(in srgb, var(--chip-color) 10%, white);
  color: var(--text);
  font-weight: 600;
}

/* Quick Add */
.quick-add-section {
  margin-top: 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

.quick-add-section h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.3rem; }
.quick-add-section > p { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 1rem; }

.quick-add-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.quick-brand-card {
  padding: 1rem;
  background: var(--bg-warm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.quick-brand-name {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.quick-model-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.quick-model-btn {
  padding: 0.3rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
}

.quick-model-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Detail Page ───────────────────────────────────────────────── */

.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.detail-color {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.detail-info { flex: 1; min-width: 0; }

.detail-info h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.detail-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-type { background: var(--primary-light); color: var(--primary); }
.badge-ink { background: color-mix(in srgb, var(--badge-color) 15%, white); color: var(--badge-color); }
.badge-qty { background: var(--accent-light); color: var(--accent); }
.badge-finished { background: var(--success-bg); color: var(--success); }

.detail-notes {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.usage-inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.detail-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  margin-bottom: 1rem;
}

.detail-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

/* Usage Timeline */
.usage-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-left: 2px solid var(--border);
  padding-left: 1rem;
  position: relative;
}

.timeline-dot {
  position: absolute;
  left: -5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
}

.timeline-content { flex: 1; }
.timeline-note { font-size: 0.9rem; }
.timeline-time { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }

.detail-footer {
  margin-top: 1rem;
  text-align: center;
}

/* ── Toast ─────────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  top: 80px;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.2rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideIn 0.3s both;
  max-width: 300px;
}

.toast-icon { font-size: 1.2rem; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--primary); }

/* ── 404 Page ──────────────────────────────────────────────────── */

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
}

.error-page h1 {
  font-size: 5rem;
  font-weight: 800;
  color: var(--border);
}

.error-page p {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin: 1rem 0 2rem;
}

/* ── Page System ────────────────────────────────────────── */

.page {
  display: none;
}

.page.active {
  display: block;
}

/* ── Navigation updates ────────────────────────────────── */

.top-nav .nav-link {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.nav-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* ── Dashboard additions ───────────────────────────────── */

.card-title-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-select {
  padding: 0.3rem 0.6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%2364618c' d='M5 7L0 2h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
  padding-right: 1.5rem;
}

.filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.pen-badges {
  flex-shrink: 0;
  margin-left: auto;
}

.clickable { cursor: pointer; }

/* ── Status Badges ─────────────────────────────────────── */

.badge-status-normal { background: var(--success-bg); color: var(--success); }
.badge-status-broken_ink { background: #fef3c7; color: #d97706; }
.badge-status-leaking { background: #fce7f3; color: #db2777; }
.badge-status-missing_cap { background: #fef3c7; color: #d97706; }
.badge-status-damaged_tip { background: var(--danger-bg); color: var(--danger); }
.badge-status-cracked_body { background: var(--danger-bg); color: var(--danger); }
.badge-status-dry { background: #f3f4f6; color: #6b7280; }
.badge-status-loose_parts { background: var(--warning-bg); color: var(--warning); }
.badge-status-finished { background: #f3f4f6; color: #9ca3af; }
.badge-status-broken { background: var(--danger-bg); color: var(--danger); }
.badge-status-jammed { background: var(--warning-bg); color: var(--warning); }
.badge-status-damaged_case { background: var(--danger-bg); color: var(--danger); }
.badge-status-sticky_issue { background: #fef3c7; color: #d97706; }

/* ── Modals ────────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay[style*="flex"] {
  display: flex;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  animation: fadeInUp 0.3s var(--transition) both;
}

.modal-header {
  padding: 1.5rem 1.5rem 0;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.25rem 1.5rem;
}

.modal-footer {
  padding: 0 1.5rem 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Detail header inside modal */
.modal-header .detail-color {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.modal-header .detail-info h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.modal-header .detail-info .detail-meta {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.modal-header .detail-info .detail-notes {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.detail-actions-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Manage Page ───────────────────────────────────────── */

.manage-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.data-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Responsive update ─────────────────────────────────── */

@media (max-width: 768px) {
  .modal-card {
    max-width: 95vw;
    max-height: 90vh;
  }

  .nav-actions {
    gap: 0.15rem;
  }

  .nav-actions .btn-sm {
    padding: 0.25rem 0.4rem;
    font-size: 0.7rem;
  }

  .card-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .card-title-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ── Base page background for setup ────────────────────── */

body {
  background: linear-gradient(135deg, #f0f0ff 0%, #faf9fe 40%, #f5f0ff 100%);
}
