/* JobKit shared styles */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f9f8f5;
  --border: #dcd8d0;
  --text: #1d1f22;
  --muted: #676b72;
  --accent: #e36a12;       /* safety orange */
  --accent-ink: #ffffff;
  --accent-soft: #fdeee2;
  --ok: #2f8a4c;
  --warn: #b7791f;
  --bad: #c43d3d;
  --focus: #2b6cb0;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --surface: #1e2126; --surface-2: #24282e; --border: #343941;
    --text: #e8e9eb; --muted: #9aa0a8; --accent: #f07a26; --accent-ink: #15171a;
    --accent-soft: #3a2616; --ok: #4cb36b; --warn: #d9a441; --bad: #e06464; --focus: #6ea8ff;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171a; --surface: #1e2126; --surface-2: #24282e; --border: #343941;
  --text: #e8e9eb; --muted: #9aa0a8; --accent: #f07a26; --accent-ink: #15171a;
  --accent-soft: #3a2616; --ok: #4cb36b; --warn: #d9a441; --bad: #e06464; --focus: #6ea8ff;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; height: 52px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 14px; font-weight: 800; }
.topbar .page-title { color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar nav { margin-left: auto; display: flex; gap: 2px; overflow-x: auto; }
.topbar nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: 14px; white-space: nowrap; }
.topbar nav a:hover { background: var(--surface-2); color: var(--text); }
.topbar nav a.active { color: var(--accent); background: var(--accent-soft); }
.topbar .menu-btn { display: inline-flex; margin-left: 4px; }
@media (max-width: 1100px) { .topbar nav a:not(.active) { display: none; } .topbar nav a.active { display: inline-block; } }
@media (max-width: 760px) { .topbar nav { display: none; } .topbar .menu-btn { margin-left: auto; } }
.mobile-nav { display: none; position: fixed; top: 52px; right: 8px; z-index: 999; background: var(--surface); width: min(640px, calc(100vw - 16px));
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 10px; max-height: calc(100vh - 70px); overflow-y: auto;
  grid-template-columns: repeat(3, minmax(0,1fr)); gap: 4px 12px; }
.mobile-nav.open { display: grid; }
.mobile-nav > a { grid-column: 1 / -1; }
.mobile-nav .mn-group { display: flex; flex-direction: column; }
.mobile-nav .mn-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 8px 10px 4px; }
.mobile-nav a { padding: 9px 10px; color: var(--text); text-decoration: none; border-radius: 6px; }
.mobile-nav a:hover { background: var(--surface-2); }
.mobile-nav a.active { color: var(--accent); background: var(--accent-soft); }
@media (max-width: 600px) { .mobile-nav { grid-template-columns: minmax(0,1fr) minmax(0,1fr); right: 8px; } .mobile-nav a { padding: 11px 10px; } }
.sync-ind { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); text-decoration: none; white-space: nowrap; margin-left: 6px; }
.sync-ind .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync-ind[data-st="ok"] .dot, .sync-ind[data-st="synced"] .dot, .sync-ind[data-st="idle"] .dot { background: var(--ok); }
.sync-ind[data-st="syncing"] .dot { background: var(--warn); }
.sync-ind[data-st="error"] .dot, .sync-ind[data-st="auth"] .dot, .sync-ind[data-st="setup"] .dot { background: var(--bad); }
@media (max-width: 760px) { .sync-ind .txt { display: none; } .sync-ind { margin-left: auto; } .sync-ind:not(.hidden) + .menu-btn { margin-left: 6px; } }

/* Layout */
.page { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.page.wide { max-width: none; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { min-width: 0; }
.grow { flex: 1 1 auto; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 760px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0,1fr); } }
.split { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0,1fr); } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }

/* Forms */
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 9px; min-width: 0; width: 100%; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
input[type=checkbox] { width: auto; }
input.num, td input[type=number] { text-align: right; font-family: var(--mono); }

/* Buttons */
.btn { font: inherit; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 7px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 8px; font-size: 13px; }
.btn.icon { padding: 4px 8px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  padding: 6px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 4px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data td input, table.data td select { padding: 5px 6px; }
table.data tfoot td { font-weight: 700; border-bottom: none; }
table.data .r { text-align: right; }

/* Lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.list-item:hover { background: var(--surface-2); }
.list-item.active { background: var(--accent-soft); border-color: var(--accent); }
.list-item .sub { font-size: 12px; color: var(--muted); }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.bad { color: var(--bad); border-color: var(--bad); }

.stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 20px; font-weight: 700; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.note { font-size: 13px; color: var(--muted); padding: 8px 10px; border-left: 3px solid var(--border); background: var(--surface-2); border-radius: 0 6px 6px 0; }
.note.warn { border-left-color: var(--warn); }
.note.bad { border-left-color: var(--bad); color: var(--text); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 5000; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

@media print {
  .topbar, .mobile-nav, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

/* Service worker update banner */
.sw-banner { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 5001;
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.18); font-size: 14px; font-weight: 600; max-width: calc(100vw - 32px); }
