:root {
  --bg: #0d0f12;
  --panel: #171a1f;
  --panel-2: #20242b;
  --line: #343a43;
  --text: #f7f8fa;
  --muted: #aeb5bf;
  --brand: #c51b26;
  --brand-2: #ec3340;
  --good: #35c46a;
  --warn: #ffb020;
  --danger: #e44747;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #252a31 0, var(--bg) 42%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(16px, 4vw, 34px);
  background: rgba(13,15,18,.92); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
h1,h2,h3,p { margin-top: 0; }
h1 { font-size: clamp(1.35rem, 4vw, 2rem); margin-bottom: 0; }
h2 { margin-bottom: 0; }
.eyebrow { margin-bottom: 4px; color: var(--brand-2); font-size: .72rem; letter-spacing: .18em; font-weight: 800; }
.tabs {
  position: sticky; top: 76px; z-index: 19;
  display: flex; gap: 6px; overflow-x: auto;
  padding: 10px clamp(12px, 4vw, 34px);
  background: rgba(13,15,18,.96); border-bottom: 1px solid var(--line);
}
.tab {
  border: 0; border-radius: 999px; padding: 10px 18px;
  background: transparent; color: var(--muted); font-weight: 700;
}
.tab.active { background: var(--brand); color: white; }
main { width: min(1200px, 100%); margin: auto; padding: 18px; }
.view { display: none; }
.view.active { display: block; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metric, .panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(32,36,43,.98), rgba(20,23,28,.98));
  box-shadow: 0 14px 40px rgba(0,0,0,.24);
}
.metric { padding: 18px; }
.metric span { display: block; color: var(--muted); font-size: .9rem; }
.metric strong { display: block; margin-top: 7px; font-size: 2rem; }
.metric.warning strong { color: var(--warn); }
.panel { padding: 18px; margin-bottom: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-heading.compact { align-items: flex-start; }
.panel-heading p { color: var(--muted); margin-bottom: 0; }
.primary, .secondary, .danger, .ghost, .file-button {
  min-height: 44px; border-radius: 11px; padding: 10px 15px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.primary { border: 1px solid var(--brand-2); background: linear-gradient(#df2834, #a90e18); color: white; }
.secondary { border: 1px solid var(--line); background: var(--panel-2); color: white; }
.danger { border: 1px solid #7d2424; background: #4b1919; color: #ffd6d6; }
.ghost { border: 1px solid var(--line); background: transparent; color: white; }
.hidden { display: none !important; }
.card-list { display: grid; gap: 10px; }
.job-card {
  display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px;
  padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: rgba(10,12,15,.45);
}
.job-card button { all: unset; cursor: pointer; display: contents; }
.job-title { font-weight: 900; font-size: 1.06rem; }
.job-sub { color: var(--muted); margin-top: 3px; }
.job-hours { text-align: right; }
.job-hours strong { font-size: 1.35rem; }
.job-hours span { display: block; color: var(--muted); font-size: .78rem; }
.badge {
  display: inline-flex; margin-top: 8px; padding: 5px 9px; border-radius: 999px;
  font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .05em;
  background: #303640; color: #dfe4eb;
}
.badge.paid { background: rgba(53,196,106,.18); color: #7af0a0; }
.badge.review { background: rgba(255,176,32,.18); color: #ffd16f; }
.empty-state { color: var(--muted); padding: 18px 0; }
.search, .field input, .field select, .field textarea {
  width: 100%; color: white; background: #0e1115; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 13px; outline: none;
}
.search { margin-bottom: 14px; }
.field input:focus, .field select:focus, .field textarea:focus, .search:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(236,51,64,.14); }
.field { display: grid; gap: 7px; }
.field span { color: var(--muted); font-size: .85rem; font-weight: 700; }
.form-grid, .labor-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; margin-bottom: 18px; }
.labor-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.spacer { flex: 1; }
.notice { padding: 13px; border-left: 4px solid var(--warn); background: rgba(255,176,32,.09); border-radius: 8px; color: #ffe2a7; margin-bottom: 14px; }
.drop-zone {
  display: grid; place-items: center; text-align: center; min-height: 150px; padding: 20px;
  border: 2px dashed #59616d; border-radius: 14px; background: rgba(255,255,255,.025);
}
.drop-zone span { color: var(--muted); margin-top: 5px; }
.drop-zone input, .file-button input { display: none; }
.preview-grid, .photo-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(120px,1fr)); gap: 10px; margin: 14px 0; }
.preview-grid img, .photo-grid img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.progress-wrap { margin: 15px 0; }
.progress { height: 10px; background: #0b0d10; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress div { width: 0%; height: 100%; background: var(--brand-2); transition: width .2s; }
#ocrStatus { color: var(--muted); margin-top: 7px; }
dialog {
  width: min(900px, calc(100% - 20px)); max-height: 92vh; overflow: auto;
  border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: white; padding: 0;
}
dialog::backdrop { background: rgba(0,0,0,.76); backdrop-filter: blur(5px); }
#jobForm { padding: 20px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: white; font-size: 1.7rem; }
.photo-section { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 18px; }
.file-button { cursor: pointer; }
@media (max-width: 760px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .labor-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { padding-top: max(14px, env(safe-area-inset-top)); }
  .tabs { top: 72px; }
  main { padding: 12px; }
  .panel { padding: 14px; }
}
@media (max-width: 430px) {
  .metric { padding: 14px; }
  .metric strong { font-size: 1.55rem; }
  .panel-heading { align-items: flex-start; }
  .job-card { grid-template-columns: 1fr; }
  .job-hours { text-align: left; }
}
