/* Data Vision brand design system (DESIGN.md) applied to this app's actual
   surface — a login-gated CRUD tool, not a marketing site. The token
   values, typography, buttons, cards, forms, and badges below are taken
   directly from DESIGN.md; the marketing-only components it defines (hero
   sections, proof bars, pricing cards, timelines) aren't used here since
   nothing on this app needs them.

   report_pdf.html is deliberately NOT themed with this system — those PDFs
   go out under Structure CPM Ltd's own name to banks and solicitors, and
   are already matched to their real report branding (see that template's
   own styles); applying Data Vision's brand there would be wrong. */

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Core brand */
  --navy:        #1C2B3A;
  --navy-mid:    #2D4156;
  --steel:       #3B5B7A;

  /* Accent */
  --amber:       #E8A020;
  --amber-lt:    #FEF3DC;

  /* Trust / positive */
  --green:       #3D7A5F;
  --green-lt:    #EBF4EF;

  /* Data / technical */
  --indigo:      #4F46E5;
  --indigo-lt:   #EEF2FF;

  /* Neutrals */
  --parch:       #F5F3EF;
  --cream:       #F8F7F4;
  --stone:       #E8E5DF;
  --border:      #D4D0C8;
  --text:        #1E1E1E;
  --muted:       #6B7280;
  --white:       #FFFFFF;

  /* Semantic */
  --color-error:   #E55C5C;
  --color-warning: #E8A020;
  --color-success: #3D7A5F;

  /* Radius scale */
  --radius-sm:  4px;
  --radius-md:  6px;
  --radius-lg:  8px;
  --radius-xl:  10px;
  --radius-2xl: 12px;
  --radius-3xl: 14px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card:  0 2px 8px rgba(28,43,58,0.08);
  --shadow-lift:  0 8px 30px rgba(28,43,58,0.12);
  --shadow-modal: 0 20px 60px rgba(28,43,58,0.20);
  --shadow-amber: 0 0 0 3px rgba(232,160,32,0.15);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--parch);
  line-height: 1.6;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ---- nav ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 4rem;
  padding: 0 2rem;
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar .brand a, .topbar .brand span {
  color: #fff;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.3rem;
}
.topbar-nav { display: flex; gap: 1.5rem; flex: 1; }
.topbar-nav .nav-link { color: rgba(255,255,255,0.65); font-size: 0.875rem; font-weight: 500; }
.topbar-nav .nav-link.is-active, .topbar-nav .nav-link:hover { color: #fff; text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 0.9rem; }
.text-dim { color: var(--muted); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 2rem; }

.page-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header-actions { display: flex; gap: 0.5rem; align-items: center; }

h1 { font-family: 'Playfair Display', serif; font-weight: 700; font-size: clamp(1.5rem, 2.5vw, 2rem); line-height: 1.2; letter-spacing: -0.02em; color: var(--navy); }
h2 {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--steel);
  margin: 2rem 0 0.9rem;
}
h3 { font-size: 1.05rem; font-weight: 600; color: var(--navy); }

/* ---- cards ---- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 1.75rem;
  margin-bottom: 1rem;
}
.card-narrow { max-width: 380px; margin: 3rem auto; }
.template-section-child { margin-left: 1.75rem; border-left: 2px solid var(--border); padding-left: 1rem; }

/* ---- forms ---- */
.form-row { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--navy); margin-bottom: 0.35rem; }
.form-input, select.form-input, textarea.form-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.875rem;
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus, select.form-input:focus, textarea.form-input:focus { border-color: var(--amber); }
.form-row.has-error .form-input { border-color: var(--color-error); }
.field-error { color: var(--color-error); font-size: 0.8rem; margin-top: 0.3rem; }

/* ---- buttons ---- */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.8rem 1.75rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.btn-primary { background: var(--amber); color: var(--navy); font-weight: 700; }
.btn-primary:hover { background: #d4911a; text-decoration: none; }

/* On the navy topbar only */
.btn-ghost { background: transparent; color: rgba(255,255,255,0.75); border-color: rgba(255,255,255,0.2); font-weight: 500; }
.btn-ghost:hover { border-color: rgba(255,255,255,0.5); color: #fff; text-decoration: none; }

/* Secondary action on light/card backgrounds */
.btn-outline { background: transparent; color: var(--navy); border-color: var(--border); font-weight: 600; }
.btn-outline:hover { border-color: var(--navy); text-decoration: none; }

.btn-sm { padding: 0.5rem 1rem; font-size: 0.82rem; }

/* ---- table ---- */
/* Every .table is wrapped in .table-wrap — on a narrow phone a 5-6 column
   table can't fit, so it scrolls sideways *inside this box* rather than
   pushing the whole page wider than the viewport. The border/radius live
   on the wrapper so the rounded corners survive the scroll clipping. */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
}
.table { width: 100%; border-collapse: collapse; background: var(--white); }
.table th, .table td { text-align: left; padding: 0.7rem 1rem; border-bottom: 1px solid var(--stone); }
.table th { background: var(--parch); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }

/* ---- status / rating badges ---- */
.status { display: inline-block; padding: 0.2rem 0.6rem; border-radius: var(--radius-full); font-size: 0.7rem; font-weight: 700; font-family: 'Inter', sans-serif; }
.status-draft { background: var(--amber-lt); color: #B87A10; }
.status-in_review { background: var(--indigo-lt); color: var(--indigo); }
.status-final { background: var(--green-lt); color: var(--green); }
/* Job's five-stage pipeline (ReportVersion keeps the three statuses above) */
.status-booked { background: var(--stone); color: var(--muted); }
.status-inspected { background: var(--amber-lt); color: #B87A10; }
.status-drafting { background: var(--amber-lt); color: #B87A10; }
.status-under_review { background: var(--indigo-lt); color: var(--indigo); }
.status-issued { background: var(--green-lt); color: var(--green); }
.status-archived { background: var(--stone); color: var(--muted); margin-left: 0.4rem; }
.status-rating-good { background: var(--green-lt); color: var(--green); }
.status-rating-fair { background: var(--amber-lt); color: #B87A10; }
.status-rating-poor { background: rgba(229,92,92,0.12); color: var(--color-error); }
.status-rating-urgent { background: rgba(229,92,92,0.22); color: #B33; }

.section-block { display: flex; flex-direction: column; gap: 1rem; }
.observation-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.observation-list li { padding: 0.6rem 0.85rem; background: var(--parch); border-radius: var(--radius-md); }
.observation-list .status { margin-right: 0.5rem; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}
.inline-form .form-row { margin-bottom: 0; flex: 1 1 200px; }
.inline-form textarea.form-input { min-height: 2.4rem; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.6rem; }
.signature-pad { display: block; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 0.5rem; touch-action: none; cursor: crosshair; }
.signature-preview { max-height: 80px; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; margin-top: 0.4rem; }
.signature-typed-preview { font-style: italic; font-size: 1.4rem; display: inline-block; border-bottom: 1px solid var(--border); padding-bottom: 0.2rem; margin-top: 0.4rem; }

.audit-log { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.audit-log li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.audit-log li:last-child { border-bottom: none; }

.photo-thumb { margin: 0; }
.photo-thumb img { width: 100%; height: 100px; object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--border); }
.photo-thumb figcaption { font-size: 0.75rem; margin-top: 0.2rem; color: var(--muted); }
.caption-form { display: flex; gap: 0.3rem; margin-top: 0.3rem; }
.caption-form .form-input { font-size: 0.8rem; padding: 0.25rem 0.4rem; }
.photo-tag { display: block; font-size: 0.7rem; margin-top: 0.2rem; color: var(--muted); }

.section-number { color: var(--muted); margin-right: 0.4rem; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 0.75rem; }

.mono { font-family: 'DM Mono', ui-monospace, monospace; }

.report-version-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.report-version-list li { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding: 0.6rem 0.85rem; background: var(--parch); border-radius: var(--radius-md); }
.report-version-list a { font-size: 0.9rem; }

.detail-list { display: grid; grid-template-columns: 160px 1fr; row-gap: 0.5rem; margin: 0; }
.detail-list dt { font-weight: 600; color: var(--muted); font-size: 0.85rem; }
.detail-list dd { margin: 0; }

.flash { padding: 0.8rem 1.1rem; border-radius: var(--radius-md); margin-bottom: 1rem; font-size: 0.9rem; }
.flash-error { background: rgba(229,92,92,0.12); color: var(--color-error); }
.flash-info { background: var(--indigo-lt); color: var(--indigo); }

.site-footer { background: var(--navy); padding: 2rem; text-align: center; border-top: 1px solid rgba(255,255,255,0.06); }
.site-footer .wrap { padding: 0; color: rgba(255,255,255,0.35); font-size: 0.78rem; }

/* Tap/click-to-open help, via <details>/<summary> — works identically on
   touch and desktop, unlike a :hover-only tooltip (which never fires on a
   phone: there's no hover state to trigger it, only a click). */
.tooltip {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.3rem;
}
.tooltip summary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: var(--border);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  list-style: none;
}
/* The visible "?" badge stays small so it doesn't crowd inline text, but
   a 17px circle is well under a comfortable tap target — this invisible
   layer pads the actual hit area out to ~37px without changing how it
   looks. */
.tooltip summary::before {
  content: "";
  position: absolute;
  inset: -10px;
}
.tooltip summary::-webkit-details-marker { display: none; }
.tooltip summary::marker { content: ""; }
.tooltip summary:hover, .tooltip[open] summary, .tooltip summary:focus-visible {
  background: var(--steel);
  outline: none;
}
.tooltip .tooltip-content {
  position: absolute;
  top: 135%;
  left: 0;
  background: var(--navy);
  color: #fff;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  width: max-content;
  max-width: min(260px, calc(100vw - 3rem));
  box-shadow: var(--shadow-modal);
  z-index: 30;
}

@media (max-width: 600px) {
  .wrap { padding: 1.25rem; }
  .topbar { padding: 0 1.25rem; flex-wrap: wrap; height: auto; padding-top: 0.75rem; padding-bottom: 0.75rem; }
  .topbar-nav { flex: 1 1 100%; order: 3; flex-wrap: wrap; gap: 0.9rem; }

  /* Property/Client/etc. — a fixed 160px label column gets cramped next
     to a full address on a narrow phone; stack label above value instead. */
  .detail-list { grid-template-columns: 1fr; row-gap: 0.9rem; }
  .detail-list dt { margin-bottom: 0.15rem; }

  /* Page-header actions (Archive, New Job, ...) wrap under the title
     rather than squeezing onto the same line as it. */
  .page-header { flex-direction: column; align-items: stretch; }
}
