:root {
  color-scheme: dark;
  --bg: #07101d;
  --panel: #0b1628;
  --panel-2: #0f1f35;
  --line: #29415f;
  --line-soft: rgba(91, 126, 166, 0.3);
  --text: #e7f1ff;
  --muted: #8ba2bd;
  --cyan: #16d9f4;
  --blue: #2d7cff;
  --pink: #ff4fa1;
  --green: #27e49f;
  --red: #ff4d67;
  --yellow: #ffd166;
  --shadow: rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 32% -8%, rgba(22, 217, 244, 0.13), transparent 32rem),
    linear-gradient(180deg, #081321 0%, #050b14 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.auth-hidden {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.login-panel {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(13, 28, 49, 0.98), rgba(8, 18, 34, 0.98));
  box-shadow: 0 22px 50px var(--shadow);
}

.login-brand {
  padding: 0 0 8px;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line-soft);
  background: rgba(6, 14, 27, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 22px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(22, 217, 244, 0.55);
  border-radius: 8px;
  color: var(--cyan);
  background: rgba(22, 217, 244, 0.08);
  font-weight: 800;
}

.brand strong,
.brand span,
.side-status strong,
.side-status span {
  display: block;
}

.brand span,
.side-status span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #b8cae0;
  text-decoration: none;
  font-size: 14px;
}

.nav-link:hover,
.nav-link.active {
  border-color: rgba(22, 217, 244, 0.28);
  background: rgba(22, 217, 244, 0.08);
  color: white;
}

.nav-link span {
  width: 18px;
  color: var(--cyan);
  text-align: center;
}

.side-status {
  position: absolute;
  right: 14px;
  bottom: 122px;
  left: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(15, 31, 53, 0.72);
}

.pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
}

.user-panel {
  position: absolute;
  right: 14px;
  bottom: 18px;
  left: 14px;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(15, 31, 53, 0.72);
}

.user-panel span {
  color: var(--muted);
  font-size: 12px;
}

.user-panel strong {
  font-size: 14px;
}

.main {
  padding: 20px;
  overflow: hidden;
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.today-pill {
  min-width: 155px;
  padding: 10px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(11, 22, 40, 0.8);
  text-align: right;
}

.today-pill span,
.today-pill strong {
  display: block;
}

.today-pill span {
  color: var(--muted);
  font-size: 12px;
}

.today-pill strong {
  margin-top: 2px;
}

.page-section {
  display: none;
  margin-bottom: 22px;
}

.page-section.active {
  display: block;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

.grid {
  display: grid;
  gap: 12px;
}

.capture-grid,
.db-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.panel,
.pool-card,
.forecast-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(13, 28, 49, 0.94), rgba(8, 18, 34, 0.94));
  box-shadow: 0 16px 36px var(--shadow);
}

.panel {
  padding: 14px;
}

.form-row.split {
  display: grid;
  grid-template-columns: minmax(220px, 0.35fr) 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #c6d6e8;
  font-size: 13px;
}

input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: #081426;
  color: var(--text);
  padding: 0 11px;
}

input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(22, 217, 244, 0.1);
}

textarea {
  width: 100%;
  min-height: 140px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: #081426;
  color: var(--text);
  padding: 11px;
  resize: vertical;
}

textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(22, 217, 244, 0.1);
}

.save-note {
  padding: 11px 12px;
  border: 1px solid rgba(45, 124, 255, 0.28);
  border-radius: 7px;
  background: rgba(45, 124, 255, 0.08);
}

.save-note strong,
.save-note span {
  display: block;
}

.save-note span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.pool-inputs {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.capture-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.pool-input-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(150px, 1fr) 34px;
  gap: 10px;
  align-items: end;
}

.icon-button {
  width: 34px;
  height: 40px;
  border: 1px solid rgba(255, 77, 103, 0.42);
  border-radius: 7px;
  background: rgba(255, 77, 103, 0.08);
  color: var(--red);
  cursor: pointer;
}

.primary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  border: 0;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  color: #03111f;
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(15, 31, 53, 0.82);
  color: var(--text);
  padding: 0 14px;
}

.metric-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.comparison {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-size: 22px;
}

.comparison.up {
  color: var(--green);
  border-color: rgba(39, 228, 159, 0.45);
  background: rgba(39, 228, 159, 0.08);
}

.comparison.down {
  color: var(--red);
  border-color: rgba(255, 77, 103, 0.45);
  background: rgba(255, 77, 103, 0.08);
}

.hero-number {
  margin: 20px 0 4px;
  color: white;
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 800;
}

.delta-line,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.mini-table {
  display: grid;
  gap: 9px;
  margin-top: 22px;
}

.mini-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(91, 126, 166, 0.18);
  font-size: 13px;
}

.mini-row span:first-child {
  color: #d6e5f6;
}

.reset-tag {
  color: var(--yellow);
  font-size: 12px;
}

.range-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.range-toggle button {
  min-width: 62px;
  height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: rgba(11, 22, 40, 0.78);
  color: var(--muted);
  cursor: pointer;
}

.range-toggle button:last-child {
  border-right: 0;
}

.range-toggle button.active {
  background: rgba(22, 217, 244, 0.12);
  color: var(--cyan);
}

.total-panel {
  margin-bottom: 12px;
}

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

.pool-card,
.forecast-card {
  padding: 14px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.card-top strong {
  font-size: 15px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.metric-box {
  padding: 9px;
  border: 1px solid rgba(91, 126, 166, 0.24);
  border-radius: 7px;
  background: rgba(5, 12, 22, 0.38);
}

.metric-box span,
.metric-box strong {
  display: block;
}

.metric-box span {
  color: var(--muted);
  font-size: 11px;
}

.metric-box strong {
  margin-top: 3px;
  font-size: 14px;
}

.chart {
  width: 100%;
  height: 170px;
  margin-top: 12px;
}

.chart path.line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart path.area {
  opacity: 0.13;
}

.chart .axis {
  stroke: rgba(139, 162, 189, 0.18);
  stroke-width: 1;
}

.forecast-card.feature {
  grid-column: span 2;
}

.forecast-value {
  margin: 16px 0 6px;
  font-size: 34px;
  font-weight: 800;
}

.forecast-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.instructions ol {
  margin: 0;
  padding-left: 20px;
  color: #c0d0e2;
  line-height: 1.65;
}

code {
  color: var(--cyan);
}

.db-actions {
  display: grid;
  gap: 10px;
  align-content: start;
}

.upload-box {
  display: grid;
  min-height: 118px;
  place-items: center;
  border: 1px dashed rgba(22, 217, 244, 0.46);
  border-radius: 8px;
  background: rgba(22, 217, 244, 0.06);
  cursor: pointer;
  text-align: center;
}

.upload-box input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-box span {
  font-weight: 800;
}

.upload-box small {
  display: block;
  color: var(--muted);
}

.csv-paste-box {
  line-height: 1.45;
}

.paste-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.upload-result {
  min-height: 38px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
}

.import-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.history-panel {
  margin-top: 12px;
}

.history-table {
  margin-top: 12px;
  overflow-x: auto;
}

.history-table table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

.history-table th,
.history-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(91, 126, 166, 0.18);
  text-align: left;
  white-space: nowrap;
}

.history-table th {
  color: var(--muted);
  font-weight: 700;
}

.history-table input {
  width: 130px;
}

.history-table input[name="editPool"] {
  width: 90px;
}

.table-actions {
  display: flex;
  gap: 8px;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(15, 31, 53, 0.82);
  color: var(--text);
  cursor: pointer;
}

.small-button.danger {
  border-color: rgba(255, 77, 103, 0.42);
  color: var(--red);
}

.empty-state {
  padding: 26px;
  border: 1px dashed rgba(139, 162, 189, 0.32);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

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

  .sidebar {
    position: relative;
    height: auto;
  }

  .side-status {
    position: static;
    margin-top: 12px;
  }

  .user-panel {
    position: static;
    margin-top: 12px;
  }

  .capture-grid,
  .db-grid,
  .pool-cards,
  .forecast-grid {
    grid-template-columns: 1fr;
  }

  .forecast-card.feature {
    grid-column: auto;
  }
}

@media (max-width: 660px) {
  .main {
    padding: 14px;
  }

  .topbar,
  .section-header,
  .form-row.split {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .pool-input-row {
    grid-template-columns: 1fr;
  }

  .capture-actions {
    grid-template-columns: 1fr;
  }

  .mini-row {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }

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