:root {
  --bg: #f4f1ea;
  --panel: #fffaf0;
  --card: #ffffff;
  --ink: #233126;
  --muted: #657064;
  --line: #ddd3c2;
  --green: #386641;
  --green-dark: #1f3b28;
  --sage: #cad2b9;
  --gold: #d7a84f;
  --danger: #9d3d32;
  --shadow: 0 18px 45px rgba(35, 49, 38, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(215, 168, 79, 0.18), transparent 32rem),
    linear-gradient(180deg, #fbf7ee 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

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

button,
.button {
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  padding: 0.75rem 1rem;
  text-decoration: none;
}

button:hover,
.button:hover {
  background: var(--green-dark);
}

button.secondary,
.button.secondary {
  background: white;
  border: 1px solid var(--line);
  color: var(--green-dark);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--sage);
}

.hidden {
  display: none !important;
}

.app-header {
  align-items: center;
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  padding: 2rem clamp(1rem, 4vw, 3rem) 1.25rem;
}

.eyebrow {
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0 0 0.35rem;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
  margin-bottom: 0.75rem;
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  margin-bottom: 0.5rem;
}

h3 {
  margin-bottom: 0.75rem;
}

.subtitle,
.section-heading p,
.card p {
  color: var(--muted);
}

.subtitle {
  font-size: 1.05rem;
  max-width: 58rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

.share-dialog {
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  color: var(--ink);
  max-width: min(92vw, 42rem);
  padding: 0;
}

.share-dialog::backdrop {
  background: rgba(31, 59, 40, 0.45);
}

.share-dialog form {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
}

.share-dialog-header {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.share-links {
  display: grid;
  gap: 0.75rem;
}

.share-help {
  color: var(--muted);
  margin: 0;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0 1rem 1rem;
  position: sticky;
  top: 0;
  z-index: 2;
}

.tab {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  color: var(--green-dark);
  white-space: nowrap;
}

.tab.active {
  background: var(--green-dark);
  color: white;
}

.tab-count {
  display: inline-block;
  margin-left: 0.4rem;
  min-width: 1.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
}

.tab.active .tab-count {
  background: rgba(255, 255, 255, 0.28);
}

main {
  padding: 0 clamp(1rem, 4vw, 3rem) 3rem;
}

.panel {
  display: none;
}

.active-panel {
  display: block;
}

.section-heading {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin: 1rem 0;
}

.saved-pill {
  background: var(--sage);
  border-radius: 999px;
  color: var(--green-dark);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
}

.saved-pill-button {
  border: 0;
  cursor: pointer;
}

.saved-pill-button:hover,
.saved-pill-button:focus-visible {
  background: var(--green-dark);
  color: white;
  outline: none;
}

.sync-status-dialog {
  max-width: min(94vw, 38rem);
}

.sync-status-dialog-inner {
  display: grid;
  gap: 0.85rem;
  padding: 1.25rem;
}

.sync-status-body {
  display: grid;
  gap: 0.75rem;
}

.sync-status-body p {
  margin: 0;
}

.sync-status-summary {
  border-radius: 0.65rem;
  font-weight: 700;
  padding: 0.6rem 0.75rem;
}

.sync-status-summary.sync-status-good {
  background: #dcebd5;
  color: #1f4e28;
}

.sync-status-summary.sync-status-warn {
  background: #f8e8bf;
  color: #704d00;
}

.sync-status-help {
  color: var(--muted);
  font-size: 0.9rem;
}

.sync-status-command {
  background: #1f3b28;
  border-radius: 0.65rem;
  color: #fbf7ee;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.82rem;
  margin: 0;
  overflow-x: auto;
  padding: 0.75rem;
  white-space: pre;
}

.sync-status-links {
  display: grid;
  gap: 0.6rem;
}

.sync-status-loading {
  color: var(--muted);
  font-style: italic;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

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

.metric-card,
.card,
.entry-form,
.table-wrap {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 1.25rem;
}

.metric-card span {
  color: var(--green);
  display: block;
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
}

.metric-card p {
  color: var(--muted);
  margin: 0.45rem 0 0;
}

.grid {
  display: grid;
  gap: 1rem;
  margin: 1rem 0;
}

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

.card {
  padding: 1.25rem;
}

.clean-list,
.checklist {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
}

.clean-list li,
.check-row {
  background: #fbf7ee;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  list-style: none;
  padding: 0;
}

.clean-list li {
  overflow: hidden;
}

.priority-btn {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  display: flex;
  font-weight: 600;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  text-align: left;
  width: 100%;
}

.priority-btn:hover,
.priority-btn:focus-visible {
  background: var(--sage);
  color: var(--green-dark);
  outline: none;
}

.priority-label {
  flex: 1 1 auto;
  line-height: 1.35;
}

.priority-affordance {
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green-dark);
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.3rem 0.65rem;
  white-space: nowrap;
}

.files-dialog {
  max-width: min(94vw, 48rem);
}

.files-dialog-inner {
  display: grid;
  gap: 0.85rem;
  padding: 1.25rem;
}

.files-path {
  color: var(--muted);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.8rem;
  margin: 0.35rem 0 0;
  word-break: break-all;
}

.files-summary {
  color: var(--green-dark);
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0;
}

.files-list {
  display: grid;
  gap: 0.5rem;
  max-height: 22rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.files-status {
  color: var(--muted);
  margin: 0;
  padding: 0.75rem;
  text-align: center;
}

.files-status.files-error {
  color: var(--danger);
}

.file-row {
  align-items: center;
  background: #fbf7ee;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  color: var(--ink);
  display: flex;
  font-weight: 500;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  text-align: left;
  width: 100%;
}

.file-row:hover,
.file-row:focus-visible {
  background: var(--sage);
  color: var(--green-dark);
  outline: none;
}

.file-badge {
  background: var(--green-dark);
  border-radius: 0.45rem;
  color: white;
  flex: 0 0 auto;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.5rem;
}

.file-info {
  display: grid;
  flex: 1 1 auto;
  gap: 0.15rem;
  min-width: 0;
}

.file-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.file-action {
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green-dark);
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  white-space: nowrap;
}

.files-help {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0;
}

.check-row {
  align-items: center;
  display: flex;
  gap: 0.65rem;
}

.check-row input {
  accent-color: var(--green);
  height: 1.1rem;
  width: 1.1rem;
}

.snapshot,
.entry-form {
  display: grid;
  gap: 0.9rem;
}

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

.snapshot label:last-child {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.9rem;
  font-weight: 700;
  gap: 0.35rem;
}

input,
textarea,
select {
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  color: var(--ink);
  padding: 0.75rem;
  width: 100%;
}

textarea {
  min-height: 5rem;
  resize: vertical;
}

.entry-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1rem;
  padding: 1rem;
}

.entry-form textarea {
  grid-column: span 2;
}

.entry-form button {
  align-self: end;
}

.table-wrap {
  overflow-x: auto;
  padding: 0.5rem;
}

table {
  border-collapse: collapse;
  min-width: 980px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--green-dark);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td {
  color: var(--ink);
  font-size: 0.92rem;
}

.status {
  border-radius: 999px;
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.35rem 0.6rem;
}

.status.good {
  background: #dcebd5;
  color: #1f4e28;
}

.status.watch {
  background: #f8e8bf;
  color: #704d00;
}

.status.risk {
  background: #f2d4d0;
  color: #7a2119;
}

.row-actions {
  display: flex;
  gap: 0.4rem;
}

.row-actions button {
  border-radius: 0.65rem;
  font-size: 0.8rem;
  padding: 0.45rem 0.55rem;
}

.row-actions .delete {
  background: var(--danger);
}

.empty-state {
  color: var(--muted);
  padding: 1rem;
  text-align: center;
}

.report-output {
  background: #fffdf7;
  font-family: "Courier New", Courier, monospace;
  min-height: 34rem;
  white-space: pre;
}

@media (max-width: 980px) {
  .app-header,
  .section-heading {
    display: block;
  }

  .header-actions {
    justify-content: flex-start;
    margin-top: 1rem;
  }

  .status-pills {
    justify-content: flex-start;
    margin-bottom: 1rem;
  }

  .metric-grid,
  .grid.two,
  .snapshot,
  .entry-form {
    grid-template-columns: 1fr;
  }

  .entry-form textarea {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding-top: 1rem;
  }

  h1 {
    font-size: 2.1rem;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  .tabs {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .tab,
  button,
  .button {
    min-height: 44px;
  }

  main {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .metric-card,
  .card,
  .entry-form {
    border-radius: 1rem;
  }

  table {
    min-width: 760px;
  }
}
