:root {
  --ink: #1c1915;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e4d9c8;
  --amber: #c45312;
  --amber-dark: #8a3412;
  --navy: #1e3a8a;
  --foam: #4fc3f7;
  --blue: #1e3a8a;
  --muted: #6d655c;
  --good: #1f6b45;
  --shadow: 0 10px 30px rgba(48, 32, 14, 0.06);
  --nav-h: 4.6rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(79, 195, 247, 0.16), transparent 50%),
    var(--paper);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 1.05rem;
  line-height: 1.45;
}

h1, h2, h3, .wordmark, .stat {
  font-family: "Barlow Condensed", "Arial Narrow", "Segoe UI", sans-serif;
  letter-spacing: 0.01em;
}

a { color: var(--blue); }
a:hover { color: #142a66; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: white;
  padding: 0.4rem 0.7rem;
  z-index: 20;
}
.skip-link:focus { top: 0.5rem; }

.topbar {
  background: var(--ink);
  color: #f6f1e8;
  border-bottom: 4px solid var(--foam);
}

.topbar-inner, .page {
  width: min(1100px, calc(100% - 1.5rem));
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  min-height: 4.2rem;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}
.job-search {
  flex: 1 1 14rem;
  min-width: min(100%, 12rem);
  margin: 0;
}
.job-search input {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  background: #fffdf8;
  color: var(--ink);
}
.job-number-input {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.checklist { list-style: none; padding: 0; margin: 0; }
.guideline-alerts { list-style: none; padding: 0; margin: 0; }
.guideline-alerts li { margin: 0.7rem 0; }
.checklist li { margin: 0.35rem 0; }

.wordmark {
  color: white;
  text-decoration: none;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.wordmark img {
  height: 38px;
  width: auto;
  display: block;
}
.wordmark span { color: var(--foam); }
.brand-lockup {
  width: min(100%, 19rem);
  height: auto;
  display: block;
  margin: 0 0 0.85rem;
}

.company-chip {
  color: #d9d0c3;
  font-size: 0.92rem;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
}
.lang-switch form { margin: 0; }
.lang-switch button {
  background: transparent;
  color: inherit;
  border: 0;
  min-height: 44px;
  min-width: 2.4rem;
  padding: 0.2rem 0.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.lang-switch button.active { text-decoration: underline; text-underline-offset: 0.18rem; }
.login-card .lang-switch { margin: 0.75rem 0 0.25rem; }
.login-card .lang-switch button { color: var(--ink); }
.desktop-nav { display: none; gap: 0.1rem; }
.public-nav, .topbar-about { display: flex; align-items: center; gap: 0.35rem; }
.desktop-nav a, .bottom-nav a, .public-nav a, .topbar-about {
  color: #f3ecdf;
  text-decoration: none;
  font-weight: 600;
}
.public-nav a, .topbar-about {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
}
.public-nav a.active, .public-nav a:hover,
.topbar-about.active, .topbar-about:hover { background: rgba(255,255,255,0.08); color: white; }
.desktop-nav a {
  padding: 0.4rem 0.45rem;
  border-radius: 999px;
}
.desktop-nav a.active, .desktop-nav a:hover { background: rgba(255,255,255,0.08); color: white; }

.logout-btn {
  background: transparent;
  color: #f3ecdf;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  min-height: 40px;
}

.page { padding: 1.25rem 0 2rem; }

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  overflow-x: auto;
  background: var(--ink);
  border-top: 1px solid rgba(255,255,255,0.08);
  z-index: 15;
  padding-bottom: env(safe-area-inset-bottom);
  scrollbar-width: none;
}
.bottom-nav::-webkit-scrollbar { display: none; }
.bottom-nav a {
  flex: 1 0 4.25rem;
  min-width: 4.25rem;
  text-align: center;
  padding: 0.5rem 0.08rem 0.4rem;
  font-size: 0.68rem;
  color: #d9d0c3;
}
.bottom-nav a.active { color: var(--foam); }
.bottom-nav svg { display: block; margin: 0 auto 0.1rem; }

body.signed-in { padding-bottom: var(--nav-h); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem 1.05rem;
}

.kicker {
  color: var(--navy);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
}

.muted { color: var(--muted); }
.stat { font-size: 2.6rem; font-weight: 700; line-height: 0.95; }
.stat small { font-size: 1.1rem; font-weight: 600; color: var(--muted); }

.grid-2, .grid-3 { display: grid; gap: 0.8rem; }

.reactor-card h2 { font-size: 1.45rem; margin: 0 0 0.2rem; }
.metric-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.28rem 0; border-bottom: 1px solid rgba(228, 217, 200, 0.7); }
.metric-row span:last-child { font-weight: 700; text-align: right; }
.metric-row-wrap { flex-wrap: wrap; align-items: baseline; }
.metric-row-wrap span:last-child { flex: 1 1 12rem; font-weight: 600; }

.btn-amber {
  background: var(--amber);
  border-color: var(--amber);
  color: white;
  font-weight: 700;
}
.btn-amber:hover, .btn-amber:focus { background: var(--amber-dark); border-color: var(--amber-dark); color: white; }
.btn-ink { background: var(--blue); border-color: var(--blue); color: white; font-weight: 700; }
.btn-ink:hover { background: #0e2c3e; color: white; }
.btn { min-height: 44px; }
#id_cell_type,
#id_dimension_unit {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
#id_cell_type label,
#id_dimension_unit label {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-weight: 650;
}
#id_cell_type input[type="radio"],
#id_dimension_unit input[type="radio"] {
  width: 1.2rem;
  height: 1.2rem;
  margin: 0 0.6rem 0 0;
  accent-color: #1e3a8a;
  appearance: auto;
}
.photo-slot input[type="file"],
input[type="file"].form-control { min-height: 44px; }
.form-check { min-height: 44px; display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem 0.65rem; }
.form-check .form-text, .form-check .invalid-feedback { flex-basis: 100%; margin-top: 0; }
.form-check-input { width: 1.25rem; height: 1.25rem; margin-top: 0; }
.library-meta { display: flex; flex-wrap: wrap; gap: 0.2rem 0.85rem; margin-top: 0.25rem; }
.table-scroll { overflow-x: auto; }
.materials-table { min-width: 44rem; }
.warning-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.library-card .status-pill { max-width: 100%; white-space: normal; }
.density-list { display: grid; gap: 0.8rem; }
.density-card { display: block; }
.density-thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.density-thumbs img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  border-radius: 10px;
  background: #efe7da;
}
.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-ok { background: #e5f2ea; color: var(--good); }
.status-info { background: #e7eef8; color: #1d3d6e; }
.status-warn { background: #f8e7b0; color: #7a5b00; }
.status-alert { background: #f8d6d2; color: #8d1d14; }
.status-plain { background: transparent; color: var(--ink); padding-left: 0; }
.rig-maint-alert { border-color: #e3b2ac; }
.maint-link-alert { border-color: #e3b2ac; }
.safety-warn { background: #f8e7b0; border-color: #e0c36a; }
.safety-alert { background: #f8d6d2; border-color: #e3b2ac; }
.access-row .form-label { margin-top: 0.65rem; }
.maint-note {
  background: #f8e7b0;
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
}
.maint-entry {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
}
.maint-entry img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 10px;
  background: #efe7da;
}
.btn-sm { min-height: 32px; padding-top: 0.15rem; padding-bottom: 0.15rem; }

.write-in {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 1.15rem;
  margin: 0.4rem 0 0.8rem;
}
.write-in .line {
  flex: 1;
  border-bottom: 1.5px solid var(--ink);
  min-width: 8rem;
  height: 1.1rem;
}

.yield-hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
}
.yield-hero .stat { font-size: 4rem; }

.photo-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 0.55rem; margin-top: 0.35rem; }
.photo-stack-slots { display: flex; flex-direction: column; gap: 0.55rem; width: 100%; }
.photo-stack-slot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem; }
.photo-stack-slot input[type="file"] { flex: 1 1 14rem; }
.photo-stack-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; background: #efe7da; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.7rem; }
.photo-grid img { width: 100%; height: 150px; object-fit: cover; border-radius: 12px; background: #efe7da; }
.photo-grid figcaption { font-size: 0.9rem; margin-top: 0.3rem; }

.chart-frame {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: auto;
}
.chart-frame img { width: 100%; height: auto; display: block; }

.drop-zone {
  border: 2px dashed #c8b49a;
  border-radius: 16px;
  padding: 1.2rem;
  background: #fffaf3;
}
.drop-zone input[type=file] { min-height: 3.2rem; }

.badge-open, .badge-done {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 700;
}
.badge-open { background: #fde7d4; color: var(--amber-dark); }
.badge-done { background: #e5f2ea; color: var(--good); }

.login-wrap {
  min-height: calc(100vh - 9rem);
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.about-page { width: min(740px, calc(100% - 1.5rem)); }
.about-copy h1 { font-size: 2.7rem; line-height: 0.95; margin: 0 0 0.8rem; }
.about-copy p { font-size: 1.08rem; margin: 0 0 1rem; }
.about-cta { margin: 1.3rem 0 0.2rem; }
.about-cta .btn { display: inline-flex; align-items: center; text-decoration: none; padding: 0.55rem 1.1rem; }
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: auto;
}
.site-footer-inner {
  width: min(1100px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1rem 0 1.2rem;
}
.site-footer nav { display: flex; gap: 1rem; margin-bottom: 0.35rem; }
.site-footer nav a { font-weight: 700; text-decoration: none; }
.site-footer p { color: var(--muted); font-size: 0.86rem; margin: 0; max-width: 40rem; }
body.public { min-height: 100vh; display: flex; flex-direction: column; }
body.public main { flex: 1; }
.login-card { width: min(440px, 100%); }
.login-card h1 { font-size: 3rem; margin: 0 0 0.35rem; }
.login-card .brand-lockup { margin-bottom: 0.15rem; }

.alert { border-radius: 12px; }

table.report { width: 100%; }
table.report th { font-size: 0.82rem; color: var(--muted); font-weight: 700; }
table.report td, table.report th { padding: 0.45rem 0.35rem; border-bottom: 1px solid var(--line); vertical-align: top; }

.history-pills { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.history-pills a {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  text-decoration: none;
  color: var(--ink);
}
.history-pills a.active { background: var(--ink); color: white; border-color: var(--ink); }

.report-filters {
  display: grid;
  gap: 0.75rem;
}
.report-filters .form-control,
.report-filters .form-select { min-height: 44px; }
.report-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.report-card-body {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: flex-start;
}
.report-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.report-card .status-pill { display: inline-block; margin-bottom: 0.35rem; }

@media (min-width: 768px) {
  body.signed-in { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .wordmark img { height: 46px; }
  .desktop-nav { display: flex; align-items: center; }
  .topbar-about { display: none; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1.2fr 1fr 1fr; }
  .page { padding-top: 1.6rem; }
  .report-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .report-filter-search { grid-column: span 2; }
}

@media (max-width: 767.98px) {
  .job-search { flex: 1 1 100%; }
  .hide-sm { display: none; }
  .stat { font-size: 2.3rem; }
  .yield-hero { align-items: start; flex-direction: column; }
  .yield-hero .stat { font-size: 3.4rem; }
}

@media print {
  .topbar, .bottom-nav, .site-footer, .no-print { display: none !important; }
  body { background: white; padding: 0; }
  .panel { box-shadow: none; }
}
