/* TROT Platform — visual system
   Palette is drawn from the operation itself, not a generic SaaS template:
   loam (soil), parchment (the ledger page), moss (growth), water (flow),
   ochre (harvest) used once, sparingly, as the only bright note.
   Type uses only system font stacks — deliberately no external font CDN,
   consistent with the platform's "owned, no outside dependency" ethos.
*/

:root {
  --loam: #2B2420;
  --parchment: #F2ECDC;
  --parchment-dim: #E7DFC9;
  --moss: #45624A;
  --moss-deep: #324A37;
  --water: #2D5D6B;
  --ochre: #C2873A;
  --sage: #8B9A87;
  --hairline: rgba(43, 36, 32, 0.16);

  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --font-body: -apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--parchment);
  color: var(--loam);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--water);
  outline-offset: 2px;
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.ledger-nav {
  background: var(--loam);
  color: var(--parchment-dim);
  display: flex;
  flex-direction: column;
  padding: 28px 0;
  border-right: 1px solid rgba(0,0,0,0.3);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 28px;
  border-bottom: 1px solid rgba(242,236,220,0.12);
  margin-bottom: 12px;
}

.ring-mark {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--ochre);
  stroke-width: 1.4;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: 0.06em;
}

nav {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: none;
  border: none;
  text-align: left;
  padding: 12px 24px;
  cursor: pointer;
  color: inherit;
  border-left: 2px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.nav-index {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--sage);
}

.nav-item:hover {
  background: rgba(242,236,220,0.05);
}

.nav-item.is-active {
  background: rgba(242,236,220,0.08);
  border-left-color: var(--ochre);
  color: var(--parchment);
}

.nav-footer {
  padding: 16px 24px 4px;
  border-top: 1px solid rgba(242,236,220,0.12);
  font-size: 12px;
  color: var(--sage);
}

/* ---------- Main content ---------- */

.content {
  padding: 40px 48px 64px;
  max-width: 980px;
}

.page-header {
  position: relative;
  margin-bottom: 32px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--hairline);
  overflow: hidden;
}

.contour {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 280px;
  height: 84px;
  opacity: 0.5;
}

.contour path {
  fill: none;
  stroke: var(--sage);
  stroke-width: 1;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 32px;
  margin: 0 0 6px;
  position: relative;
}

.eyebrow {
  margin: 0;
  font-size: 13px;
  color: var(--sage);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: relative;
}

/* ---------- Shared view elements ---------- */

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.metric-card {
  background: white;
  border: 1px solid var(--hairline);
  padding: 18px 20px;
}

.metric-card .value {
  font-family: var(--font-display);
  font-size: 30px;
  display: block;
  color: var(--moss-deep);
}

.metric-card .label {
  font-size: 12px;
  color: var(--sage);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-title {
  font-family: var(--font-display);
  font-size: 19px;
  margin: 0 0 12px;
}

table.ledger {
  width: 100%;
  border-collapse: collapse;
  background: white;
  margin-bottom: 28px;
}

table.ledger th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sage);
  font-weight: 500;
  border-bottom: 1px solid var(--loam);
  padding: 10px 14px;
}

table.ledger td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  font-size: 14px;
  vertical-align: top;
}

table.ledger tr:last-child td {
  border-bottom: none;
}

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--hairline);
  background: var(--parchment-dim);
  white-space: nowrap;
}

.tag.status-todo { color: var(--water); border-color: var(--water); }
.tag.status-in_progress { color: var(--ochre); border-color: var(--ochre); }
.tag.status-done { color: var(--moss-deep); border-color: var(--moss-deep); }

.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 28px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 11px;
  color: var(--sage);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input, .field select, .field textarea {
  border: 1px solid var(--hairline);
  background: white;
  padding: 8px 10px;
  min-width: 160px;
}

.field textarea {
  min-width: 320px;
  min-height: 90px;
  resize: vertical;
}

button.primary {
  background: var(--moss);
  color: var(--parchment);
  border: none;
  padding: 9px 18px;
  cursor: pointer;
  height: 38px;
}

button.primary:hover { background: var(--moss-deep); }

button.ghost {
  background: none;
  border: 1px solid var(--hairline);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
}

select.status-select {
  border: 1px solid var(--hairline);
  background: var(--parchment-dim);
  padding: 4px 6px;
}

.empty-state {
  border: 1px dashed var(--hairline);
  padding: 32px;
  text-align: center;
  color: var(--sage);
}

.ai-output {
  background: white;
  border: 1px solid var(--hairline);
  padding: 16px 18px;
  white-space: pre-wrap;
  font-size: 14px;
  margin-bottom: 14px;
}

.ai-output .meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--sage);
  margin-bottom: 8px;
  display: block;
}

/* ---------- Login screen ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--loam);
}

.login-card {
  background: var(--parchment);
  padding: 40px 36px;
  width: 320px;
  text-align: center;
  border: 1px solid rgba(0,0,0,0.2);
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 10px 0 2px;
}

.ring-mark-lg {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  display: block;
}

.login-card .eyebrow { margin-bottom: 22px; }

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.login-card .field input { width: 100%; }

.login-error {
  color: #9C3B3B;
  font-size: 13px;
  min-height: 18px;
  margin: 12px 0 0;
}

/* ---------- Role badge ---------- */

.user-badge {
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-badge .role {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ochre);
}

/* ---------- Boundary preview (GIS-lite) ---------- */

.boundary-preview {
  width: 56px;
  height: 36px;
  border: 1px solid var(--hairline);
  background: var(--parchment-dim);
  vertical-align: middle;
}

.boundary-preview polygon {
  fill: rgba(69,98,74,0.25);
  stroke: var(--moss-deep);
  stroke-width: 2;
}

/* ---------- Automation ledger ---------- */

.automation-row {
  border-bottom: 1px solid var(--hairline);
  padding: 14px 0;
}

.automation-row:last-child { border-bottom: none; }

.automation-rule {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--water);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: block;
  margin-bottom: 4px;
}

.automation-time {
  color: var(--sage);
  font-size: 12px;
}

.tag.status-needs_attention { color: #9C3B3B; border-color: #9C3B3B; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .ledger-nav { flex-direction: row; overflow-x: auto; padding: 12px 0; }
  .brand, .nav-footer { display: none; }
  nav { flex-direction: row; }
  .content { padding: 24px; }
}
