:root {
  --bg: #151718;
  --surface: #f6f1e8;
  --surface-2: #efe8dc;
  --ink: #14181c;
  --ink-soft: #3f4650;
  --line: #d7cfc1;
  --accent: #be8f52;
  --positive-bg: #e9f6eb;
  --positive-fg: #135a31;
  --negative-bg: #fceaea;
  --negative-fg: #8f1f1f;
  --neutral-bg: #eaf0f7;
  --neutral-fg: #2d4760;
  --warn: #8b5c00;
  --danger: #aa1f1f;
  --radius: 14px;
  --shadow: 0 14px 28px rgba(0, 0, 0, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% -10%, #2d3338 0%, transparent 40%),
    radial-gradient(circle at 100% 0%, #283138 0%, transparent 35%),
    var(--bg);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Barlow Condensed", "Space Grotesk", sans-serif;
  letter-spacing: 0.02em;
}

h1 {
  font-size: 2.1rem;
}

h2 {
  font-size: 1.45rem;
  margin-bottom: 10px;
}

h3 {
  font-size: 1.12rem;
}

p {
  margin: 0;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  animation: cardIn 260ms ease-out both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  background: linear-gradient(145deg, var(--surface), var(--surface-2));
}

.eyebrow {
  color: var(--ink-soft);
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.subhead {
  margin-top: 8px;
  color: var(--ink-soft);
  max-width: 680px;
}

.topbar-controls {
  display: grid;
  gap: 10px;
  min-width: 270px;
}

.file-drop {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

.file-drop input {
  border: 1px solid #bca98d;
  border-radius: 10px;
  background: #fff;
  padding: 8px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #3f2f18;
  background: #edd9bb;
}

.dashboard-main {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
}

.summary-card {
  display: grid;
  gap: 12px;
}

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

.kpi-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 5px;
}

.label {
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.value {
  font-size: 1.1rem;
  font-weight: 700;
}

.rule-badge {
  display: inline-block;
  width: fit-content;
  background: #232b31;
  color: #f8e6ca;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 0.8rem;
}

.meta-row {
  display: grid;
  gap: 8px;
}

.meta-row p {
  color: #2f3640;
  font-size: 0.95rem;
}

.equity-panel {
  background: linear-gradient(165deg, #f7f2e9, #efe8dc);
  display: grid;
  gap: 10px;
}

.equity-caption {
  color: #4a525a;
  font-size: 0.9rem;
}

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

.manual-grid label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

.manual-grid input {
  border: 1px solid #bca98d;
  border-radius: 10px;
  background: #fff;
  padding: 9px;
}

.error {
  color: var(--danger);
  min-height: 1.2em;
  font-size: 0.92rem;
}

.warnings {
  color: var(--warn);
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}

.equity-card {
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 14px;
  display: grid;
  gap: 6px;
}

.equity-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.equity-value {
  font-size: 2rem;
  font-weight: 700;
}

.equity-card.positive {
  background: var(--positive-bg);
  border-color: #95d4ac;
  color: var(--positive-fg);
}

.equity-card.negative {
  background: var(--negative-bg);
  border-color: #ebb6b6;
  color: var(--negative-fg);
}

.equity-card.neutral {
  background: var(--neutral-bg);
  border-color: #c2d4e7;
  color: var(--neutral-fg);
}

.dates-panel {
  margin-top: 2px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
}

th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #454d56;
  background: #ebe3d6;
  padding: 9px;
}

td {
  border-top: 1px solid #eadfce;
  padding: 9px;
  font-size: 0.93rem;
}

.raw-panel details {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fff;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
  margin-top: 8px;
  background: #f8f6f2;
  border: 1px solid #e6dccb;
  border-radius: 8px;
  padding: 9px;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .dashboard-main {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: 1fr;
    display: grid;
  }
}

@media (max-width: 700px) {
  .app {
    padding: 14px;
  }

  h1 {
    font-size: 1.65rem;
  }

  .kpi-grid,
  .manual-grid {
    grid-template-columns: 1fr;
  }
}
