/* move-estimator - one stylesheet for all pages.
   Each company's brand color is injected as --brand (see templates/base.html). */

:root {
  --brand: #1d4ed8;
  --on-brand: #ffffff;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --ok: #15803d;      --ok-bg: #dcfce7;
  --warn: #b45309;    --warn-bg: #fef3c7;
  --bad: #b91c1c;     --bad-bg: #fee2e2;
  --info: #1e40af;    --info-bg: #dbeafe;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
img { max-width: 100%; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: .9em; }

.container { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
.container.narrow { max-width: 760px; }
.container.tiny { max-width: 440px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.mt { margin-top: 1rem; }
.mb0 { margin-bottom: 0; }

/* ---- Layout helpers ---- */
.stack { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack.end { justify-content: flex-end; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.layout-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.sticky { position: sticky; top: 16px; }
@media (max-width: 960px) {
  .layout-main { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  h1 { font-size: 1.35rem; }
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card > h2:first-child, .card > .between:first-child { margin-bottom: 12px; }
.card.hero { text-align: center; padding: 36px 24px; }
.card.hero .stack { justify-content: center; margin-top: 16px; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }

/* ---- Headers ---- */
.brand-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.brand-header .inner { max-width: 1180px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 14px; justify-content: space-between; flex-wrap: wrap; }
.brand-header .logo { height: 44px; width: auto; display: block; }
.brand-header .company-name { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand-header .contact { color: var(--muted); font-size: .9rem; }
.brand-bar { height: 4px; background: var(--brand); }
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-nav a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: 999px; font-weight: 500; }
.admin-nav a:hover { background: var(--surface-2); color: var(--text); }
.admin-nav a.active { background: var(--brand); color: var(--on-brand); }
.mock-banner { background: var(--warn-bg); color: var(--warn); text-align: center; font-size: .85rem; padding: 6px 12px; font-weight: 600; }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > label, .label { font-weight: 600; font-size: .9rem; }
.field .hint { color: var(--muted); font-size: .82rem; }
.field .error { color: var(--bad); font-size: .82rem; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number],
input[type=password], input[type=url], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  min-height: 42px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
input[type=color] { width: 56px; height: 40px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 2px; background: var(--surface); }
.invalid { border-color: var(--bad) !important; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 4px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 6px; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.choice { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer; background: var(--surface); user-select: none; }
.choice:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, white); }
.choice input { accent-color: var(--brand); width: 18px; height: 18px; margin: 0; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented label { padding: 9px 14px; cursor: pointer; border-right: 1px solid var(--border-strong); background: var(--surface); font-weight: 500; }
.segmented label:last-child { border-right: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--brand); color: var(--on-brand); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: 9px 16px; min-height: 42px; line-height: 1.2;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover:not(:disabled) { filter: brightness(.94); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--surface); color: var(--bad); border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: var(--bad-bg); }
.btn-success { background: var(--ok); color: #fff; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .85rem; }
.btn-lg { padding: 13px 22px; min-height: 50px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

/* ---- Alerts & badges ---- */
.alert { border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; border: 1px solid; }
.alert-error { background: var(--bad-bg); color: var(--bad); border-color: #fecaca; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #bbf7d0; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #bfdbfe; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-uploading { background: #f3f4f6; color: #4b5563; }
.badge-new { background: var(--info-bg); color: var(--info); }
.badge-analyzed { background: #ede9fe; color: #6d28d9; }
.badge-reviewed { background: var(--ok-bg); color: var(--ok); }
.badge-sent { background: #e0f2fe; color: #0369a1; }
.badge-error { background: var(--bad-bg); color: var(--bad); }
.badge-working { background: var(--warn-bg); color: var(--warn); }
.badge-muted { background: #f3f4f6; color: #4b5563; }
.chip { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); margin: 1px 2px 1px 0; white-space: nowrap; }
.chip-fragile { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }
.chip-special { background: #fdf2f8; border-color: #fbcfe8; color: #be185d; }
button.chip { cursor: pointer; font: inherit; font-size: .75rem; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr.room-row td { background: var(--surface-2); font-weight: 700; font-size: .85rem; padding-top: 7px; padding-bottom: 7px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; font-weight: 500; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { text-decoration: none; padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 500; font-size: .9rem; }
.tabs a.active { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.tabs a .count { opacity: .7; margin-left: 4px; }

/* ---- Stats ---- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat .label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.2rem; font-weight: 700; }
.stat .sub { font-size: .8rem; color: var(--muted); }
.total-box { background: color-mix(in srgb, var(--brand) 7%, white); border: 1px solid color-mix(in srgb, var(--brand) 25%, white); border-radius: var(--radius-sm); padding: 14px; text-align: center; margin: 12px 0; }
.total-box .amount { font-size: 2rem; font-weight: 800; color: var(--brand); line-height: 1.1; }
.total-box .range { color: var(--muted); font-size: .9rem; }

/* ---- Progress ---- */
.progress { height: 12px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.file-list { list-style: none; padding: 0; margin: 8px 0 0; }
.file-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 6px; background: var(--surface-2); font-size: .9rem; }
.file-list li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 26px 16px; text-align: center; background: var(--surface-2); cursor: pointer; }
.dropzone.drag { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, white); }
.dropzone input { display: none; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Frames gallery + lightbox ---- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.gallery figure { margin: 0; position: relative; }
.gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: zoom-in; display: block; background: #eee; }
.gallery figcaption { position: absolute; left: 4px; top: 4px; background: rgba(17,24,39,.75); color: #fff; font-size: .7rem; padding: 0 6px; border-radius: 4px; }
.gallery figure.highlight img { outline: 3px solid var(--brand); }
.gallery .play-from { position: absolute; right: 4px; bottom: 4px; border: 0; border-radius: 4px; background: rgba(17,24,39,.8); color: #fff; font-size: .72rem; padding: 2px 6px; cursor: pointer; }
.gallery .play-from:hover { background: var(--brand); color: var(--on-brand); }
.player { width: 100%; max-height: 62vh; background: #000; border-radius: 8px; display: block; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; flex-direction: column; gap: 10px; }
.lightbox.open { display: flex; }
.lightbox img { max-height: 84vh; max-width: 96vw; border-radius: 6px; }
.lightbox .cap { color: #e5e7eb; font-size: .9rem; }
.lightbox button { position: absolute; background: rgba(255,255,255,.15); color: #fff; border: 0; font-size: 1.6rem; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; }
.lightbox .close { top: 14px; right: 14px; }
.lightbox .prev { left: 14px; top: 50%; }
.lightbox .next { right: 14px; top: 50%; }

/* ---- Inventory editor ---- */
.inv-table input[type=text], .inv-table input[type=number], .inv-table select { min-height: 34px; padding: 5px 7px; font-size: .88rem; }
.inv-table td { padding: 5px 6px; }
.inv-table .w-qty input { min-width: 62px; }
.inv-table .w-num input { min-width: 78px; }
.inv-table .w-room input { min-width: 140px; }
.inv-table .w-type select { min-width: 130px; }
.inv-table { min-width: 980px; }
.inv-table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.inv-table tr.locked input, .inv-table tr.locked select { background: var(--surface-2); }
.save-state { font-size: .82rem; color: var(--muted); }
.save-state.saving { color: var(--warn); }
.save-state.saved { color: var(--ok); }
.save-state.error { color: var(--bad); }
.estimate-lines td { padding: 6px 4px; }
.estimate-lines tr.total td { font-weight: 800; border-top: 2px solid var(--text); border-bottom: 0; }
.estimate-lines .detail { display: block; font-size: .78rem; color: var(--muted); }
.override-note { font-size: .78rem; color: var(--warn); font-weight: 600; }

/* ---- Crew / photo cards ---- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.photo-card { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.photo-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; cursor: zoom-in; }
.photo-card .body { padding: 8px 10px; font-size: .82rem; }
.condition-excellent, .condition-good { color: var(--ok); font-weight: 700; }
.condition-fair { color: var(--warn); font-weight: 700; }
.condition-poor, .condition-damaged { color: var(--bad); font-weight: 700; }
.sticky-bottom { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); }

.link-list { list-style: none; padding: 0; margin: 0; }
.link-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.link-list li:last-child { border-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.copy-field { display: flex; gap: 6px; }
.copy-field input { font-size: .85rem; }

/* Super-admin system check */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.checks li:last-child { border-bottom: 0; }
.check-icon { flex: none; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.check-ok .check-icon { background: var(--ok-bg); color: var(--ok); }
.check-warn .check-icon { background: var(--warn-bg); color: var(--warn); }
.check-bad .check-icon { background: var(--bad-bg); color: var(--bad); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
