:root {
  color-scheme: dark;
  --bg: #03040a;
  --panel: rgba(13, 16, 28, 0.94);
  --panel-2: rgba(21, 26, 40, 0.96);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f7f8ff;
  --muted: #a9adbc;
  --accent: #ff304f;
  --accent-2: #1677ff;
  --good: #72dda6;
  --danger: #ff6b7a;
  --radius: 14px;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.45);
  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: var(--bg);
  color: var(--text);
}

button,
input,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(22, 119, 255, 0.12), rgba(255, 48, 79, 0.08)),
    #03040a;
}

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

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
  background: linear-gradient(135deg, rgba(22, 119, 255, 0.14), rgba(255, 48, 79, 0.1)), var(--bg);
}

.auth-card {
  width: min(100%, 440px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand.compact {
  margin-bottom: 28px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 520px);
  align-items: center;
  gap: 22px;
  max-width: 1220px;
  margin: 0 auto 24px;
}

.top-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
}

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

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow);
}

.brand-mark svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: white;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.goal-progress {
  display: grid;
  gap: 9px;
}

.goal-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.86rem;
}

.goal-progress-meta strong {
  color: var(--text);
}

.goal-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 48, 79, 0.26);
}

.goal-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff304f 0%, #f0c54a 45%, #72dda6 100%);
  transition: width 220ms ease;
}

.goal-needed {
  color: var(--muted);
  font-size: 0.86rem;
  text-align: right;
}

.date-pill {
  min-width: 170px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
}

.app-frame {
  display: grid;
  grid-template-columns: 250px 1fr;
  max-width: 1220px;
  min-height: 720px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(10, 11, 14, 0.78);
  box-shadow: var(--shadow);
}

aside {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  padding: 24px;
}

.nav-title {
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  margin-bottom: 10px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-button.is-active,
.nav-button:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

main {
  padding: clamp(22px, 4vw, 42px);
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

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

.screen-header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 3.1rem);
}

.screen-header p {
  max-width: 640px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.entry-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0.75fr;
  gap: 22px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
}

.form-card {
  padding: clamp(20px, 4vw, 32px);
}

.form-card h3 {
  margin: 0 0 18px;
  font-size: 1.15rem;
}

.today-goal-card {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 48, 79, 0.16), rgba(22, 119, 255, 0.18)),
    rgba(255, 255, 255, 0.04);
}

.today-goal-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.today-goal-card strong {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
}

.today-goal-result {
  width: fit-content;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 750;
}

.today-goal-card.is-hit {
  border-color: rgba(114, 221, 166, 0.65);
}

.today-goal-card.is-hit .today-goal-result {
  border-color: rgba(114, 221, 166, 0.5);
  color: var(--good);
}

.today-goal-card.is-miss {
  border-color: rgba(255, 107, 122, 0.65);
}

.today-goal-card.is-miss .today-goal-result {
  border-color: rgba(255, 107, 122, 0.5);
  color: var(--danger);
}

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

.field {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.9rem;
}

input {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--text);
}

input:focus {
  border-color: color-mix(in srgb, var(--accent), white 25%);
}

.save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 750;
  text-decoration: none;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.danger-button {
  min-height: 58px;
  border: 1px solid rgba(255, 107, 122, 0.5);
  border-radius: 10px;
  padding: 0 18px;
  background: rgba(255, 107, 122, 0.12);
  color: var(--danger);
  font-weight: 750;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
}

.secondary-button:disabled,
.save-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.secondary-button.small {
  min-height: 42px;
}

.segmented,
.button-stack {
  display: grid;
  gap: 12px;
}

#cancelEditButton {
  display: none;
}

#cancelEditButton.is-visible {
  display: inline-flex;
}

.link-button {
  text-align: center;
}

.form-message {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--muted);
}

.form-message.is-success {
  color: var(--good);
}

.form-message.is-error {
  color: var(--danger);
}

.session-preview {
  padding: 24px;
  background: var(--panel-2);
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.metric-row:last-child {
  border-bottom: 0;
}

.metric-row span {
  color: var(--muted);
}

.metric-row strong {
  font-size: 1.18rem;
  text-align: right;
}

.period-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.year-map-card {
  margin-bottom: 24px;
  padding: 22px;
}

.year-map {
  display: grid;
  grid-template-columns: repeat(73, minmax(4px, 1fr));
  grid-template-rows: repeat(5, 8px);
  gap: 4px;
  margin-top: 18px;
}

.year-day {
  min-width: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
}

.year-day.is-done {
  background: #72dda6;
}

.year-day.is-missed {
  background: #ff304f;
}

.year-day.is-future {
  background: rgba(255, 255, 255, 0.14);
}

.year-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.year-map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.year-map-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-done {
  background: #72dda6;
}

.legend-missed {
  background: #ff304f;
}

.legend-future {
  background: rgba(255, 255, 255, 0.18);
}

.period-card {
  padding: 16px;
  transition:
    border-color 180ms ease,
    transform 180ms ease;
}

.period-card.is-active {
  border-color: rgba(255, 48, 79, 0.65);
  transform: translateY(-2px);
}

.period-head {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.period-head span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
}

.period-head strong {
  display: block;
  margin-top: 4px;
  font-size: 0.92rem;
  line-height: 1.3;
}

.icon-button {
  display: grid;
  min-width: 34px;
  min-height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 1.3rem;
}

.period-metrics {
  display: grid;
  gap: 8px;
}

.period-metrics span {
  color: var(--muted);
  font-size: 0.85rem;
}

.graphs-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.graphs-header span {
  color: var(--muted);
  display: block;
  font-size: 0.86rem;
}

.graphs-header strong {
  display: block;
  margin-top: 4px;
  font-size: 1.2rem;
}

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

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 22px;
}

.forecast-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.forecast-card {
  min-height: 118px;
  padding: 20px;
}

.forecast-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.forecast-card strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
}

.history-table-card {
  padding: 22px;
}

.history-table,
.sessions-table {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  overflow-x: auto;
}

.history-row,
.sessions-row {
  display: grid;
  grid-template-columns: 0.7fr repeat(4, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.sessions-row {
  grid-template-columns: 0.9fr 0.8fr 0.85fr 0.75fr 0.75fr 0.75fr minmax(128px, auto);
  min-width: 760px;
}

.sessions-row.compact-row {
  grid-template-columns: 0.9fr 0.8fr 0.8fr 0.8fr 0.8fr;
  min-width: 560px;
}

.history-row:last-child,
.sessions-row:last-child {
  border-bottom: 0;
}

.history-head,
.sessions-head {
  color: var(--text);
  font-weight: 750;
}

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

.mini-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.mini-button.danger {
  border-color: rgba(255, 107, 122, 0.45);
  color: var(--danger);
}

.import-errors {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  color: var(--danger);
  font-size: 0.9rem;
}

.import-errors p {
  margin: 0;
}

.chart-panel {
  padding: 22px;
}

.chart-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
}

.chart-title strong {
  color: var(--text);
}

.chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18px, 1fr));
  align-items: end;
  gap: 8px;
  height: 210px;
  padding-top: 18px;
}

.bar-wrap {
  display: grid;
  align-items: end;
  gap: 8px;
  height: 100%;
}

.bar {
  min-height: 8px;
  border-radius: 999px 999px 6px 6px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
}

.bar-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-chart {
  display: grid;
  grid-column: 1 / -1;
  height: 100%;
  place-items: center;
  color: var(--muted);
}

@media (max-width: 1080px) {
  .period-grid,
  .graphs-grid,
  .forecast-grid,
  .forecast-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .screen-header {
    align-items: stretch;
  }

  .topbar,
  .top-actions {
    grid-template-columns: 1fr;
  }

  .app-frame,
  .entry-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .field-grid,
  .period-grid,
  .graphs-grid,
  .forecast-grid,
  .forecast-summary {
    grid-template-columns: 1fr;
  }

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

  .history-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .chart {
    height: 190px;
  }

  .year-map {
    gap: 3px;
  }
}
