:root {
  --brand: #0b5cad;
  --brand-dark: #08457f;
  --accent: #f5b301;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --text: #1b2430;
  --muted: #5d6b7c;
  --border: #dbe1e8;
  --ok: #1a8f4c;
  --warn: #b7791f;
  --err: #c53030;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
img { max-width: 100%; display: block; }
a { color: var(--brand); }
[hidden] { display: none !important; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--brand); color: #fff;
  box-shadow: var(--shadow);
}
.topbar .brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.topbar .brand .logo {
  width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--brand-dark);
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
}
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 14px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.topbar a, .topbar button.link { color: #fff; font-size: 14px; }

/* ---------- Layout ---------- */
.container { max-width: 640px; margin: 0 auto; padding: 16px; }
.container.wide { max-width: 1200px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Form ---------- */
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 6px; }
input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text);
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; padding: 11px 16px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: var(--brand); color: #fff; min-height: 44px;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--brand); border-color: var(--brand); }
.btn.secondary:hover { background: #eef4fb; }
.btn.danger { background: var(--err); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 14px; }
.btn.block { width: 100%; }
button.link { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; color: var(--brand); }

.capture-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.capture-buttons .btn { min-height: 72px; flex-direction: column; gap: 4px; font-size: 15px; }
.capture-buttons .btn .ico { font-size: 24px; line-height: 1; }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 10px 0; }
.alert.err { background: #fdecec; color: var(--err); border: 1px solid #f5c2c2; }
.alert.ok { background: #e8f6ee; color: var(--ok); border: 1px solid #bfe5cf; }
.alert.warn { background: #fdf5e6; color: var(--warn); border: 1px solid #f1dbb0; }

/* ---------- GPS chip ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 999px; font-size: 13px; font-weight: 600; background: #eef1f5; color: var(--muted);
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.ok { background: #e8f6ee; color: var(--ok); }
.chip.warn { background: #fdf5e6; color: var(--warn); }
.chip.err { background: #fdecec; color: var(--err); }

/* ---------- Preview ---------- */
.preview { margin-top: 12px; border-radius: 10px; overflow: hidden; background: #111; }
.preview img { width: 100%; max-height: 70vh; object-fit: contain; margin: 0 auto; }
.meta-list { font-size: 13px; color: var(--muted); margin: 8px 0 0; padding: 0; list-style: none; }
.meta-list li { padding: 2px 0; }

.progress { height: 8px; border-radius: 99px; background: #e5e9ef; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; width: 0; background: var(--brand); transition: width .15s; }

/* ---------- Grid foto ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit;
  display: block; text-decoration: none; width: 100%;
}
.tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #e5e9ef; }
.tile .body { padding: 8px; font-size: 13px; }
.tile .desc { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .head { text-align: center; margin-bottom: 8px; }
.login-card .head .logo {
  width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 14px; background: var(--brand); color: var(--accent);
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
}
.login-card .head h1 { margin: 0; font-size: 20px; }
.login-card.admin .head .logo { background: #1b2430; }
.login-card .foot { text-align: center; margin-top: 14px; font-size: 14px; }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button {
  font: inherit; font-weight: 600; background: none; border: 0; padding: 10px 14px; cursor: pointer;
  color: var(--muted); border-bottom: 3px solid transparent;
}
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.filters label { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.stat .n { font-size: 22px; font-weight: 700; }
.stat .l { font-size: 13px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef1f5; }
.badge.admin { background: #e7eefb; color: var(--brand); }
.badge.off { background: #fdecec; color: var(--err); }

dialog {
  border: 0; border-radius: var(--radius); padding: 0; width: min(960px, calc(100vw - 24px));
  max-height: calc(100vh - 24px); box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(10, 15, 25, .6); }
.dlg-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; }
.dlg-head h3 { margin: 0; font-size: 16px; flex: 1; }
.dlg-body { padding: 16px; display: grid; gap: 16px; }
@media (min-width: 800px) { .dlg-body { grid-template-columns: 3fr 2fr; } }
.dlg-body img { width: 100%; border-radius: 8px; background: #111; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100;
  background: #1b2430; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: calc(100vw - 32px);
}
.empty { text-align: center; padding: 24px; color: var(--muted); }
