/* ============================================
   Chamanke HSE Module — Styles
   Inherits from theme.css universal system
   Accent: Chamanke Red #e52121
   ============================================ */

/* ---- HSE KPIs → Alias to universal ---- */
.hse-kpi-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:16px; margin-bottom:24px }
.hse-kpi-card {
  background:var(--bg-card);
  border:1px solid var(--border-primary);
  border-radius:var(--radius-lg);
  padding:20px;
  display:flex; align-items:center; gap:14px;
  transition:all var(--transition-med);
  box-shadow:var(--shadow-card);
}
.hse-kpi-card:hover { border-color:#cbd5e1; transform:translateY(-2px); box-shadow:var(--shadow-md) }
.hse-kpi-icon {
  width:48px; height:48px;
  border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  font-size:1.25rem; flex-shrink:0;
}
.hse-kpi-info { display:flex; flex-direction:column; gap:2px }
.hse-kpi-value { font-size:1.5rem; font-weight:800; letter-spacing:-0.03em; line-height:1.1; color:var(--text-primary) }
.hse-kpi-label { font-size:0.76rem; color:var(--text-secondary); font-weight:500 }

/* ---- HSE Charts ---- */
.hse-charts-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:20px; margin-bottom:24px }

/* ---- HSE Sub-navigation ---- */
.hse-subnav {
  display:flex; gap:6px; margin-bottom:24px;
  border-bottom:2px solid var(--border-primary);
  padding-bottom:0;
  overflow-x:auto;
}
.hse-subnav-btn {
  padding:10px 18px;
  background:none; border:none;
  color:var(--text-secondary);
  font-size:0.85rem; font-weight:600; font-family:inherit;
  cursor:pointer;
  border-bottom:2px solid transparent;
  margin-bottom:-2px;
  transition:all var(--transition-fast);
  white-space:nowrap;
  display:flex; align-items:center; gap:6px;
}
.hse-subnav-btn:hover { color:var(--text-primary); background:rgba(30,41,59,0.04) }
.hse-subnav-btn.active {
  color:var(--accent);
  border-bottom-color:var(--accent);
}
.hse-subnav-badge {
  font-size:0.68rem; font-weight:700;
  padding:1px 7px; border-radius:10px;
  background:rgba(229,33,33,0.1); color:var(--accent);
}

/* ---- HSE Sub-panels ---- */
.hse-subpanel { display:none; animation:fadeInUp 0.3s ease }
.hse-subpanel.active { display:block }

/* ---- HSE Section Header ---- */
.hse-section-header {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:18px; flex-wrap:wrap; gap:10px;
}
.hse-section-header h3 { font-size:1.05rem; font-weight:700; color:var(--text-primary) }

/* ---- HSE Table ---- */
.hse-table-wrapper {
  overflow-x:auto;
  border:1px solid var(--border-primary);
  border-radius:var(--radius-lg);
  background:var(--bg-card);
  box-shadow:var(--shadow-card);
}
.hse-table { width:100%; border-collapse:collapse; font-size:0.85rem }
.hse-table thead { position:sticky; top:0; z-index:10 }
.hse-table th {
  background:var(--table-header-bg); padding:12px 16px;
  text-align:left; font-weight:700; color:var(--table-header-text);
  font-size:0.85rem; text-transform:uppercase; letter-spacing:0.04em;
  border-right:1px solid rgba(255,255,255,0.15); white-space:nowrap;
}
.hse-table th:last-child { border-right:none; }
.hse-table td {
  padding:12px 16px; border-bottom:1px solid var(--table-border);
  border-right:1px solid var(--table-border); vertical-align:middle; color:var(--text-primary);
}
.hse-table td:last-child { border-right:none; }
.hse-table tbody tr { background:var(--bg-card); transition:all var(--transition-fast); cursor:pointer }
.hse-table tbody tr:hover { filter:brightness(0.96); box-shadow:inset 0 0 0 1px rgba(30,41,59,0.15) }
.hse-table tbody tr:last-child td { border-bottom:none }

/* ---- HSE Severity Badges ---- */
.hse-severity {
  display:inline-flex; align-items:center; gap:4px;
  padding:3px 10px; border-radius:20px;
  font-size:0.76rem; font-weight:600; white-space:nowrap;
}
.hse-sev-critical { background:rgba(220,38,38,0.1); color:#dc2626 }
.hse-sev-major { background:rgba(234,88,12,0.1); color:#ea580c }
.hse-sev-minor { background:rgba(217,119,6,0.1); color:#d97706 }
.hse-sev-observation { background:rgba(37,99,235,0.1); color:#2563eb }

/* ---- HSE Status Badges ---- */
.hse-status {
  display:inline-flex; align-items:center; gap:4px;
  padding:3px 10px; border-radius:20px;
  font-size:0.76rem; font-weight:600; white-space:nowrap;
}
.hse-st-open { background:rgba(220,38,38,0.08); color:#dc2626 }
.hse-st-investigating { background:rgba(217,119,6,0.08); color:#d97706 }
.hse-st-closed { background:rgba(22,163,74,0.08); color:#16a34a }
.hse-st-active { background:rgba(37,99,235,0.08); color:#2563eb }
.hse-st-expired { background:rgba(148,163,184,0.15); color:#64748b }
.hse-st-scheduled { background:rgba(147,51,234,0.08); color:#9333ea }

/* ---- HSE Cards Grid ---- */
.hse-cards-grid {
  display:grid; grid-template-columns:repeat(auto-fill,minmax(320px,1fr));
  gap:14px; margin-bottom:20px;
}
.hse-card {
  background:var(--bg-card); border:1px solid var(--border-primary);
  border-left:4px solid var(--bg-sidebar);
  border-radius:var(--radius-md); padding:16px 18px;
  cursor:pointer; transition:all var(--transition-med);
  box-shadow:var(--shadow-card);
}
.hse-card:hover { transform:translateY(-2px); box-shadow:var(--shadow-md) }
.hse-card.card-critical { border-left-color:#dc2626 }
.hse-card.card-major { border-left-color:#ea580c }
.hse-card.card-minor { border-left-color:#d97706 }
.hse-card.card-expired { border-left-color:#dc2626 }
.hse-card.card-expiring { border-left-color:#d97706 }

.hse-card-top { display:flex; justify-content:space-between; align-items:center; margin-bottom:6px }
.hse-card-id { font-family:'JetBrains Mono','Fira Code',monospace; font-size:0.8rem; color:var(--text-tertiary); font-weight:600 }
.hse-card-title { font-size:1rem; font-weight:700; color:var(--text-primary); margin-bottom:8px }
.hse-card-meta { display:grid; grid-template-columns:repeat(2,1fr); gap:4px 12px; font-size:0.82rem }
.hse-card-meta-label { font-size:0.72rem; font-weight:700; text-transform:uppercase; letter-spacing:0.05em; color:var(--text-tertiary) }
.hse-card-meta-value { color:var(--text-primary); font-weight:500 }

/* ---- HSE Days Counter ---- */
.hse-days-counter {
  text-align:center; padding:30px 20px;
  background:var(--bg-card); border:1px solid var(--border-primary);
  border-radius:var(--radius-lg); box-shadow:var(--shadow-card);
  margin-bottom:20px;
}
.hse-days-number {
  font-size:4rem; font-weight:900; color:var(--accent);
  letter-spacing:-0.04em; line-height:1;
}
.hse-days-label { font-size:0.9rem; color:var(--text-secondary); font-weight:600; margin-top:6px }

/* ---- HSE Corrective Actions Inline ---- */
.hse-actions-list { display:flex; flex-direction:column; gap:6px; margin-top:10px }
.hse-actions-list-header > div { min-width: 0; }
.hse-action-item {
  display:flex; align-items:center; gap:10px;
  padding:8px 12px; background:var(--bg-primary);
  border:1px solid var(--border-primary);
  border-radius:var(--radius-sm); font-size:0.82rem;
}
.hse-action-item.overdue { border-left:3px solid #dc2626 }
.hse-action-item.done { opacity:0.6 }
.hse-action-item .input-field { min-width: 0; width: 100%; }
.hse-action-check { font-size:1rem }

/* ---- HSE Cert Calendar ---- */
.hse-cert-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:12px }
.hse-cert-card {
  background:var(--bg-card); border:1px solid var(--border-primary);
  border-radius:var(--radius-md); padding:14px 16px;
  box-shadow:var(--shadow-card); transition:all var(--transition-med);
}
.hse-cert-card:hover { box-shadow:var(--shadow-md) }
.hse-cert-name { font-weight:700; font-size:0.95rem; color:var(--text-primary); margin-bottom:4px }
.hse-cert-role { font-size:0.8rem; color:var(--text-secondary); margin-bottom:8px }
.hse-cert-badges { display:flex; flex-wrap:wrap; gap:4px }
.hse-cert-badge {
  display:inline-flex; align-items:center; gap:4px;
  padding:3px 8px; border-radius:6px;
  font-size:0.72rem; font-weight:600;
}
.hse-cert-valid { background:rgba(22,163,74,0.08); color:#16a34a }
.hse-cert-expiring { background:rgba(217,119,6,0.1); color:#d97706 }
.hse-cert-expired { background:rgba(220,38,38,0.1); color:#dc2626 }

/* ---- HSE Permits Board ---- */
.hse-permits-board { display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); gap:14px }
.hse-permit-card {
  background:var(--bg-card); border:1px solid var(--border-primary);
  border-top:4px solid var(--accent);
  border-radius:var(--radius-md); padding:16px;
  box-shadow:var(--shadow-card); transition:all var(--transition-med);
  cursor:pointer;
}
.hse-permit-card:hover { box-shadow:var(--shadow-md); transform:translateY(-2px) }
.hse-permit-card.permit-active { border-top-color:#2563eb }
.hse-permit-card.permit-expired { border-top-color:#dc2626; opacity:0.8 }
.hse-permit-card.permit-closed { border-top-color:#64748b; opacity:0.7 }

/* ---- HSE Toolbox Log ---- */
.hse-toolbox-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(340px,1fr)); gap:12px }
.hse-toolbox-card {
  background:var(--bg-card); border:1px solid var(--border-primary);
  border-radius:var(--radius-md); padding:14px 16px;
  box-shadow:var(--shadow-card); transition:all var(--transition-med);
  cursor:pointer;
}
.hse-toolbox-card:hover { box-shadow:var(--shadow-md) }

/* ---- HSE Empty State ---- */
.hse-empty { text-align:center; padding:60px 20px }
.hse-empty .empty-icon { font-size:3.5rem; margin-bottom:16px; opacity:0.6 }
.hse-empty h3 { font-size:1.15rem; font-weight:600; margin-bottom:8px; color:var(--text-primary) }
.hse-empty p { color:var(--text-secondary); margin-bottom:24px; font-size:0.9rem }

/* ---- HSE Compliance Gauge ---- */
.hse-gauge-wrap { display:flex; align-items:center; justify-content:center; gap:20px; padding:20px }
.hse-gauge-bar {
  width:100%; height:24px; background:var(--bg-primary);
  border-radius:12px; overflow:hidden; position:relative;
}
.hse-gauge-fill {
  height:100%; border-radius:12px;
  background:linear-gradient(90deg,var(--bg-sidebar),var(--accent));
  transition:width 0.6s ease;
}
.hse-gauge-text {
  position:absolute; right:10px; top:50%; transform:translateY(-50%);
  font-size:0.78rem; font-weight:700; color:var(--text-primary);
}

/* ---- HSE Inspection Score ---- */
.hse-score {
  display:inline-flex; align-items:center; justify-content:center;
  width:40px; height:40px; border-radius:50%;
  font-size:0.82rem; font-weight:800; color:#fff;
}
.hse-score-good { background:#16a34a }
.hse-score-ok { background:#d97706 }
.hse-score-bad { background:#dc2626 }

/* ---- HSE Form Section in Modal ---- */
.hse-form-section { margin-bottom:20px }
.hse-form-section-title {
  font-size:0.8rem; font-weight:600;
  text-transform:uppercase; letter-spacing:0.06em;
  color:#1e293b;
  margin-bottom:12px; padding-bottom:6px;
  border-bottom:1px solid var(--border-primary);
  padding-left:10px;
  border-left:3px solid var(--accent);
}

/* ---- Responsive ---- */
@media(max-width:1024px) { .hse-charts-grid{grid-template-columns:1fr} }
@media(max-width:768px) {
  .hse-cards-grid,.hse-cert-grid,.hse-permits-board,.hse-toolbox-grid{grid-template-columns:1fr}
  .hse-card-meta{grid-template-columns:1fr}
  .hse-subnav{gap:2px}
  .hse-subnav-btn{padding:8px 12px; font-size:0.8rem}
}

/* ============================================
   HSE — Corrective Action Tracker (overview)
   ============================================ */
.hse-action-tracker .hse-action-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.hse-action-count {
  font-size: 0.8rem; font-weight: 700; color: var(--text-secondary);
  background: var(--bg-input); border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm); padding: 3px 12px;
}
.hse-action-empty { text-align: center; padding: 28px; color: #16a34a; font-weight: 600; font-size: 0.9rem; }
.hse-action-tracker tbody tr { cursor: pointer; }
.hse-act-row-overdue { background: rgba(220,38,38,0.05); }
.hse-act-overdue { color: #dc2626; font-weight: 700; white-space: nowrap; }
.hse-act-soon { color: #d97706; font-weight: 600; white-space: nowrap; }
.hse-act-tag {
  display: inline-block; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.02em;
  border-radius: 4px; padding: 1px 6px; margin-left: 4px; vertical-align: middle;
  background: rgba(220,38,38,0.12);
}
.hse-act-soon .hse-act-tag { background: rgba(217,119,6,0.14); }
.hse-src-badge {
  display: inline-block; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.03em;
  border-radius: 4px; padding: 1px 7px; vertical-align: middle;
}
.hse-src-inc  { background: rgba(220,38,38,0.12); color: #dc2626; }
.hse-src-insp { background: rgba(37,99,235,0.12); color: #2563eb; }

/* ============================================
   HSE — Toolbar / Search / Filters (per subview)
   ============================================ */
.hse-toolbar {
  display:flex; flex-wrap:wrap; align-items:center; gap:10px;
  margin-bottom:14px; padding:12px;
  background:var(--bg-card); border:1px solid var(--border-primary);
  border-radius:var(--radius-md);
}
.hse-search-wrap { position:relative; flex:1 1 240px; min-width:200px; }
.hse-search-icon {
  position:absolute; left:10px; top:50%; transform:translateY(-50%);
  font-size:0.9rem; color:var(--text-tertiary); pointer-events:none;
}
.hse-search-input {
  width:100%; padding:8px 12px 8px 32px;
  background:var(--bg-input); border:1px solid var(--border-input);
  border-radius:var(--radius-sm); font-size:0.88rem; color:var(--text-primary);
  font-family:inherit;
}
.hse-search-input:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px rgba(229,33,33,0.1); }
.hse-filter-select {
  padding:8px 28px 8px 10px;
  background:var(--bg-input); border:1px solid var(--border-input);
  border-radius:var(--radius-sm); font-size:0.85rem; color:var(--text-primary);
  font-family:inherit; cursor:pointer; min-width:140px;
}
.hse-filter-select:focus { outline:none; border-color:var(--accent); }

/* ---- Collapsible Overview blocks ---- */
.hse-collapse-block { margin-bottom:20px }
.hse-collapse-toggle {
  display:flex; align-items:center; gap:8px;
  padding:8px 14px; margin-bottom:12px;
  background:var(--bg-card); border:1px solid var(--border-primary);
  border-radius:var(--radius-sm); cursor:pointer;
  font-size:0.85rem; font-weight:700; color:var(--text-primary);
  font-family:inherit;
}
.hse-collapse-toggle:hover { background:var(--bg-input); border-color:var(--accent); }
.hse-collapse-toggle span { font-size:0.75rem; color:var(--accent); }

/* ---- Clickable KPI cards ---- */
.hse-kpi-clickable { cursor:pointer; }
.hse-kpi-clickable:hover { transform:translateY(-2px); box-shadow:var(--shadow-md); border-color:var(--accent); }

/* ---- Today / Now buttons next to date fields ---- */
.hse-date-wrap { position:relative; display:flex; gap:6px; align-items:stretch; }
.hse-date-wrap input { flex:1; min-width:0; }
.hse-today-btn {
  padding:0 10px; border:1px solid var(--border-input);
  background:var(--bg-input); color:var(--text-primary);
  border-radius:var(--radius-sm); font-size:0.75rem; font-weight:700;
  cursor:pointer; white-space:nowrap; font-family:inherit;
  transition:all var(--transition-fast);
}
.hse-today-btn:hover { background:var(--accent); color:#fff; border-color:var(--accent); }

/* ---- "+ Add new" inline text input revealed by select ---- */
.hse-new-input { animation:fadeInUp 0.2s ease; }

/* ---- Inline Days Lost hint ---- */
.hse-field-hint {
  display:inline-block; font-size:0.7rem; font-weight:600;
  margin-left:6px; padding:1px 6px; border-radius:4px;
  background:rgba(220,38,38,0.12); color:#dc2626;
}
.hse-field-hint:empty { display:none; }

/* ---- Quick-close button in action tracker ---- */
.hse-act-close-btn {
  padding:3px 9px; border:1px solid var(--border-input);
  background:var(--bg-input); color:#16a34a;
  border-radius:var(--radius-sm); font-size:0.72rem; font-weight:700;
  cursor:pointer; white-space:nowrap; font-family:inherit;
}
.hse-act-close-btn:hover { background:#16a34a; color:#fff; border-color:#16a34a; }

/* ---- Cert filter highlight (when filter set by KPI click) ---- */
.hse-cert-card.hse-cert-hidden { display:none; }

/* ---- Mobile toolbar wrap ---- */
@media(max-width:768px) {
  .hse-toolbar { padding:10px; gap:8px; }
  .hse-search-wrap { flex:1 1 100%; }
  .hse-filter-select { flex:1 1 calc(50% - 4px); min-width:0; }
  .hse-toolbar .btn-secondary { flex:1 1 100%; }
  .hse-collapse-toggle { width:100%; justify-content:flex-start; }
}
