:root {
  color-scheme: light;
  --bg: #f2f6f3;
  --surface: #ffffff;
  --surface-soft: #e8f0ec;
  --ink: #18231f;
  --muted: #65736f;
  --line: #d8e1dc;
  --accent: #1f5f58;
  --accent-2: #8a5b2f;
  --danger: #a13d3d;
  --shadow: 0 16px 42px rgba(24, 35, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

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

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #fcfdfc;
}

.brand-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar h1,
.topbar h2,
.login-card h2 {
  margin: 0;
  letter-spacing: 0;
}

.sidebar h1 {
  font-size: 23px;
  line-height: 1.15;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-button,
.ghost-button {
  justify-content: start;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.nav-button {
  border: 1px solid transparent;
}

.nav-button.is-active {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--accent);
}

.ghost-button {
  margin-top: auto;
  color: var(--muted);
}

.main {
  min-width: 0;
}

.workspace {
  display: none;
  padding: 22px;
}

.is-authenticated .workspace {
  display: block;
}

.login-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.is-authenticated .login-panel {
  display: none;
}

.login-card {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.form-error {
  color: var(--danger);
  min-height: 20px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.toolbar input {
  width: min(52vw, 340px);
}

.view {
  display: none;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel,
.item-card,
.timeline-item,
.media-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
}

.metric p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(300px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 10px;
}

.section-head h3,
.panel h3 {
  margin: 0;
  font-size: 18px;
}

.panel {
  padding: 18px;
}

.stack {
  display: grid;
  gap: 16px;
}

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

.form-grid h3,
.form-grid button,
.span-all {
  grid-column: 1 / -1;
}

.form-help {
  margin: -4px 0 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.partial-date-input.is-hidden {
  display: none;
}

.compact {
  gap: 10px;
}

.card-list,
.timeline {
  display: grid;
  gap: 10px;
}

.section-head select {
  max-width: 260px;
}

.compact-list .item-card {
  padding: 10px 12px;
}

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

.item-card h4 {
  margin: 0 0 4px;
  font-size: 16px;
}

.item-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.item-card .mini {
  margin-top: 6px;
  font-size: 12px;
}

.weight-sparkline {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  max-width: 360px;
  color: var(--muted);
  font-size: 12px;
}

.weight-sparkline svg {
  width: 140px;
  height: 34px;
  overflow: visible;
}

.weight-sparkline polyline {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.weight-sparkline.is-up {
  color: #15803d;
}

.weight-sparkline.is-down {
  color: #b91c1c;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 99px;
  background: #eee3d7;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 99px;
  background: var(--surface-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

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

.notice {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.timeline-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.agenda-item {
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr) auto;
  align-items: center;
}

.timeline-item time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.timeline-item p {
  margin: 4px 0 0;
  color: var(--muted);
}

.filters {
  display: flex;
  gap: 8px;
}

.filter-button {
  min-height: 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
}

.filter-button.is-active {
  background: var(--surface-soft);
  color: var(--accent);
}

.danger-button {
  background: #f7e8e8;
  color: var(--danger);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.media-card {
  overflow: hidden;
}

.media-card img,
.media-card video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #d8e1dc;
}

.media-card div {
  padding: 12px;
}

.media-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar h1 {
    font-size: 19px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-button {
    white-space: nowrap;
    min-width: max-content;
  }

  .ghost-button {
    display: none;
  }

  .workspace {
    padding: 14px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar input {
    width: 100%;
  }

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

  .item-card {
    grid-template-columns: 1fr;
  }

  .agenda-item {
    grid-template-columns: 1fr;
  }

  .filters {
    width: 100%;
    flex-direction: column;
  }
}
