:root {
  color-scheme: light;
  --ink: #14201d;
  --muted: #61706d;
  --line: #d9e4df;
  --paper: #f7faf8;
  --surface: #ffffff;
  --green: #187c62;
  --blue: #2f71c8;
  --orange: #d97924;
  --red: #b54237;
  --shadow: 0 18px 60px rgba(20, 32, 29, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

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

h1 {
  margin-bottom: 18px;
  font-size: clamp(42px, 6.2vw, 76px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(28px, 3.2vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 22px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.button,
.icon-button,
.range-button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
}

.button:hover,
.icon-button:hover,
.range-button:hover {
  transform: translateY(-1px);
  border-color: #a9c2b8;
}

.button.primary {
  color: white;
  background: var(--green);
  border-color: var(--green);
}

.button.secondary {
  background: #fbfdfc;
}

.compact-button {
  min-height: 38px;
  padding: 0 13px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
  border-color: var(--green);
  font-size: 24px;
  line-height: 1;
}

.login-screen {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(320px, 520px);
  min-height: 100svh;
  background:
    linear-gradient(120deg, rgba(24, 124, 98, 0.12), transparent 38%),
    linear-gradient(160deg, #f7faf8 0%, #eef5f1 50%, #fff8ef 100%);
}

.login-visual {
  position: relative;
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: space-between;
  gap: 34px;
  padding: clamp(28px, 5vw, 72px);
  overflow: hidden;
  border-right: 1px solid rgba(20, 32, 29, 0.10);
}

.login-visual::before,
.profile-home::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(20, 32, 29, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 32, 29, 0.08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(90deg, #000 0%, transparent 86%);
  pointer-events: none;
}

.login-brand,
.chart-preview,
.login-visual p {
  position: relative;
  z-index: 1;
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-weight: 950;
  background: linear-gradient(135deg, var(--green), var(--blue));
}

.login-brand strong,
.login-brand small,
.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.login-brand small,
.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chart-preview {
  width: min(100%, 720px);
  margin: auto 0;
  border: 1px solid rgba(20, 32, 29, 0.12);
  background: rgba(255, 255, 255, 0.64);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(82px, 1fr));
  grid-auto-rows: minmax(82px, 1fr);
}

.chart-grid span {
  display: flex;
  min-height: 82px;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.chart-grid b {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}

.chart-grid small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  text-transform: none;
}

.chart-grid strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.1;
}

.chart-grid span:nth-child(4n) {
  border-right: 0;
}

.chart-grid span:nth-last-child(-n + 4) {
  border-bottom: 0;
}

.chart-grid .chart-core {
  align-items: center;
  justify-content: center;
  gap: 6px;
  grid-column: 2 / 4;
  grid-row: 2 / 4;
  min-height: 164px;
  color: var(--green);
  background: linear-gradient(135deg, rgba(24, 124, 98, 0.14), rgba(47, 113, 200, 0.11));
  text-align: center;
}

.chart-grid .chart-core b {
  color: var(--green);
  font-size: 11px;
}

.chart-grid .chart-core strong {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 21px;
}

.chart-grid .chart-core small {
  max-width: 92%;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.login-visual p {
  max-width: 560px;
  margin: 0;
  color: #3f504c;
  font-size: clamp(18px, 2vw, 25px);
  font-weight: 850;
  line-height: 1.25;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100svh;
  padding: clamp(28px, 5vw, 72px);
  background: var(--surface);
}

.login-copy {
  max-width: 420px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.4;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span,
.remember {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfdfc;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field textarea {
  min-height: 84px;
  padding-top: 12px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--green);
  background: white;
  box-shadow: 0 0 0 4px rgba(24, 124, 98, 0.13);
}

.remember {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
  text-transform: none;
}

.remember input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.login-error,
.profile-status {
  min-height: 22px;
  margin-bottom: 14px;
  color: var(--red);
  font-size: 14px;
  font-weight: 850;
}

.login-submit {
  width: 100%;
  min-height: 52px;
}

.shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 14px clamp(18px, 4vw, 56px);
  background: rgba(247, 250, 248, 0.94);
  border-bottom: 1px solid rgba(20, 32, 29, 0.08);
  backdrop-filter: blur(16px);
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav a {
  padding: 9px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 850;
}

.nav a:hover {
  color: var(--ink);
  background: #eaf2ee;
}

.session-tools {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.session-tools span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.profile-home {
  position: relative;
  padding: clamp(30px, 5vw, 64px) clamp(18px, 4vw, 56px);
  background:
    radial-gradient(circle at 86% 18%, rgba(217, 121, 36, 0.17), transparent 24%),
    linear-gradient(135deg, #f8fbf8 0%, #edf6f1 56%, #f8f5ef 100%);
  overflow: hidden;
}

.home-copy,
.profile-workspace {
  position: relative;
  z-index: 1;
}

.home-copy {
  max-width: 900px;
  margin-bottom: clamp(22px, 4vw, 42px);
}

.profile-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  min-height: 560px;
  border: 1px solid rgba(20, 32, 29, 0.12);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.profile-library,
.profile-form-panel,
.panel,
.selected-profile-bar {
  min-width: 0;
  background: rgba(255, 255, 255, 0.82);
}

.profile-library {
  padding: 24px;
  border-right: 1px solid var(--line);
}

.library-header,
.form-heading,
.panel-heading.split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.profile-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.profile-card {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 5px solid transparent;
  background: #fbfdfc;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.profile-card:hover,
.profile-card.is-selected {
  transform: translateY(-1px);
  border-color: #a9c2b8;
  border-left-color: var(--orange);
  background: #fff8ef;
}

.profile-card span {
  font-size: 18px;
  font-weight: 950;
}

.profile-card small {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.3;
}

.profile-form-panel {
  padding: clamp(24px, 4vw, 42px);
}

.profile-form {
  max-width: 920px;
}

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

.field-grid.three {
  grid-template-columns: 1.1fr 0.8fr 0.8fr;
}

.location-map-panel {
  margin: 2px 0 18px;
  border: 1px solid var(--line);
  background: #fbfdfc;
}

.map-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.map-toolbar h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.birth-map {
  width: 100%;
  min-height: 320px;
  background: #eaf2ee;
}

.map-status {
  min-height: 22px;
  margin: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.profile-dashboard {
  padding: clamp(26px, 4vw, 56px);
  background: var(--paper);
}

.selected-profile-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  margin-bottom: 18px;
}

.profile-facts {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr);
  gap: 8px 14px;
  min-width: min(100%, 520px);
  margin: 0;
}

.profile-facts dt {
  color: var(--muted);
  font-weight: 900;
}

.profile-facts dd {
  margin: 0;
  font-weight: 850;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
}

.dashboard-grid > * {
  min-width: 0;
}

.panel {
  border: 1px solid var(--line);
  padding: 22px;
}

.energy-panel {
  grid-column: span 2;
}

.panel-heading {
  margin-bottom: 16px;
}

.rashi-chart {
  border: 1px solid var(--line);
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
}

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

.slim table {
  min-width: 460px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.energy-controls {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfdfc;
}

.range-button {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
}

.range-button.is-active {
  color: white;
  background: var(--green);
  border-color: var(--green);
}

#energyCanvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  background: #fbfdfc;
}

.energy-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 12px;
}

.energy-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.energy-legend i {
  display: inline-block;
  width: 18px;
  height: 4px;
  border-radius: 999px;
}

.compact-field {
  margin-bottom: 16px;
}

.mix-meter {
  display: grid;
  gap: 12px;
}

.mix-meter span {
  position: relative;
  display: block;
  min-height: 34px;
  padding-bottom: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.mix-meter span::before,
.mix-meter span::after {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  bottom: 0;
  height: 10px;
  border-radius: 999px;
}

.mix-meter span::before {
  right: 0;
  background: #eaf2ee;
}

.mix-meter span::after {
  width: var(--value);
  background: linear-gradient(90deg, var(--green), var(--orange));
}

.aspect-list {
  display: grid;
  gap: 10px;
}

.aspect-list article {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.aspect-list article:last-child {
  border-bottom: 0;
}

.aspect-list strong {
  font-weight: 950;
}

.aspect-list span {
  color: var(--muted);
  font-weight: 800;
}

.aspect-list em {
  min-width: 70px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 950;
  text-align: center;
  text-transform: uppercase;
}

.aspect-list em.high {
  color: white;
  background: var(--red);
}

.aspect-list em.medium {
  color: #7a440c;
  background: #fff0df;
}

.aspect-list em.low {
  color: var(--green);
  background: #e6f5ee;
}

@media (max-width: 1060px) {
  .login-screen,
  .profile-workspace,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(20, 32, 29, 0.10);
  }

  .login-panel {
    min-height: auto;
  }

  .profile-library {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .energy-panel {
    grid-column: auto;
  }

  .selected-profile-bar {
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  h1 {
    font-size: 40px;
  }

  h2 {
    font-size: 28px;
  }

  .login-visual,
  .login-panel,
  .profile-home,
  .profile-dashboard {
    padding: 24px 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .nav {
    width: 100%;
    overflow-x: auto;
  }

  .session-tools {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
  }

  .chart-grid {
    grid-template-columns: repeat(4, minmax(64px, 1fr));
    grid-auto-rows: minmax(70px, 1fr);
  }

  .chart-grid span {
    min-height: 70px;
    padding: 9px;
  }

  .chart-grid .chart-core {
    min-height: 140px;
  }

  .field-grid,
  .field-grid.three {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .library-header,
  .form-heading,
  .panel-heading.split,
  .map-toolbar,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .button,
  .profile-form-panel .compact-button,
  .map-actions .button {
    width: 100%;
  }

  .birth-map {
    min-height: 260px;
  }

  .selected-profile-bar,
  .profile-library,
  .profile-form-panel,
  .panel {
    padding: 18px;
  }

  table,
  .slim table {
    min-width: 420px;
  }

  .profile-facts {
    grid-template-columns: 1fr;
  }

  .aspect-list article {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}
