/* Industrial CMMS Website — Purple-style layout, CMMS brand colors */
:root {
  --primary: #1565C0;
  --primary-dark: #0D47A1;
  --primary-light: #e3f2fd;
  --accent: #26A69A;
  --bg: #f4f5f9;
  --sidebar-w: 260px;
  --navbar-h: 70px;
  --card: #ffffff;
  --text: #343a40;
  --muted: #6c757d;
  --border: #ebedf2;
  --orange: #F57C00;
  --green: #43A047;
  --late: #B71C1C;
  --gradient-1: linear-gradient(135deg, #ff6f61 0%, #ff8a65 100%);
  --gradient-2: linear-gradient(135deg, #42a5f5 0%, #1565C0 100%);
  --gradient-3: linear-gradient(135deg, #26A69A 0%, #66bb6a 100%);
  --gradient-4: linear-gradient(135deg, #7e57c2 0%, #ab47bc 100%);
  --gradient-5: linear-gradient(135deg, #ef5350 0%, #B71C1C 100%);
  --gradient-6: linear-gradient(135deg, #00897b 0%, #26a69a 100%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Ubuntu', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.material-icons { vertical-align: middle; font-size: 22px; }
button, input, select { font-family: inherit; }
a { color: var(--primary); text-decoration: none; }

/* ========== Landing (SCADA / CMMS tabs) ========== */
.landing-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(120deg, var(--primary-dark), var(--primary) 55%, #42a5f5);
  padding: 40px 20px;
}
.landing-page h1 { color: #fff; font-size: 38px; margin-bottom: 8px; }
.landing-page p { color: rgba(255,255,255,.85); margin-bottom: 40px; }
.module-tabs { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
.module-tab {
  width: 260px; min-height: 220px; background: #fff; border: none;
  border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.18);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; cursor: pointer; transition: transform .2s, box-shadow .2s;
}
.module-tab:hover { transform: translateY(-6px); box-shadow: 0 14px 36px rgba(0,0,0,.22); }
.module-tab .material-icons { font-size: 64px; color: var(--primary); }
.module-tab span.title { font-size: 24px; font-weight: 700; color: var(--text); }
.module-tab span.sub { font-size: 13px; color: var(--muted); }

.under-dev {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: var(--bg);
}
.under-dev .material-icons { font-size: 80px; color: var(--muted); opacity: .5; }
.under-dev h2 { font-size: 32px; color: var(--text); }
.back-btn {
  margin-top: 20px; padding: 10px 24px; background: var(--primary); color: #fff;
  border: none; border-radius: 6px; font-weight: 600; cursor: pointer;
}

/* ========== Login overlay ========== */
.login-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.login-box {
  background: #fff; border-radius: 10px; padding: 36px; width: 100%; max-width: 400px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.login-box h2 { color: var(--primary); margin-bottom: 20px; text-align: center; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px;
}
.field input:focus { outline: none; border-color: var(--primary); }
.btn-primary {
  width: 100%; padding: 12px; background: var(--primary); color: #fff;
  border: none; border-radius: 6px; font-weight: 600; font-size: 15px; cursor: pointer;
}
.btn-primary:hover { background: var(--primary-dark); }
.err-msg { color: var(--late); font-size: 13px; margin: 8px 0; }

/* ========== App shell ========== */
.app-shell { display: flex; min-height: 100vh; }
.app-shell.sidebar-collapsed { --sidebar-w: 0px; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100; overflow-y: auto;
  transition: width .25s, min-width .25s;
  box-shadow: 2px 0 8px rgba(0,0,0,.04);
}
.app-shell.sidebar-collapsed .sidebar { overflow: hidden; border: none; }
.sidebar-profile {
  padding: 24px 20px; text-align: center;
  border-bottom: 1px solid var(--border);
}
.sidebar-profile .avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--gradient-2); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; margin: 0 auto 10px;
}
.sidebar-profile .name { font-weight: 700; font-size: 15px; }
.sidebar-profile .role { font-size: 12px; color: var(--muted); margin-top: 4px; }
.sidebar-nav { padding: 12px 0; }
.nav-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; color: var(--text); font-size: 14px; font-weight: 500;
  border: none; background: none; width: 100%; text-align: left; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--primary-light); color: var(--primary); }
.nav-link.active { background: var(--primary-light); color: var(--primary); font-weight: 700; }
.nav-link .material-icons { font-size: 20px; color: var(--muted); }
.nav-link.active .material-icons { color: var(--primary); }

/* Main */
.main-area {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  transition: margin-left .25s;
  min-height: 100vh;
}

/* Navbar */
.navbar {
  height: var(--navbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 22px; font-weight: 700; color: var(--primary);
  white-space: nowrap;
}
.navbar-brand .logo-icon {
  width: 36px; height: 36px; background: var(--primary);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.nav-icon-btn {
  width: 42px; height: 42px; border: none; background: transparent;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer; position: relative;
}
.nav-icon-btn:hover { background: var(--primary-light); color: var(--primary); }
.search-wrap { flex: 1; max-width: 420px; position: relative; }
.search-wrap input {
  width: 100%; padding: 10px 16px 10px 42px;
  border: 1px solid var(--border); border-radius: 24px;
  background: #fafbfc; font-size: 14px;
}
.search-wrap input:focus { outline: none; border-color: var(--primary); background: #fff; }
.search-wrap .material-icons {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 20px; color: var(--muted); pointer-events: none;
}
.navbar-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.user-block {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px; border-radius: 30px;
  background: #f8f9fa; margin-right: 8px;
}
.user-block .avatar-sm {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gradient-2); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.user-block .uname { font-size: 14px; font-weight: 600; color: var(--text); }
.badge-dot {
  position: absolute; top: 6px; right: 6px;
  min-width: 18px; height: 18px; border-radius: 9px;
  background: #ff6b6b; color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* Content */
.content { flex: 1; padding: 24px 28px 40px; }

/* Page header row */
.page-top {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px; margin-bottom: 24px;
}
.page-top-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-top-right {
  display: flex; align-items: center; gap: 8px;
  font-size: 18px; font-weight: 700; color: var(--text);
}
.page-top-right .material-icons { color: var(--primary); font-size: 26px; }
.filter-select {
  padding: 10px 36px 10px 14px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; font-size: 14px; font-weight: 500;
  color: var(--text); cursor: pointer; min-width: 140px;
}
.filter-select:focus { outline: none; border-color: var(--primary); }

/* Stat cards — dashboard: 3 per row (6 cards = 2 rows) */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}
.stats-row.dashboard-stats { grid-template-columns: repeat(3, 1fr); }
.stats-row.tasks-row { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 992px) { .stats-row.tasks-row { grid-template-columns: repeat(2, 1fr); } }
.stat-card.task-stat.active-stat { outline: 3px solid var(--primary); outline-offset: 2px; }
@media (max-width: 1200px) { .stats-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .stats-row { grid-template-columns: 1fr 1fr; } }

.stat-card {
  border-radius: 10px; padding: 22px 20px; color: #fff;
  position: relative; overflow: hidden; min-height: 130px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.stat-card::after {
  content: ''; position: absolute; right: -20px; top: -20px;
  width: 90px; height: 90px; border-radius: 50%;
  background: rgba(255,255,255,.15);
}
.stat-card .sc-icon { font-size: 32px; opacity: .9; margin-bottom: 8px; }
.stat-card .sc-label { font-size: 14px; font-weight: 500; opacity: .95; }
.stat-card .sc-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-card.c1 { background: var(--gradient-2); }
.stat-card.c2 { background: var(--gradient-1); }
.stat-card.c3 { background: var(--gradient-3); }
.stat-card.c4 { background: var(--gradient-4); }
.stat-card.c5 { background: var(--gradient-5); }
.stat-card.c6 { background: var(--gradient-6); }

/* MTTR / MTTF two columns */
.analysis-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 992px) { .analysis-row { grid-template-columns: 1fr; } }

.panel-card {
  background: #fff; border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
  overflow: hidden;
}
.panel-head {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  font-size: 17px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; justify-content: space-between;
}
.period-tabs { display: flex; gap: 6px; }
.period-tab {
  padding: 6px 14px; border: 1px solid var(--border); background: #fff;
  border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.period-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.panel-body { padding: 20px 22px; }

.chart-box {
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.chart-box-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-height: 160px;
  padding: 10px 0;
}
.chart-bar-wrap {
  flex: 0 0 48px;
  min-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.chart-bar {
  width: 100%; max-width: 48px; border-radius: 6px 6px 0 0;
  background: var(--primary); min-height: 4px;
  transition: height .3s;
}
.chart-bar-label { font-size: 10px; color: var(--muted); text-align: center; word-break: break-word; }
.chart-bar-val { font-size: 11px; font-weight: 700; color: var(--primary); }

.summary-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-bottom: 20px;
}
.summary-item {
  background: var(--primary-light); border-radius: 8px;
  padding: 14px; text-align: center;
}
.summary-item .si-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.summary-item .si-val { font-size: 20px; font-weight: 700; color: var(--primary); margin-top: 4px; }

.data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.complaint-table-wrap .data-table { min-width: 720px; }
.data-table-wrap::after {
  content: '';
  display: block;
  height: 0;
}
@media (max-width: 991px) {
  .complaint-table-wrap::before {
    content: 'Swipe sideways to see all columns';
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 8px;
    text-align: center;
  }
  .data-table { min-width: 560px; }
}
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table th {
  background: #f8f9fa; padding: 12px 14px; text-align: left;
  font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--border);
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: #fafbfc; }

/* Empty page placeholder */
.empty-page {
  background: #fff; border-radius: 10px; border: 1px solid var(--border);
  padding: 80px 40px; text-align: center; color: var(--muted);
}
.empty-page .material-icons { font-size: 64px; opacity: .35; margin-bottom: 12px; }

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 300; display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: #fff; border-radius: 10px; width: 90%; max-width: 480px;
  max-height: 80vh; overflow-y: auto; box-shadow: 0 16px 48px rgba(0,0,0,.2);
}
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-weight: 700; display: flex; justify-content: space-between; align-items: center;
}
.modal-body { padding: 20px; }
.notif-item {
  padding: 12px 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.notif-item:last-child { border-bottom: none; }

/* Clickable stat cards */
.stat-card.clickable { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.stat-card.clickable:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.18); }

/* Page sections */
.page-section { background: #fff; border-radius: 10px; border: 1px solid var(--border); padding: 24px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.page-section-head { margin-bottom: 20px; }
.page-section-head h2 { font-size: 20px; font-weight: 700; }

.toolbar-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.btn-outline {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border: 1px solid var(--primary); background: #fff;
  color: var(--primary); border-radius: 6px; font-weight: 600; cursor: pointer;
}
.btn-outline:hover { background: var(--primary-light); }
.btn-secondary {
  padding: 12px 24px; border: 1px solid var(--border); background: #fff;
  border-radius: 6px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.btn-secondary:hover { background: #f8f9fa; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; align-items: flex-end; }
.field.inline { margin-bottom: 0; min-width: 160px; }
.field.inline label { font-size: 12px; margin-bottom: 4px; }
.field.inline input, .field.inline select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }

/* Forms */
.form-card { background: #fafbfc; border: 1px solid var(--border); border-radius: 10px; padding: 24px; margin-bottom: 24px; }
.form-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; resize: vertical; }
.form-grid select { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; background: #fff; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; }

.registry-title { font-size: 16px; font-weight: 700; margin: 8px 0 12px; }
.registry-list { display: flex; flex-direction: column; gap: 8px; }
.registry-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 8px; background: #fafbfc;
}
.registry-item-body { flex: 1; min-width: 0; }
.registry-item .material-icons { color: var(--primary); }
.registry-item .registry-delete { flex-shrink: 0; }
.registry-item-actions { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }
.muted { color: var(--muted); font-size: 13px; }
.inline-check { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.inline-check input { width: auto; }
.perm-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.perm-row { font-weight: 500; }
.machine-section-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.machine-section-row input { flex: 1; padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.bulk-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px; padding: 10px 14px; border-radius: 8px;
  background: #fdecea; border: 1px solid #f5c2c0;
}
.bulk-toolbar[hidden] { display: none !important; }
.bulk-count { font-weight: 600; color: #b71c1c; }
.bulk-col { width: 42px; text-align: center; }
.bulk-col input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.btn-danger {
  background: #d32f2f; color: #fff; border: none; border-radius: 6px;
  padding: 8px 14px; font-weight: 600; cursor: pointer;
}
.btn-danger:hover { background: #b71c1c; }
.btn-danger:disabled { opacity: 0.6; cursor: not-allowed; }
.faults-filters { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
.faults-filter-dates { display: flex; gap: 12px; width: 100%; }
.faults-filter-dates .field { flex: 1; min-width: 0; }
.faults-filter-dates input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }

.complaint-table-wrap { margin-top: 8px; }
.complaint-table { font-size: 12px; }
.complaint-table th, .complaint-table td { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.row-late td { background: #fff8f8; }
.late-badge { color: var(--late); font-weight: 700; }
.empty-table-msg { text-align: center; padding: 48px; color: var(--muted); }

.tbl-btn {
  width: 34px; height: 34px; border: none; background: transparent;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: var(--primary); cursor: pointer; vertical-align: middle;
}
.tbl-btn:hover { background: var(--primary-light); }
.tbl-btn.danger { color: var(--late); }
.tbl-btn.danger:hover { background: #ffebee; }
.tbl-btn .material-icons { font-size: 20px; }
.tbl-btn[data-action="pdf"] .material-icons { color: #c62828; }
.btn-tbl-text {
  padding: 6px 12px; border: 1px solid var(--primary); background: #fff;
  color: var(--primary); border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.btn-tbl-text:hover:not(:disabled) { background: var(--primary-light); }
.btn-tbl-text:disabled { opacity: .5; cursor: default; border-color: var(--border); color: var(--muted); }
.btn-tbl-text.active-pill { background: var(--primary-light); border-color: var(--primary); font-weight: 700; }

.date-badge {
  display: inline-block; margin-top: 4px; padding: 2px 6px; border-radius: 4px;
  font-size: 11px; font-weight: 700;
}
.date-badge.status-overdue { color: #c62828; background: #ffebee; }
.date-badge.status-due { color: #e65100; background: #fff3e0; }
.date-badge.status-upcoming { color: #2e7d32; background: #e8f5e9; }

.drill-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.drill-header h2 { font-size: 18px; font-weight: 700; margin: 0; }
.btn-back {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border: 1px solid var(--border); background: #fff; border-radius: 6px;
  font-weight: 600; cursor: pointer; color: var(--primary);
}
.btn-back:hover { background: var(--primary-light); }

.modal-wide { max-width: 640px; }

/* ========== Project Gantt chart ========== */
.gantt-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  overflow: hidden;
}
.gantt-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.gantt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
}
.gantt-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.gantt-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  font-style: normal;
}
.gantt-scroll {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.gantt-header-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.gantt-corner {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 13px;
  border-right: 1px solid var(--border);
  background: #fafbfc;
}
.gantt-header-scroll {
  overflow: hidden;
  flex: 1;
}
.gantt-header {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.gantt-week-row,
.gantt-day-row {
  display: flex;
  flex-wrap: nowrap;
}
.gantt-week-label {
  flex-shrink: 0;
  padding: 6px 4px 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  border-right: 1px solid var(--border);
}
.gantt-day-label {
  flex-shrink: 0;
  text-align: center;
  padding: 2px 0 6px;
  font-size: 10px;
  color: var(--muted);
  border-right: 1px solid #eef0f4;
}
.gantt-body {
  display: flex;
  max-height: 520px;
  overflow: hidden;
}
.gantt-labels {
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--border);
  background: #fff;
}
.gantt-group-label {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.gantt-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 12px;
  border-bottom: 1px solid #eef0f4;
}
.gantt-label-title {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gantt-label-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gantt-chart-area {
  flex: 1;
  overflow: auto;
  position: relative;
  background: #fff;
}
.gantt-grid {
  position: absolute;
  top: 0;
  left: 0;
  background-image: linear-gradient(to right, #eef0f4 1px, transparent 1px);
  pointer-events: none;
  z-index: 0;
}
.gantt-rows {
  position: relative;
  z-index: 1;
}
.gantt-row {
  position: relative;
  border-bottom: 1px solid #eef0f4;
}
.gantt-group-spacer {
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.gantt-track {
  position: relative;
}
.gantt-bar {
  position: absolute;
  top: 8px;
  height: calc(100% - 16px);
  min-height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

@media (max-width: 768px) { .form-grid { grid-template-columns: 1fr; } }

.team-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.team-toggle input { cursor: pointer; }

.attendance-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin-right: 4px;
  border-radius: 20px;
  background: #f8f9fa;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.attendance-toggle input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.manpower-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--muted);
}
.manpower-legend span,
.avail-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.avail-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ========== Mobile responsive ========== */
@media (max-width: 991px) {
  body { overflow-x: hidden; }
  .app-shell { --sidebar-w: 0px; }
  .sidebar {
    width: 260px;
    min-width: 260px;
    transform: translateX(-100%);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    z-index: 120;
  }
  .app-shell:not(.sidebar-collapsed) .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }
  .app-shell.sidebar-collapsed .sidebar {
    overflow: hidden;
    border: none;
  }
  .main-area { margin-left: 0; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 110;
  }
  .navbar {
    padding: 0 12px;
    gap: 8px;
    height: 60px;
  }
  .navbar-brand span:last-child { display: none; }
  .search-wrap { display: none; }
  .user-block .uname { display: none; }
  .user-block {
    padding: 4px;
    margin-right: 0;
    background: transparent;
  }
  .content { padding: 16px 14px 32px; }
  .page-top {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-top-left {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .page-top-left .filter-select { width: 100%; }
  .page-top-right { font-size: 16px; }
  .filter-select { width: 100%; min-width: 0; }
  .stats-row,
  .stats-row.dashboard-stats,
  .stats-row.tasks-row {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .stat-card { min-height: 110px; padding: 16px 14px; }
  .stat-card .sc-value { font-size: 22px; }
  .summary-grid { grid-template-columns: 1fr; }
  .panel-card { border-radius: 8px; }
  .panel-head {
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 16px;
  }
  .panel-body { padding: 16px; }
  .period-tabs { flex-wrap: wrap; }
  .page-section { padding: 16px; }
  .page-section-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .page-section-head .btn-outline,
  .page-section-head .btn-back {
    width: 100%;
    justify-content: center;
    margin-bottom: 0 !important;
  }
  .page-section-head h2 { font-size: 18px; }
  .toolbar-row { flex-direction: column; align-items: stretch; }
  .toolbar-row .btn-outline,
  .toolbar-row .btn-primary,
  .toolbar-row .btn-secondary {
    width: 100%;
    justify-content: center;
  }
  .filter-bar { flex-direction: column; align-items: stretch; gap: 12px; }
  .field.inline { min-width: 0; width: 100%; }
  .form-card { padding: 16px; }
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions button { width: 100%; }
  .bulk-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .bulk-toolbar .btn-danger { width: 100%; }
  .drill-header { flex-direction: column; align-items: stretch; }
  .drill-header h2 { font-size: 16px; }
  .btn-back { width: 100%; justify-content: center; }
  .registry-item { flex-wrap: wrap; gap: 10px; }
  .registry-item-actions { width: 100%; justify-content: flex-end; }
  .faults-filter-dates { flex-direction: column; }
  .modal-box { width: 94%; max-height: 90vh; }
  .modal-wide { max-width: none; }
  .login-box { margin: 16px; padding: 24px 20px; }
  .gantt-body { max-height: 360px; }
  .gantt-corner,
  .gantt-labels { min-width: 100px; }
  .gantt-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .chart-box { max-height: none; }
  .complaint-table { font-size: 11px; }
  .complaint-table th,
  .complaint-table td { padding: 8px 10px; }
  #edit-complaint-form,
  #add-task-form,
  #edit-task-form,
  #add-schedule-form {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }
  .machine-section-row { flex-direction: column; align-items: stretch; }
  .machine-section-row input,
  .machine-section-row button { width: 100%; }
  .perm-list { font-size: 14px; }
  .dashboard-section-head { font-size: 17px; flex-wrap: wrap; }
  .util-check-list { grid-template-columns: 1fr !important; }
  .page-top-left,
  .page-top-right { width: 100%; }
  .nav-icon-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }
  .attendance-toggle {
    padding: 6px 8px;
    margin-right: 0;
  }
}

@media (max-width: 575px) {
  .landing-page { padding: 28px 16px; }
  .landing-page h1 { font-size: 28px; }
  .landing-page p { font-size: 14px; margin-bottom: 28px; }
  .module-tabs { flex-direction: column; align-items: center; width: 100%; }
  .module-tab {
    width: 100%;
    max-width: 320px;
    min-height: 160px;
  }
  .module-tab .material-icons { font-size: 48px; }
  .module-tab span.title { font-size: 20px; }

  .stats-row,
  .stats-row.dashboard-stats,
  .stats-row.tasks-row {
    grid-template-columns: 1fr;
  }
  .navbar-brand .logo-icon { width: 32px; height: 32px; }
  .stat-card .sc-value { font-size: 20px; }
  .stat-card .sc-label { font-size: 12px; }
  .stat-card .sc-icon { font-size: 26px; }

  .attendance-toggle span:first-child { display: none; }
  .empty-page { padding: 48px 20px; }
  .empty-table-msg { padding: 32px 16px; }
  .manpower-legend { flex-direction: column; gap: 8px; }
  .btn-tbl-text {
    padding: 8px 10px;
    font-size: 11px;
  }
  .tbl-btn {
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 991px) and (orientation: landscape) {
  .sidebar { width: 240px; min-width: 240px; }
  .content { padding-top: 12px; }
}
