:root{
  --bg:#f5f7fb;
  --white:#ffffff;
  --ink:#0A2342;
  --muted:#6b7280;
  --brand:#0A2342;
  --brand-2:#274b7a;
  --accent:#1f6feb;

  --risk-red:#ff0000;
  --risk-orange:#f59e0b;
  --risk-yellow:#ffff00;
  --risk-green:#00b050;
  --risk-blue:#00b0f0;

  --green:#4caf50;
  --red:#d9534f;
  --amber:#f59e0b;

  --rounded:16px;
  --shadow:0 10px 24px rgba(2,22,60,.08);
  --card-shadow:0 10px 18px rgba(2,22,60,.07);
  --radius:14px;
  --gap:18px;

  font-size:16px;
}

*{
  box-sizing:border-box;
}

html,
body{
  height:100%;
}

body{
  margin:0;
  font-family:"Nunito", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:var(--bg);
  color:#0f172a;
}

/* =========================================================
   LAYOUT
========================================================= */

.layout{
  display:grid;
  grid-template-columns:280px 1fr;
  min-height:100vh;
  transition:grid-template-columns .3s ease-in-out;
}

.layout.sidebar-closed{
  grid-template-columns:0 1fr;
}

.main-wrapper{
  display:flex;
  flex-direction:column;
  max-height:100vh;
  overflow-x:hidden;
}

.main{
  padding:0 30px 26px 30px;
  flex-grow:1;
  overflow-y:auto;
}

/* =========================================================
   SIDEBAR
========================================================= */

.sidebar{
  background:#e7eef4;
  padding:28px 22px;
  position:sticky;
  top:0;
  height:100vh;
  border-right:1px solid #dbe3ee;

  display:flex;
  flex-direction:column;
  overflow:hidden;

  transition:
    margin-left .3s ease-in-out,
    padding .3s ease-in-out,
    border-color .3s ease-in-out;
}

.layout.sidebar-closed .sidebar{
  margin-left:-280px;
  padding-left:0;
  padding-right:0;
  border-right-color:transparent;
}

.brand{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  margin-bottom:24px;
}

.brand img{
  width:120px;
  height:auto;
  object-fit:contain;
}

.brand h3{
  margin:0;
  font-weight:800;
  letter-spacing:.3px;
  color:var(--ink);
}

.brand p{
  margin:0;
  margin-top:-4px;
  color:var(--muted);
  font-size:.96rem;
}

/* =========================================================
   MENU
========================================================= */

.menu{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-top:10px;
  flex-grow:1;
}

.menu a{
  display:flex;
  align-items:center;
  gap:10px;

  background:transparent;
  color:#0f172a;
  text-decoration:none;

  padding:12px 14px;
  border-radius:14px;

  font-weight:700;
  font-size:1rem;

  transition:.2s ease;
}

.menu a:hover{
  background:#dde7f2;
}

.menu a.active{
  background:var(--white);
  box-shadow:var(--card-shadow);
  border:1px solid #eaf0f7;
}

.menu-logout{
  margin-top:20px;
  padding-top:15px;
  border-top:2px solid #dbe3ee;
}

.menu-logout a{
  display:flex;
  align-items:center;
  gap:10px;

  text-decoration:none;

  padding:12px 14px;
  border-radius:14px;

  font-weight:700;
  font-size:1rem;

  transition:.2s ease;

  background:#f8fafc;
  color:#b91c1c;
}

.menu-logout a:hover{
  background:#dc2626;
  color:#ffffff;
}

/* =========================================================
   TOPBAR
========================================================= */

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;

  margin-bottom:18px;
  padding:26px 30px 0 30px;

  position:sticky;
  top:0;

  background:var(--bg);
  z-index:10;
}

.topbar-left{
  display:flex;
  align-items:center;
  gap:15px;
}

.topbar h2{
  margin:0;
  font-size:2rem;
  letter-spacing:.3px;
  color:var(--ink);
}

.user{
  display:flex;
  align-items:center;
  gap:12px;
  color:var(--muted);
  font-weight:700;
}

.logout{
  background:var(--brand);
  color:#fff;
  text-decoration:none;

  padding:10px 16px;
  border-radius:12px;

  box-shadow:var(--shadow);
  font-weight:800;
}

.logout:hover{
  background:var(--brand-2);
}

.hamburger-menu{
  font-size:28px;
  background:none;
  border:none;
  cursor:pointer;
  color:var(--ink);
  padding:0 10px;
  margin-left:-10px;
}

/* =========================================================
   LOGIN
========================================================= */

.login-wrap{
  max-width:980px;
  margin:40px auto;

  display:grid;
  grid-template-columns:1fr 1fr;

  background:#fff;
  border-radius:18px;
  overflow:hidden;

  box-shadow:var(--shadow);
}

.login-left{
  background:#2c7be4;
  color:#fff;

  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;

  padding:30px 24px;
  gap:10px;
}

.login-left img{
  width:120px;
}

.login-left h2{
  margin:0;
  font-size:22px;
  text-align:center;
}

.login-right{
  padding:34px;
}

.login-right h3{
  margin-top:0;
  font-size:22px;
}

.login-right .alert{
  margin-top:6px;
}

.login-right button{
  margin-top:8px;
}

/* =========================================================
   CARDS
========================================================= */

.cards{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(280px,1fr));
  gap:20px;
  margin:18px 0 26px;
}

.card{
  background:var(--white);
  border-radius:var(--radius);
  padding:22px;

  box-shadow:var(--card-shadow);
  border:1px solid #eef2f7;
}

.card .icon{
  font-size:30px;
}

.card h3{
  margin:8px 0;
  color:var(--ink);
  font-size:1.4rem;
}

.card p{
  margin:0 0 12px;
  color:var(--muted);
}

/* =========================================================
   BUTTONS
========================================================= */

.btn,
.btn-add{
  background:var(--brand);
  color:#fff;
  border:none;
  text-decoration:none;

  padding:10px 16px;
  border-radius:12px;

  font-weight:800;
  display:inline-flex;
  align-items:center;
  gap:6px;

  cursor:pointer;
}

.btn:hover,
.btn-add:hover{
  background:var(--brand-2);
}

.btn-primary{
  background:#16a34a;
  color:#fff;
}

.btn-primary:hover{
  background:#15803d;
}

.btn-reset{
  background:transparent;
  color:#0A2342;
  text-decoration:underline;
  box-shadow:none;
}

/* =========================================================
   FORM
========================================================= */

.form-card{
  background:var(--white);
  border-radius:var(--radius);
  padding:22px;

  box-shadow:var(--card-shadow);
  border:1px solid #eef2f7;
}

form label{
  font-weight:700;
  margin-top:10px;
  display:block;
}

form input,
form textarea,
form select{
  width:100%;
  padding:10px;

  border:1px solid #dbe3ee;
  border-radius:8px;

  margin-top:5px;
  font-size:14px;
}

input:focus,
textarea:focus,
select:focus{
  border-color:#6aa7ff;
  box-shadow:0 0 0 3px rgba(26,115,232,.15);
  outline:none;
}

textarea{
  min-height:90px;
  resize:vertical;
}

.form-section{
  margin-top:30px;
  border-top:2px solid #f1f5f9;
  padding-top:15px;
}

.form-section h3{
  margin:0 0 12px;
  color:var(--ink);
}

.row-2{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:12px;
}

/* =========================================================
   READONLY / AUTO RISK BOX
========================================================= */

.readonly-box{
  background:#f3f4f6;
  border:1px solid #cbd5e1;

  font-weight:800;
  text-align:center;

  transition:.2s ease;
}

.readonly-box:focus{
  outline:none;
}

/* =========================================================
   ALERT
========================================================= */

.alert{
  background:#eaf5ff;
  border:1px solid #cfe6ff;
  padding:10px 14px;
  color:#0b316b;
  border-radius:10px;
  font-weight:800;
  margin-bottom:12px;
}

.error{
  background:#ffecec;
  border-color:#ffd3d3;
  color:#7a0f0f;
}

.success{
  background:#ecfff3;
  border-color:#c6f1d6;
  color:#0b6b2b;
}

/* =========================================================
   FILTER
========================================================= */

.filter-bar,
.filter-rows{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:10px;
  margin:15px 0;
}

.filter-rows .field{
  min-width:220px;
}

.filter-bar input,
.filter-bar select,
.filter-rows input[type="text"],
.filter-rows select{
  width:100%;
  padding:10px 12px;

  border-radius:10px;
  border:1px solid #e5e7eb;

  background:#fff;
  font-size:14px;
  font-weight:600;

  box-shadow:0 6px 18px rgba(2,6,23,.06);
}

.filter-bar button,
.filter-rows button{
  background:#0A2342;
  color:white;
  border:none;

  padding:10px 14px;
  border-radius:10px;

  font-weight:700;
  cursor:pointer;
}

.filter-bar button:hover,
.filter-rows button:hover{
  background:#163a6b;
}

/* =========================================================
   DEFAULT TABLE
========================================================= */

.table-container{
  margin-top:16px;
  background:#ffffff;
  border-radius:18px;
  box-shadow:0 8px 28px rgba(15,23,42,.06);
  overflow:hidden;
  border:1px solid #e5e7eb;
}

table{
  border-collapse:collapse;
  width:100%;
  font-size:14px;
}

th,
td{
  border:1px solid #e2e8f0;
  padding:10px;
  text-align:left;
}

th{
  background:#0A2342;
  color:white;
  font-weight:600;

  position:sticky;
  top:0;
  z-index:2;
}

tr:nth-child(even){
  background:#f8fafc;
}

tr:hover{
  background:#f6f9ff;
}

/* =========================================================
   RISK TABLE / DAFTAR RISK
========================================================= */

.table-wrapper{
  width:100%;
  overflow:auto;
  max-height:75vh;
}

.table-wrapper::-webkit-scrollbar{
  height:10px;
  width:10px;
}

.table-wrapper::-webkit-scrollbar-thumb{
  background:#94a3b8;
  border-radius:999px;
}

.table-wrapper::-webkit-scrollbar-track{
  background:#f1f5f9;
}

.risk-table{
  border-collapse:separate;
  border-spacing:0;
  width:max-content;
  min-width:2800px;
  table-layout:fixed;
  background:#fff;
}

.risk-table thead th{
  position:sticky;
  top:0;
  z-index:5;

  background:#0A2342;
  color:#ffffff;

  font-size:13px;
  font-weight:800;
  letter-spacing:.2px;

  padding:14px 12px;

  border-right:1px solid rgba(255,255,255,.08);
  border-bottom:1px solid #08192f;

  text-align:left;
  vertical-align:middle;

  min-width:140px;
}

.risk-table tbody td{
  padding:12px 12px;
  border-bottom:1px solid #e5e7eb;
  border-right:1px solid #eef2f7;

  font-size:13px;
  line-height:1.6;
  color:#0f172a;

  vertical-align:top;

  white-space:normal;
  word-break:break-word;
  overflow-wrap:anywhere;

  background:#ffffff;

  transition:background .15s ease;
}

.risk-table tbody tr:nth-child(even) td{
  background:#f8fafc;
}

.risk-table tbody tr:hover td{
  background:#eef6ff;
}

.risk-table th:first-child,
.risk-table td:first-child{
  border-left:none;
}

.risk-table th:last-child,
.risk-table td:last-child{
  border-right:none;
}

.risk-table th{
  position:relative;
}

.risk-table th .resizer,
.resizer{
  position:absolute;
  top:0;
  right:0;

  width:7px;
  height:100%;

  cursor:col-resize;
  user-select:none;

  transition:background .15s ease;
}

.risk-table th .resizer:hover,
.resizer:hover{
  background:rgba(255,255,255,.35);
}

/* sticky action column */
.risk-table th:last-child,
.risk-table td:last-child{
  position:sticky;
  right:0;
  z-index:4;
}

.risk-table th:last-child{
  background:#0A2342;
}

.risk-table tbody td:last-child{
  background:#ffffff;
  min-width:170px;
}

.risk-table tbody tr:nth-child(even) td:last-child{
  background:#f8fafc;
}

.risk-table tbody tr:hover td:last-child{
  background:#eef6ff;
}

.scroll-hint{
  padding:10px 14px;
  font-size:12px;
  color:#64748b;
  background:#f8fafc;
  border-top:1px solid #e5e7eb;
  text-align:right;
}

/* optional column widths */
.col-no{
  width:70px;
}

.col-kode{
  width:130px;
}

.col-owner{
  width:170px;
}

.col-score{
  width:110px;
}

.col-status{
  width:160px;
}

.col-aksi{
  width:180px;
}

.col-lvl{
  width:90px;
}

/* =========================================================
   ACTION BUTTONS
========================================================= */

.action-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;

  padding:7px 12px;
  margin:2px;

  border-radius:10px;

  font-size:12px;
  font-weight:700;

  text-decoration:none;

  transition:.18s ease;
}

.action-btn.edit,
.edit{
  background:#facc15;
  color:#111827;
}

.action-btn.edit:hover,
.edit:hover{
  background:#eab308;
  transform:translateY(-1px);
}

.action-btn.delete,
.delete{
  background:#ef4444;
  color:#ffffff;
}

.action-btn.delete:hover,
.delete:hover{
  background:#dc2626;
  transform:translateY(-1px);
}

/* =========================================================
   STATUS BADGE
========================================================= */

.st-badge{
  display:inline-block;
  padding:4px 10px;
  border-radius:999px;

  font-weight:800;
  font-size:12px;

  color:#0b1220;
  white-space:nowrap;
}

.st-vhigh{
  background:#ff0000;
  color:#ffffff;
  border:1px solid #dc2626;
}

.st-high{
  background:#f59e0b;
  color:#111827;
  border:1px solid #d97706;
}

.st-med{
  background:#ffff00;
  color:#111827;
  border:1px solid #eab308;
}

.st-low{
  background:#00b050;
  color:#ffffff;
  border:1px solid #16a34a;
}

.st-vlow{
  background:#00b0f0;
  color:#ffffff;
  border:1px solid #0284c7;
}

.st-unk{
  background:#e2e8f0;
  color:#0f172a;
  border:1px solid #cbd5e1;
}

/* =========================================================
   HEATMAP MATRIX / DASHBOARD
========================================================= */

.matrix-container{
  margin-top:20px;
  background:#ffffff;
  border-radius:18px;
  padding:24px;
  box-shadow:0 6px 18px rgba(0,0,0,.06);
  overflow-x:auto;
}

.matrix-title{
  margin-bottom:18px;
  font-size:20px;
  font-weight:800;
  color:#0A2342;
}

.matrix-table{
  width:100%;
  min-width:760px;
  border-collapse:collapse;
  table-layout:fixed;
  text-align:center;
  margin-bottom:15px;
}

.matrix-table th,
.matrix-table td{
  border:1px solid #dbe2ea;
  text-align:center;
  vertical-align:middle;
  padding:12px;
  min-height:78px;
  height:78px;
  font-weight:700;
  transition:.2s ease;
  word-break:break-word;
  white-space:normal;
}

.matrix-table td:hover,
.matrix-cell:hover{
  transform:scale(1.03);
  z-index:2;
  position:relative;
  box-shadow:0 2px 10px rgba(0,0,0,.12);
}

.matrix-cell{
  position:relative;
  cursor:pointer;
  min-width:140px;
  height:64px;
}

.matrix-cell small{
  font-size:12px;
}

/* axis */
.axis-x{
  background:#0A2342;
  color:#ffffff;
  font-size:15px;
}

.axis-y{
  background:#0A2342;
  color:#ffffff;
  width:70px;
  font-size:15px;

  writing-mode:vertical-lr;
  transform:rotate(180deg);
  text-align:center;
}

.axis-label{
  background:#e8eef5;
  font-weight:800;
  color:#0A2342;
}

/* risk heatmap colors */
.risk-red{
  background:var(--risk-red) !important;
  color:#ffffff !important;
}

.risk-orange{
  background:var(--risk-orange) !important;
  color:#000000 !important;
}

.risk-yellow{
  background:var(--risk-yellow) !important;
  color:#000000 !important;
}

.risk-green{
  background:var(--risk-green) !important;
  color:#ffffff !important;
}

.risk-blue{
  background:var(--risk-blue) !important;
  color:#ffffff !important;
}

/* legend */
.legend,
.matrix-legend{
  display:flex;
  flex-wrap:wrap;
  gap:14px;
  margin-top:18px;
  font-size:14px;
}

.legend p{
  width:100%;
  margin:0 0 6px;
}

.legend-item,
.legend-box{
  display:inline-flex;
  align-items:center;
  gap:8px;
  margin-right:10px;
  font-size:14px;
  font-weight:700;
}

.legend-item span,
.legend-color{
  display:inline-block;
  width:22px;
  height:22px;
  border-radius:6px;
  border:1px solid rgba(0,0,0,.15);
}

/* tooltip */
.rr-tooltip{
  position:fixed;
  z-index:9999;
  background:rgba(15,23,42,.95);
  color:#fff;
  padding:10px 12px;
  border-radius:10px;
  font-size:13px;
  line-height:1.35;
  pointer-events:none;
  display:none;
  max-width:280px;
  box-shadow:0 10px 25px rgba(0,0,0,.18);
}

.rr-tooltip .ttl{
  font-weight:800;
  margin-bottom:4px;
}

.rr-tooltip .muted{
  opacity:.85;
  font-size:12px;
}

/* =========================================================
   CHART
========================================================= */

.chart-card{
  background:#fff;
  padding:25px 30px;
  border-radius:12px;
  box-shadow:0 4px 12px rgba(0,0,0,.05);
  max-width:950px;
  margin:15px auto;
}

.chart-card h2{
  color:#0A2342;
  margin-bottom:10px;
}

.chart-card select{
  padding:8px 10px;
  border-radius:6px;
  border:1px solid #cbd5e1;
  font-size:14px;
}

.chart-card label{
  font-weight:bold;
}

.chart-grid{
  display:grid;
  grid-template-columns:2fr 1fr;
  gap:16px;
  align-items:start;
}

.chart-side{
  border:1px solid #e5e7eb;
  border-radius:12px;
  padding:12px;
  background:#fff;
}

.btn-toggle{
  background:#0b5ed7;
  color:#fff;
  border:none;
  padding:8px 12px;
  border-radius:10px;
  font-weight:700;
  cursor:pointer;
}

/* =========================================================
   KPI
========================================================= */

.kpi{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:8px 10px;
  border:1px solid #eef2f7;
  border-radius:10px;
  margin-bottom:8px;
  background:#f8fafc;
}

.kpi .label{
  font-weight:700;
  color:#0f172a;
}

.kpi .val{
  font-weight:800;
  font-size:18px;
}

.kpi.gray{
  border-color:#e5e7eb;
  background:#f9fafb;
}

.kpi.gray .val{
  color:#0f172a;
}

.kpi.blue{
  border-color:#bfdbfe;
  background:#eff6ff;
}

.kpi.blue .val{
  color:#1d4ed8;
}

.kpi.orange{
  border-color:#fed7aa;
  background:#fff7ed;
}

.kpi.orange .val{
  color:#ea580c;
}

.kpi.green{
  border-color:#bbf7d0;
  background:#f0fdf4;
}

.kpi.green .val{
  color:#16a34a;
}

.kpi.red{
  border-color:#fecaca;
  background:#fef2f2;
}

.kpi.red .val{
  color:#dc2626;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media(max-width:1024px){
  .chart-grid{
    grid-template-columns:1fr;
  }
}

@media(max-width:980px){

  .layout{
    grid-template-columns:1fr;
  }

  .layout.sidebar-closed{
    grid-template-columns:1fr;
  }

  .sidebar{
    position:fixed;
    z-index:30;
    left:0;
    top:0;
    width:280px;
    height:100vh;
  }

  .layout.sidebar-closed .sidebar{
    margin-left:-280px;
  }

  .login-wrap{
    grid-template-columns:1fr;
  }

  table{
    min-width:900px;
  }

  .topbar{
    padding:20px 18px 0 18px;
  }

  .main{
    padding:0 18px 24px 18px;
  }

  .topbar h2{
    font-size:1.5rem;
  }
}

@media(max-width:768px){

  .row-2{
    grid-template-columns:1fr;
  }

  .matrix-table th,
  .matrix-table td{
    height:64px;
    font-size:12px;
    padding:8px;
  }

  .table-wrapper{
    max-height:none;
  }

  .risk-table thead th{
    font-size:12px;
    padding:12px 10px;
  }

  .risk-table tbody td{
    font-size:12px;
    padding:10px;
  }

  .user{
    align-items:flex-end;
    flex-direction:column;
    gap:6px;
  }
}