/* BlueRock Presence portal. Uses the tokens from /shared.css when present, with fallbacks. */
:root {
  --p-deep: var(--br-deep, #1b4332);
  --p-green: var(--br-green, #2d6a4f);
  --p-mint: var(--br-mint, #d8f3dc);
  --p-gold: var(--br-gold, #d4a843);
  --p-amber: var(--br-amber, #c98a1b);
  --p-page: var(--br-page, #f0f4f1);
  --p-text: var(--br-text, #1f2a24);
  --p-surface: var(--br-surface, #ffffff);
  --p-muted: var(--br-muted, #5b6b62);
  --p-border: var(--br-border, #c9d6cd);
  --p-danger: var(--br-danger, #b3261e);
  --p-danger-bg: var(--br-danger-bg, #fbe9e7);
  --p-radius: var(--br-radius, 12px);
  --p-shadow: var(--br-shadow, 0 2px 10px rgba(27, 67, 50, 0.12));
  --p-font: var(--br-font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  --p-mono: var(--br-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--p-font); font-size: 1rem; line-height: 1.45;
  color: var(--p-text); background: var(--p-page);
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--p-gold); outline-offset: 2px; }
h1, h2, h3 { color: var(--p-deep); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
[hidden] { display: none !important; }

/* Shell */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--p-deep); color: #fff;
}
.brand { font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.brand small { font-weight: 400; opacity: .75; margin-left: 6px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .875rem; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.menu-toggle { display: none; background: transparent; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.topbar .link-btn { white-space: nowrap; background: transparent; border: 0; color: #fff; text-decoration: underline; cursor: pointer; padding: 4px; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 52px); }
.nav { background: var(--p-surface); border-right: 1px solid var(--p-border); padding: 12px 8px; }
.nav a {
  display: block; padding: 10px 12px; border-radius: 8px; color: var(--p-text); text-decoration: none; margin-bottom: 2px;
}
.nav a:hover { background: var(--p-mint); }
.nav a.active { background: var(--p-green); color: #fff; font-weight: 600; }
.main { padding: 20px; min-width: 0; max-width: 1200px; }

.banner { background: var(--p-gold); color: var(--p-text); padding: 8px 16px; font-weight: 600; text-align: center; }

/* Cards, tiles */
.card { background: var(--p-surface); border-radius: var(--p-radius); box-shadow: var(--p-shadow); padding: 16px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--p-surface); border-radius: var(--p-radius); box-shadow: var(--p-shadow); padding: 14px 16px; border-top: 5px solid var(--p-green); }
.tile .n { font-size: 2.2rem; font-weight: 700; color: var(--p-deep); line-height: 1.1; }
.tile .l { color: var(--p-muted); font-size: .9rem; }
.tile.gold { border-top-color: var(--p-gold); }
.tile.mint { border-top-color: var(--p-mint); }
.muted { color: var(--p-muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--p-mono); }
.empty { color: var(--p-muted); padding: 8px 0; }

/* Buttons and forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  padding: 6px 14px; border-radius: 10px; border: 1px solid var(--p-green); background: var(--p-green); color: #fff;
  cursor: pointer; font-weight: 600; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--p-surface); color: var(--p-green); }
.btn.amber { background: var(--p-amber); border-color: var(--p-amber); }
.btn.danger { background: var(--p-surface); color: var(--p-danger); border-color: var(--p-danger); }
.btn.small { min-height: 32px; padding: 3px 10px; font-size: .875rem; }
.btn.big { min-height: 56px; font-size: 1.15rem; padding: 10px 22px; width: 100%; }
.btn.gold { background: var(--p-gold); border-color: var(--p-gold); color: var(--p-text); }

form.stack, .stack { display: grid; gap: 10px; }
label.field { display: grid; gap: 4px; font-size: .9rem; color: var(--p-muted); }
label.field > span { font-weight: 600; color: var(--p-text); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=url], input[type=search], input[type=tel], select, textarea {
  width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid var(--p-border); border-radius: 8px; background: #fff;
}
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; align-items: end; }
input[type=number], input[type=time] {
  min-height: 36px; padding: 4px 8px; border: 1px solid var(--p-border); border-radius: 8px; background: #fff;
}
input[type=number].num { width: 5.5em; }
/* Setup: inline edit row under the row being edited */
tr.editing td { background: var(--p-mint); }
tr.edit-row > td { background: #f7faf8; padding: 12px; }
.edit-form fieldset.aco { border: 1px solid var(--p-border); border-radius: 8px; padding: 8px 12px 10px; margin: 0; display: grid; gap: 8px; }
.edit-form fieldset.aco legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
.aco-opts { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.aco-opts label { font-size: .95rem; gap: 6px; }
.error { background: var(--p-danger-bg); color: var(--p-danger); border-radius: 8px; padding: 8px 12px; }
.ok { background: var(--p-mint); color: var(--p-deep); border-radius: 8px; padding: 8px 12px; }

/* Tables / lists */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--p-border); vertical-align: middle; font-size: .925rem; }
th { color: var(--p-muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tr.inactive td { opacity: .55; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; background: var(--p-mint); color: var(--p-deep); font-weight: 600; }
.pill.amber { background: #f6e3bf; color: #6b4708; }
.pill.red { background: var(--p-danger-bg); color: var(--p-danger); }
.pill.grey { background: #e4e8e5; color: var(--p-muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #b8c2bc; vertical-align: middle; }
.dot.on { background: #2fa36b; box-shadow: 0 0 0 3px rgba(47,163,107,.2); }
.flag { border-left: 4px solid var(--p-amber); padding: 6px 10px; margin-bottom: 6px; background: #fbf5e8; border-radius: 6px; }
.flag.unknown_face { border-left-color: var(--p-danger); background: var(--p-danger-bg); }

/* Approvals */
.reg { display: grid; grid-template-columns: 140px 1fr; gap: 14px; }
.reg img { width: 140px; height: 170px; object-fit: cover; border-radius: 10px; background: var(--p-mint); }
.reg .noimg { width: 140px; height: 170px; border-radius: 10px; background: var(--p-mint); display: grid; place-items: center; color: var(--p-muted); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(13, 31, 23, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--p-surface); border-radius: 16px; padding: 20px; width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal h2 { margin-top: 0; }
.pair-code {
  font-family: var(--p-mono); font-size: clamp(2.2rem, 11vw, 4.2rem); font-weight: 800; letter-spacing: .12em;
  text-align: center; color: var(--p-deep); background: var(--p-mint); border-radius: 14px; padding: 16px 8px; margin: 12px 0; word-break: break-all;
}
.countdown { text-align: center; font-size: 1.1rem; font-weight: 600; }
.countdown.expired { color: var(--p-danger); }
.secret { font-family: var(--p-mono); background: #f4f6f5; border: 1px dashed var(--p-border); padding: 10px; border-radius: 8px; word-break: break-all; user-select: all; }
.warn { background: #fbf0d9; border-left: 4px solid var(--p-gold); padding: 8px 12px; border-radius: 6px; }

/* Roll call */
.rollcall { max-width: 520px; margin: 0 auto; }
.rc-head { position: sticky; top: 52px; z-index: 5; background: var(--p-page); padding: 8px 0; }
.rc-remaining { font-size: 2rem; font-weight: 800; color: var(--p-deep); }
.rc-dept { margin: 14px 0 6px; color: var(--p-muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.rc-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 14px; margin-bottom: 6px;
  border: 2px solid var(--p-border); border-radius: 12px; background: var(--p-surface); text-align: left; cursor: pointer; font-size: 1.1rem;
}
.rc-item .box { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--p-green); flex: none; display: grid; place-items: center; font-weight: 800; color: #fff; }
.rc-item.done { background: var(--p-mint); border-color: var(--p-green); }
.rc-item.done .box { background: var(--p-green); }
.rc-item.done .nm { text-decoration: line-through; color: var(--p-muted); }
.rc-item .sub { font-size: .8rem; color: var(--p-muted); }

/* Login */
.login { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.login .logo { font-size: 1.6rem; font-weight: 800; color: var(--p-deep); margin-bottom: 4px; }

.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--p-deep); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: calc(100% - 32px); }
.toast.err { background: var(--p-danger); }

/* Phone */
@media (max-width: 760px) {
  .menu-toggle { display: inline-block; }
  .layout { grid-template-columns: 1fr; }
  .nav { display: none; position: fixed; top: 52px; left: 0; right: 0; bottom: 0; z-index: 30; border-right: 0; overflow: auto; }
  .nav.open { display: block; }
  .main { padding: 12px 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .tiles { gap: 8px; }
  .tile { padding: 10px; }
  .tile .n { font-size: 1.7rem; }
  .tile .l { font-size: .78rem; }
  .topbar .who, .brand small { display: none; }
  .reg { grid-template-columns: 96px 1fr; }
  .reg img, .reg .noimg { width: 96px; height: 120px; }
  table.resp thead { display: none; }
  table.resp tr { display: block; border-bottom: 1px solid var(--p-border); padding: 6px 0; }
  table.resp td { display: flex; justify-content: space-between; gap: 10px; border: 0; padding: 3px 0; }
  table.resp td::before { content: attr(data-l); color: var(--p-muted); font-size: .8rem; font-weight: 600; }
  table.resp td:empty { display: none; }
  table.resp tr.edit-row > td { display: block; }
  table.resp tr.edit-row > td::before { content: none; }
}

/* Texts: conversations as chat bubbles (team member left, BlueRock Presence right) */
.convos { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.convos .card { margin-bottom: 0; }
.thread { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.bubble { max-width: 85%; padding: 8px 12px; border-radius: 14px; overflow-wrap: anywhere; }
.bubble.in { align-self: flex-start; background: #eef2ef; border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--p-mint); border-bottom-right-radius: 4px; }
.bubble .body { white-space: pre-wrap; }
.bubble .meta { margin-top: 2px; }
.bubble .ai-read { margin-top: 4px; font-size: .85rem; }
.flag.left_company, .flag.needs_review { border-left-color: var(--p-gold); }
.flag.running_late { border-left-color: var(--p-green); background: #eef7f0; }
.flag-actions { margin-top: 6px; }
fieldset.schedule .days { gap: 4px 12px; }
fieldset.schedule .day { display: inline-flex; gap: 4px; align-items: center; }
@media (max-width: 760px) { .convos { grid-template-columns: 1fr; } .bubble { max-width: 95%; } }
/* Shifts (sql/006): day chips, Default badge, per-site sections, schedule summaries */
.pill.gold { background: #f6e7bf; color: #5c4306; }
.daychips { display: inline-flex; gap: 3px; flex-wrap: nowrap; }
.daychip { display: inline-grid; place-items: center; width: 26px; height: 22px; border-radius: 6px; font-size: .72rem; font-weight: 600;
  background: #eef1ef; color: #9aa79f; }
.daychip.on { background: var(--p-green); color: #fff; }
.shift-site + .shift-site { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--p-border); }
.shift-site h3 { margin-bottom: 6px; }
.edit-form.shift-form { background: #f7faf8; border: 1px solid var(--p-border); border-radius: 10px; padding: 12px; }
tr.edit-row .edit-form.shift-form { border: 0; padding: 0; }
.custom-sched { border-left: 3px solid var(--p-mint); padding-left: 10px; }
@media (max-width: 760px) { .daychip { width: 22px; } }
.sched { display: inline-grid; gap: 1px; }
.sched .sched-name { font-weight: 600; }
.sched .sched-when { font-size: .8rem; color: var(--p-muted); white-space: nowrap; }
.sched.default .sched-name { font-weight: 400; color: var(--p-muted); }
.sched.custom .sched-name { font-style: italic; }
@media (max-width: 760px) { .sched { text-align: right; } }
