:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --surface: #ffffff;
  --background: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
  background: var(--background);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* ─── Navbar ─── */
.navbar {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
  padding: 0.75rem 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.navbar-brand img { height: 36px; }
.navbar .nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem !important;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  color: rgba(255,255,255,0.75) !important;
}
.navbar .nav-link:hover,
.navbar .nav-link.active {
  color: #fff !important;
  background: rgba(255,255,255,0.1);
}
.navbar .nav-link i { margin-right: 0.35rem; font-size: 0.9rem; }
.navbar .dropdown-menu {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  margin-top: 0.5rem;
}
.navbar .dropdown-item {
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: var(--transition);
}
.navbar .dropdown-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.navbar .dropdown-item i { margin-right: 0.5rem; width: 1rem; }

/* ─── Main Container ─── */
.main-wrap {
  min-height: calc(100vh - 64px);
  padding-bottom: 2rem;
}

/* ─── Cards ─── */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  font-weight: 600;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-body { padding: 1.25rem; }

/* ─── Stat Cards ─── */
.stat-card {
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  border: none;
  transition: var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}
.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}
.stat-card .stat-label {
  font-size: 0.8rem;
  opacity: 0.8;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Machine Card ─── */
.machine-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
  cursor: default;
}
.machine-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}
.machine-card .machine-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--primary);
  margin: 0 auto 0.75rem;
}

/* ─── Machine Detail ─── */
.machine-detail-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary-light), #eff6ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--primary);
  margin: 0 auto 1rem;
}
.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 600;
}
.state-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}

/* ─── Buttons ─── */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.55rem 1.1rem;
  transition: var(--transition);
  border: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 0.95rem; border-radius: var(--radius); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 4px 14px rgba(37,99,235,0.25);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(37,99,235,0.35); }
.btn-success { background: linear-gradient(135deg, #059669, #047857); box-shadow: 0 4px 14px rgba(16,185,129,0.25); }
.btn-info { background: linear-gradient(135deg, #0891b2, #0e7490); box-shadow: 0 4px 14px rgba(6,182,212,0.25); color: #fff; }
.btn-danger { background: linear-gradient(135deg, #dc2626, #b91c1c); box-shadow: 0 4px 14px rgba(239,68,68,0.25); }
.btn-outline-primary {
  border: 1.5px solid var(--primary);
  color: var(--primary);
  background: transparent;
}
.btn-outline-primary:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-outline-success { border: 1.5px solid #10b981; color: #10b981; background: transparent; }
.btn-outline-success:hover { background: #10b981; color: #fff; }
.btn-outline-danger { border: 1.5px solid #ef4444; color: #ef4444; background: transparent; }
.btn-outline-danger:hover { background: #ef4444; color: #fff; }
button:disabled, .btn:disabled {
  opacity: 0.45 !important;
  transform: none !important;
  box-shadow: none !important;
  cursor: not-allowed;
}

/* ─── Forms ─── */
.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  transition: var(--transition);
  background: var(--surface);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.3rem; }
.form-control-lg { padding: 0.75rem 1rem; font-size: 1rem; }

/* ─── Badges ─── */
.badge { font-weight: 500; padding: 0.3em 0.7em; border-radius: 100px; font-size: 0.8rem; }

/* ─── Alerts / Flash ─── */
.alert {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0.85rem 1.1rem;
  font-size: 0.9rem;
}

/* ─── Tables ─── */
.table { margin: 0; }
.table > :not(caption) > * > * {
  padding: 0.75rem 0.5rem;
  vertical-align: middle;
  border-bottom-color: var(--border);
}

/* ─── Breadcrumb ─── */
.breadcrumb { background: none; padding: 0; margin-bottom: 0; font-size: 0.85rem; }

/* ─── Page Header ─── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.page-header h4 {
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Run Timer ─── */
.run-timer {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.run-timer .timer-value {
  font-size: 2.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}
.run-timer .timer-label { font-size: 0.8rem; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.05em; }

/* ─── Empty State ─── */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state i { font-size: 3rem; color: #cbd5e1; margin-bottom: 1rem; }
.empty-state p { color: var(--text-secondary); max-width: 400px; margin: 0 auto; }

/* ─── Dividers ─── */
.divider { display: flex; align-items: center; gap: 1rem; color: var(--text-secondary); font-size: 0.8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ─── Social Buttons ─── */
.btn-social {
  flex: 1;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: var(--transition);
}
.btn-social:hover { border-color: var(--primary); background: var(--primary-light); }

/* ─── Footer ─── */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ─── Responsive ─── */
@media (max-width: 991px) {
  .navbar .nav-link { padding: 0.5rem 0.75rem !important; border-radius: var(--radius-sm); }
  .navbar-collapse { background: #1e293b; margin: 0.5rem -0.75rem -0.75rem; padding: 0.5rem 0.75rem; border-radius: 0 0 var(--radius) var(--radius); }
}

@media (max-width: 767px) {
  .stat-card .stat-value { font-size: 1.5rem; }
  .page-header h4 { font-size: 1.15rem; }
  .run-timer .timer-value { font-size: 2rem; }
  .machine-detail-icon { width: 64px; height: 64px; font-size: 2rem; }
}

@media (max-width: 575px) {
  .card-body { padding: 1rem; }
  .stat-card { padding: 1rem; }
  .stat-card .stat-icon { width: 40px; height: 40px; font-size: 1rem; }
}
