:root {
  --bg: #0f1216;
  --fg: #e8edf2;
  --muted: #a8b3bf;
  --card: #171b21;
  --accent: #4ea1ff;
  --ok: #35c48a;
  --warn: #ffb020;
  --bad: #ff5a5a;
}

* { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--fg); background: linear-gradient(180deg, #0e1114, #0a0c0f);
}

header, footer { text-align: center; padding: 20px 10px; }
header h1 { margin: 6px 0 0; font-size: 26px; font-weight: 700; }
header p { margin: 6px 0 0; color: var(--muted); }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid #222831;
  border-radius: 14px;
  padding: 16px;
  margin: 16px 0;
  box-shadow: 0 4px 18px rgba(0,0,0,0.25);
}

h2 { margin: 0 0 12px 0; font-size: 18px; }
h3 { margin: 12px 0 8px; font-size: 15px; }
.muted { color: var(--muted); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.kv {
  border: 1px solid #2a313b;
  border-radius: 12px;
  padding: 12px;
  background: #12161b;
}
.kv .k { color: var(--muted); font-size: 12px; }
.kv .v { font-size: 22px; font-weight: 700; }

/* Bar charts */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-label {
  flex: 0 0 90px;
  font-size: 13px;
  color: var(--muted);
}

.bar {
  flex: 1;
  background: #10141a;
  border-radius: 999px;
  overflow: hidden;
  height: 14px;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #35c48a, #4ea1ff);
}

/* Donuts */
.donut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.donut-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.donut {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, #20252e 0deg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.donut-inner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #0f1216;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: #101418;
  border: 1px solid #222831;
  border-radius: 10px;
  overflow: hidden;
}
th, td { padding: 8px 10px; border-bottom: 1px solid #1d232b; font-size: 13px; }
thead th { background: #151a21; text-align: left; color: var(--muted); }
tbody tr:hover { background: #141920; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
}
.badge.low { background: #173b2d; color: var(--ok); border: 1px solid #245f4a; }
.badge.medium { background: #3b3417; color: #ffcf66; border: 1px solid #6b5a1f; }
.badge.high { background: #3b1d17; color: #ff9b7a; border: 1px solid #6b2a1f; }
.badge.critical { background: #3b1717; color: var(--bad); border: 1px solid #6b1f1f; }

/* Heatmap */
#risk-heatmap td.level-cell {
  text-align: center;
  font-weight: 600;
}
.level-low { background: rgba(53,196,138,0.12); color: #84e0b6; }
.level-medium { background: rgba(255,176,32,0.12); color: #ffd27a; }
.level-high { background: rgba(255,90,90,0.16); color: #ffb2b2; }
.level-critical { background: rgba(255,40,40,0.25); color: #ff9c9c; }

/* CSV preview */
#csv-upload {
  margin-bottom: 10px;
}
#csv-preview-table {
  margin-top: 6px;
}
