:root {
  --navy: #1f3a5f;
  --navy-dark: #16293f;
  --open: #b45309;
  --closed: #15803d;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #dfe3e8;
  --text: #23282f;
  --muted: #6b7280;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
header.topbar {
  background: var(--navy);
  color: white;
  padding: 12px 24px;
}
header.topbar a { color: white; text-decoration: none; }
header.topbar .brand { font-weight: 700; font-size: 15px; line-height: 1.25; max-width: 420px; }
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.topbar-project { font-size: 14px; opacity: 0.9; }
.topbar-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 8px;
}
.topbar-links a { font-size: 13px; opacity: 0.9; }
.topbar-links a:hover { opacity: 1; text-decoration: underline; }
.container { max-width: 1000px; margin: 24px auto; padding: 0 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
}
h1, h2, h3 { color: var(--navy-dark); }
h1 { font-size: 22px; }
h2 { font-size: 18px; margin-top: 0; }
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 20px; }
.subnav a {
  padding: 7px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--navy-dark);
  font-size: 14px;
}
.subnav a:hover { background: #eef1f5; }
table { border-collapse: collapse; width: 100%; margin: 10px 0; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #f0f2f5; color: var(--navy-dark); }
.badge { font-weight: 700; padding: 2px 8px; border-radius: 10px; font-size: 11px; color: white; background: #9ca3af; }
.badge.open { background: var(--open); }
.badge.closed { background: var(--closed); }
.archived-banner {
  background: #fff7ed; border: 1px solid var(--open); color: #7c2d12;
  padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 14px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.archived-banner a { color: #7c2d12; font-weight: 600; }
.danger-zone { border: 1px solid #c0392b; border-radius: 8px; padding: 16px; margin-top: 24px; }
.danger-zone h2 { color: #c0392b; margin-top: 0; }
.btn.danger { background: #c0392b; }
.btn.danger:hover { background: #a5311f; }
form label { display: block; margin: 10px 0 4px; font-size: 13px; font-weight: 600; color: #374151; }
input[type=text], input[type=date], input[type=email], input[type=number], input[type=url],
input[type=password], textarea, select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 16px;
  font-family: inherit;
}
/* 16px above (not 14px) is deliberate: iOS Safari auto-zooms the page when
   focusing an input with a smaller font size, which is disorienting on a
   phone -- this keeps the keyboard-open view stable. */
details.settings-panel { margin-bottom: 18px; }
details.settings-panel > summary {
  cursor: pointer; font-weight: 700; color: var(--navy-dark); padding: 4px 0; list-style: none;
}
details.settings-panel > summary::-webkit-details-marker { display: none; }
details.settings-panel > summary::before { content: "⚙ "; }
textarea { min-height: 80px; resize: vertical; }
input[type=file] { margin-top: 4px; }
input:disabled, textarea:disabled, select:disabled {
  background: #f3f4f6; color: #9ca3af; cursor: not-allowed;
}
.row { display: flex; gap: 16px; }
.row > div { flex: 1; }
.btn {
  display: inline-block; background: var(--navy); color: white; border: none;
  padding: 9px 16px; border-radius: 6px; font-size: 14px; cursor: pointer; text-decoration: none;
  margin-top: 14px;
}
.btn:hover { background: var(--navy-dark); }
.btn.secondary { background: white; color: var(--navy-dark); border: 1px solid var(--border); }
.btn.small { padding: 4px 10px; font-size: 12px; margin-top: 0; }
.muted { color: var(--muted); font-size: 13px; }
.project-card { display: flex; justify-content: space-between; align-items: center; }
.project-card a.name { font-size: 16px; font-weight: 700; color: var(--navy-dark); text-decoration: none; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 500; }
.photo-slot { border: 1px dashed var(--border); border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.flash { background: #eafaf0; border: 1px solid var(--closed); padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.flash.error { background: #fdecea; border-color: #c0392b; }
.progress-bar { background: #e5e7eb; border-radius: 4px; height: 10px; width: 100%; overflow: hidden; }
.progress-bar > div { background: var(--navy); height: 100%; }

/* ------------------------------------------------------------- dropzone
   A big, obviously-droppable file upload target -- replaces plain
   <input type="file"> everywhere a file gets added, since the native
   control's drag-and-drop support (it's always been there) is easy to
   miss at its default tiny "Choose File" button size. JS wiring lives in
   static/app.js (initDropzone); the underlying <input type="file"> is
   still present (visually hidden) so normal form submission is unchanged. */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  background: #fafbfc;
  transition: background 0.15s, border-color 0.15s;
  margin-top: 6px;
}
.dropzone:hover, .dropzone:focus, .dropzone.dragover {
  background: #eef4fb;
  border-color: var(--navy);
  outline: none;
}
.dropzone .dz-icon { font-size: 30px; line-height: 1; margin-bottom: 8px; color: var(--navy); }
.dropzone .dz-main { font-size: 15px; font-weight: 700; color: var(--navy-dark); }
.dropzone .dz-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.dropzone .dz-filename {
  margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--navy-dark);
  background: white; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px;
  display: none;
}
/* Compact variant -- for grids of several small file slots (photo uploads,
   logo uploads) where a full-size dropzone per slot would be overwhelming,
   but the same "obviously droppable" affordance still matters. */
.dropzone.compact { padding: 14px 10px; }
.dropzone.compact .dz-icon { font-size: 20px; margin-bottom: 4px; }
.dropzone.compact .dz-main { font-size: 13px; }
.dropzone.compact .dz-sub { font-size: 11px; }
.dropzone.compact .dz-filename { margin-top: 8px; font-size: 12px; padding: 4px 8px; }

/* "Take Photo" button shown next to every photo dropzone -- opens the
   device camera directly on phones/tablets (see wireCameraCapture in
   app.js), as an additional option alongside dropping/browsing a file,
   not a replacement for it. */
.camera-btn-row { margin-top: 6px; }
.camera-btn { width: 100%; text-align: center; }

/* ---------------------------------------------------- rich text editor
   (Monthly Report's Bold/Italic/Underline/Bulleted-list text boxes) */
.rt-toolbar { display: flex; gap: 4px; margin-bottom: 4px; }
.rt-toolbar button {
  border: 1px solid var(--border); background: white; border-radius: 5px;
  padding: 5px 10px; font-size: 13px; cursor: pointer; color: var(--navy-dark);
  line-height: 1;
}
.rt-toolbar button:hover { border-color: var(--navy); }
.rt-toolbar button.active { background: var(--navy); color: white; border-color: var(--navy); }
.richtext {
  width: 100%; min-height: 80px; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 16px; font-family: inherit; background: white;
}
.richtext:focus { outline: none; border-color: var(--navy); }
.richtext ul { margin: 0 0 0 20px; padding: 0; }
.richtext[data-short] { min-height: 40px; }

/* --------------------------------------------------------- photo picker
   (Monthly Report's "choose from existing photos" library grid) */
.photo-pick-cell { width: 130px; }
.photo-pick-cell img { width: 130px; height: 95px; object-fit: cover; border-radius: 4px; border: 2px solid var(--border); display: block; }
.photo-pick-cell.checked img { border-color: var(--navy); }
.photo-pick-cell input[type=text] { font-size: 11px; padding: 5px 6px; margin-top: 4px; }
.photo-pick-label { display: flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 11px; cursor: pointer; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 30, 47, 0.55);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: white; border-radius: 10px; padding: 24px; max-width: 480px; width: 100%;
  max-height: 85vh; overflow-y: auto; box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}
.modal-box h2 { margin-top: 0; }

/* ---------------------------------------------------------------- signature */
.sig-summary {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  margin: 8px 0 10px; font-size: 14px; background: #f7f9fc;
}
.sig-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.sig-option {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px; text-align: center;
  cursor: pointer; width: 150px; font-weight: normal; transition: border-color 0.15s, background 0.15s;
}
.sig-option:hover { border-color: var(--navy); background: #f7f9fc; }
.sig-option img { width: 100%; height: 46px; object-fit: contain; background: white; display: block; margin: 4px 0; }
.sig-option .sig-name { font-size: 12px; font-weight: 600; }
.sig-option .sig-contact { font-size: 11px; }
.sig-option.sig-new-option {
  border-style: dashed; display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 84px;
}
.sig-option .sig-plus { font-size: 22px; line-height: 1; color: var(--navy); margin-bottom: 4px; }
.sig-canvas {
  border: 1px solid var(--border); border-radius: 8px; background: white;
  width: 100%; max-width: 520px; height: 160px; touch-action: none; cursor: crosshair; display: block;
}
#signature-modal .modal-box { max-width: 560px; }

/* ---------------------------------------------------------- phone / tablet */
@media (max-width: 700px) {
  .container { margin: 14px auto; padding: 0 10px; }
  .card { padding: 14px; }
  header.topbar { padding: 10px 14px; }

  /* Wide data tables don't reflow well at phone widths -- let each one
     scroll horizontally within itself rather than squeezing every column
     down to unreadable, or breaking the page layout. */
  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  thead, tbody, tr { display: table; width: 100%; table-layout: fixed; }

  /* Side-by-side form fields stack instead of squeezing narrow. */
  .row { flex-direction: column; gap: 0; }

  /* Bigger tap targets everywhere a finger has to land. */
  .btn { padding: 12px 18px; font-size: 15px; }
  .btn.small { padding: 8px 12px; font-size: 13px; }
  .subnav a { padding: 10px 14px; font-size: 14px; }
  .checkbox-row input[type=checkbox], .checkbox-row input[type=radio] { width: 20px; height: 20px; }

  .project-card { flex-direction: column; align-items: flex-start; gap: 8px; }

  h1 { font-size: 19px; }
  h2 { font-size: 16px; }
}

/* trade tags on observations */
.trade-tag { display: inline-block; background: #e0e7ef; color: #1f3a5f; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px; margin: 0 2px 2px 0; }
.trade-tag-picker { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.trade-tag-option { font-weight: normal; display: flex; align-items: center; gap: 4px; margin: 0; }
