@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Manrope:wght@400;500;600;700&display=swap");

:root {
  --bg: #edf1f5;
  --bg-top: #f8fafc;
  --bg-bottom: #e8edf4;
  --ink: #17202a;
  --ink-soft: #314050;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: rgba(247, 250, 253, 0.99);
  --panel-muted: rgba(247, 249, 252, 0.78);
  --field-bg: #ffffff;
  --field-hover-bg: #ffffff;
  --button-bg: rgba(255, 255, 255, 0.96);
  --button-hover-bg: #ffffff;
  --button-border: rgba(38, 52, 69, 0.12);
  --button-border-hover: rgba(38, 52, 69, 0.25);
  --action-bg: rgba(255, 255, 255, 0.8);
  --action-hover-bg: #ffffff;
  --nav-bg: rgba(255, 255, 255, 0.9);
  --nav-border: rgba(38, 52, 69, 0.08);
  --chart-grid: rgba(38, 52, 69, 0.12);
  --chart-axis: #667587;
  --chart-tooltip-bg: rgba(255, 255, 255, 0.96);
  --chart-tooltip-ink: #17202a;
  --chart-target: #b45309;
  --accent: #0f766e;
  --accent-soft: #d6efe7;
  --accent-strong: #0b5f5a;
  --danger: #b45309;
  --danger-soft: #ffedd5;
  --muted: #667587;
  --border: rgba(38, 52, 69, 0.14);
  --border-strong: rgba(38, 52, 69, 0.22);
  --shadow-sm: 0 8px 18px rgba(23, 32, 42, 0.045);
  --shadow-md: 0 18px 34px rgba(23, 32, 42, 0.07);
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --shell-max: 1180px;
  --shell-max-wide: 1280px;
}

html {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111d;
  --bg-top: #0b1220;
  --bg-bottom: #111b2e;
  --ink: #e6edf6;
  --ink-soft: #c4cfde;
  --panel: rgba(14, 23, 38, 0.94);
  --panel-strong: rgba(18, 29, 46, 0.98);
  --panel-muted: rgba(21, 33, 52, 0.85);
  --field-bg: rgba(7, 14, 25, 0.98);
  --field-hover-bg: rgba(10, 18, 31, 1);
  --button-bg: rgba(18, 29, 46, 0.96);
  --button-hover-bg: rgba(24, 37, 58, 0.98);
  --button-border: rgba(163, 184, 210, 0.18);
  --button-border-hover: rgba(163, 184, 210, 0.32);
  --action-bg: rgba(18, 29, 46, 0.88);
  --action-hover-bg: rgba(24, 37, 58, 0.98);
  --nav-bg: rgba(18, 29, 46, 0.88);
  --nav-border: rgba(163, 184, 210, 0.14);
  --chart-grid: rgba(163, 184, 210, 0.16);
  --chart-axis: #9fb0c6;
  --chart-tooltip-bg: rgba(10, 18, 31, 0.96);
  --chart-tooltip-ink: #e6edf6;
  --chart-target: #f59e0b;
  --accent-soft: rgba(24, 83, 74, 0.42);
  --danger-soft: rgba(124, 45, 18, 0.35);
  --muted: #8fa0b5;
  --border: rgba(163, 184, 210, 0.18);
  --border-strong: rgba(163, 184, 210, 0.28);
  --shadow-sm: 0 8px 20px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 18px 42px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  height: 100%;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  color: var(--ink);
  font-family: "Manrope", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  line-height: 1.45;
}

body.app-page {
  color: var(--ink);
}

body.app-login {
  display: grid;
  place-items: center;
  padding: 16px;
}

main,
.app-shell {
  width: min(var(--shell-max), calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.app-shell--wide {
  width: min(var(--shell-max-wide), calc(100vw - 32px));
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--ink);
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-weight: 700;
  line-height: 1.08;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.03em;
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -0.025em;
}

h3 {
  font-size: 1.08rem;
}

p {
  margin: 0;
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.14em;
}

a:hover {
  color: var(--accent);
}

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

.subtitle {
  color: var(--muted);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-md);
}

.stat-panel {
  background: var(--panel-strong);
  border: 1px solid rgba(38, 52, 69, 0.08);
  border-radius: var(--radius-md);
  padding: 18px;
}

.pill,
.kind-pill,
.group-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.78rem;
  line-height: 1;
  background: var(--panel-strong);
  color: var(--muted);
}

.kind-pill {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
  background: var(--accent-soft);
}

html[data-theme="dark"] .pill,
html[data-theme="dark"] .group-pill {
  background: rgba(24, 37, 58, 0.98);
  color: #e2ebf5;
  box-shadow: inset 0 0 0 1px rgba(163, 184, 210, 0.16);
}

html[data-theme="dark"] .kind-pill {
  color: #f4fffa;
  background: rgba(18, 100, 83, 0.72);
  box-shadow: inset 0 0 0 1px rgba(167, 243, 208, 0.1);
}

button,
.link-button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px 14px;
  background: var(--field-bg);
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: rgba(15, 118, 110, 0.36);
  background: var(--field-hover-bg);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  border-color: rgba(163, 184, 210, 0.22);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 0 0 1px rgba(5, 10, 18, 0.18);
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  border-color: rgba(94, 234, 212, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 0 0 1px rgba(5, 10, 18, 0.1);
}

button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--button-border);
  border-radius: 12px;
  padding: 10px 16px;
  background: var(--button-bg);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(23, 32, 42, 0.02);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease;
}

button:hover,
.link-button:hover {
  background: var(--button-hover-bg);
  color: var(--ink);
  border-color: var(--button-border-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(23, 32, 42, 0.05);
}

button:active,
.link-button:active {
  transform: translateY(0);
}

.danger-button {
  border-color: rgba(185, 28, 28, 0.2);
  background: var(--danger-soft);
  color: #9a3412;
}

.danger-button:hover {
  background: #fff;
  border-color: rgba(185, 28, 28, 0.35);
}

.action-link,
button.action-link,
a.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  border: 1px solid var(--button-border);
  background: var(--action-bg);
  box-shadow: 0 1px 2px rgba(23, 32, 42, 0.03);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.action-link:hover,
button.action-link:hover,
a.action-link:hover {
  color: var(--ink);
  background: var(--action-hover-bg);
  border-color: var(--button-border-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(23, 32, 42, 0.05);
}

.action-link.danger,
button.action-link.danger,
a.action-link.danger {
  color: #9a3412;
}

.action-link.danger:hover,
button.action-link.danger:hover,
a.action-link.danger:hover {
  background: rgba(254, 242, 242, 0.9);
  color: #7f1d1d;
  border-color: rgba(185, 28, 28, 0.25);
}

.app-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.app-toolbar--start {
  align-items: flex-start;
}

.app-toolbar--compact {
  margin-bottom: 12px;
}

.app-toolbar form {
  margin: 0;
}

.app-toolbar form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: max-content;
  padding: 8px 12px;
  font-size: 0.95rem;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(38, 52, 69, 0.12);
  color: var(--muted);
  box-shadow: none;
}

html[data-theme="dark"] .app-toolbar form button {
  background: rgba(16, 27, 42, 0.88);
  border-color: rgba(163, 184, 210, 0.14);
  color: #c9d6e5;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

html[data-theme="dark"] .app-toolbar form button:hover {
  background: rgba(20, 33, 50, 0.94);
  border-color: rgba(163, 184, 210, 0.2);
  color: #ecf4fd;
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--nav-border);
  background: var(--nav-bg);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.app-nav a.active-link {
  background: var(--accent-soft);
  border-color: rgba(15, 118, 110, 0.2);
}

html[data-theme="dark"] .app-nav a {
  color: #e2ebf5;
  background: rgba(24, 37, 58, 0.96);
  border-color: rgba(163, 184, 210, 0.18);
  font-weight: 700;
}

html[data-theme="dark"] .app-nav a.active-link {
  color: #f4fffa;
  background: rgba(18, 100, 83, 0.72);
  border-color: rgba(74, 222, 128, 0.3);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.18),
    inset 0 0 0 1px rgba(167, 243, 208, 0.08);
}

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

.app-inline-nav a {
  text-decoration: none;
}

.app-inline-nav .divider {
  color: rgba(111, 100, 87, 0.55);
}

.app-hero {
  margin-bottom: 22px;
}

.app-title-block {
  display: grid;
  gap: 8px;
}

.app-section-stack {
  display: grid;
  gap: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

@media (max-width: 760px) {
  main,
  .app-shell,
  .app-shell--wide {
    width: min(100vw - 24px, var(--shell-max));
    padding: 14px 0 40px;
  }

  h1 {
    font-size: clamp(1.8rem, 8vw, 2.45rem);
  }

  .app-toolbar {
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
  }

  .app-toolbar--compact {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .app-inline-nav {
    font-size: 0.95rem;
  }
}


/* --- Extracted Shared Primitives --- */

.metric {
  font-size: clamp(2rem, 4vw, 2.6rem);
  color: var(--accent);
  margin: 10px 0 6px;
  line-height: 1;
}

.click-row,
.click-card {
  display: block;
  color: inherit;
  text-decoration: none;
}

.click-row {
  margin: -12px -2px;
  padding: 12px 2px;
  border-radius: 12px;
}

.click-card {
  margin: -18px;
  padding: 18px;
  border-radius: 18px;
}

.click-row:hover,
.click-card:hover {
  background: rgba(15, 118, 110, 0.05);
  color: inherit;
}

.click-row:focus-visible,
.click-card:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  outline-offset: 2px;
}

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

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(38, 52, 69, 0.05);
}

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

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

.app-list-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.app-list-item:last-child {
  border-bottom: 0;
}

.entry-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.entry-row--top {
  align-items: start;
}

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


/* --- Group Themes --- */
.theme-fitness {
  --accent: #ea580c;
  --accent-soft: #ffedd5;
  --accent-strong: #c2410c;
}
.theme-focus {
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --accent-strong: #1d4ed8;
}
.theme-negative {
  --accent: #dc2626;
  --accent-soft: #fee2e2;
  --accent-strong: #b91c1c;
}
.theme-growth {
  --accent: #7c3aed;
  --accent-soft: #ede9fe;
  --accent-strong: #6d28d9;
}
.theme-family {
  --accent: #db2777;
  --accent-soft: #fce7f3;
  --accent-strong: #be185d;
}
.theme-inactive {
  --accent: #475569;
  --accent-soft: #e2e8f0;
  --accent-strong: #334155;
}
