:root {
  --brand: #1f4e79;
  --brand-dark: #163a5c;
  --brand-light: #2e75b6;
  --accent: #17a673;
  --warning: #e0a800;
  --danger: #c0392b;
  --bg: #f4f6fa;
  --card-bg: #ffffff;
  --border: #e3e7ee;
  --text: #24303d;
  --text-muted: #6b7686;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
}

.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 250px;
  background: linear-gradient(180deg, var(--brand-dark), var(--brand));
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left 0.25s ease;
}
.sidebar-brand {
  font-size: 1.4rem;
  font-weight: 700;
  padding: 24px 20px;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.sidebar-brand i { margin-right: 8px; color: #8ecae6; }
.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin-bottom: 2px; border-radius: 8px;
  color: rgba(255,255,255,0.82); text-decoration: none; font-size: 0.93rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav a i { font-size: 1.05rem; width: 18px; text-align: center; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,0.16); color: #fff; font-weight: 600; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.12); }
.sidebar-footer a { color: rgba(255,255,255,0.75); text-decoration: none; font-size: 0.9rem; }
.sidebar-footer a:hover { color: #fff; }

/* Main area */
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; background: var(--card-bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.sidebar-toggle { background: none; border: none; font-size: 1.3rem; color: var(--text-muted); cursor: pointer; display: none; }
.page-title { font-size: 1.15rem; font-weight: 600; margin: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.notif-bell { position: relative; font-size: 1.2rem; color: var(--text-muted); cursor: pointer; }
.notif-count {
  position: absolute; top: -6px; right: -8px; background: var(--danger); color: #fff;
  font-size: 0.65rem; padding: 1px 5px; border-radius: 10px; font-weight: 700;
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-light); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-name { font-size: 0.88rem; font-weight: 600; line-height: 1.1; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }

.content { padding: 26px; }

/* Cards */
.card { border: 1px solid var(--border); border-radius: 12px; background: var(--card-bg); box-shadow: 0 1px 3px rgba(20,30,50,0.04); }
.stat-card { padding: 20px; display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: #fff; flex-shrink: 0; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: 0.85rem; }

.bg-brand { background: var(--brand); }
.bg-accent { background: var(--accent); }
.bg-warning-solid { background: var(--warning); }
.bg-danger-solid { background: var(--danger); }

/* Tables */
.table thead th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); border-bottom-width: 1px; }
.table td { vertical-align: middle; font-size: 0.92rem; }
.card-table { padding: 0; overflow: hidden; }
.card-table .table { margin-bottom: 0; }
.card-header-flex { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card-header-flex h2 { font-size: 1rem; font-weight: 600; margin: 0; }

/* Badges */
.badge-status { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-running, .badge-healthy, .badge-completed, .badge-received, .badge-available { background: #e6f7ef; color: #17a673; }
.badge-maintenance, .badge-warning, .badge-pending, .badge-scheduled, .badge-busy, .badge-in_progress, .badge-ordered { background: #fef6e0; color: #b8860b; }
.badge-stopped, .badge-critical, .badge-cancelled, .badge-off_duty { background: #fdecea; color: #c0392b; }

/* Health gauge */
.health-ring { position: relative; width: 78px; height: 78px; }
.health-ring svg { transform: rotate(-90deg); }
.health-ring-value { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; }

/* Forms */
.form-label { font-weight: 600; font-size: 0.85rem; }
.form-card { padding: 24px; max-width: 760px; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

/* Login page */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand-light));
  padding: 20px;
}
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,0.2); }
.login-logo { text-align: center; margin-bottom: 8px; font-size: 2rem; color: var(--brand); }
.login-title { text-align: center; font-weight: 700; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 26px; }
.demo-creds { background: #f4f6fa; border-radius: 8px; padding: 12px 14px; font-size: 0.78rem; color: var(--text-muted); margin-top: 18px; }

/* Recommendation cards */
.rec-card { border-left: 4px solid var(--brand-light); padding: 14px 16px; border-radius: 8px; background: #f8fafc; margin-bottom: 10px; }
.rec-card.rec-stop { border-left-color: var(--danger); background: #fdf2f1; }
.rec-card.rec-major_maintenance { border-left-color: #e07b39; background: #fdf5ee; }
.rec-card.rec-minor_maintenance, .rec-card.rec-inspect { border-left-color: var(--warning); background: #fefaef; }
.rec-card.rec-none { border-left-color: var(--accent); background: #f2faf6; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 1000; margin-left: -250px; }
  .sidebar.open { margin-left: 0; }
  .sidebar-toggle { display: block; }
}
