:root {
  color-scheme: dark;
  --bg: #0f0f0d;
  --panel: #171714;
  --panel-2: #1f1f1b;
  --line: #32322b;
  --line-soft: #262620;
  --text: #f2f0e8;
  --muted: #a5a196;
  --soft: #d4d0c3;
  --green: #2fd18b;
  --red: #ef5d4f;
  --amber: #d5a642;
  --cyan: #53b9c9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.login-body {
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.login-brand,
.topbar-main {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #4b452f;
  border-radius: 8px;
  color: var(--amber);
  background: #15130d;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
}

h2 {
  font-size: 14px;
  line-height: 1.2;
  color: var(--soft);
}

.login-brand p,
.topbar p,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--soft);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  color: var(--text);
  background: #10100e;
  outline: none;
}

input:focus {
  border-color: var(--amber);
}

select:focus {
  border-color: var(--amber);
}

.login-error {
  color: var(--red);
  font-size: 13px;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 13px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
}

button:hover {
  border-color: #5b574b;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 15, 13, 0.96);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  width: 36px;
  padding: 0;
}

.ghost-button {
  background: transparent;
}

.terminal {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(110px, 1fr));
  gap: 8px;
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(150px, 200px) minmax(150px, 200px) auto;
  align-items: end;
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 11px;
  background: var(--panel);
}

.filter-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
}

.filter-panel button {
  width: 86px;
}

.metric {
  min-height: 74px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 11px;
  background: var(--panel);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.tabs,
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  padding-top: 2px;
}

.tab {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
  background: transparent;
}

.tab.active {
  color: var(--amber);
  border-color: var(--line);
  border-bottom-color: var(--panel);
  background: var(--panel);
}

.toolbar {
  justify-content: space-between;
  padding-bottom: 10px;
}

.toolbar input {
  max-width: 480px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 270px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #1a1a17;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
}

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  font-size: 12px;
}

tbody tr:hover {
  background: #202019;
}

.long {
  color: var(--green);
  font-weight: 700;
}

.short {
  color: var(--red);
  font-weight: 700;
}

.approved {
  color: var(--green);
}

.rejected {
  color: var(--red);
}

.tag-list {
  display: flex;
  gap: 4px;
  max-width: 420px;
  overflow: hidden;
}

.pill {
  display: inline-block;
  max-width: 180px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--soft);
  text-overflow: ellipsis;
}

.scope-badge {
  display: inline-block;
  min-width: 58px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  text-align: center;
  font-size: 11px;
}

.scope-official {
  color: var(--green);
  border-color: rgba(47, 209, 139, 0.45);
  background: rgba(47, 209, 139, 0.08);
}

.scope-study {
  color: var(--cyan);
  border-color: rgba(83, 185, 201, 0.45);
  background: rgba(83, 185, 201, 0.08);
}

.scope-bruno {
  color: var(--amber);
  border-color: rgba(213, 166, 66, 0.45);
  background: rgba(213, 166, 66, 0.08);
}

.scope-shadow {
  min-width: auto;
  margin-left: 4px;
  color: var(--soft);
  border-color: rgba(212, 208, 195, 0.35);
  background: rgba(212, 208, 195, 0.07);
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.report-block {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.report-block.wide {
  grid-column: 1 / -1;
}

canvas {
  display: block;
  width: 100%;
  height: 220px;
  margin-top: 12px;
}

.rank-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 48px;
  align-items: center;
  gap: 10px;
  color: var(--soft);
  font-size: 12px;
}

.rank-bar {
  height: 7px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #27251d;
}

.rank-fill {
  height: 100%;
  background: var(--amber);
}

.portfolio-state {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.audit-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.state-item {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px;
  background: #141411;
}

.state-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.state-item strong {
  display: block;
  margin-top: 6px;
  font-size: 16px;
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(4, minmax(110px, 1fr));
  }

  .filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .filter-panel,
  .audit-strip,
  .portfolio-state {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tabs {
    overflow-x: auto;
  }
}
