:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --ink: #111827;
  --muted: #667085;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --accent: #147d64;
  --accent-ink: #ffffff;
  --blue: #175cd3;
  --amber: #b54708;
  --bad: #b42318;
  --shadow: 0 16px 40px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 82px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px max(18px, env(safe-area-inset-left)) 12px;
  border-bottom: 1px solid rgba(228, 231, 236, 0.88);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand {
  font-size: 22px;
  font-weight: 750;
  line-height: 1.1;
}

main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 16px 32px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.16;
  letter-spacing: 0;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.grid {
  display: grid;
  gap: 12px;
  align-items: end;
}

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

.grid.three {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  background: #fff;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(20, 125, 100, 0.12);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

button {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 720;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background-color 0.14s ease;
}

button:active {
  transform: scale(0.985);
}

button.primary {
  width: 100%;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

button.secondary {
  border-color: rgba(20, 125, 100, 0.3);
  color: var(--accent);
  background: rgba(20, 125, 100, 0.07);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(20, 125, 100, 0.2);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--accent);
  background: rgba(20, 125, 100, 0.08);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.status.offline {
  border-color: rgba(180, 35, 24, 0.2);
  color: var(--bad);
  background: rgba(180, 35, 24, 0.08);
}

.preview,
.result,
.summary {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.preview-title {
  font-size: 17px;
  font-weight: 760;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  background: #eef2f6;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.chip.info {
  background: #eff8ff;
  color: var(--blue);
}

.chip.warn {
  background: #fffaeb;
  color: var(--amber);
}

.field-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  padding: 0;
  margin: 12px 0 0;
  list-style: none;
}

.field-list li,
.submission {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fff;
}

.field-list b {
  display: block;
  margin-bottom: 4px;
}

.field-meta,
.files,
.field-help {
  color: var(--muted);
  font-size: 13px;
}

.dynamic-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.file-picker {
  position: relative;
  display: block;
  margin: 12px 0;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.file-picker input[type="file"] {
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  box-shadow: none;
}

.file-picker-title {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-weight: 760;
}

.file-picker-help {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.action-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 14px;
  font-weight: 720;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.copyline {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.copyline:last-child {
  border-bottom: 0;
}

.copyline span {
  color: var(--muted);
  font-weight: 650;
}

.copyline code {
  overflow-wrap: anywhere;
  color: #1d2939;
}

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

.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.summary-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.submission {
  margin: 10px 0;
}

.submission header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.submission pre {
  overflow: auto;
  margin: 8px 0;
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
  color: #344054;
  font-size: 12px;
}

.error {
  color: var(--bad);
  font-weight: 700;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #fff;
  text-align: center;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(420px, calc(100% - 24px));
  padding: 6px;
  border: 1px solid rgba(208, 213, 221, 0.84);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 36px rgba(17, 24, 39, 0.16);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  justify-items: center;
  gap: 3px;
  min-height: 54px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 7px 4px;
}

.nav-item.active {
  background: #ecfdf3;
  color: var(--accent);
}

.nav-icon {
  position: relative;
  width: 20px;
  height: 20px;
  display: inline-block;
}

.nav-icon::before,
.nav-icon::after {
  content: "";
  position: absolute;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.nav-icon-create::before {
  inset: 4px 3px 3px;
}

.nav-icon-create::after {
  width: 8px;
  height: 0;
  top: 9px;
  left: 6px;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}

.nav-icon-submit::before {
  left: 4px;
  right: 4px;
  bottom: 3px;
  height: 7px;
}

.nav-icon-submit::after {
  left: 7px;
  top: 2px;
  width: 6px;
  height: 10px;
  border-right: 0;
  border-bottom: 0;
  transform: rotate(45deg);
}

.nav-icon-admin::before {
  inset: 3px;
}

.nav-icon-admin::after {
  inset: 7px;
  border-radius: 999px;
}

@media (min-width: 900px) {
  .app-shell {
    padding-bottom: 96px;
  }

  main {
    padding-top: 28px;
  }

  .panel {
    padding: 24px;
  }
}

@media (max-width: 760px) {
  main {
    padding: 14px 12px 28px;
  }

  .topbar {
    padding-right: max(14px, env(safe-area-inset-right));
  }

  .panel {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    padding: 16px 14px;
    box-shadow: none;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

  .grid.two,
  .grid.three,
  .dynamic-form {
    grid-template-columns: 1fr;
  }

  .grid.three button {
    width: 100%;
  }

  .field-list {
    grid-template-columns: 1fr;
  }

  .copyline {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .result-actions > * {
    flex: 1 1 100%;
  }

  .submission header {
    flex-direction: column;
  }
}
