/* =========================================================
   Ajay Metal ERP — app.css
   Bootstrap 5.3 overrides + custom component styles
   ========================================================= */

/* ─── Base ─────────────────────────────────────────────── */
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #f1f5f9;
  color: #111827;
}

/* Full-height fixed layout (dashboard) */
body.layout-fixed {
  height: 100vh;
  overflow: hidden;
}
body.layout-fixed .main {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.layout-fixed .content-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 30px;
  -webkit-overflow-scrolling: touch;
}

/* Scrollable layout (admin, masters pages) */
body:not(.layout-fixed) .main {
  min-height: 100vh;
}
body:not(.layout-fixed) .content-body {
  padding: 20px 24px 30px;
}

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: -250px;
  top: 0;
  width: 240px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 600;
  transition: left 0.25s ease;
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 60%, #3730a3 100%);
}
.sidebar.open { left: 0; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 599;
}
.sidebar-overlay.open { display: block; }

/* Brand */
.sidebar-brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.sidebar-brand img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.brand-name {
  color: #f9fafb;
  font-size: 14px;
  font-weight: 700;
  margin-top: 6px;
  letter-spacing: 0.3px;
}
.brand-sub {
  color: rgba(255,255,255,0.4);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Nav sections */
.nav-section {
  padding: 16px 16px 5px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

/* Nav items */
a.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  margin: 1px 0;
}
a.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
  border-left-color: rgba(255,255,255,0.2);
}
a.nav-item.active {
  background: rgba(255,255,255,0.13);
  color: #fff;
  border-left-color: #818cf8;
  font-weight: 600;
}
a.nav-item i {
  font-size: 15px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

/* Sidebar footer — user identity */
.sidebar-footer {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.sb-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.sb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sb-user-info { min-width: 0; }
.sb-user-name {
  color: #f9fafb;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-user-role {
  color: rgba(255,255,255,0.45);
  font-size: 10px;
  margin-top: 1px;
}
.sb-logout {
  color: rgba(255,255,255,0.4);
  font-size: 17px;
  text-decoration: none;
  flex-shrink: 0;
  padding: 4px;
  border-radius: 5px;
  transition: all 0.15s;
}
.sb-logout:hover {
  color: #f87171;
  background: rgba(239,68,68,0.15);
}

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left  { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-size: 15px; font-weight: 700; color: #111827; }
#live-clock   { font-size: 15px; font-weight: 700; color: #111827; font-variant-numeric: tabular-nums; min-width: 76px; text-align: right; }

.hamburger {
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  cursor: pointer;
  padding: 5px 8px;
  color: #374151;
  font-size: 18px;
  display: flex;
  align-items: center;
  line-height: 1;
  transition: all 0.15s;
}
.hamburger:hover { background: #f3f4f6; border-color: #d1d5db; }

.live-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #f0fdf4;
  color: #16a34a;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.live-dot {
  width: 7px; height: 7px;
  background: #16a34a;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}
.topbar-hide-mobile { display: flex; align-items: center; }

/* ─── Info Strip ────────────────────────────────────────── */
.info-strip {
  background: #fff;
  border-radius: 8px;
  padding: 7px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  font-size: 12px;
  color: #6b7280;
  flex-wrap: nowrap;
  overflow: visible;
}
.info-strip span strong { color: #111827; }
.info-divider  { width: 1px; height: 14px; background: #e5e7eb; flex-shrink: 0; }
.info-plant    { white-space: nowrap; flex-shrink: 0; }
.info-user     { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex-shrink: 1; }

/* Plant label + its divider hide on narrow screens; dropdown always stays */
@media (max-width: 640px) {
  .info-plant          { display: none; }
  .info-plant-divider  { display: none; }
  .info-strip          { gap: 8px; }
}

/* ─── KPI Cards ─────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.kpi-card {
  background: #fff;
  border-radius: 10px;
  padding: 13px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border-left: 4px solid;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: box-shadow 0.2s;
}
.kpi-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.09); }
.kpi-card.c-running { border-color: #10b981; }
.kpi-card.c-idle    { border-color: #f59e0b; }
.kpi-card.c-offline { border-color: #ef4444; }
.kpi-card.c-weight  { border-color: #8b5cf6; }
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.kpi-card.c-running .kpi-value { color: #10b981; }
.kpi-card.c-idle    .kpi-value { color: #f59e0b; }
.kpi-card.c-offline .kpi-value { color: #ef4444; }
.kpi-card.c-weight  .kpi-value { color: #8b5cf6; }
.kpi-sub { font-size: 11px; color: #9ca3af; margin-top: 2px; }

/* ─── Section Header ────────────────────────────────────── */
.section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.section-hdr h2 { font-size: 13px; font-weight: 700; color: #111827; display: flex; align-items: center; gap: 6px; }
.badge-sm {
  background: #f3f4f6;
  color: #6b7280;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

/* ─── Machine Grid ──────────────────────────────────────── */
.machine-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.mc-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px 15px 13px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border-top: 3px solid;
  transition: box-shadow 0.2s, transform 0.15s;
  cursor: pointer;
  min-width: 0;
}
.mc-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.1); transform: translateY(-1px); }
.mc-card.s-running { border-color: #10b981; }
.mc-card.s-idle    { border-color: #f59e0b; }
.mc-card.s-offline { border-color: #ef4444; background: #fcfcfc; }

/* Header row: [M01 · WS01] ───────────── [Running] */
.mc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.mc-id-wrap { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.mc-id    { font-size: 17px; font-weight: 700; color: #111827; flex-shrink: 0; }
.mc-scale { font-size: 11px; color: #b0b7c3; font-weight: 500; }

.status-pill {
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}
.status-pill.s-running { background: #dcfce7; color: #16a34a; }
.status-pill.s-idle    { background: #fef3c7; color: #d97706; }
.status-pill.s-offline { background: #fee2e2; color: #dc2626; }

/* Meta row: Operator name + Dept tag inline */
.mc-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
  min-width: 0;
}
.mc-operator {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.mc-dept-tag {
  background: #eff6ff;
  color: #1d4ed8;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Detail row: Process · Item */
.mc-detail {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 9px;
  min-width: 0;
  overflow: hidden;
}
.mc-process   { font-size: 12px; color: #6b7280; font-weight: 500; flex-shrink: 0; }
.mc-dot       { font-size: 12px; color: #d1d5db; flex-shrink: 0; }
.mc-item-name { font-size: 12px; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Weight row: [value kg  idle?]  [Live/Paused] */
.mc-weight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  border-top: 1px solid #f3f4f6;
  padding-top: 8px;
}
.mc-weight-left  { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.mc-weight-val   { font-size: 22px; font-weight: 700; color: #111827; font-variant-numeric: tabular-nums; line-height: 1; }
.mc-weight-unit  { font-size: 12px; color: #9ca3af; }
.mc-weight-status      { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 2px; }
.mc-weight-status.up   { color: #10b981; }
.mc-weight-status.idle { color: #f59e0b; }

.idle-warn {
  font-size: 11px;
  color: #d97706;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}

/* Progress bar */
.mc-bar-wrap { background: #f0f0f0; border-radius: 2px; height: 4px; }
.mc-bar      { height: 4px; border-radius: 2px; transition: width 0.8s ease; }
.s-running .mc-bar { background: linear-gradient(90deg, #10b981, #34d399); }
.s-idle    .mc-bar { background: #f59e0b; }

/* Offline card */
.mc-offline-msg {
  margin-top: 12px;
  padding: 12px 0 6px;
  text-align: center;
  font-size: 13px;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.mc-offline-msg i { font-size: 16px; color: #d1d5db; }

@keyframes weightFlash {
  0%   { background: #fff; }
  30%  { background: #f0fdf4; }
  100% { background: #fff; }
}
.mc-card.weight-flash { animation: weightFlash 0.7s ease; }

/* ─── Bottom Row Tables ─────────────────────────────────── */
.bottom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.tbl-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
}
.tbl-card-hdr {
  padding: 14px 18px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tbl-card-hdr h3 { font-size: 13px; font-weight: 700; color: #111827; display: flex; align-items: center; gap: 6px; }

/* Table overrides (sit on top of Bootstrap's table reset) */
.tbl-card table  { width: 100%; border-collapse: collapse; margin: 0; }
.tbl-card thead th {
  padding: 9px 14px;
  font-size: 11px; font-weight: 600;
  color: #6b7280; text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #f9fafb; text-align: left;
  border: none;
}
.tbl-card tbody td { padding: 10px 14px; font-size: 13px; border-top: 1px solid #f9fafb; vertical-align: middle; }
.tbl-card tbody tr:hover { background: #f9fafb; }

/* ─── Department & Rank Pills ───────────────────────────── */
.dept-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.d1 { background: #eff6ff; color: #1d4ed8; }
.d2 { background: #f0fdf4; color: #16a34a; }
.d3 { background: #fef3c7; color: #92400e; }
.d4 { background: #fdf4ff; color: #7e22ce; }

.rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 11px; font-weight: 700;
}
.rk1 { background: #fef3c7; color: #b45309; }
.rk2 { background: #f3f4f6; color: #374151; }
.rk3 { background: #fff7ed; color: #c2410c; }
.rk-o{ background: #f9fafb; color: #9ca3af; }

.prod-bar-wrap { background: #f3f4f6; border-radius: 3px; height: 6px; width: 80px; display: inline-block; vertical-align: middle; }
.prod-bar      { height: 6px; border-radius: 3px; background: #2563eb; }

/* ─── Toast System ──────────────────────────────────────── */
.toast-wrap {
  position: fixed;
  top: 66px; right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.app-toast {
  background: #fff;
  border-radius: 10px;
  padding: 12px 15px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.13);
  border-left: 4px solid;
  display: flex;
  gap: 10px;
  min-width: 300px;
  max-width: 380px;
  animation: toastIn 0.28s ease;
  pointer-events: all;
}
.app-toast.t-success { border-color: #10b981; }
.app-toast.t-warn    { border-color: #f59e0b; }
.app-toast.t-error   { border-color: #ef4444; }
.app-toast.t-info    { border-color: #2563eb; }
.toast-ico { font-size: 17px; flex-shrink: 0; margin-top: 1px; }
.app-toast.t-success .toast-ico { color: #10b981; }
.app-toast.t-warn    .toast-ico { color: #f59e0b; }
.app-toast.t-error   .toast-ico { color: #ef4444; }
.app-toast.t-info    .toast-ico { color: #2563eb; }
.toast-body  { flex: 1; }
.toast-title { font-size: 13px; font-weight: 600; color: #111827; }
.toast-msg   { font-size: 12px; color: #6b7280; margin-top: 2px; }
.toast-close { cursor: pointer; color: #9ca3af; font-size: 16px; align-self: flex-start; line-height: 1.5; }
.toast-close:hover { color: #374151; }
.toast-out   { animation: toastOut 0.25s ease forwards; }
@keyframes toastIn  { from { transform: translateX(60px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(60px); } }

/* ─── Custom Modal (machine detail, confirmations) ──────── */
.app-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 800;
  align-items: center;
  justify-content: center;
}
.app-overlay.open { display: flex; }
.app-modal {
  background: #fff;
  border-radius: 14px;
  width: 600px;
  max-width: 94vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.22s ease;
  overflow: hidden;
}
.app-modal.app-modal-sm { width: 420px; }
.app-modal.app-modal-lg { width: 780px; }
.app-modal-hd {
  padding: 18px 22px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.app-modal-hd h2 { font-size: 16px; font-weight: 700; color: #111827; margin: 0; }
.app-modal-x { cursor: pointer; color: #9ca3af; font-size: 20px; line-height: 1; background: none; border: none; padding: 0; }
.app-modal-x:hover { color: #374151; }
.app-modal-bd { padding: 20px 22px; overflow-y: auto; flex: 1; }
.app-modal-ft {
  padding: 14px 22px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
@keyframes modalIn { from { transform: scale(0.93); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Modal weight chart */
.mdl-chart-section {
  background: #f8fafc;
  border-radius: 9px;
  padding: 12px 14px 10px;
}
.mdl-chart-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.mdl-chart-title {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.mdl-chart-val {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
}
.mdl-chart-wrap {
  position: relative;
  height: 130px;
}

/* Machine detail modal internals */
.mdl-status-banner {
  border-radius: 9px; padding: 13px 16px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.mdl-status-banner.s-running { background: #f0fdf4; }
.mdl-status-banner.s-idle    { background: #fef3c7; }
.mdl-status-banner.s-offline { background: #fee2e2; }
.mdl-status-icon { font-size: 24px; }
.mdl-status-banner.s-running .mdl-status-icon { color: #10b981; }
.mdl-status-banner.s-idle    .mdl-status-icon { color: #d97706; }
.mdl-status-banner.s-offline .mdl-status-icon { color: #dc2626; }
.mdl-status-title { font-size: 15px; font-weight: 700; color: #111827; }
.mdl-status-sub   { font-size: 12px; color: #6b7280; margin-top: 2px; }

.mdl-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 16px; }
.mdl-stat  { background: #f8fafc; border-radius: 8px; padding: 12px 14px; }
.mdl-stat-val { font-size: 20px; font-weight: 700; color: #111827; }
.mdl-stat-lbl { font-size: 10px; color: #9ca3af; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.3px; }

.mdl-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.mdl-info-row  { background: #f8fafc; border-radius: 7px; padding: 10px 13px; }
.mdl-info-lbl  { font-size: 10px; color: #9ca3af; text-transform: uppercase; font-weight: 600; letter-spacing: 0.3px; }
.mdl-info-val  { font-size: 13px; font-weight: 600; color: #111827; margin-top: 3px; }

/* ─── Department Filter Dropdown ───────────────────────── */
.dept-filter-wrap { position: relative; }

.dept-filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  font-family: inherit;
  white-space: nowrap;
  line-height: 1.4;
}
.dept-filter-btn:hover { border-color: #6366f1; color: #4f46e5; }
.dept-filter-btn.active {
  border-color: #6366f1;
  background: #f5f3ff;
  color: #4f46e5;
}
.dept-chevron { font-size: 11px; transition: transform 0.2s; margin-left: 2px; }
.dept-filter-wrap.open .dept-chevron { transform: rotate(180deg); }

.dept-filter-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.15);
  min-width: 210px;
  z-index: 600;
  overflow: hidden;
}
.dept-filter-wrap.open .dept-filter-dropdown { display: block; }

/* On very narrow screens keep dropdown within viewport */
@media (max-width: 400px) {
  .dept-filter-dropdown { right: auto; left: 0; min-width: 180px; }
}

.dept-search-input {
  display: block;
  width: 100%;
  border: none;
  border-bottom: 1px solid #f3f4f6;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  color: #374151;
  outline: none;
  background: #fafafa;
}
.dept-search-input::placeholder { color: #b0b7c3; }
.dept-search-input:focus { background: #fff; }

.dept-options { padding: 4px 0; }

.dept-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: background 0.12s;
}
.dept-option:hover    { background: #f9fafb; }
.dept-option.selected { background: #f5f3ff; color: #4f46e5; font-weight: 600; }
.dept-option.hidden   { display: none; }
.dept-opt-full        { color: #6b7280; font-size: 12px; }
.dept-option.selected .dept-opt-full { color: #818cf8; }

/* ─── Animations ────────────────────────────────────────── */
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.3; } }

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

/* Tablet portrait / small screen */
@media (max-width: 900px) {
  .machine-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .bottom-row   { gap: 10px; }
}

/* Large phone landscape */
@media (max-width: 767px) {
  .kpi-grid              { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .machine-grid          { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .bottom-row            { grid-template-columns: 1fr; }
  body.layout-fixed .content-body { padding: 10px 12px 16px; }
  .topbar                { padding: 0 12px; }
  .info-strip            { gap: 10px; font-size: 11px; }
  .info-divider          { display: none; }
  .topbar-hide-mobile    { display: none !important; }
}

/* Phone portrait */
@media (max-width: 480px) {
  .kpi-grid     { grid-template-columns: 1fr 1fr; gap: 8px; }
  .machine-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-value    { font-size: 24px; }
  .mc-weight-val { font-size: 18px; }
}

/* ─── Page Header ───────────────────────────────────────── */
.page-hdr { margin-bottom: 18px; }
.page-hdr h1 { font-size: 18px; font-weight: 700; color: #111827; margin: 0 0 4px; }
.page-hdr p  { font-size: 13px; color: #6b7280; margin: 0; max-width: 680px; line-height: 1.5; }

/* ─── Standard topbar for scrollable pages ──────────────── */
body:not(.layout-fixed) .topbar {
  position: sticky; top: 0; z-index: 100;
}

/* ─── Tab System ────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 3px; flex-wrap: wrap;
  background: #f3f4f6; border-radius: 9px;
  padding: 4px; margin-bottom: 16px;
}
.tab-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border: none; background: transparent;
  border-radius: 7px; font-size: 13px; font-weight: 500;
  color: #6b7280; cursor: pointer; font-family: inherit;
  transition: all 0.15s; white-space: nowrap;
}
.tab-btn:hover  { background: rgba(255,255,255,0.7); color: #374151; }
.tab-btn.active { background: #fff; color: #111827; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.tab-btn i      { font-size: 13px; }
.tab-panel      { display: none; }
.tab-panel.active { display: block; }

/* ─── Report / Admin Filter Bar ────────────────────────── */
.filter-bar {
  background: #fff; border-radius: 9px;
  padding: 10px 16px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; row-gap: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  font-size: 12px; color: #6b7280;
}
.filter-bar label { font-weight: 600; white-space: nowrap; }
.filter-bar .erp-inp, .filter-bar .erp-sel {
  height: 34px; border: 1.5px solid #e5e7eb; border-radius: 7px;
  padding: 0 10px; font-size: 13px; font-family: inherit;
  color: #374151; background: #fff; outline: none;
  transition: border-color 0.15s;
}
.filter-bar .erp-inp:focus, .filter-bar .erp-sel:focus { border-color: #6366f1; }

/* ─── ERP Form Inputs (shared) ──────────────────────────── */
.erp-inp, .erp-sel {
  height: 38px; border: 1.5px solid #e5e7eb; border-radius: 8px;
  padding: 0 11px; font-size: 13px; font-family: inherit;
  color: #374151; background: #fff; outline: none;
  transition: border-color 0.15s; box-sizing: border-box;
}
.erp-inp:focus, .erp-sel:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.erp-inp::placeholder { color: #b0b7c3; }

/* Field group */
.fg { display: flex; flex-direction: column; gap: 4px; }
.fg label, .af-g label {
  font-size: 11px; font-weight: 700; color: #6b7280;
  text-transform: uppercase; letter-spacing: 0.4px;
}

/* ─── Form Card (planning add form etc) ─────────────────── */
.form-card {
  background: #fff; border-radius: 10px;
  padding: 18px 20px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.form-card h3 { font-size: 14px; font-weight: 700; color: #111827; margin: 0 0 14px; display: flex; align-items: center; gap: 7px; }
.form-grid {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
}
.form-grid .fg { min-width: 140px; flex: 1; }
.info-box {
  margin-top: 10px; border-radius: 8px; padding: 10px 14px;
  font-size: 13px; display: flex; align-items: center; gap: 7px;
}
.info-box.blue  { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.info-box.amber { background: #fef3c7; border: 1px solid #fde68a; color: #92400e; }

/* ─── Coverage Bar ───────────────────────────────────────── */
.coverage-card {
  background: #fff; border-radius: 10px;
  padding: 14px 18px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.cov-top   { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cov-title { font-size: 13px; font-weight: 700; color: #111827; display: flex; align-items: center; gap: 6px; }
.cov-pct   { font-size: 13px; font-weight: 700; }
.cov-bar-bg{ height: 8px; background: #f3f4f6; border-radius: 4px; }
.cov-bar   { height: 8px; border-radius: 4px; transition: width 0.6s ease; }
.cov-warnings { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cov-warn-item {
  background: #fef3c7; color: #92400e; border-radius: 5px;
  padding: 2px 8px; font-size: 11px; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}

/* ─── Plan / Data Table Wrapper ─────────────────────────── */
.plan-table-wrap {
  background: #fff; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); overflow: hidden;
}
.plan-table-hdr {
  padding: 13px 18px; border-bottom: 1px solid #f3f4f6;
  display: flex; justify-content: space-between; align-items: center;
}
.plan-table-hdr h3 { font-size: 13px; font-weight: 700; color: #111827; display: flex; align-items: center; gap: 6px; margin: 0; }
.plan-table-wrap table { width: 100%; border-collapse: collapse; }
.plan-table-wrap thead th {
  padding: 9px 14px; font-size: 11px; font-weight: 600;
  color: #6b7280; text-transform: uppercase; letter-spacing: 0.4px;
  background: #f9fafb; text-align: left; border: none; white-space: nowrap;
}
.plan-table-wrap tbody td { padding: 10px 14px; font-size: 13px; border-top: 1px solid #f9fafb; vertical-align: middle; }
.plan-table-wrap tbody tr:hover { background: #fafafa; }
.empty-state { text-align: center; padding: 40px; color: #9ca3af; }
.empty-state i { font-size: 28px; display: block; margin-bottom: 8px; }
.empty-state p { font-size: 13px; margin: 0; }

/* ─── Status Dot ────────────────────────────────────────── */
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.sd-running { background: #10b981; }
.sd-idle    { background: #f59e0b; }
.sd-offline { background: #ef4444; }
.sd-pending { background: #9ca3af; }

/* ─── Status / Active Pill ──────────────────────────────── */
.spill { display: inline-block; padding: 2px 9px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.spill-active   { background: #dcfce7; color: #16a34a; }
.spill-inactive { background: #f3f4f6; color: #9ca3af; }
.spill-pending  { background: #fef3c7; color: #92400e; }
.spill-admin    { background: #ede9fe; color: #6d28d9; }
.spill-super    { background: #e0f2fe; color: #0369a1; }

/* ─── Action Buttons ────────────────────────────────────── */
.btn-icon {
  width: 30px; height: 30px; border-radius: 7px; border: none;
  cursor: pointer; font-size: 13px; display: inline-flex;
  align-items: center; justify-content: center; transition: all 0.15s;
}
.btn-icon.edit { background: #eff6ff; color: #2563eb; }
.btn-icon.edit:hover { background: #dbeafe; }
.btn-icon.del  { background: #fef2f2; color: #dc2626; }
.btn-icon.del:hover  { background: #fee2e2; }
.btn-icon.view    { background: #f0fdf4; color: #16a34a; }
.btn-icon.view:hover { background: #dcfce7; }
.btn-icon.tog-on  { background: #dcfce7; color: #16a34a; }
.btn-icon.tog-on:hover  { background: #bbf7d0; }
.btn-icon.tog-off { background: #f1f5f9; color: #9ca3af; }
.btn-icon.tog-off:hover { background: #e2e8f0; color: #374151; }
.btn-icon:disabled      { opacity: 0.32; cursor: not-allowed; pointer-events: none; }
/* Action column — shrink to button width, stick right */
.plan-table-wrap table th:last-child,
.plan-table-wrap table td:last-child {
  width: 1%; white-space: nowrap; text-align: right;
}

/* ─── Report Stats Grid ─────────────────────────────────── */
.report-stat-grid {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 12px; margin-bottom: 14px;
}
.rstat {
  background: #fff; border-radius: 10px;
  padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  text-align: center;
}
.rstat-val { font-size: 22px; font-weight: 700; line-height: 1.2; }
.rstat-lbl { font-size: 11px; color: #9ca3af; margin-top: 3px; font-weight: 500; }

/* ─── Chart Cards ───────────────────────────────────────── */
.chart-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.chart-card {
  background: #fff; border-radius: 10px;
  padding: 16px 18px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chart-card h3, .chart-card h4 {
  font-size: 13px; font-weight: 700; color: #111827;
  margin: 0 0 14px; display: flex; align-items: center; gap: 6px;
}
.chart-card canvas { max-height: 280px; }
.chart-full { margin-bottom: 14px; }
.chart-full canvas { max-height: 320px; }

/* Utilization inline bar */
.util-wrap { display: flex; align-items: center; gap: 8px; }
.util-bar-bg { flex: 1; height: 6px; background: #f3f4f6; border-radius: 3px; min-width: 50px; }
.util-bar    { height: 6px; border-radius: 3px; }
.util-high   { background: #10b981; }
.util-medium { background: #f59e0b; }
.util-low    { background: #ef4444; }

/* ─── Masters Nav ───────────────────────────────────────── */
.master-nav {
  display: flex; gap: 4px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.m-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border: 1.5px solid #e5e7eb;
  border-radius: 8px; background: #fff;
  font-size: 12px; font-weight: 500; color: #6b7280;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
  white-space: nowrap;
}
.m-tab:hover  { border-color: #6366f1; color: #4f46e5; }
.m-tab.active { background: #4f46e5; border-color: #4f46e5; color: #fff; font-weight: 600; }
.m-tab i      { font-size: 13px; }
.m-panel      { display: none; }
.m-panel.active { display: block; }

/* ─── Add Form Card (masters) ────────────────────────────── */
.add-form-card {
  background: #f8fafc; border: 1px solid #e5e7eb;
  border-radius: 9px; padding: 16px 18px; margin-bottom: 14px;
}
.add-form-card h4 {
  font-size: 13px; font-weight: 700; color: #374151;
  margin: 0 0 12px; display: flex; align-items: center; gap: 6px;
}
.add-form-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.af-g { display: flex; flex-direction: column; gap: 4px; }
.af-g .erp-inp, .af-g .erp-sel { min-width: 80px; }

/* ─── Date Range Picker (daterangepicker v3 + Moment.js) ─── */
/* Trigger wrapper — calendar icon + readonly text input */
.drp-wrap {
  position: relative; display: inline-flex; align-items: center;
}
.drp-wrap .drp-icon {
  position: absolute; left: 10px; color: #6366f1; font-size: 14px;
  pointer-events: none; z-index: 1;
}
.drp-wrap .drp-inp {
  padding-left: 32px !important; cursor: pointer; min-width: 210px;
}

/* Popup container */
.daterangepicker {
  font-family: 'Inter', system-ui, sans-serif !important;
  border: 1.5px solid #e5e7eb !important; border-radius: 12px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10) !important; z-index: 9999 !important;
}
.daterangepicker::before, .daterangepicker::after { display: none !important; }

/* Preset ranges list */
.daterangepicker .ranges li {
  font-size: 13px; color: #374151; border-radius: 6px; padding: 6px 14px; margin: 2px 4px;
}
.daterangepicker .ranges li:hover { background: #f3f4f6; color: #374151; }
.daterangepicker .ranges li.active { background: #6366f1 !important; color: #fff !important; }

/* Calendar header */
.daterangepicker th.month { font-weight: 600; font-size: 13px; color: #1e1b4b !important; }
.daterangepicker .prev span, .daterangepicker .next span { border-color: #6366f1 !important; }

/* Day cells */
.daterangepicker td.available:hover { background: #ede9fe !important; color: #4f46e5; border-radius: 6px !important; }
.daterangepicker td.in-range { background: #ede9fe !important; color: #4f46e5 !important; border-radius: 0 !important; }
.daterangepicker td.active,
.daterangepicker td.active:hover { background: #6366f1 !important; color: #fff !important; border-radius: 6px !important; }
.daterangepicker td.start-date { border-radius: 6px 0 0 6px !important; }
.daterangepicker td.end-date   { border-radius: 0 6px 6px 0 !important; }
.daterangepicker td.start-date.end-date { border-radius: 6px !important; }
.daterangepicker td.off, .daterangepicker td.off.in-range,
.daterangepicker td.off.active { background: transparent !important; color: #d1d5db !important; }
.daterangepicker td.today { font-weight: 700 !important; }

/* Month / year selects */
.daterangepicker select.monthselect,
.daterangepicker select.yearselect {
  border: 1.5px solid #e5e7eb !important; border-radius: 6px !important;
  font-family: inherit !important; font-size: 12px !important; color: #374151 !important;
}

/* Apply / Cancel buttons */
.daterangepicker .drp-buttons { border-top: 1px solid #f3f4f6; padding: 8px 14px; }
.daterangepicker .drp-buttons .btn { font-family: inherit !important; font-size: 12px !important; border-radius: 7px !important; }
.daterangepicker .drp-buttons .applyBtn { background: #6366f1 !important; border-color: #6366f1 !important; }
.daterangepicker .drp-buttons .cancelBtn { background: #fff !important; color: #374151 !important; border: 1.5px solid #e5e7eb !important; }
.daterangepicker .drp-buttons .cancelBtn:hover { background: #f3f4f6 !important; }

/* Process tags in machines table */
.proc-tag {
  display: inline-block; background: #f3f4f6; color: #374151;
  padding: 2px 7px; border-radius: 4px; font-size: 11px;
  margin: 1px 2px 1px 0;
}

/* ─── Admin page ─────────────────────────────────────────── */
.perm-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.perm-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.perm-chip.on  { background: #dcfce7; color: #15803d; }
.perm-chip.off { background: #f3f4f6; color: #9ca3af; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-size: 14px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ─── Responsive for inner pages ────────────────────────── */
@media (max-width: 991px) {
  .report-stat-grid { grid-template-columns: repeat(2,1fr); }
  .chart-row        { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .report-stat-grid { grid-template-columns: repeat(2,1fr); gap: 8px; }
  .form-grid        { flex-direction: column; }
  .form-grid .fg    { min-width: unset; }
  .add-form-row     { flex-direction: column; align-items: stretch; }
  .master-nav       { gap: 4px; }
  .m-tab            { font-size: 11px; padding: 6px 10px; }
}

.activity-meta { font-size: 11px; color: #9ca3af; margin-top: 3px; }

/* ─── Floating Label Fields (border-notch style) ─────────── */
.fl-wrap { position: relative; padding-top: 8px; }
.fl-inp, .fl-sel {
  display: block; width: 100%; height: 46px;
  border: 1.5px solid #d1d5db; border-radius: 8px;
  font-size: 13px; font-family: inherit; color: #374151;
  background: #fff; outline: none; box-sizing: border-box;
  transition: border-color 0.15s;
}
.fl-inp { padding: 0 14px; }
.fl-inp::placeholder { color: transparent; }
.fl-inp:focus { border-color: #6366f1; }
/* Label: resting inside field (vertically centered) */
/* top = padding-top(8) + input-height/2(23) = 31px */
.fl-wrap > label {
  position: absolute; left: 14px; top: 31px;
  transform: translateY(-50%);
  font-size: 13px; color: #9ca3af;
  pointer-events: none; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  max-width: calc(100% - 28px); line-height: 1;
  transition: top 0.15s, font-size 0.15s, color 0.15s, background 0.15s, padding 0.15s, left 0.15s;
  background: transparent; padding: 0;
}
/* Floated: label sits ON the top border (white bg notches through it) */
.fl-inp:focus ~ label,
.fl-inp:not(:placeholder-shown) ~ label {
  top: 8px; transform: translateY(-50%);
  font-size: 10px; font-weight: 700; color: #6366f1;
  background: #fff; padding: 0 4px; left: 10px;
}
.fl-inp:not(:focus):not(:placeholder-shown) ~ label { color: #6b7280; }
/* Select */
.fl-sel {
  padding: 0 36px 0 14px;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
}
.fl-sel:focus { border-color: #6366f1; }
/* Select label: always on border (selects always have a value) */
.fl-sel-wrap > label {
  top: 8px; transform: translateY(-50%);
  font-size: 10px; font-weight: 700; color: #6b7280;
  background: #fff; padding: 0 4px; left: 10px;
}
.fl-sel:focus ~ label { color: #6366f1; }
/* Hide number spinners */
.fl-inp[type="number"]::-webkit-inner-spin-button,
.fl-inp[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
.fl-inp[type="number"] { -moz-appearance: textfield; }

/* ─── Select2 (searchable dropdown) ─────────────────────── */
.select2-container { display: block !important; width: 100% !important; }
.select2-container--default .select2-selection--single {
  height: 46px; width: 100% !important; box-sizing: border-box !important;
  border: 1.5px solid #d1d5db !important; border-radius: 8px !important;
  background-color: #fff !important; box-shadow: none !important; outline: none !important;
  display: flex !important; align-items: center !important; position: relative !important;
  cursor: pointer; transition: border-color 0.15s;
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: #6366f1 !important; box-shadow: none !important; outline: none !important;
}
.select2-container--default.select2-container--open.select2-container--below .select2-selection--single {
  border-bottom-left-radius: 0 !important; border-bottom-right-radius: 0 !important;
}
.select2-container--default.select2-container--open.select2-container--above .select2-selection--single {
  border-top-left-radius: 0 !important; border-top-right-radius: 0 !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  padding: 0 36px 0 14px; line-height: 1; color: #374151;
  font-size: 13px; font-family: inherit;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.select2-container--default .select2-selection--single .select2-selection__rendered[title="— Select —"],
.select2-container--default .select2-selection--single .select2-selection__placeholder { color: #9ca3af !important; }
.select2-container--default .select2-selection--single .select2-selection__arrow {
  position: absolute !important; right: 0; top: 0; width: 36px; height: 100%;
}
.select2-container--default .select2-selection--single .select2-selection__arrow b { display: none !important; }
.select2-container--default .select2-selection--single .select2-selection__arrow::after {
  content: ''; display: block; width: 12px; height: 12px;
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: center; background-size: 12px;
}
.select2-container--default.select2-container--focus .select2-selection__arrow::after,
.select2-container--default.select2-container--open .select2-selection__arrow::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236366f1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}
.fl-wrap .select2-container--focus ~ label,
.fl-wrap .select2-container--open ~ label { color: #6366f1; }
/* ─── Select2 Multiple selection ────────────────────────── */
.select2-container--default .select2-selection--multiple {
  min-height: 46px !important; border: 1.5px solid #d1d5db !important;
  border-radius: 8px !important; background: #fff !important;
  padding: 4px 8px !important; box-shadow: none !important;
  display: flex !important; flex-wrap: wrap !important; align-items: flex-start !important;
  cursor: pointer; transition: border-color 0.15s; box-sizing: border-box !important;
}
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--multiple  {
  border-color: #6366f1 !important;
}
.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple {
  border-bottom-left-radius: 0 !important; border-bottom-right-radius: 0 !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
  display: flex !important; flex-wrap: wrap !important; gap: 4px !important;
  padding: 2px 0 !important; margin: 0 !important; list-style: none !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
  background: #ede9fe !important; color: #4f46e5 !important;
  border: none !important; border-radius: 5px !important;
  padding: 3px 8px 3px 6px !important; font-size: 11px !important; font-weight: 600 !important;
  margin: 0 !important; display: flex !important; align-items: center !important; gap: 4px !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: #6366f1 !important; font-size: 14px !important; line-height: 1 !important;
  order: -1 !important; background: none !important; border: none !important; padding: 0 !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
  color: #4338ca !important; background: none !important;
}
.select2-container--default .select2-selection--multiple .select2-search__field {
  font-family: inherit !important; font-size: 13px !important;
  color: #374151 !important; margin: 2px 0 !important; border: none !important; outline: none !important;
}
/* ─── Select2 Dropdown panel ─────────────────────────────── */
.select2-dropdown {
  border: 1.5px solid #6366f1 !important; border-top: none !important;
  border-radius: 0 0 8px 8px !important;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08) !important;
  font-family: inherit !important; background: #fff !important; z-index: 9999 !important;
}
.select2-dropdown--above {
  border-top: 1.5px solid #6366f1 !important; border-bottom: none !important;
  border-radius: 8px 8px 0 0 !important;
}
.select2-container--default .select2-search--dropdown { padding: 8px 10px 4px; }
.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid #d1d5db; border-radius: 6px; padding: 7px 10px;
  font-size: 12px; font-family: inherit; color: #374151;
  width: 100%; box-sizing: border-box; outline: none;
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus {
  border-color: #6366f1; box-shadow: none; outline: none;
}
.select2-results__options { padding: 4px 0; margin: 0; }
.select2-container--default .select2-results__option {
  padding: 9px 14px; color: #374151; font-size: 13px; font-family: inherit; cursor: pointer;
}
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background: #f5f5ff !important; color: #4338ca !important;
}
.select2-container--default .select2-results__option--selected {
  background: #ede9fe !important; color: #4338ca !important; font-weight: 600;
}
.select2-container--default .select2-results__message {
  padding: 9px 14px; color: #9ca3af; font-size: 12px; font-style: italic;
}

/* ─── DataTables — Professional Override ────────────────── */

/* Reset DT wrapper padding and Bootstrap row margins */
.dataTables_wrapper { padding: 0; }
.dataTables_wrapper .row.mt-2 { margin-top: 0 !important; }
.dataTables_wrapper .row { --bs-gutter-x: 0; }

/* ── Top controls bar ──────────────────────────────────────*/
.plan-table-wrap .dataTables_wrapper > .row:first-child {
  background: #f8fafc; border-bottom: 1px solid #eef2f7;
  padding: 9px 18px; align-items: center;
}
.plan-table-wrap .dataTables_wrapper > .row:first-child > [class*="col"] { padding: 0; }

/* Length — "Show X entries" */
.dataTables_length label {
  display: flex !important; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 500; color: #6b7280; margin: 0; white-space: nowrap;
}
.dataTables_length select {
  display: inline-block !important; width: auto !important;
  height: 28px !important; padding: 2px 24px 2px 9px !important;
  font-size: 12px !important; font-weight: 500 !important;
  border: 1.5px solid #d1d5db !important; border-radius: 6px !important;
  color: #374151 !important; background-color: #fff !important;
  box-shadow: none !important; cursor: pointer; line-height: 1.3;
  -webkit-appearance: none !important; appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 6px center !important;
  background-size: 11px !important;
}
.dataTables_length select:focus {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12) !important;
  outline: none !important;
}

/* Filter — Search input */
.dataTables_filter { display: flex; justify-content: flex-end; }
.dataTables_filter label {
  display: flex !important; align-items: center; margin: 0;
  font-size: 0 !important; /* hide "Search:" text node */
  position: relative;
}
.dataTables_filter label::before {
  content: '\F52A';
  font-family: 'bootstrap-icons'; font-style: normal; font-weight: 400;
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: #9ca3af; z-index: 1; pointer-events: none;
  line-height: 1;
}
.dataTables_filter input {
  height: 28px !important; width: 210px !important;
  padding: 3px 10px 3px 30px !important;
  font-size: 12px !important; font-weight: 400 !important;
  border: 1.5px solid #d1d5db !important; border-radius: 6px !important;
  color: #374151 !important; background: #fff !important;
  box-shadow: none !important;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-left: 0 !important;
}
.dataTables_filter input:focus {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12) !important;
  outline: none !important;
}

/* ── Table row (no padding from Bootstrap grid) ────────────*/
.plan-table-wrap .dataTables_wrapper > .row:nth-child(2) { margin: 0 !important; }
.plan-table-wrap .dataTables_wrapper > .row:nth-child(2) > [class*="col"] { padding: 0 !important; }

/* Keep table flush */
.plan-table-wrap table.dataTable { margin: 0 !important; border-collapse: collapse !important; }

/* thead — inherit our existing plan-table-wrap th styles; just fix sort indicator colours */
.plan-table-wrap table.dataTable thead th { cursor: pointer; user-select: none; }
table.dataTable thead th.sorting:not(.sorting_asc):not(.sorting_desc) {
  color: #9ca3af;
}
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
  color: #6366f1 !important;
}
/* DT 1.x appends sort arrows via ::after */
table.dataTable thead th.sorting::after,
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::after {
  font-size: 10px; vertical-align: middle; margin-left: 4px;
}
table.dataTable thead th.sorting::after         { opacity: 0.28; }
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::after    { opacity: 1; color: #6366f1; }

/* tbody rows */
.plan-table-wrap table.dataTable tbody td {
  padding: 9px 14px !important;
  border-top: 1px solid #f3f4f6 !important;
  border-bottom: none !important;
}
.plan-table-wrap table.dataTable tbody tr:hover > td {
  background: rgba(99,102,241,0.04) !important;
}
/* Stripe (DT adds odd/even — suppress) */
table.dataTable.stripe tbody tr.odd { background: inherit; }

/* ── Bottom info + pagination bar ──────────────────────────*/
.plan-table-wrap .dataTables_wrapper > .row:last-child {
  background: #f8fafc; border-top: 1px solid #eef2f7;
  padding: 7px 18px; align-items: center; margin: 0 !important;
}
.plan-table-wrap .dataTables_wrapper > .row:last-child > [class*="col"] { padding: 0; }

.dataTables_info {
  font-size: 11px !important; color: #9ca3af !important; padding: 4px 0 0 !important;
}

/* Pagination buttons */
.dataTables_paginate .pagination { margin: 0 !important; gap: 3px; flex-wrap: nowrap; }
.dataTables_paginate .pagination .page-item .page-link {
  min-width: 30px; height: 28px;
  padding: 3px 9px !important; line-height: 20px !important;
  font-size: 12px !important; font-weight: 500 !important; text-align: center;
  color: #374151 !important;
  border: 1.5px solid #e5e7eb !important; border-radius: 6px !important;
  background: #fff !important; box-shadow: none !important;
  transition: all 0.13s;
}
.dataTables_paginate .pagination .page-item .page-link:hover {
  background: #ede9fe !important; border-color: #6366f1 !important; color: #6366f1 !important;
}
.dataTables_paginate .pagination .page-item.active .page-link {
  background: #6366f1 !important; border-color: #6366f1 !important;
  color: #fff !important; box-shadow: 0 2px 8px rgba(99,102,241,0.28) !important;
}
.dataTables_paginate .pagination .page-item.disabled .page-link {
  color: #d1d5db !important; background: #f9fafb !important;
  border-color: #eef2f7 !important; pointer-events: none;
}

/* ─── Role Form ──────────────────────────────────────────── */
.role-card {
  background: #fff; border-radius: 12px; border: 1px solid #e5e7eb;
  margin-bottom: 16px; overflow: hidden;
}
.role-card-body { padding: 20px 22px 18px; }
.role-section-title {
  font-size: 15px; font-weight: 700; color: #111827;
  margin: 0 0 16px; display: flex; align-items: center; gap: 0;
}
.role-section-title span { color: #6366f1; }
.role-fields-row {
  display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px;
}
.role-field {
  display: flex; flex-direction: column; gap: 0; flex: 1; min-width: 140px;
  position: relative; border: 1.5px solid #e5e7eb; border-radius: 8px;
  padding: 6px 12px 8px; background: #fff; transition: border-color 0.15s;
}
.role-field:focus-within { border-color: #6366f1; }
.role-field label {
  font-size: 10px; font-weight: 600; color: #9ca3af;
  text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 2px;
  display: flex; align-items: center; gap: 5px;
}
.role-field label i { font-size: 11px; }
.role-field input, .role-field select, .role-field textarea {
  border: none; outline: none; font-size: 13px; font-family: inherit;
  color: #374151; background: transparent; padding: 0; resize: none;
}
.role-field input::placeholder, .role-field textarea::placeholder { color: #d1d5db; }
.role-field-hint { font-size: 11px; color: #f59e0b; margin-top: 5px; }
.role-field-desc { border-radius: 8px; }

/* Permissions table */
.perm-table-wrap { border-top: 1px solid #e5e7eb; }
.perm-table { width: 100%; border-collapse: collapse; }
.perm-table-head { background: #f9fafb; }
.perm-table-head th {
  padding: 10px 14px; font-size: 11px; font-weight: 700;
  color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px;
  text-align: left; border-bottom: 1px solid #e5e7eb;
}
.perm-table-head th.perm-col {
  text-align: center; width: 80px;
}
.perm-table-head th.perm-col label {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; cursor: pointer;
}
.perm-section-row td {
  background: #f9fafb; padding: 6px 14px;
  font-size: 10px; font-weight: 700; color: #9ca3af;
  text-transform: uppercase; letter-spacing: 1px;
  border-top: 1px solid #f3f4f6;
}
.perm-module-row td {
  padding: 10px 14px; font-size: 13px; color: #374151;
  border-top: 1px solid #f9fafb;
}
.perm-module-row:hover td { background: #fafafa; }
.perm-module-row td.perm-col { text-align: center; }
.perm-module-name { display: flex; align-items: center; gap: 8px; }
.perm-module-name i { font-size: 14px; color: #9ca3af; }
/* Styled checkboxes */
.perm-cb {
  width: 16px; height: 16px; accent-color: #6366f1; cursor: pointer;
}
.role-actions {
  padding: 14px 22px; border-top: 1px solid #f3f4f6;
  display: flex; justify-content: flex-end; gap: 8px;
}
@media (max-width: 640px) {
  .role-fields-row { flex-direction: column; }
  .perm-table-head th.perm-col, .perm-module-row td.perm-col { width: 52px; }
}
