:root {
  color-scheme: light;
  --paper: #f6f7f3;
  --panel: #ffffff;
  --ink: #1f2623;
  --muted: #66736d;
  --line: #d8dfd8;
  --green: #2f6f5f;
  --blue: #315f8f;
  --rose: #8c3f55;
  --gold: #a37525;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.topbar-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.icon-button,
.primary-button,
.secondary-button,
.tabs button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 58px;
  font-weight: 800;
  color: var(--blue);
}

.profile-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.profile-strip select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
  color: var(--ink);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tabs button {
  min-width: 72px;
  padding: 8px 6px;
  font-size: 13px;
}

.tabs button.active {
  background: var(--green);
  color: #ffffff;
  border-color: var(--green);
}

.view {
  padding: 18px;
}

body.auth-required .profile-strip,
body.auth-required .tabs,
body.auth-required #syncButton {
  display: none;
}

.auth-panel {
  min-height: calc(100vh - 112px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 18px;
}

.auth-panel h2 {
  margin-bottom: 0;
  font-size: 26px;
}

.primary-link-button,
.secondary-link-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  text-decoration: none;
  font-weight: 800;
}

.primary-link-button {
  background: var(--green);
  color: #ffffff;
  border-color: var(--green);
}

.secondary-link-button {
  background: var(--panel);
  color: var(--blue);
}

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

.metric,
.panel,
.hero-panel,
.list-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
}

.hero-panel {
  padding: 16px;
  background: #eef5f0;
}

.hero-panel h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.metric {
  padding: 12px;
}

.metric strong {
  display: block;
  font-size: 24px;
  color: var(--green);
}

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

.panel {
  margin-top: 14px;
  padding: 14px;
}

.panel h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field input,
.field select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
}

.primary-button {
  width: 100%;
  background: var(--green);
  color: #ffffff;
  border-color: var(--green);
  font-weight: 800;
}

.secondary-button {
  width: 100%;
  color: var(--blue);
  font-weight: 700;
}

.danger-button {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--rose);
  border-radius: 8px;
  background: var(--rose);
  color: #ffffff;
  font: inherit;
  font-weight: 800;
}

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

.list-row {
  padding: 10px;
}

.list-row strong {
  display: block;
}

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

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.status-line:last-child {
  border-bottom: 0;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.group-grid {
  display: grid;
  gap: 10px;
}

.group-button {
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
  color: var(--ink);
  text-align: left;
}

.group-button strong,
.group-card strong {
  display: block;
}

.group-button span,
.group-card span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.group-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
  padding: 12px;
}

.group-items {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf5f0;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.notice {
  border-left: 4px solid var(--gold);
  padding: 10px 12px;
  background: #fff8e8;
  color: #493918;
}

@media (max-width: 420px) {
  .app-shell {
    border: 0;
  }

  .topbar {
    padding-top: 16px;
  }

  h1 {
    font-size: 24px;
  }

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