:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #687385;
  --line: #e2e6ec;
  --primary: #1d5fd1;
  --primary-ink: #ffffff;
  --ok: #18864b;
  --ok-bg: #e6f5ec;
  --warn: #b25e00;
  --warn-bg: #fff3e0;
  --bad: #c62828;
  --bad-bg: #fdecec;
  --info-bg: #e8f0fd;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 760px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

/* ---------- Top bar & nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; background: #12233f; color: #fff;
  display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 52px;
}
.topbar .brand { font-weight: 700; color: #fff; letter-spacing: .2px; }
.topbar .who { margin-left: auto; font-size: .85rem; opacity: .85; display: flex; gap: 10px; align-items: center; }
.topbar .who a, .topbar .who button { color: #fff; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
.adminnav {
  background: #1a2f52; display: flex; gap: 2px; overflow-x: auto; padding: 0 10px; scrollbar-width: none;
  position: sticky; top: 52px; z-index: 49;
}
.adminnav::-webkit-scrollbar { display: none; }
.adminnav a { color: #c8d4ea; padding: 11px 12px; white-space: nowrap; font-size: .92rem; border-bottom: 3px solid transparent; }
.adminnav a.on { color: #fff; border-bottom-color: #6aa3ff; }
.adminnav a:hover { text-decoration: none; color: #fff; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 640px; }
body.tech .wrap { padding-bottom: 90px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: #fff; border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { flex: 1; text-align: center; padding: 10px 0 12px; color: var(--muted); font-size: .8rem; }
.tabbar a .ic { display: block; font-size: 1.35rem; line-height: 1.2; }
.tabbar a.on { color: var(--primary); font-weight: 600; }
.tabbar a:hover { text-decoration: none; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card.tight { padding: 12px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.jobcard { display: block; color: inherit; border-left: 5px solid var(--line); }
.jobcard:hover { text-decoration: none; }
.jobcard.urgent { border-left-color: var(--bad); }
.jobcard.st-in_progress { border-left-color: var(--primary); }
.jobcard .title { font-weight: 650; font-size: 1.05rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eef1f5; color: #3d4757; white-space: nowrap; }
.badge.urgent, .badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.ok, .badge.st-signed { background: var(--ok-bg); color: var(--ok); }
.badge.warn, .badge.st-revisit, .badge.st-completed { background: var(--warn-bg); color: var(--warn); }
.badge.st-pending { background: #f1e9ff; color: #6a3fc1; }
.badge.st-assigned, .badge.st-accepted { background: var(--info-bg); color: var(--primary); }
.badge.st-in_progress { background: var(--primary); color: #fff; }
.badge.st-cancelled { background: #eceff1; color: #78858f; text-decoration: line-through; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 5px; }
label.inline { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; margin: 8px 0; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=tel], input[type=date],
input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid #cdd3dc; border-radius: 10px; font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0ff; border-color: var(--primary); }
input[type=checkbox] { width: 20px; height: 20px; }
.help { color: var(--muted); font-size: .82rem; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid #cdd3dc; background: #fff; color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 44px;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: #fff; border-color: #e8b4b4; color: var(--bad); }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: .88rem; }
.btn.big { width: 100%; padding: 16px; font-size: 1.1rem; min-height: 56px; border-radius: 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.flash.info { background: var(--info-bg); color: var(--primary); }
.alert { padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: .92rem; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: .92rem; }
th { background: #f7f9fc; color: #4a5568; font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f7faff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.tabs a { padding: 7px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--text); white-space: nowrap; font-size: .9rem; }
.tabs a.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.tabs a:hover { text-decoration: none; }
.tabs .n { opacity: .7; margin-left: 4px; }

.pager { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }

/* ---------- Tech job page ---------- */
.step { border-left: 4px solid var(--line); }
.step.done { border-left-color: var(--ok); }
.step.active { border-left-color: var(--primary); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0 6px 22px; position: relative; font-size: .92rem; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 12px; width: 9px; height: 9px; border-radius: 50%; background: #c5ccd6; }
.timeline li.done::before { background: var(--ok); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #e9edf2; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 28px; height: 28px; font-size: 16px; cursor: pointer; }
.photo .tag { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.55); color: #fff; font-size: .7rem; padding: 1px 6px; border-radius: 6px; text-transform: uppercase; }
.photo.uploading { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8rem; }
.uploadbtn { position: relative; overflow: hidden; }
.uploadbtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.partrow { display: grid; grid-template-columns: 1fr 80px 40px; gap: 8px; align-items: center; margin-bottom: 8px; }
.partrow button { height: 44px; }
.seg { display: flex; border: 1px solid #cdd3dc; border-radius: 10px; overflow: hidden; }
.seg label { flex: 1; margin: 0; text-align: center; padding: 12px 6px; cursor: pointer; font-weight: 600; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--primary); color: #fff; }

/* ---------- Signature ---------- */
.sigpad { width: 100%; height: 240px; border: 2px dashed #9aa6b6; border-radius: 12px; background: #fff; touch-action: none; display: block; }

/* ---------- Autocomplete ---------- */
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 20; max-height: 300px; overflow-y: auto; }
.ac-list div { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f0f2f5; }
.ac-list div:hover, .ac-list div.hi { background: #f2f7ff; }

/* ---------- Dashboard ---------- */
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat .v { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .82rem; }
.medal { font-size: 1.1rem; }

/* ---------- Map ---------- */
#map { width: 100%; height: calc(100vh - 210px); min-height: 380px; border-radius: var(--radius); }
.legend span { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-size: .88rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* ---------- Login ---------- */
.login { max-width: 380px; margin: 10vh auto; padding: 16px; }
.login .card { padding: 24px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; background: #1c2430; color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 100; max-width: 90vw; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
.busy { position: fixed; inset: 0; background: rgba(255,255,255,.6); z-index: 90; display: flex; align-items: center; justify-content: center; font-weight: 600; }

@media print { .topbar, .adminnav, .tabbar, .btn { display: none !important; } }
