/* Shared styles for the PI app and the customer portal.
   Brand system from precisionintegrators.com: dark green navbar, forest-green
   buttons, olive accent, cream surfaces, Arvo headings, BDO Grotesk body. */

:root {
  /* PI brand */
  --pi-dark-green: #22381f;
  --pi-forest: #3d7136;
  --pi-forest-2: #6e8d66;     /* end of the website's button gradient */
  --pi-olive: #8e9f86;
  --pi-cream: #fefaf3;
  --pi-cream-2: #f8f4e7;
  --pi-ink: #1d1e1c;

  --bg: var(--pi-cream-2);
  --surface: #fffdf8;
  --sunk: #efeadb;
  --line: #e2dccb;
  --line-strong: #cbc3ad;
  --fg: var(--pi-ink);
  --muted: #55584f;
  --faint: #85887c;
  --steel: var(--pi-dark-green);
  --steel-2: var(--pi-forest);
  --steel-fg: var(--pi-cream);
  --accent: var(--pi-forest);
  --accent-hover: #2f5a2a;
  --accent-soft: #e4ecdf;
  --accent-fg: var(--pi-cream);
  --select-bg: #e4ecdf;
  --ok: #2f6b2a; --ok-bg: #e0eed9;
  --warn: #8a5300; --warn-bg: #f8e6c4;
  --bad: #b3261e; --bad-bg: #f9dedb;
  --info: #24537a; --info-bg: #e1ecf5;
  --focus: #1d6fd6;

  --display: "Arvo", Georgia, serif;
  --body: "BDO Grotesk", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --r-sm: 9px; --r: 10px; --r-lg: 14px;
  --shadow: 0 1px 2px rgba(29, 30, 28, .05), 0 4px 14px rgba(29, 30, 28, .06);
  --shadow-lg: 0 10px 40px rgba(29, 30, 28, .22);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 15px/1.45 var(--body);
}
img { max-width: 100%; display: block; }
a { color: var(--steel-2); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -.01em; margin: 0; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: .92em; }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg);
  font: 600 14px/1 var(--body); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--sunk); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(90deg, var(--pi-forest), var(--pi-forest-2)); border-color: var(--pi-forest); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-steel { background: var(--steel-2); border-color: var(--steel-2); color: #fff; }
.btn-steel:hover { background: var(--steel); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--sunk); }
.btn-danger { color: var(--bad); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: 17px; border-radius: var(--r); }
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ── Forms ───────────────────────────────────────────────────────────── */
.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field > span, .label { font-weight: 600; font-size: 13px; color: var(--muted); }
.field small { color: var(--faint); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--fg); font: 400 15px/1.3 var(--body);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--steel-2); }
.form-error { background: var(--bad-bg); color: var(--bad); padding: 9px 12px; border-radius: var(--r-sm); margin-bottom: 12px; font-weight: 500; }

/* ── Pills / chips ───────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--sunk); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-new { background: var(--warn-bg); color: var(--warn); }
.pill-in_review { background: var(--info-bg); color: var(--info); }
.pill-qualified { background: var(--ok-bg); color: var(--ok); }
.pill-closed { background: var(--sunk); color: var(--faint); }
.pill-plain::before { display: none; }
.chip { display: inline-block; padding: 2px 8px; border-radius: var(--r-sm); background: var(--sunk); font-size: 12.5px; font-weight: 500; margin: 0 4px 4px 0; }

/* ── Cards / tables ──────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-head p { margin: 2px 0 0; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--pi-cream); }
.table .actions { text-align: right; white-space: nowrap; }
.table tr.inactive td { color: var(--faint); }

/* ── Toast + modal ───────────────────────────────────────────────────── */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--fg); color: #fff; padding: 11px 16px; border-radius: var(--r); box-shadow: var(--shadow-lg); font-weight: 500; animation: toast-in .18s ease-out; }
.toast-error { background: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 25, 20, .45); display: grid; place-items: center; padding: 16px; z-index: 90; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 0; }
.modal form { padding: 16px 20px 20px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ══ PI app shell ═══════════════════════════════════════════════════════ */
.topbar { background: var(--steel); color: var(--steel-fg); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 20px; height: 58px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-logo { height: 34px; width: auto; display: block; }
.brand-text { font: 500 14px/1 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--pi-olive); padding-left: 14px; border-left: 1px solid rgba(254, 250, 243, .25); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: rgba(255, 255, 255, .78); text-decoration: none; font-weight: 600; padding: 8px 12px; border-radius: var(--r-sm); display: flex; align-items: center; gap: 7px; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.nav a.active { color: #fff; background: rgba(255, 255, 255, .14); }
.nav .count { background: var(--pi-cream); color: var(--pi-dark-green); font-size: 11.5px; padding: 1px 7px; border-radius: 999px; }
.account { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.account .btn { color: #fff; border-color: rgba(255, 255, 255, .3); background: transparent; }
.account .btn:hover { background: rgba(255, 255, 255, .1); }

.page { max-width: 1240px; margin: 0 auto; padding: 26px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.back:hover { color: var(--fg); }
.stack { display: grid; gap: 18px; }

/* Filters */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: inline-flex; background: var(--sunk); padding: 3px; border-radius: var(--r); gap: 2px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 7px 12px; border-radius: 7px; font: 600 13.5px/1 var(--body); color: var(--muted); cursor: pointer; display: flex; gap: 6px; align-items: center; }
.tabs button.active { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.tabs .n { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.toolbar select { width: auto; min-width: 180px; }

/* Submission list */
.sub-list { display: grid; gap: 10px; }
.sub-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 16px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.sub-row:hover { border-color: var(--line-strong); }
.sub-row.is-new { border-left: 4px solid var(--warn); }
.sub-thumb { width: 92px; height: 72px; border-radius: var(--r-sm); background: var(--sunk) center/cover no-repeat; }
.sub-main { min-width: 0; }
.sub-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sub-ref { font-family: var(--mono); font-weight: 500; font-size: 13px; color: var(--muted); }
.sub-loc { font: 700 16.5px/1.25 var(--display); margin: 3px 0 2px; }
.sub-meta { color: var(--muted); font-size: 13.5px; }
.sub-side { text-align: right; color: var(--muted); font-size: 13px; display: grid; gap: 4px; justify-items: end; }

/* Submission detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; padding: 16px; }
.photo-card { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--sunk); cursor: zoom-in; padding: 0; text-align: left; font: inherit; color: inherit; }
.photo-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo-card span { display: block; padding: 8px 10px; background: var(--surface); font-weight: 600; font-size: 13px; }
.dl { display: grid; grid-template-columns: 110px 1fr; gap: 10px 12px; margin: 0; font-size: 14px; }
.dl dt { color: var(--muted); font-weight: 600; font-size: 13px; }
.dl dd { margin: 0; }
.loc-big { font: 700 20px/1.2 var(--display); }
.callout { border-radius: var(--r); padding: 12px 14px; font-size: 14px; }
.callout-warn { background: var(--warn-bg); color: var(--warn); }
.callout a { color: inherit; font-weight: 700; }

.lightbox { position: fixed; inset: 0; background: rgba(8, 12, 10, .92); z-index: 95; display: grid; grid-template-rows: auto 1fr; }
.lightbox-bar { display: flex; align-items: center; justify-content: space-between; color: #fff; padding: 12px 16px; gap: 12px; }
.lightbox-bar .btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .25); color: #fff; }
.lightbox-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 0 64px 16px; }
.lightbox-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-size: 24px; cursor: pointer; }
.lightbox-nav:hover { background: rgba(255, 255, 255, .25); }
.lightbox-nav.prev { left: 10px; } .lightbox-nav.next { right: 10px; }

/* Customer detail */
.link-url { display: flex; gap: 6px; align-items: center; }
.link-url code { font-family: var(--mono); font-size: 12.5px; background: var(--sunk); padding: 5px 8px; border-radius: var(--r-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--pi-dark-green) 0%, var(--pi-forest) 100%); }
.login-card { width: min(400px, 100%); padding: 28px; }
.login-card .brand-logo { height: 46px; margin-bottom: 22px; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar-inner { gap: 12px; padding: 0 12px; }
  .brand-text { display: none; }
  .brand-logo { height: 28px; }
  .nav a { padding: 8px 9px; }
  .account .who { display: none; }
  .page { padding: 18px 14px 50px; }
  .sub-row { grid-template-columns: 72px 1fr; }
  .sub-thumb { width: 72px; height: 60px; }
  .sub-side { grid-column: 2; justify-items: start; text-align: left; }
  .row-2 { grid-template-columns: 1fr; }
  .lightbox-stage { padding: 0 8px 12px; }
}
