/* ===================================================================
   LIA EMS -- components.css
   Sections, Tables, Buttons, Badges, Tabs, KPIs, Modals, Toasts, etc.
   =================================================================== */

/* -- SECTIONS -- */
.section {
  background: var(--white);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  margin-bottom: 12px;
  box-shadow: var(--sh);
  overflow: hidden;
  width: 100%;
  min-width: 0;
  transition: box-shadow .15s;
}

.section:hover {
  box-shadow: 0 4px 16px rgba(15, 23, 42, .08);
}

.section.ai-section {
  border-color: var(--ai-border);
  box-shadow: var(--sh-ai);
}

.section.ai-section:hover {
  box-shadow: 0 6px 24px rgba(109, 40, 217, .25);
}

.sec-hd {
  padding: 9px 13px;
  border-bottom: 1px solid var(--bd);
  background: var(--surf);
  border-radius: var(--r2) var(--r2) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.sec-hd.ai-hd {
  background: linear-gradient(135deg, var(--ai-lt), transparent);
}

.sec-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 5px;
}

.sec-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  flex-shrink: 0;
}

.sec-dot.ai {
  background: var(--ai);
}

.sec-body {
  padding: 12px 14px;
  overflow: hidden;
}

.sec-body-sm {
  padding: 10px 14px;
  overflow: hidden;
}

/* -- TABLES -- */
.tw {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--bd);
  border-radius: var(--r);
}

.tw table {
  min-width: max-content;
  width: 100%;
}

.tw::-webkit-scrollbar {
  height: 5px;
}

.tw::-webkit-scrollbar-thumb {
  background: var(--blue);
  border-radius: 3px;
}

.tw::-webkit-scrollbar-track {
  background: var(--bd);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

th {
  padding: 6px 9px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--tx3);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--bd);
  background: var(--surf);
  white-space: nowrap;
}

td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--bd);
  vertical-align: middle;
  word-break: break-word;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #EEF3FB;
  transition: background .1s;
}

tr.selected td {
  background: #e0f2fe !important;
}

td input.fi {
  min-width: 50px;
}

td select.fi {
  min-width: 70px;
}

/* -- BUTTONS -- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: var(--r);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all .12s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn:active {
  transform: scale(.97);
}

.btn.loading {
  opacity: .7;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-left: 5px;
}

.btn.done {
  background: var(--green) !important;
}

.btn-blue {
  background: var(--blue);
  color: #fff;
}

.btn-blue:hover {
  background: var(--blue2);
}

.btn-navy {
  background: var(--navy);
  color: #fff;
}

.btn-navy:hover {
  background: var(--blue-dk);
}

.btn-green {
  background: var(--green);
  color: #fff;
}

.btn-green:hover {
  filter: brightness(.9);
}

.btn-red {
  background: var(--red);
  color: #fff;
}

.btn-red:hover {
  filter: brightness(.9);
}

.btn-teal {
  background: var(--teal);
  color: #fff;
}

.btn-teal:hover {
  background: var(--teal2);
}

.btn-amber {
  background: var(--amber);
  color: #fff;
}

.btn-amber:hover {
  filter: brightness(.9);
}

.btn-ghost {
  background: var(--white);
  color: var(--tx2);
  border: 1px solid var(--bd2);
}

.btn-ghost:hover {
  background: var(--surf);
}

/* AI Button */
.btn-ai {
  background: linear-gradient(135deg, var(--ai), #8B5CF6);
  color: #fff;
  box-shadow: 0 2px 12px rgba(109, 40, 217, .35);
}

.btn-ai:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 18px rgba(109, 40, 217, .45);
}

.btn-ai::before {
  content: '\2728 ';
}

.btn-sm {
  padding: 4px 9px;
  font-size: 11px;
}

.btn-xs {
  padding: 2px 7px;
  font-size: 10px;
}

.btn-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 0 4px;
  border-top: 1px solid var(--bd);
  margin-top: 8px;
  width: 100%;
}

/* -- BADGES -- */
.b {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.b-blue {
  background: var(--blue3);
  color: var(--blue2);
}

.b-green {
  background: var(--green-p);
  color: var(--green);
}

.b-red {
  background: var(--red-p);
  color: var(--red);
}

.b-amber {
  background: var(--amber-p);
  color: var(--amber);
}

.b-teal {
  background: var(--teal-p);
  color: var(--teal);
}

.b-purple {
  background: var(--purple-p);
  color: var(--purple);
}

.b-gray {
  background: var(--surf);
  color: var(--tx3);
  border: 1px solid var(--bd);
}

.b-draft {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.b-sap {
  background: #0070F2;
  color: #fff;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
}

.b-odoo {
  background: #714B67;
  color: #fff;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
}

.b-gap {
  background: var(--amber-p);
  color: #92400e;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
}

.b-new {
  background: var(--teal-p);
  color: var(--teal);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
}

/* AI badge */
.b-ai {
  background: var(--ai-p);
  color: var(--ai);
  border: 1px solid var(--ai-border);
  font-size: 9px;
  padding: 1px 7px;
  border-radius: 8px;
  font-weight: 800;
}

.b-live {
  animation: badgePulse 2s ease infinite;
}

@keyframes badgePulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(5, 150, 105, .4);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(5, 150, 105, 0);
  }
}

/* -- TABS -- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--bd);
  margin-bottom: 12px;
  overflow-x: auto;
}

.tab {
  padding: 7px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--tx3);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .12s;
  white-space: nowrap;
}

.tab:hover {
  color: var(--blue);
}

.tab.on {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* -- TAGS -- */
.tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.tag {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--bd2);
  background: var(--white);
  color: var(--tx3);
  transition: all .1s;
}

.tag:hover {
  background: var(--surf);
}

.tag.on {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* -- KPI CARDS -- */
.kpi {
  background: var(--white);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  padding: 12px;
  box-shadow: var(--sh);
  min-width: 0;
  transition: transform .13s, box-shadow .13s;
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh2);
}

.kpi-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--tx4);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 4px;
}

.kpi-val {
  font-size: clamp(18px, 2.5vw, 26px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.5px;
  color: var(--navy);
}

.kpi-val.blue {
  color: var(--blue2);
}

.kpi-val.green {
  color: var(--green);
}

.kpi-val.amber {
  color: var(--amber);
}

.kpi-val.red {
  color: var(--red);
}

.kpi-sub {
  font-size: 10.5px;
  color: var(--tx3);
  margin-top: 4px;
}

.kpi-bar {
  height: 3px;
  background: var(--bd);
  border-radius: 2px;
  margin-top: 7px;
  overflow: hidden;
}

.kpi-bf {
  height: 100%;
  border-radius: 2px;
}

/* -- PROGRESS BARS -- */
.prog-bar {
  height: 6px;
  background: var(--bd);
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
}

.prog-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .8s cubic-bezier(.4, 0, .2, 1);
  max-width: 100%;
}

/* -- ALERTS -- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 8px 11px;
  border-radius: var(--r);
  font-size: 11.5px;
  margin-bottom: 10px;
}

.alert-info {
  background: var(--blue-lt);
  border: 1px solid #bfdbfe;
  color: var(--navy);
}

.alert-warn {
  background: var(--amber-p);
  border: 1px solid #fcd34d;
  color: #78350f;
}

.alert-red {
  background: var(--red-p);
  border: 1px solid #fca5a5;
  color: #7f1d1d;
}

.alert-green {
  background: var(--green-p);
  border: 1px solid #bbf7d0;
  color: #064e3b;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  margin-bottom: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .12s;
  word-break: break-word;
}

.alert-item:hover {
  filter: brightness(.96);
}

.alert-item.crit {
  background: var(--red-p);
  border-color: #fca5a5;
}

.alert-item.warn {
  background: var(--amber-p);
  border-color: #fcd34d;
}

.alert-item.info {
  background: var(--blue-lt);
  border-color: #bfdbfe;
}

.alert-item.ok {
  background: var(--green-p);
  border-color: #bbf7d0;
}

/* -- PAGE HEADER -- */
.ph {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--bd);
}

.ph-bc {
  font-size: 10px;
  color: var(--tx4);
  margin-bottom: 3px;
}

.ph-bc span {
  color: var(--blue);
  cursor: pointer;
  transition: color .1s;
}

.ph-bc span:hover {
  color: var(--blue2);
}

.ph-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ph-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -.4px;
}

.ph-sub {
  font-size: 11.5px;
  color: var(--tx3);
  margin-top: 3px;
  max-width: 640px;
  line-height: 1.6;
}

/* -- System Compare Tags -- */
.sys-compare {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.sys-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.sys-sap {
  background: #0070F2;
  color: #fff;
}

.sys-odoo {
  background: #714B67;
  color: #fff;
}

.sys-gap {
  background: var(--amber-p);
  border-color: #fcd34d;
  color: #92400e;
}

/* -- Lifecycle Steps -- */
.lifecycle {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.lc-step {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  border: 1px solid var(--bd);
  color: var(--tx3);
  background: var(--white);
  white-space: nowrap;
}

.lc-step.done {
  background: var(--green-p);
  border-color: #bbf7d0;
  color: var(--green);
}

.lc-step.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.lc-arrow {
  color: var(--tx4);
  font-size: 9px;
}

/* -- DASHBOARD CARDS -- */
.dash-card {
  background: var(--white);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--sh);
  transition: all .15s;
  position: relative;
  overflow: hidden;
  min-width: 0;
  cursor: pointer;
}

.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh2);
}

.dash-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 12px 12px 0 0;
}

.dash-card.blue::before {
  background: var(--blue);
}

.dash-card.green::before {
  background: var(--green);
}

.dash-card.amber::before {
  background: var(--amber);
}

.dash-card.red::before {
  background: var(--red);
}

.dash-card.teal::before {
  background: var(--teal);
}

.dash-card.purple::before {
  background: var(--purple);
}

.dash-card.ai::before {
  background: linear-gradient(135deg, var(--ai), #8B5CF6);
}

.dc-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.dc-num {
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.8px;
  margin-bottom: 4px;
}

.dc-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--tx3);
  text-transform: uppercase;
  letter-spacing: .07em;
}

.dc-delta {
  font-size: 10.5px;
  font-weight: 600;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.dc-delta.up {
  color: var(--green);
}

.dc-delta.dn {
  color: var(--red);
}

.dc-delta.flat {
  color: var(--tx4);
}

/* -- ACTIVITY FEED -- */
.act-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 0;
  border-bottom: 1px solid var(--bd);
}

.act-row:last-child {
  border-bottom: none;
}

.act-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.act-body {
  flex: 1;
}

.act-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--tx);
}

.act-sub {
  font-size: 10.5px;
  color: var(--tx3);
}

.act-time {
  font-size: 10px;
  color: var(--tx4);
  white-space: nowrap;
  flex-shrink: 0;
}

/* -- DISPOSITION BLOCK -- */
.disp-block {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  background: var(--surf);
  border-radius: var(--r);
  margin-bottom: 10px;
  border: 1px solid var(--bd);
}

.disp-item {
  text-align: center;
  padding: 8px;
}

.disp-val {
  font-size: 22px;
  font-weight: 800;
  font-family: var(--mono);
  line-height: 1;
}

.disp-lbl {
  font-size: 10px;
  color: var(--tx4);
  margin-top: 3px;
  text-transform: uppercase;
}

/* -- TOAST -- */
.toast-container {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  min-width: 260px;
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .18);
  animation: toastIn .25s cubic-bezier(.34, 1.56, .64, 1) forwards;
  pointer-events: all;
  border: 1px solid transparent;
}

.toast.out {
  animation: toastOut .2s ease forwards;
}

.toast-success {
  background: rgba(5, 150, 105, .95);
  color: #fff;
}

.toast-error {
  background: rgba(220, 38, 38, .95);
  color: #fff;
}

.toast-info {
  background: rgba(68, 114, 196, .95);
  color: #fff;
}

.toast-warn {
  background: rgba(217, 119, 6, .95);
  color: #fff;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px) scale(.94);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* -- MODAL -- */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(11, 37, 69, .5);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn .18s ease;
}

.modal {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, .22);
  max-width: 480px;
  width: calc(100% - 28px);
  overflow: hidden;
  animation: modalIn .22s cubic-bezier(.34, 1.56, .64, 1);
}

.modal-hd {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--bd);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--navy);
}

.modal-close {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surf);
  border: 1px solid var(--bd);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--tx3);
}

.modal-body {
  padding: 16px 20px;
}

.modal-ft {
  padding: 12px 20px;
  border-top: 1px solid var(--bd);
  display: flex;
  gap: 7px;
  justify-content: flex-end;
  background: var(--surf);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(.92) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* -- LIVE INDICATORS -- */
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  animation: pulseLive 1.8s ease infinite;
  flex-shrink: 0;
}

@keyframes pulseLive {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.5);
    opacity: .5;
  }
}

.rt-clock {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--tx3);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* -- CHECK ROW -- */
.cr {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 0;
  border-bottom: 1px solid var(--bd);
}

.cr:last-child {
  border-bottom: none;
}

.cr-item {
  flex: 1.2;
  font-size: 11.5px;
  color: var(--tx2);
  font-weight: 500;
}

.cr-detail {
  flex: 2;
  font-size: 11px;
  color: var(--tx3);
}

/* -- VALIDATION SNAPSHOT ROW -- */
.vs-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--bd);
}

.vs-row:last-child {
  border-bottom: none;
}

.vs-rule {
  flex: 2;
  font-size: 11px;
  color: var(--tx2);
}

.vs-result {
  width: 100px;
  text-align: center;
}

.vs-impact {
  flex: 1.5;
  font-size: 11px;
  color: var(--tx3);
}

/* -- IG ROW (Ingredient Grid) -- */
.ig-row {
  display: grid;
  grid-template-columns: 140px 1fr 1fr 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid var(--bd);
}

.ig-row:last-child {
  border-bottom: none;
}

.ig-cell {
  padding: 5px 8px;
  font-size: 11px;
  color: var(--tx2);
  border-right: 1px solid var(--bd);
}

.ig-cell:last-child {
  border-right: none;
}

.ig-cell.head {
  background: var(--surf);
  font-weight: 700;
  font-size: 10px;
  color: var(--tx3);
  text-transform: uppercase;
}

/* -- Alert Item Sub-components -- */
.ai-ico {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.ai-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--tx);
}

.ai-sub {
  font-size: 10.5px;
  color: var(--tx3);
  margin-top: 1px;
}

.ai-time {
  font-size: 9.5px;
  color: var(--tx4);
  margin-top: 2px;
}

.ai-act {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all .1s;
  margin-top: 4px;
}

/* -- Chart Bar Hover -- */
.chart-bar:hover {
  filter: brightness(1.15);
  transform: scaleX(1.02);
}

/* -- KEYFRAME ANIMATIONS -- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulseLoad {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: .7;
  }
}
