:root {
  --bg: #0f1420;
  --panel: #171e2e;
  --panel-2: #1e2739;
  --text: #e8ecf4;
  --muted: #8b93a7;
  --border: #2a3346;
  --accent: #4f8cff;
  --green: #35c48c;
  --red: #ef5a6f;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

h1 { margin: 0 0 4px; font-size: 1.6rem; }
h2 { margin: 0 0 12px; font-size: 1.05rem; }
.subtle { margin: 0; color: var(--muted); font-size: 0.85rem; }
.muted { color: var(--muted); }

.btn {
  display: inline-block;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.actions { display: flex; gap: 10px; }

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.summary-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.summary-card .label { color: var(--muted); font-size: 0.8rem; margin-bottom: 6px; }
.summary-card .value { font-size: 1.4rem; font-weight: 600; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.grid-2 {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.error-list { font-size: 0.85rem; line-height: 1.5; }
.error-item { color: var(--red); margin-bottom: 4px; }

.alloc-bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--panel-2);
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  padding: 5px 0;
}
.swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-label { flex: 1; }
.legend-value { color: var(--muted); }

.section-title {
  margin: 26px 0 10px;
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.9rem;
}
th, td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--panel-2); }
.name-cell { display: flex; flex-direction: column; }
.name-cell .code { color: var(--muted); font-size: 0.78rem; }
.stale { color: var(--red); font-size: 0.75rem; }
.table-wrap { overflow-x: auto; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal form label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.modal form input, .modal form select {
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.92rem;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.hidden { display: none !important; }

.suggestions {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 160px;
  overflow-y: auto;
}
.suggestion-item { padding: 8px 10px; cursor: pointer; font-size: 0.82rem; }
.suggestion-item:hover { background: var(--accent); color: white; }
