:root {
  color-scheme: light;
  --bg: #eef5f1;
  --surface: #ffffff;
  --surface-soft: #f7faf7;
  --ink: #152d27;
  --muted: #62766d;
  --line: #d9e5de;
  --brand: #146b54;
  --brand-dark: #0f4a3c;
  --gold: #d8a927;
  --danger: #b84b3f;
  --shadow: 0 18px 44px rgba(16, 68, 52, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(20, 107, 84, 0.08), transparent 34%),
    var(--bg);
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

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

.auth-card,
.setup-card {
  width: min(520px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.auth-card h1,
.setup-card h1 {
  margin: 0 0 8px;
  font-size: 32px;
  line-height: 1.1;
}

.auth-card p,
.setup-card p,
.muted {
  color: var(--muted);
}

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

.field {
  display: grid;
  gap: 7px;
}

.field span,
.label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: white;
  outline: none;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(20, 107, 84, 0.15);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  color: white;
  background: var(--brand);
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button {
  color: var(--brand-dark);
  border-color: #bad5c9;
  background: #edf7f2;
}

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

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

.icon-button {
  width: 42px;
  padding: 0;
}

button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  margin-bottom: 18px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: var(--brand);
  font-weight: 900;
}

.brand span {
  display: block;
  max-width: 160px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.nav-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  text-align: left;
}

.nav-button.active,
.nav-button:hover {
  color: var(--brand-dark);
  border-color: #cfe1d8;
  background: #eef7f2;
}

.workspace {
  min-width: 0;
  padding: 28px 28px 96px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 0 auto 18px;
  max-width: 1180px;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.kicker {
  min-height: 18px;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

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

.view {
  max-width: 1180px;
  margin: 0 auto;
}

.grid {
  display: grid;
  gap: 14px;
}

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

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel,
.card,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(21, 45, 39, 0.05);
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.panel-header h2,
.panel h2 {
  margin: 0;
  font-size: 18px;
}

.metric {
  min-height: 108px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

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

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

.item {
  min-height: 58px;
  padding: 12px;
  border: 1px solid #e2ece6;
  border-radius: 8px;
  display: grid;
  gap: 6px;
  background: var(--surface-soft);
}

.item-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.item-title {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  font-weight: 850;
}

.item-title span:last-child {
  overflow-wrap: anywhere;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--brand);
  flex: 0 0 auto;
}

.pill {
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--brand-dark);
  background: #e8f4ee;
  font-size: 12px;
  font-weight: 800;
}

.pill.gold {
  color: #69510c;
  background: #fbf0c7;
}

.pill.red {
  color: #7c3029;
  background: #f8ded9;
}

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

.tiny-button {
  min-height: 30px;
  border: 1px solid #d3e1da;
  border-radius: 8px;
  padding: 0 9px;
  color: var(--ink);
  background: white;
  font-size: 12px;
  font-weight: 800;
}

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

.calendar-title {
  font-size: 20px;
  font-weight: 900;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.weekday,
.day-cell {
  min-width: 0;
  text-align: center;
}

.weekday {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.day-cell {
  aspect-ratio: 1;
  border: 1px solid #dfe9e3;
  border-radius: 8px;
  padding: 6px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: white;
  font-weight: 850;
}

.day-cell.outside {
  color: #a4b2ab;
  background: #f4f8f5;
}

.day-cell.selected {
  color: white;
  border-color: var(--brand);
  background: var(--brand);
}

.day-cell.has-items:not(.selected) {
  border-color: #9ed1b8;
  background: #eef8f2;
}

.day-cell small {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  line-height: 1;
}

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

.full {
  grid-column: 1 / -1;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 30;
  padding: 18px;
  display: grid;
  place-items: center;
  background: rgba(14, 36, 30, 0.42);
}

.modal {
  width: min(640px, 100%);
  max-height: min(820px, calc(100vh - 36px));
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  box-shadow: var(--shadow);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-body {
  padding: 16px;
}

.modal-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: white;
  background: var(--brand-dark);
  box-shadow: var(--shadow);
  font-weight: 750;
}

.empty {
  min-height: 92px;
  border: 1px dashed #c6d8ce;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1ebe5;
}

.progress > span {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--brand);
}

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

  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 20;
    height: auto;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .brand {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
  }

  .nav-button {
    min-height: 48px;
    padding: 4px 2px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    font-size: 10px;
  }

  .workspace {
    padding: 18px 14px 92px;
  }

  .topbar {
    align-items: flex-start;
  }

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

  .topbar-actions .primary-button span {
    display: none;
  }

  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 520px) {
  .screen {
    padding: 14px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .nav-button span {
    font-size: 9px;
  }

  .panel,
  .auth-card,
  .setup-card {
    padding: 14px;
  }

  .month-grid {
    gap: 4px;
  }

  .day-cell {
    padding: 2px;
    font-size: 13px;
  }
}
