:root {
  color-scheme: light;
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-soft: #f2f5f4;
  --ink: #2a333f;
  --muted: #6b7480;
  --faint: #9aa3ad;
  --line: #e9ebee;
  --line-strong: #dadde2;
  --accent: #6f9c8c;
  --accent-strong: #4f7a6b;
  --violet: #8c84b0;
  --coral: #c08a6a;
  --green: #6f9c8c;
  --blue: #5b7fa6;
  --danger: #c2554e;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 12px 30px rgba(16, 24, 40, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 15px;
  background: var(--ink);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

button:hover {
  background: #2b3548;
  box-shadow: var(--shadow-sm);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--ink);
}

button.secondary:hover,
button.ghost:hover {
  border-color: rgba(111, 156, 140, 0.44);
  background: var(--surface-soft);
}

button.danger-button {
  border-color: rgba(220, 38, 38, 0.22);
  color: var(--danger);
}

button.danger-button:hover {
  background: #fff1f2;
}

button.ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(111, 156, 140, 0.72);
  box-shadow: 0 0 0 3px rgba(111, 156, 140, 0.12);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

code {
  border-radius: 6px;
  background: #f2f4f7;
  padding: 2px 5px;
}

pre {
  overflow-x: auto;
  border-radius: 8px;
  background: #111827;
  color: #e5edf8;
  padding: 16px;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 calc((100vw - min(1480px, calc(100vw - 32px))) / -2);
  border-bottom: 1px solid rgba(230, 232, 239, 0.9);
  background: rgba(248, 250, 252, 0.92);
  padding: 14px calc((100vw - min(1480px, calc(100vw - 32px))) / 2);
  backdrop-filter: blur(14px);
}

.topbar h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 23px;
  font-weight: 850;
}

.panel h2 {
  font-size: 17px;
  font-weight: 820;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(111, 156, 140, 0.30);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-strong);
  padding: 0 11px;
  font-size: 12px;
  font-weight: 820;
}

.status-pill.muted {
  border-color: var(--line);
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.setup-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: center;
  margin-top: 20px;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  margin-top: 20px;
}

.auth-panel {
  min-height: 340px;
}

.helper {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.privacy-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.privacy-grid div {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.privacy-grid strong,
.privacy-grid span {
  display: block;
}

.privacy-grid span {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr) 330px;
  gap: 14px;
  align-items: start;
  margin-top: 16px;
}

.left-column,
.main-column,
.right-column {
  display: grid;
  gap: 14px;
}

.panel-heading,
.active-group-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.active-group-panel {
  border-color: rgba(111, 156, 140, 0.30);
  background:
    linear-gradient(90deg, rgba(111, 156, 140, 0.08), rgba(91, 127, 166, 0.05)),
    #fff;
}

.stack {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.compact-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

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

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.group-list,
.item-list,
.feed-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.group-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  text-align: left;
}

.group-button:hover {
  border-color: rgba(111, 156, 140, 0.40);
  background: var(--surface-soft);
}

.group-button.active {
  border-color: rgba(111, 156, 140, 0.55);
  background: var(--surface-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.group-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-pill,
.small-pill {
  border-radius: 999px;
  background: #f2f4f7;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 820;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  display: grid;
  gap: 8px;
  border-top: 3px solid rgba(111, 156, 140, 0.75);
}

.metric:nth-child(2) {
  border-top-color: rgba(91, 127, 166, 0.75);
}

.metric:nth-child(3) {
  border-top-color: rgba(192, 138, 106, 0.75);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.metric strong {
  font-size: 25px;
  letter-spacing: 0;
}

.chart-panel {
  min-height: 275px;
}

.chart-toggle {
  display: inline-flex;
  align-self: flex-start;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}

.chart-toggle-btn {
  min-height: 32px;
  padding: 0 13px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.chart-toggle-btn:hover {
  background: rgba(111, 156, 140, 0.12);
  box-shadow: none;
}

.chart-toggle-btn.active {
  background: var(--accent);
  color: #fff;
}

.chart-toggle-btn.active:hover {
  background: var(--accent-strong);
}

.chart-empty {
  display: grid;
  min-height: 210px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fbfcff;
  color: var(--muted);
  text-align: center;
}

.chart-wrap {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.chart-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.chart-actions button {
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
}

.chart-svg {
  width: 100%;
  min-height: 220px;
  overflow: visible;
}

.chart-axis {
  stroke: #cbd5e1;
  stroke-width: 1;
}

.chart-grid {
  stroke: #edf0f5;
  stroke-width: 1;
}

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

.chart-dot {
  stroke: var(--surface);
  stroke-width: 2.5;
}

.chart-dot-hover {
  cursor: pointer;
  transition: r 120ms ease;
}

.chart-dot-hover:hover {
  r: 7px;
}

.chart-tooltip {
  position: fixed;
  z-index: 20;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  padding: 10px 16px;
  pointer-events: none;
  min-width: 84px;
  text-align: center;
}

.tt-date {
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  margin-bottom: 3px;
}

.tt-name {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 2px;
}

.tt-val {
  color: var(--ink);
  font-size: 18px;
  font-weight: 840;
  letter-spacing: -0.3px;
}

.group-danger-zone {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.group-hint {
  margin: 10px 0 0;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.weight-log-list {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  max-height: 280px;
  overflow-y: auto;
}

.weight-log-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  margin-bottom: 2px;
}

.weight-log-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
}

.wl-date {
  min-width: 40px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.wl-kg {
  flex: 1;
  font-size: 14px;
  font-weight: 820;
}

.wl-actions {
  display: flex;
  gap: 6px;
}

.wl-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.chart-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 720;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.item,
.feed-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
}

.item-top,
.feed-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item strong,
.feed-item strong {
  display: block;
}

.item small,
.feed-item small {
  color: var(--muted);
  line-height: 1.5;
}

.video-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.video-actions button {
  min-height: 34px;
  padding: 0 11px;
}

.video-actions a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.video-card {
  display: grid;
  gap: 10px;
}

.video-thumb {
  position: relative;
  display: block;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  padding: 0;
  aspect-ratio: 16 / 9;
  background: #0f172a;
}

.video-thumb:hover {
  background: #0f172a;
}

.video-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition:
    transform 160ms ease,
    opacity 160ms ease;
}

.video-thumb:hover img {
  opacity: 0.86;
  transform: scale(1.015);
}

.play-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 21px;
  font-weight: 900;
  line-height: 1;
}

.video-player {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 12px;
}

.video-player iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 8px;
  background: #0f172a;
}

.video-player-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.video-player-title strong {
  line-height: 1.4;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow-md);
  padding: 14px 16px;
  line-height: 1.5;
}

.danger {
  color: var(--danger);
}

@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: 300px minmax(0, 1fr);
  }

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

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 20px, 760px);
    padding-top: 10px;
  }

  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    margin: 0;
    border: 0;
    background: transparent;
    padding: 0 0 14px;
  }

  .active-group-panel,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-layout,
  .setup-panel,
  .dashboard-grid,
  .right-column,
  .metric-row,
  .privacy-grid {
    grid-template-columns: 1fr;
  }

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

  .topbar h1 {
    font-size: 22px;
  }

  .metric strong {
    font-size: 23px;
  }
}
