:root {
  --bg: #f4f6fb; --card: #fff; --line: #dde3ee; --text: #18243a; --muted: #5f6f87;
  --brand: #4f46e5; --brand-dark: #3f37c9; --brand-soft: #eef0ff;
  --ok: #0f8a5f; --ok-soft: #e3f6ee; --warn: #b66a00; --warn-soft: #fff3df; --bad: #c62f3d; --bad-soft: #fde8ea;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 20px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 18px 0 6px; }
code { background: #eef1f7; padding: 1px 6px; border-radius: 5px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }

/* side navbar */
:root { --side-w: 240px; --side-bg: #1b1f3b; --side-text: #c4c8e4; --side-hover: #272c52; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 1.05rem; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 30; display: flex; flex-direction: column;
  background: var(--side-bg); color: var(--side-text); padding: 18px 12px 12px; }
.side .brand { color: #fff; padding: 2px 10px 18px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 10px; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; color: #7f86b3; padding: 14px 12px 6px; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--side-text);
  font-weight: 500; font-size: .93rem; text-decoration: none; }
.side nav a.sub { font-size: .87rem; }
.side nav a:hover { background: var(--side-hover); color: #fff; }
.side nav a.on { background: var(--brand); color: #fff; }
.side svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.side-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.side-foot form { margin: 0; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--side-text); text-decoration: none; }
.me:hover, .me.on { background: var(--side-hover); text-decoration: none; }
.me strong { display: block; color: #fff; font-size: .9rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.me small { display: block; font-size: .75rem; color: #8f96c2; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: #3a3f73; color: #fff; font-weight: 700; }
.signout { display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 12px; border: 0; border-radius: 9px;
  background: none; color: var(--side-text); font: inherit; font-size: .88rem; cursor: pointer; }
.signout:hover { background: var(--side-hover); color: #fff; }
.side-shade { display: none; }
body.with-side .page { margin-left: var(--side-w); max-width: none; }
body.with-side .page > *:not(.narrow) { max-width: 1180px; }

/* top navbar (beside the side navbar) */
.topbar { position: sticky; top: 0; z-index: 20; margin-left: var(--side-w); height: 60px; display: flex; align-items: center;
  gap: 18px; padding: 0 32px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.menu-btn { display: none; border: 0; background: none; padding: 6px; cursor: pointer; color: var(--text); }
.menu-btn svg { width: 24px; height: 24px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: .92rem; min-width: 0; white-space: nowrap; }
.crumbs strong { overflow: hidden; text-overflow: ellipsis; }
.crumb-home, .crumb-sep { color: var(--muted); }
.top-search { flex: 1; max-width: 420px; margin-left: auto; position: relative; display: flex; align-items: center; }
.top-search svg { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.top-search input { padding: 8px 12px 8px 36px; border-radius: 99px; background: #f3f5fa; border-color: transparent; }
.top-search input:focus { background: #fff; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions .btn svg { width: 16px; height: 16px; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--muted); border: 1px solid var(--line); background: #fff; }
.icon-btn:hover { color: var(--brand); border-color: #c7c9ff; text-decoration: none; }
.top-user { display: flex; align-items: center; gap: 8px; padding: 3px 12px 3px 3px; border-radius: 99px; color: var(--text); font-weight: 600; font-size: .88rem; }
.top-user:hover, .top-user.on { background: var(--brand-soft); text-decoration: none; }
.top-user .avatar { width: 30px; height: 30px; background: var(--brand); font-size: .85rem; }

@media (max-width: 1100px) { .crumb-home, .crumb-sep, .top-name { display: none; } }
@media (max-width: 900px) {
  .side { transform: translateX(-100%); transition: transform .2s ease; }
  body.side-open .side { transform: none; box-shadow: 0 0 30px rgba(0,0,0,.3); }
  body.side-open .side-shade { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(15,20,40,.45); }
  .topbar { margin-left: 0; padding: 0 12px; gap: 10px; height: 56px; }
  .menu-btn { display: grid; }
  .top-search { max-width: none; }
  body.with-side .page { margin-left: 0; padding: 20px 16px 80px; }
}
@media (max-width: 600px) {
  .top-actions .btn span, .icon-btn { display: none; }
  .top-actions .btn { padding: 7px 9px; }
  .crumbs { display: none; }
}

.page { max-width: 1180px; margin: 0 auto; padding: 28px 32px 80px; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.narrow { max-width: 620px; }
.auth-card { width: 100%; max-width: 400px; text-align: left; }
.auth-card h1 { margin-top: 8px; }
.auth-logo { width: 46px; height: 46px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head-row.tight { align-items: center; margin-bottom: 6px; }
.head-row.tight h2 { margin: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }

label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; color: #34425a; margin-bottom: 12px; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--text); padding: 8px 10px; border: 1px solid #c9d1df; border-radius: 8px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c7c9ff; border-color: var(--brand); }
textarea { resize: vertical; }
input[type=checkbox] { width: auto; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.fields.two { grid-template-columns: 1fr 1fr; }
.fields .full { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.check { flex-direction: row; align-items: center; gap: 7px; font-weight: 500; margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: .9rem;
  padding: 8px 15px; border-radius: 8px; border: 1px solid #c9d1df; background: #fff; color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { background: #f3f5fa; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #f0b8bf; }
.btn.ghost { border-color: transparent; background: none; }
.btn.small { padding: 5px 10px; font-size: .82rem; }
.btn.wide { width: 100%; margin-top: 6px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--bad); }

.flash { padding: 10px 14px; border-radius: 9px; margin-bottom: 16px; font-size: .92rem; background: var(--brand-soft); }
.flash.ok { background: var(--ok-soft); color: #0b5e41; }
.flash.error { background: var(--bad-soft); color: #8c1f2a; }
.tag { padding: 1px 8px; border-radius: 99px; font-size: .82rem; font-weight: 600; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.empty { color: var(--muted); text-align: center; padding: 18px; margin: 0; }

.search { display: flex; gap: 8px; margin-bottom: 14px; max-width: 520px; }
.table-wrap { padding: 4px 6px; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.grid td { padding: 11px 12px; border-bottom: 1px solid #edf0f6; vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.grid tr.off td { opacity: .55; }
.clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { display: inline-block; width: 80px; height: 7px; background: #e8ebf3; border-radius: 9px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.meter span { display: block; height: 100%; background: var(--brand); }
form.inline { display: inline; margin: 0; }
form.inline select { width: auto; padding: 4px 8px; }
.inline-pop { display: inline-block; margin-left: 12px; }
.inline-pop summary { list-style: none; display: inline; }
.inline-pop form { display: flex; gap: 6px; margin-top: 6px; }

.jump { display: flex; flex-wrap: wrap; gap: 4px; }
.jump a { font-size: .82rem; padding: 4px 10px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--muted); }
.row-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 2px; margin: 10px 0; background: #fafbfe; }
.row-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: .9rem; }
.row-tools { display: flex; gap: 12px; }
.savebar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 12px 0;
  background: linear-gradient(transparent, var(--bg) 35%); }
.upload { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.upload label { margin: 0; flex: 1; min-width: 180px; }
.danger-zone { text-align: right; }
.device { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #edf0f6; }
.device form { margin: 0; }
.steps { padding-left: 20px; margin: 0; }
.steps li { margin-bottom: 8px; }
.search-note { margin: -6px 0 14px; color: var(--muted); font-size: .9rem; }

/* sign-in and roles */
.btn.google { background: #fff; border-color: #c9d1df; color: #1f2937; gap: 10px; padding: 10px 15px; }
.btn.google svg { width: 20px; height: 20px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .82rem; margin: 16px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.code-input { font-size: 1.5rem; letter-spacing: .4em; text-align: center; font-weight: 600; }
.code-links { display: flex; justify-content: space-between; margin-top: 12px; }
.auth-foot { margin: 18px 0 0; text-align: center; }
.auth-foot a { margin-left: 4px; }
.row-btns { display: flex; gap: 10px; margin-top: 14px; }
.role { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .76rem; font-weight: 700; vertical-align: middle; }
.role.admin { background: #fde8ea; color: #a3202e; }
.role.manager { background: #fff3df; color: #8a5000; }
.role.lead { background: #e3f0ff; color: #1d5fb0; }
.role.user { background: #e3f6ee; color: #0b6b48; }
.roles-key { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 22px; font-size: .86rem; color: #34425a; }
.roles-key > div { display: flex; gap: 10px; align-items: baseline; }
.roles-key .role { width: 72px; text-align: center; flex: none; }
@media (max-width: 900px) { .roles-key { grid-template-columns: 1fr; } }
.pw-form { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 4px; }

/* Users page: "Add a person" fields on one row */
.add-row { display: grid; grid-template-columns: 1.1fr 1.5fr .9fr 1fr auto; gap: 14px; align-items: end; }
.add-row label { margin: 0; }
.add-row label.off { opacity: .5; }
.add-row .btn { height: 39px; white-space: nowrap; }
@media (max-width: 1100px) { .add-row { grid-template-columns: 1fr 1fr; } .add-row .btn { justify-self: start; } }
@media (max-width: 600px) { .add-row { grid-template-columns: 1fr; } }
.add-row.site-row { grid-template-columns: 1.2fr 1fr 1.6fr 1.2fr auto; }
@media (max-width: 1100px) { .add-row.site-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .add-row.site-row { grid-template-columns: 1fr; } }
.formats td:first-child { width: 22%; }
.formats td:last-child { width: 34%; }
.sites { list-style: none; margin: 0; padding: 0; }
.sites li { padding: 3px 0; }
.sites li + li { border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 3px; }
.site-meta { font-size: .88rem; }
.sites .inline { display: inline; margin-left: 12px; }
.site-edit form { flex-direction: column; align-items: stretch; min-width: 280px; max-width: 420px; }
.site-edit label { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 3px 10px; border: 1px solid var(--line); border-radius: 99px; font-size: .88rem; background: var(--bg); }
.add-row.bulk-row { grid-template-columns: minmax(0, 520px) auto; justify-content: start; }
.add-row.bulk-row input[type=file] { padding: 6px; }
.sending { border-color: #c7c9ff; background: #f7f7ff; }
.meter.wide { display: block; width: 100%; height: 8px; margin: 10px 0 6px; }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); }
.confirm-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.confirm-bar .row-btns { margin: 0; }
