:root {
  color-scheme: light;
  --bg: #f5f1ea;
  --ink: #1f1f1f;
  --accent: #c0463b;
  --muted: #6f6a63;
  --card: #ffffff;
  --border: #e1d8cc;
  --ok: #2f855a;
  --warn: #b7791f;
  --error: #c53030;
}

[x-cloak] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.version-corner {
  position: fixed;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 1000;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  line-height: 1;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  pointer-events: none;
}

header {
  padding: 2rem 1.5rem 1rem;
  border-bottom: 2px solid var(--border);
}

main {
  padding: 2rem 1.5rem 3rem;
  max-width: 960px;
  margin: 0 auto;
}

footer {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
}

.card {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.accent {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

.divider {
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  margin: 1.5rem 0;
}

.upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.file-input {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #faf7f2;
  cursor: pointer;
}

.file-input input {
  display: none;
}

button.primary,
button.secondary {
  padding: 0.75rem 1.2rem;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: white;
  min-width: 6rem;
  font-size: 1rem;
}

button.secondary {
  background: #efebe4;
  color: var(--ink);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.6rem;
}

.list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.progress-card {
  margin: 1.2rem 0;
  padding: 1rem;
  border-radius: 12px;
  background: #fdf6e3;
}

.progress-track {
  height: 10px;
  background: #eadfd4;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.6rem 0;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
}

.progress-meta {
  font-size: 0.9rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge.amber {
  background: #fbd38d;
  color: #7b341e;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
}

.alert.error {
  background: #fed7d7;
  color: #742a2a;
}

.alert.warning {
  background: #fefcbf;
  color: #744210;
}

.section {
  margin-top: 2rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid.three {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kpi {
  padding: 1rem;
  text-align: left;
}

.kpi-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-value {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 0.4rem;
}

.kpi.good {
  border-left: 4px solid var(--ok);
}

.kpi.warn {
  border-left: 4px solid var(--warn);
}

.kpi.bad {
  border-left: 4px solid var(--error);
}

.kv {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f1e9dc;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.6rem;
}

.table th,
.table td {
  text-align: left;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid #eee2d6;
}

.placeholder {
  padding: 1rem;
  background: #fdfaf6;
  border: 1px dashed #e4d9cc;
  border-radius: 12px;
  color: var(--muted);
}

.chart {
  width: 100%;
  height: 320px;
}

/* --- Tab bar --- */
.tab-bar {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  margin: -0.5rem -0.25rem 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 10;
  padding: 0 0.25rem;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  padding: 0.65rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--ink); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Sub-tab pills (Environment) --- */
.sub-tab-bar {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}
.sub-tab {
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.sub-tab:hover { background: #f3ede5; color: var(--ink); }
.sub-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* --- Collapsible details --- */
details.section-details {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
details.section-details > summary {
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  background: #faf7f2;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
details.section-details > summary::before {
  content: "\25B6";
  font-size: 0.65rem;
  transition: transform 0.2s;
}
details.section-details[open] > summary::before {
  transform: rotate(90deg);
}
details.section-details > .details-body {
  padding: 0.75rem 1rem;
}

/* --- Bar track (allocation/I/O bars) --- */
.bar-track {
  height: 10px;
  background: #eadfd4;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.bar-fill.green { background: var(--ok); }
.bar-fill.amber { background: var(--warn); }

/* --- Grid four columns --- */
.grid.four {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

/* --- Section heading inside partials --- */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

/* --- No-data muted note --- */
.no-data {
  padding: 0.75rem 1rem;
  color: var(--muted);
  font-style: italic;
  font-size: 0.88rem;
}

@media (max-width: 640px) {
  .report-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .tab-bar {
    margin: -0.5rem -1rem 1.5rem;
    padding: 0 0.5rem;
  }
}
