:root {
  color-scheme: light;
  --green-950: #073c34;
  --green-800: #0f5c4d;
  --green-700: #16705f;
  --green-100: #dcefe9;
  --green-50: #eef8f4;
  --ink: #1c2925;
  --muted: #66736f;
  --line: #d8e1dd;
  --paper: #ffffff;
  --canvas: #f3f6f4;
  --amber: #b96b06;
  --amber-bg: #fff4dc;
  --red: #b53a35;
  --red-bg: #ffebe9;
  --shadow: 0 12px 32px rgba(24, 54, 46, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0%, rgba(244, 201, 93, 0.17), transparent 24rem),
    var(--canvas);
  font-size: 16px;
  line-height: 1.5;
}

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

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(1rem, env(safe-area-inset-top)) max(1.1rem, env(safe-area-inset-right)) 1rem max(1.1rem, env(safe-area-inset-left));
  color: #fff;
  background: rgba(7, 60, 52, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(16px);
}

.app-header h1 { margin: 0; font-size: clamp(1.22rem, 4vw, 1.55rem); line-height: 1.12; letter-spacing: -0.02em; }
.eyebrow, .step-label { margin: 0 0 0.15rem; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.13em; }
.eyebrow { color: #a9d7ca; }
.step-label { color: var(--green-700); }
.header-actions { display: flex; align-items: center; gap: 0.65rem; }

.network-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.25rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  font-size: 0.83rem;
  font-weight: 700;
}

.status-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #f5c459; box-shadow: 0 0 0 4px rgba(245,196,89,.15); }
.network-badge.online .status-dot { background: #68e0b7; box-shadow: 0 0 0 4px rgba(104,224,183,.14); }
.network-badge.offline .status-dot { background: #ff958e; box-shadow: 0 0 0 4px rgba(255,149,142,.14); }

.app-shell { width: min(100% - 1.25rem, 860px); margin: 0 auto; padding: 1rem 0 4rem; }

.sync-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid #cbdcd6;
  border-radius: 14px;
  color: var(--green-950);
  background: var(--green-50);
  font-size: 0.9rem;
}
.sync-summary > div { display: flex; align-items: center; gap: 0.5rem; }
.sync-icon { display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; color: #fff; background: var(--green-700); font-weight: 900; }
.text-button { padding: 0.2rem; border: 0; color: var(--green-800); background: transparent; font-weight: 800; white-space: nowrap; }
.text-button:disabled { opacity: .45; cursor: not-allowed; }

.panel { margin-bottom: 1rem; padding: 1.1rem; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.panel-heading h2 { margin: 0; font-size: 1.35rem; line-height: 1.25; letter-spacing: -0.025em; }
.draft-label { padding: 0.35rem 0.55rem; border-radius: 8px; color: var(--muted); background: #eef1f0; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }

.field-grid { display: grid; gap: 0.9rem; }
.field { display: block; margin-bottom: 1rem; }
.field > span, .field legend { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-bottom: 0.38rem; color: #34413d; font-size: 0.9rem; font-weight: 750; }
.field b { color: var(--red); }
.field em { color: #89938f; font-size: 0.75rem; font-style: normal; font-weight: 550; }

input[type="text"], select, textarea {
  width: 100%;
  border: 1px solid #c9d4d0;
  border-radius: 12px;
  outline: none;
  color: var(--ink);
  background: #fcfdfc;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input[type="text"], select { min-height: 3rem; padding: 0 0.85rem; }
textarea { min-height: 7.3rem; padding: 0.75rem 0.85rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green-700); background: #fff; box-shadow: 0 0 0 4px rgba(22,112,95,.11); }
.invalid { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(181,58,53,.09) !important; }
.error-text { min-height: 1.1rem; margin-top: .25rem; color: var(--red); font-size: .76rem; }
.field-meta { display: flex; justify-content: space-between; color: #89938f; }

.severity-field { padding: 0; border: 0; }
.segmented-control { display: grid; grid-template-columns: repeat(3, 1fr); min-height: 3rem; overflow: hidden; border: 1px solid #c9d4d0; border-radius: 12px; background: #fcfdfc; }
.segmented-control label { position: relative; display: grid; place-items: center; cursor: pointer; }
.segmented-control label + label { border-left: 1px solid #d9e1de; }
.segmented-control input { position: absolute; opacity: 0; }
.segmented-control span { display: grid; place-items: center; width: 100%; height: 100%; color: #53615c; font-size: .88rem; font-weight: 700; }
.segmented-control input:checked + span { color: #fff; background: var(--green-700); }
.segmented-control input:focus-visible + span { outline: 3px solid #8bc8b8; outline-offset: -3px; }

.evidence-grid { display: grid; gap: .8rem; margin-bottom: 1rem; }
.evidence-card { min-width: 0; padding: .9rem; border: 1px solid var(--line); border-radius: 16px; background: #fafcfb; }
.evidence-heading { display: flex; align-items: center; gap: .7rem; margin-bottom: .8rem; }
.evidence-heading h3 { margin: 0; font-size: .94rem; }
.evidence-heading p { margin: .05rem 0 0; overflow-wrap: anywhere; color: var(--muted); font-size: .76rem; }
.evidence-icon { display: grid; place-items: center; flex: 0 0 auto; width: 2.5rem; height: 2.5rem; border-radius: 11px; }
.evidence-icon svg { width: 1.35rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.camera-icon { color: #79570b; background: #fff0c7; }
.location-icon { color: var(--green-800); background: var(--green-100); }
.secondary-button { width: 100%; min-height: 2.75rem; padding: .55rem .8rem; border: 1px solid #bfd0ca; border-radius: 10px; color: var(--green-800); background: #fff; font-weight: 800; }
.secondary-button:hover { background: var(--green-50); }

.photo-preview-box { position: relative; margin-bottom: .7rem; overflow: hidden; border-radius: 11px; background: #e8eeeb; }
.photo-preview-box img { display: block; width: 100%; height: 150px; object-fit: cover; }
.photo-preview-box button { position: absolute; top: .45rem; right: .45rem; display: grid; place-items: center; width: 2rem; height: 2rem; border: 0; border-radius: 50%; color: #fff; background: rgba(12,27,22,.78); font-size: 1.3rem; }
.location-details { display: flex; flex-direction: column; margin-bottom: .65rem; padding: .62rem .72rem; border-radius: 10px; background: var(--green-50); color: var(--green-950); }
.location-details span { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .79rem; font-weight: 750; }
.location-details small { margin-top: .1rem; color: var(--muted); }
.optional-field { margin-top: .15rem; }

.primary-button { display: flex; align-items: center; justify-content: center; gap: .55rem; width: 100%; min-height: 3.25rem; padding: .7rem 1rem; border: 0; border-radius: 13px; color: #fff; background: linear-gradient(135deg, var(--green-700), var(--green-950)); box-shadow: 0 9px 20px rgba(15,92,77,.2); font-size: 1rem; font-weight: 850; }
.primary-button:hover { filter: brightness(1.05); }
.primary-button:disabled { opacity: .62; cursor: wait; }
.primary-button svg, .icon-button svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.primary-button svg { width: 1.3rem; }
.submit-hint { margin: .55rem 0 0; color: var(--muted); text-align: center; font-size: .78rem; }

.icon-button { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; padding: 0; border: 1px solid rgba(255,255,255,.2); border-radius: 11px; color: #fff; background: rgba(255,255,255,.1); }
.icon-button svg { width: 1.25rem; }
.icon-button.neutral { border-color: var(--line); color: var(--green-800); background: #f4f8f6; }

.history-list { display: grid; gap: .7rem; }
.history-item { display: grid; grid-template-columns: 3.25rem 1fr; gap: .8rem; padding: .75rem; border: 1px solid var(--line); border-radius: 14px; background: #fcfdfc; }
.history-thumb { display: grid; place-items: center; width: 3.25rem; height: 3.25rem; overflow: hidden; border-radius: 10px; color: var(--green-800); background: var(--green-100); font-weight: 900; }
.history-thumb img { width: 100%; height: 100%; object-fit: cover; }
.history-main { min-width: 0; }
.history-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.history-main h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .94rem; }
.history-main p { display: -webkit-box; margin: .2rem 0 .35rem; overflow: hidden; color: var(--muted); font-size: .8rem; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.history-meta { display: flex; flex-wrap: wrap; gap: .45rem .8rem; color: #78837f; font-size: .73rem; }
.sync-status { flex: 0 0 auto; padding: .2rem .45rem; border-radius: 999px; font-size: .67rem; font-weight: 850; }
.sync-status.pending, .sync-status.syncing { color: var(--amber); background: var(--amber-bg); }
.sync-status.synced { color: var(--green-800); background: var(--green-100); }
.sync-status.failed { color: var(--red); background: var(--red-bg); }
.empty-state { padding: 1.5rem .5rem; color: var(--muted); text-align: center; }
.empty-state span { display: grid; place-items: center; width: 2.7rem; height: 2.7rem; margin: 0 auto .55rem; border-radius: 50%; color: var(--green-700); background: var(--green-100); font-weight: 900; }
.empty-state p { margin: 0; font-size: .86rem; }

.toast { position: fixed; z-index: 50; right: 1rem; bottom: max(1rem, env(safe-area-inset-bottom)); left: 1rem; transform: translateY(calc(100% + 2rem)); max-width: 520px; margin: 0 auto; padding: .85rem 1rem; border-radius: 13px; color: #fff; background: #193b33; box-shadow: 0 14px 35px rgba(0,0,0,.2); text-align: center; font-size: .88rem; font-weight: 750; opacity: 0; transition: transform .25s ease, opacity .25s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #8f2d29; }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (min-width: 700px) {
  .app-header { padding-right: max(2rem, calc((100vw - 860px) / 2)); padding-left: max(2rem, calc((100vw - 860px) / 2)); }
  .app-shell { padding-top: 1.4rem; }
  .panel { padding: 1.5rem; }
  .two-columns, .evidence-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .evidence-card { display: flex; flex-direction: column; }
  .evidence-card .secondary-button { margin-top: auto; }
}

@media (max-width: 430px) {
  #networkText { display: none; }
  .network-badge { min-width: 2.25rem; justify-content: center; padding: .4rem; }
  .sync-summary { align-items: flex-start; }
  .sync-summary > div { align-items: flex-start; }
  .draft-label { display: none; }
}

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