/* ═══════════════════════════════════════════════════════════
   ERM Risk Management Platform — Global Styles
   Design system dari MRB Risk Platform v2.0 prototype
═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&family=Playfair+Display:wght@600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

:root {
  --navy:   #0F2D5A;
  --navy2:  #1A5276;
  --teal:   #148F77;
  --teal2:  #1ABC9C;
  --gold:   #D4AC0D;
  --light:  #EBF5FB;
  --lteal:  #E8F8F5;
  --white:  #fff;
  --text:   #1C2833;
  --muted:  #717D7E;
  --border: #AED6F1;
  --crit:   #C0392B; --critBg: #FDEDEC;
  --high:   #E67E22; --highBg: #FEF0E7;
  --med:    #D4AC0D; --medBg:  #FDFBE4;
  --low:    #148F77; --lowBg:  #E8F8F5;
  --r:      10px;
  --sh:     0 3px 16px rgba(15,45,90,.09);
  --surface:#F0F4FA;
}

body {
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  background: var(--surface);
  color: var(--text);
  overflow-x: hidden;
  line-height: 1.5;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── RANGE SLIDER ── */
input[type=range] { -webkit-appearance: none; width: 100%; height: 6px; background: var(--border); border-radius: 3px; outline: none; cursor: pointer; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 22px; width: 22px; border-radius: 50%; background: var(--navy); border: 2.5px solid var(--teal2); box-shadow: 0 2px 6px rgba(0,0,0,.2); cursor: pointer; }
input[type=range]::-moz-range-thumb { height: 20px; width: 20px; border-radius: 50%; background: var(--navy); border: 2px solid var(--teal2); }

/* ── CARD ── */
.erm-card {
  background: #fff;
  border-radius: var(--r);
  box-shadow: var(--sh);
  overflow: hidden;
  margin-bottom: 12px;
}
.erm-ch {
  background: var(--navy);
  color: #fff;
  padding: 10px 14px;
  font-size: .83rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}
.erm-cb { padding: 13px 14px; }

/* ── HEADER ── */
.erm-header {
  background: linear-gradient(135deg, var(--navy), var(--navy2));
  padding: 0 16px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 14px rgba(0,0,0,.25);
  flex-wrap: wrap;
  gap: 8px;
}
.erm-header-logo { color: #fff; font-size: .92rem; font-weight: 700; }
.erm-header-sub  { color: var(--border); font-size: .63rem; margin-top: 1px; }
.erm-badge { background: var(--teal); color: #fff; padding: 3px 9px; border-radius: 16px; font-size: .67rem; font-weight: 600; font-family: 'DM Mono', monospace; }
.erm-hbtn { background: rgba(255,255,255,.15); border: none; color: #fff; padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: .72rem; font-family: inherit; white-space: nowrap; }
.erm-hbtn:hover { background: rgba(255,255,255,.25); }

/* ── TABS ── */
.erm-tabs {
  background: #fff;
  border-bottom: 2px solid var(--border);
  padding: 0 14px;
  display: flex;
  gap: 2px;
  position: sticky;
  top: 54px;
  z-index: 90;
  box-shadow: 0 2px 8px rgba(15,45,90,.07);
  overflow-x: auto;
}
.erm-tab {
  padding: 11px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: .83rem;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2.5px solid transparent;
  white-space: nowrap;
  transition: all .16s;
  margin-bottom: -2px;
}
.erm-tab:hover { color: var(--navy); }
.erm-tab.active { color: var(--navy); font-weight: 700; border-bottom-color: var(--teal); }

/* ── FILTER BAR ── */
.erm-fbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: sticky;
  top: 108px;
  z-index: 80;
  box-shadow: 0 2px 8px rgba(15,45,90,.06);
}
.erm-ftab {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all .16s;
}
.erm-ftab.active, .erm-ftab:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.erm-fsel {
  padding: 5px 22px 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-family: inherit;
  font-size: .72rem;
  outline: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23717D7E'/%3E%3C/svg%3E") no-repeat right 8px center;
  color: var(--text);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.erm-fsel:focus { border-color: var(--teal); }

/* ── TABLE ── */
.erm-tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.erm-tbl { width: 100%; border-collapse: collapse; font-size: .76rem; min-width: 580px; }
.erm-tbl th { background: var(--navy); color: #fff; padding: 8px 10px; text-align: left; font-weight: 600; white-space: nowrap; }
.erm-tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.erm-tbl tr:last-child td { border-bottom: none; }
.erm-tbl tr:hover td { background: var(--light); }

/* ── LEVEL BADGES ── */
.lbg { display: inline-block; padding: 2px 8px; border-radius: 9px; font-size: .66rem; font-weight: 700; }
.lbg-LOW      { background: var(--lowBg);  color: var(--low);  }
.lbg-MEDIUM   { background: var(--medBg);  color: var(--med);  }
.lbg-HIGH     { background: var(--highBg); color: var(--high); }
.lbg-CRITICAL { background: var(--critBg); color: var(--crit); }

/* ── STATUS BADGES ── */
.sbg { display: inline-block; padding: 2px 8px; border-radius: 9px; font-size: .66rem; font-weight: 700; }
.sbg-draft          { background: var(--surface); color: var(--muted); }
.sbg-submitted      { background: var(--light);   color: var(--navy2); }
.sbg-approved       { background: var(--lteal);   color: var(--teal);  }
.sbg-final_approved { background: #E8F8F0;         color: #1E8449;      }
.sbg-flagged        { background: var(--critBg);  color: var(--crit);  }

/* ── KPI CARDS ── */
.erm-kpi-row { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin-bottom: 12px; }
@media(min-width:600px) { .erm-kpi-row { grid-template-columns: repeat(4,1fr); } }
.erm-kpi {
  background: #fff;
  border-radius: var(--r);
  box-shadow: var(--sh);
  padding: 14px 12px;
  border-top: 4px solid;
}
.erm-kv { font-size: 1.9rem; font-weight: 700; font-family: 'DM Mono', monospace; line-height: 1.1; }
.erm-kl { font-size: .68rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 4px; }

/* ── HOME CARDS ── */
.erm-home-card {
  background: #fff;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  padding: 26px 20px 22px;
  cursor: pointer;
  text-align: center;
  transition: transform .18s, box-shadow .18s, border-color .18s;
  position: relative;
  overflow: hidden;
}
.erm-home-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--card-color, var(--border));
}
.erm-home-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 14px 36px rgba(15,45,90,.13);
  border-color: var(--card-color, var(--border));
}
.erm-home-card.disabled {
  opacity: .6;
  cursor: not-allowed;
}
.erm-home-card.disabled:hover { transform: none; box-shadow: none; }

/* ── INPUT & SELECT ── */
.erm-inp {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: .82rem;
  outline: none;
  background: #fff;
  -webkit-appearance: none;
  margin-bottom: 8px;
  color: var(--text);
}
.erm-inp:focus { border-color: var(--teal); }
.erm-inp.error { border-color: var(--crit); background: var(--critBg); }
.erm-sel { appearance: none; -webkit-appearance: none; cursor: pointer; }

/* ── BUTTONS ── */
.erm-btn {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: .84rem;
  font-weight: 700;
  transition: opacity .15s;
}
.erm-btn:active { opacity: .8; }
.erm-btn-primary { background: linear-gradient(135deg, var(--navy), var(--navy2)); color: #fff; }
.erm-btn-teal    { background: linear-gradient(135deg, var(--teal), var(--teal2)); color: #fff; }
.erm-btn-ghost   { background: var(--surface); color: var(--text); }
.erm-btn-sm { padding: 5px 12px; font-size: .76rem; }
.erm-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── INLINE LABEL ── */
.erm-lbl { display: block; font-size: .75rem; font-weight: 600; color: var(--navy2); margin-bottom: 4px; }

/* ── PROGRESS BAR ── */
.erm-prog-wrap { background: var(--light); border-radius: 4px; height: 6px; overflow: hidden; }
.erm-prog-bar  { height: 100%; border-radius: 4px; transition: width .4s; }

/* ── TOAST ── */
.erm-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 18px;
  border-radius: 9px;
  font-size: .84rem;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  animation: fadeup .25s ease;
  max-width: 340px;
}
@keyframes fadeup { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.erm-toast-success { background: var(--teal); color: #fff; }
.erm-toast-error   { background: var(--crit); color: #fff; }
.erm-toast-info    { background: var(--navy); color: #fff; }

/* ── MODAL ── */
.erm-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.erm-modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.erm-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--light);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.erm-modal-head h3 { margin: 0; color: var(--navy); font-size: .98rem; font-weight: 700; font-family: 'Playfair Display', serif; }
.erm-modal-body { padding: 18px; }

/* ── SPINNER ── */
.erm-spin {
  width: 32px; height: 32px;
  border: 3px solid var(--light);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── RESPONSIVE ── */
@media(max-width:600px) {
  .erm-tabs { top: 54px; }
  .erm-fbar { top: 106px; }
}

/* ── RISK CALCULATOR SPECIFIC ── */
.calc-score-box {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 9px;
  margin-bottom: 12px;
}
.calc-score-item {
  text-align: center;
  padding: 10px 6px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.08);
}
.calc-score-val { font-size: 1.7rem; font-weight: 700; font-family: 'DM Mono', monospace; line-height: 1.1; }
.calc-score-lbl { font-size: .64rem; font-weight: 600; text-transform: uppercase; color: var(--muted); margin-top: 3px; }

/* ── HEATMAP MATRIX ── */
.hm-cell {
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
  min-height: 56px;
  position: relative;
}
.hm-cell:hover { transform: scale(1.05); z-index: 2; }
.hm-cell.active { transform: scale(1.08); z-index: 3; box-shadow: 0 4px 16px rgba(0,0,0,.2); }

/* ── IMPACT DETAIL CARDS ── */
.impact-dim-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); }
.impact-dim-cell { padding: 5px 8px; }
.impact-dim-label { font-size: .61rem; font-weight: 700; margin-bottom: 1px; }
.impact-dim-val   { font-size: .68rem; line-height: 1.45; }

/* ── RISK LOG TABLE ── */
.risk-row-critical td { background: #FFF5F5 !important; }
.risk-row-high td     { background: #FFFAF5 !important; }
.risk-row-rejected td { background: #FDF0F0 !important; }
.risk-row-rejected td:first-child { border-left: 4px solid #C0392B; }
