:root {
  color-scheme: light;
  --green-950: #113c31;
  --green-800: #174f3f;
  --green-700: #21634f;
  --green-100: #e4efe9;
  --gold: #e3ad37;
  --gold-soft: #fff3cf;
  --ink: #17211d;
  --muted: #66736d;
  --line: #dce4df;
  --surface: #fffefa;
  --background: #f5f2e9;
  --danger: #a43b36;
  --danger-soft: #fff0ef;
  --shadow: 0 16px 38px rgba(17, 60, 49, 0.09);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% -10%, rgba(227, 173, 55, 0.2), transparent 30rem),
    radial-gradient(circle at 0 32rem, rgba(23, 79, 63, 0.08), transparent 28rem),
    var(--background);
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(227, 173, 55, 0.55);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 76px;
  padding: 12px 16px;
  color: white;
  background: var(--green-950);
  box-shadow: 0 4px 18px rgba(17, 60, 49, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 15px;
  color: var(--green-950);
  background: var(--gold);
  font-weight: 900;
}

.brand-name,
.eyebrow {
  margin: 0;
}

.brand-name {
  overflow: hidden;
  font-size: 16px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow {
  color: var(--green-700);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-header .eyebrow {
  margin-bottom: 3px;
  color: #b8d0c6;
}

.local-badge {
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  color: #dce9e3;
  font-size: 12px;
}

.app-shell {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 24px 16px 36px;
}

.section-heading {
  margin-bottom: 22px;
}

.section-heading h1 {
  margin: 5px 0 8px;
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1.15;
}

.section-heading > p:last-child {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.today-summary {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid rgba(227, 173, 55, 0.35);
  border-radius: 22px;
  color: white;
  background:
    radial-gradient(circle at 100% 0, rgba(227, 173, 55, 0.22), transparent 14rem),
    linear-gradient(145deg, var(--green-950), #174f3f);
  box-shadow: var(--shadow);
}

.today-summary__date {
  color: #f4cb71;
  font-size: 12px;
  font-weight: 800;
}

.today-summary h2 {
  margin: 5px 0 6px;
  font-size: 20px;
  line-height: 1.35;
}

.today-summary p {
  margin: 0;
  color: #c9ddd4;
  font-size: 14px;
  line-height: 1.55;
}

.today-summary__button {
  width: 100%;
  color: var(--green-950);
  background: var(--gold);
}

.module-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.backup-bar {
  display: grid;
  gap: 14px;
  margin-top: 20px;
  padding: 17px;
  border: 1px dashed #a8bdb2;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.backup-actions {
  display: grid;
  gap: 9px;
}

.backup-bar strong {
  display: block;
  margin-bottom: 5px;
}

.backup-bar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.module-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 4px 15px rgba(17, 60, 49, 0.04);
  text-align: left;
  cursor: pointer;
}

.module-card:active {
  transform: translateY(1px);
}

.module-card--active {
  border-color: rgba(23, 79, 63, 0.2);
  background: linear-gradient(145deg, #fffefa, #f4f8f5);
  box-shadow: var(--shadow);
}

.module-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 15px;
  color: var(--green-800);
  background: var(--green-100);
}

.module-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.module-card--active .module-icon {
  color: var(--green-950);
  background: var(--gold);
}

.module-copy {
  min-width: 0;
}

.module-copy strong,
.module-copy small {
  display: block;
}

.module-copy strong {
  margin-bottom: 5px;
  font-size: 17px;
}

.module-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-state {
  padding: 5px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: #f0f3f1;
  font-size: 11px;
  font-weight: 700;
}

.module-card--active .module-state {
  color: #6a4a00;
  background: var(--gold-soft);
}

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

.text-button {
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  color: var(--green-800);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.date-label {
  color: var(--muted);
  font-size: 14px;
}

#plannerForm {
  display: grid;
  gap: 14px;
}

.form-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(17, 60, 49, 0.035);
}

.form-card--primary {
  border-left: 5px solid var(--gold);
}

label,
legend {
  display: block;
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 850;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cbd7d0;
  border-radius: 12px;
  color: var(--ink);
  background: #fbfcfb;
  font-size: 16px;
}

input,
select {
  min-height: 50px;
  padding: 0 13px;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--green-700) 50%),
    linear-gradient(135deg, var(--green-700) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 21px,
    calc(100% - 13px) 21px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input + input,
.sr-only + input:not(:first-of-type) {
  margin-top: 10px;
}

.task-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.task-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fbfcf9;
  transition: border-color 160ms ease, background 160ms ease;
}

.task-check {
  width: 44px;
  height: 44px;
  min-height: 44px;
  margin: 0;
  accent-color: var(--green-700);
  cursor: pointer;
}

.task-row input[type="text"] {
  min-width: 0;
  margin-top: 0;
  border-color: transparent;
  background: transparent;
}

.task-row:focus-within {
  border-color: #8fb3a3;
  background: white;
}

.task-row--done {
  border-color: #b9d2c5;
  background: var(--green-100);
}

.task-row--done input[type="text"] {
  color: var(--muted);
  text-decoration: line-through;
}

textarea {
  min-height: 88px;
  padding: 12px 13px;
  line-height: 1.6;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #98a29d;
}

.action-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 4px;
}

.action-bar--vehicle {
  grid-template-columns: 1fr;
}

.button {
  min-height: 54px;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-weight: 850;
  cursor: pointer;
}

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

.button--secondary {
  border-color: #9ebbac;
  color: var(--green-800);
  background: var(--green-100);
}

.button--accent {
  border-color: #c58d17;
  color: var(--green-950);
  background: linear-gradient(135deg, #f4c65d, var(--gold));
  box-shadow: 0 8px 20px rgba(197, 141, 23, 0.18);
}

.button--danger {
  border-color: #edc7c4;
  color: var(--danger);
  background: var(--danger-soft);
}

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

.button--gpt {
  border-color: #7964ad;
  color: white;
  background: #66519b;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.field-group label {
  margin-bottom: 8px;
  font-size: 15px;
}

.checkbox-field {
  display: flex;
  align-items: flex-end;
  min-height: 50px;
}

.checkbox-field label,
.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
}

.checkbox-field input,
.inline-checkbox input {
  width: 22px;
  height: 22px;
  min-height: auto;
  margin: 0;
  accent-color: var(--green-700);
}

.compact-select {
  width: auto;
  min-width: 112px;
  min-height: 44px;
}

.compact-date {
  width: auto;
  min-height: 44px;
}

.level-badge {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: var(--green-700);
  font-size: 13px;
  font-weight: 900;
}

.level-badge--A { background: #b2483e; }
.level-badge--B { background: #bf7d12; }
.level-badge--C { background: var(--green-700); }

.record-card--completed {
  opacity: 0.68;
}

.record-card--due {
  border-color: #e3a39e;
  background: #fffafa;
}

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

.summary-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.summary-card span,
.summary-card strong {
  display: block;
}

.summary-card span {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.summary-card strong {
  color: var(--green-800);
  font-size: 22px;
}

.summary-card--warning {
  border-color: #eed59b;
  background: #fffaf0;
}

.summary-card--warning strong {
  color: #9a6410;
}

.card-heading-row,
.saved-records__heading,
.generated-content__heading,
.record-card__top,
.record-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-heading-row h2,
.saved-records__heading h2 {
  margin: 4px 0 0;
  font-size: 21px;
}

.content-button-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}

.generated-content {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.generated-content__heading {
  margin-bottom: 10px;
}

.generated-content textarea {
  min-height: 260px;
  background: #f7faf8;
}

.saved-records {
  margin-top: 30px;
}

.count-badge {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--green-800);
  background: var(--green-100);
  font-size: 12px;
  font-weight: 800;
}

.record-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.record-card,
.empty-records {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.record-card h3 {
  margin: 0;
  font-size: 17px;
}

.record-card__meta,
.empty-records {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.record-card__meta {
  margin: 7px 0 12px;
}

.record-card__actions {
  justify-content: flex-start;
}

.record-action {
  min-height: 40px;
  padding: 7px 13px;
  border: 1px solid #b9cec3;
  border-radius: 11px;
  color: var(--green-800);
  background: var(--green-100);
  font-weight: 800;
  cursor: pointer;
}

.empty-records {
  text-align: center;
}

.save-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.site-footer {
  padding: 0 16px 30px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 16px;
  bottom: 18px;
  left: 16px;
  max-width: 520px;
  margin: 0 auto;
  padding: 13px 16px;
  border-radius: 13px;
  color: white;
  background: rgba(17, 60, 49, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sync-panel {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(23, 79, 63, 0.16);
  border-radius: 18px;
  background: rgba(255, 252, 244, 0.92);
  box-shadow: var(--shadow);
}

.sync-panel__copy,
.sync-panel__actions,
.sync-dialog__heading,
.sync-dialog__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-panel__copy p,
.sync-panel__copy small,
.sync-dialog__section p {
  margin: 4px 0 0;
  color: var(--muted);
}

.sync-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #8c948f;
  box-shadow: 0 0 0 5px rgba(140, 148, 143, 0.12);
}

.sync-panel[data-state="synced"] .sync-dot {
  background: var(--green-800);
  box-shadow: 0 0 0 5px rgba(23, 79, 63, 0.12);
}

.sync-panel[data-state="syncing"] .sync-dot {
  background: var(--gold);
}

.sync-panel[data-state="offline-pending"] .sync-dot,
.sync-panel[data-state="error"] .sync-dot {
  background: #b66b32;
}

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

.sync-dialog {
  width: min(92vw, 520px);
  max-height: 85vh;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 20px;
  color: var(--ink);
  background: var(--background);
  box-shadow: 0 24px 70px rgba(15, 42, 34, 0.28);
}

.sync-dialog::backdrop {
  background: rgba(10, 31, 25, 0.58);
}

.sync-dialog__heading {
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(23, 79, 63, 0.12);
}

.sync-dialog__heading h2,
.sync-dialog__section h3 {
  margin: 0;
}

.sync-dialog__section {
  padding: 20px;
  border-bottom: 1px solid rgba(23, 79, 63, 0.12);
}

.sync-dialog form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.sync-dialog input {
  width: 100%;
  min-height: 44px;
}

.sync-dialog__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.sync-password-form {
  padding-top: 18px;
  border-top: 1px solid rgba(23, 79, 63, 0.12);
}

.sync-error {
  min-height: 24px;
  margin: 0;
  padding: 14px 20px 20px;
  color: #8d3f31;
}

@media (min-width: 640px) {
  .site-header {
    padding-right: 24px;
    padding-left: 24px;
  }

  .app-shell {
    padding: 34px 24px 48px;
  }

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

  .today-summary {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 20px 22px;
  }

  .backup-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .sync-panel {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .backup-actions {
    grid-template-columns: repeat(2, auto);
  }

  .today-summary__button {
    width: auto;
    min-width: 126px;
  }

  .action-bar {
    grid-template-columns: 1.35fr 1fr 1fr;
  }

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

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

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

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

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

@media (max-width: 420px) {
  .local-badge {
    display: none;
  }

  .brand-name {
    font-size: 14px;
  }

  .module-card {
    grid-template-columns: 44px 1fr;
  }

  .module-icon {
    width: 44px;
    height: 44px;
  }

  .module-state {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
