:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #637168;
  --surface: #ffffff;
  --soft: #f2f5f0;
  --line: #d8dfd8;
  --accent: #286245;
  --accent-dark: #194a32;
  --accent-pale: #e5f0e9;
  --danger: #9d342d;
  --shadow: 0 16px 40px rgb(28 49 37 / 9%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #f9faf8;
  line-height: 1.5;
}

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

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgb(40 98 69 / 25%);
  outline-offset: 2px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 84px;
  padding: 14px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 94%);
}

.brand {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.tagline {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

nav {
  display: flex;
  gap: 4px;
}

.nav-button {
  padding: 9px 12px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
}

.nav-button:hover,
.nav-button.is-active {
  color: var(--accent-dark);
  background: var(--accent-pale);
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

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

h1,
h2 {
  line-height: 1.15;
}

h1 {
  margin-bottom: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 3.3rem);
  font-weight: 500;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.capture-panel {
  display: grid;
  grid-template-columns: minmax(250px, 0.8fr) minmax(340px, 1.2fr);
  gap: clamp(28px, 6vw, 90px);
  align-items: end;
  margin-bottom: 64px;
  padding: clamp(28px, 5vw, 58px);
  border: 1px solid #cbd8ce;
  border-radius: 14px;
  background: linear-gradient(145deg, #eff5ee, #fff);
  box-shadow: var(--shadow);
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #bdc8c0;
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
}

textarea,
input {
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: #46544b;
  font-size: 0.83rem;
  font-weight: 650;
}

.form-actions,
.builder-actions,
.dialog-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.form-actions {
  justify-content: space-between;
}

.helper-text {
  color: var(--muted);
  font-size: 0.82rem;
}

.auth-main {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.auth-card {
  width: min(460px, 100%);
  padding: clamp(28px, 6vw, 50px);
  border: 1px solid #cbd8ce;
  border-radius: 14px;
  background: linear-gradient(145deg, #eff5ee, #fff);
  box-shadow: var(--shadow);
}

.auth-card > p:not(.eyebrow),
.settings-card > p {
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.auth-form .primary {
  margin-top: 4px;
}

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

.settings-card {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.secret-output {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #b9d2c2;
  border-radius: 8px;
  background: #eff8f2;
}

.secret-output code {
  padding: 9px;
  overflow-wrap: anywhere;
  border-radius: 5px;
  background: white;
  font-size: 0.75rem;
  user-select: all;
}

.secret-output button {
  justify-self: start;
}

.token-list {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.token-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.token-list span {
  display: grid;
}

.token-list small {
  color: var(--muted);
}

details {
  color: var(--muted);
  font-size: 0.8rem;
}

details label {
  margin-top: 9px;
  font-weight: 500;
}

button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 700;
}

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

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

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

.secondary:hover {
  border-color: #aab8ae;
  background: var(--soft);
}

.text-button {
  padding-left: 0;
  color: var(--accent);
  background: transparent;
}

.danger {
  border-color: #e7cac8;
  color: var(--danger);
  background: #fff8f7;
}

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

.section-heading p {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
}

.section-heading.compact {
  align-items: center;
  margin-bottom: 14px;
}

.section-heading.compact h2 {
  margin: 0;
}

.results {
  min-width: 0;
  overflow-x: auto;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  background: var(--surface);
}

.report-table th,
.report-table td {
  max-width: 520px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
}

.report-table th {
  color: #536159;
  background: var(--soft);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

.row-action {
  min-height: auto;
  padding: 2px 0;
  color: var(--accent);
  background: transparent;
}

.report-list,
.item-grid {
  display: grid;
  gap: 12px;
}

.report-list article,
.item-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.attribute-pair {
  display: grid;
  grid-template-columns: minmax(100px, 0.25fr) minmax(0, 0.75fr);
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #edf0ec;
}

.attribute-pair:last-child {
  border: 0;
}

.attribute-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.item-card header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.item-id {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.72rem;
}

.empty-state,
.loading-state {
  padding: 36px;
  border: 1px dashed #bdc8c0;
  border-radius: 9px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
}

.report-heading {
  align-items: start;
}

.saved-report-picker {
  min-width: 220px;
}

.report-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.8fr) minmax(420px, 1.2fr);
  gap: 28px;
  align-items: start;
}

.report-builder,
.report-output {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.report-output {
  position: sticky;
  top: 20px;
}

.working-copy-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.working-copy-heading h2 {
  margin: 0;
}

.status-pill {
  padding: 4px 8px;
  border-radius: 100px;
  color: var(--accent);
  background: var(--accent-pale);
  font-size: 0.73rem;
  font-weight: 700;
}

.status-pill.is-dirty {
  color: #79511f;
  background: #f6edda;
}

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

fieldset {
  margin: 24px 0 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 9px;
  font-size: 0.83rem;
  font-weight: 750;
}

.builder-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 7px;
  align-items: end;
  margin-bottom: 8px;
}

.sort-row {
  grid-template-columns: 1.2fr 0.7fr 0.7fr auto;
}

.builder-row select,
.builder-row input {
  min-width: 0;
  padding: 8px;
}

.remove-row,
.icon-button {
  min-width: 38px;
  padding: 4px;
  border-color: var(--line);
  color: var(--muted);
  background: var(--surface);
}

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

.check-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 600;
}

.check-list input {
  width: auto;
}

.notice {
  position: fixed;
  z-index: 10;
  top: 12px;
  left: 50%;
  max-width: min(600px, calc(100% - 30px));
  padding: 10px 14px;
  transform: translateX(-50%);
  border: 1px solid #b9d2c2;
  border-radius: 8px;
  color: var(--accent-dark);
  background: #eff8f2;
  box-shadow: var(--shadow);
}

.notice.is-error {
  border-color: #e2b8b5;
  color: #782a24;
  background: #fff3f2;
}

dialog {
  width: min(700px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 24px 90px rgb(10 25 16 / 25%);
}

dialog::backdrop {
  background: rgb(18 28 22 / 55%);
}

#item-form {
  padding: 24px;
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.item-fields {
  display: grid;
  gap: 15px;
  max-height: 55vh;
  padding-right: 4px;
  overflow-y: auto;
}

.dialog-actions {
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.spacer {
  flex: 1;
}

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

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .capture-panel,
  .report-layout,
  .account-grid {
    grid-template-columns: 1fr;
  }

  .report-output {
    position: static;
  }

  .builder-row,
  .sort-row {
    grid-template-columns: 1fr 1fr;
  }

  .remove-row {
    align-self: end;
  }
}

@media (max-width: 620px) {
  .site-header,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .site-header {
    gap: 12px;
  }

  nav {
    overflow-x: auto;
  }

  main {
    width: min(100% - 24px, 1180px);
    padding-top: 28px;
  }

  .capture-panel {
    padding: 24px 18px;
  }

  .field-grid,
  .check-list,
  .builder-row,
  .sort-row,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .builder-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
