@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-dark: #0b0f19;
  --bg-card: rgba(18, 22, 31, 0.68);
  --bg-card-strong: rgba(20, 26, 38, 0.92);
  --border-card: rgba(255, 255, 255, 0.07);
  --border-card-hover: rgba(255, 255, 255, 0.14);
  --text-main: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #7b8ba1;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --secondary: #2dd4bf;
  --down: #2dd4bf;
  --up: #fb7185;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 24% -8%, rgba(56, 189, 248, 0.18), transparent 34%),
    radial-gradient(circle at 88% 4%, rgba(45, 212, 191, 0.11), transparent 28%),
    linear-gradient(180deg, #0b0f19 0%, #111827 100%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.dashboard-container {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 46px 0 56px;
}

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

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.header h1 {
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 4.3rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-top-color: rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.glass-card:hover {
  border-color: var(--border-card-hover);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
}

.entry-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}

.record-form {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.form-header h2,
.section-header h2 {
  margin: 0;
}

.form-header p,
.section-header p {
  margin: 7px 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(5, 10, 20, 0.42);
  color: var(--text-main);
  padding: 11px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: rgba(203, 213, 225, 0.38);
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  background: rgba(5, 10, 20, 0.64);
  border-color: rgba(56, 189, 248, 0.72);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

.stepper-field {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  gap: 8px;
}

.stepper-field input {
  text-align: center;
}

.stepper-field button {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-weight: 800;
}

.stepper-field button:hover {
  color: var(--text-main);
  border-color: rgba(56, 189, 248, 0.46);
}

.form-actions {
  display: flex;
  gap: 10px;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 700;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(14, 165, 233, 0.22);
}

.primary-button:hover {
  filter: brightness(1.06);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.10);
}

.ghost-button:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.18);
}

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

.stat-grid .glass-card {
  padding: 22px;
  min-height: 148px;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.stat-value {
  margin: 12px 0 10px;
  font-size: clamp(2.1rem, 4vw, 3rem);
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0;
}

.unit {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
}

.stat-desc {
  min-height: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.down-text,
.td-down {
  color: var(--down);
  font-weight: 700;
}

.up-text,
.td-up {
  color: var(--up);
  font-weight: 700;
}

.chart-card {
  padding: 26px;
  margin-bottom: 24px;
}

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

.history-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chart-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.history-controls p {
  margin: 0;
}

.chart-controls p {
  margin: 0;
  white-space: nowrap;
}

.segmented-control {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.16);
}

.segmented-control button {
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  padding: 0 12px;
  font-size: 0.86rem;
  font-weight: 700;
}

.segmented-control button.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.segmented-control button:hover {
  color: var(--text-main);
}

.compact-button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 0.86rem;
}

.chart-title {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 700;
}

.chart-title::before {
  content: "";
  width: 3px;
  height: 18px;
  border-radius: 999px;
  background: var(--primary);
}

.chart-wrap {
  height: 390px;
  min-height: 280px;
}

.chart-readout {
  min-height: 38px;
  margin: 0 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.14);
  color: var(--text-secondary);
  padding: 9px 12px;
  font-size: 0.9rem;
  line-height: 1.35;
}

.chart-note {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.phase-content[hidden] {
  display: none;
}

.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.phase-card {
  border: 1px solid color-mix(in srgb, var(--phase-color) 24%, transparent);
  border-top: 3px solid var(--phase-color);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
}

.phase-card-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.phase-title {
  color: var(--phase-color);
  font-weight: 800;
}

.phase-range,
.spark-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 4px;
}

.phase-deltas {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.phase-spark-stack {
  display: grid;
  gap: 10px;
}

.sparkline {
  width: 100%;
  height: 76px;
  margin-top: 4px;
  border-radius: 10px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    rgba(0, 0, 0, 0.10);
  background-size: 100% 25%;
}

.sparkline-empty {
  display: grid;
  place-items: center;
  height: 76px;
  margin-top: 4px;
  border-radius: 10px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.10);
  font-size: 0.82rem;
}

.phase-summary-wrap {
  margin-top: 18px;
}

.phase-summary-table {
  min-width: 960px;
}

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

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.records-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.94rem;
}

.records-table th {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 13px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.records-table td {
  color: var(--text-secondary);
  padding: 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  vertical-align: top;
}

.records-table tbody tr {
  animation: fadeRowIn 0.18s ease both;
  transition: background 0.15s ease;
}

.records-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.035);
}

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

.td-main {
  color: var(--text-main);
  font-weight: 700;
}

.td-secondary {
  color: var(--text-secondary);
}

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

.delta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-weight: 800;
}

.delta-pill.down {
  background: rgba(45, 212, 191, 0.12);
  color: var(--down);
}

.delta-pill.up {
  background: rgba(251, 113, 133, 0.13);
  color: var(--up);
}

.delta-pill.neutral {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
}

.row-actions {
  white-space: nowrap;
  text-align: right;
}

.row-actions button {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-weight: 700;
  padding: 0 10px;
  margin-left: 6px;
}

.row-actions button:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.18);
}

.chart-tooltip {
  display: none;
}

@media (max-width: 900px) {
  .dashboard-container {
    width: min(100% - 28px, 680px);
    padding-top: 28px;
  }

  .header,
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-controls {
    width: 100%;
    justify-content: space-between;
  }

  .chart-controls {
    width: 100%;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .phase-card-header {
    flex-direction: column;
  }

  .phase-deltas {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .entry-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .dashboard-container {
    width: min(100% - 20px, 520px);
  }

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

  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .form-actions {
    flex-direction: column;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .chart-card,
  .record-form,
  .stat-grid .glass-card {
    padding: 18px;
  }

  .stat-grid .glass-card {
    min-height: 118px;
    padding: 16px;
  }

  .stat-value {
    font-size: 1.65rem;
  }

  .stat-desc {
    font-size: 0.78rem;
  }

  .chart-wrap {
    height: 360px;
  }

  .chart-readout {
    font-size: 0.82rem;
  }

  .segmented-control {
    max-width: 100%;
    overflow-x: auto;
  }
}
