/* ==========================================================================
   NMDB — application shell and component library
   ========================================================================== */

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sb {
  width: var(--sbw); flex: 0 0 var(--sbw);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 40;
  transition: width var(--t), flex-basis var(--t);
}
.sb-head {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid var(--line);
}
.sb-mark {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px;
  background: linear-gradient(145deg, var(--gold), var(--copper));
  display: grid; place-items: center;
  font-family: var(--ff-display); font-weight: 700; font-size: 13px; color: #1a1205;
  box-shadow: 0 3px 12px rgba(227,169,42,.28);
}
.sb-name { font-family: var(--ff-display); font-weight: 700; font-size: 15px; letter-spacing: -.3px; line-height: 1.1; }
.sb-sub  { font-size: 10px; color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; }

.sb-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px 20px; }
.sb-group { margin-bottom: 4px; }
.sb-group-t {
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-4); padding: 14px 10px 6px;
}
.sb-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  text-align: left; transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.sb-item:hover { background: var(--hl); color: var(--ink); text-decoration: none; }
.sb-item.on { background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.sb-item.on::before {
  content: ''; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--gold);
}
.sb-ico { width: 18px; flex: 0 0 18px; text-align: center; font-size: 15px; opacity: .95; }
.sb-lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-count {
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: var(--r-pill);
  background: var(--line); color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.sb-item.on .sb-count { background: var(--gold-line); color: var(--gold); }
.sb-count.alert { background: var(--crimson-soft); color: var(--crimson); }

.sb-foot { border-top: 1px solid var(--line); padding: 10px; }
.sb-user {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border-radius: var(--r-sm); transition: background var(--t-fast);
}
.sb-user:hover { background: var(--hl); }
.avatar {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
  background: var(--sky-soft); color: var(--sky); border: 1px solid var(--sky-line);
}
.avatar.sm { width: 24px; height: 24px; flex: 0 0 24px; font-size: 9.5px; }
.avatar.lg { width: 44px; height: 44px; flex: 0 0 44px; font-size: 15px; }

/* ---- Main column ---- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: var(--glass); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 35;
}
.tb-crumb { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 7px; }
.tb-crumb b { color: var(--ink); font-weight: 600; }
.tb-search {
  /* min-width:0 is load-bearing. A flex item defaults to min-width:auto, which
     is its content width, so without this the search box refuses to shrink and
     pushes the topbar wider than the viewport on a phone (ToR 2.6 item 11;
     NFR-11.4: no horizontal page scroll at any supported width). */
  flex: 0 1 380px; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 6px 11px; transition: border-color var(--t-fast);
}
.tb-search:focus-within { border-color: var(--sky); }
.tb-search input { flex: 1; min-width: 0; background: none; border: none; outline: none; font-size: 13px; }
.tb-search input::placeholder { color: var(--ink-4); }
.kbd {
  font-family: var(--ff-mono); font-size: 10px; padding: 2px 5px; border-radius: 4px;
  background: var(--line); color: var(--ink-3); border: 1px solid var(--line-2);
}

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--ink-2);
  transition: background var(--t-fast), color var(--t-fast); position: relative; font-size: 15px;
}
.icon-btn:hover { background: var(--hl); color: var(--ink); }
.icon-btn .dot {
  position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--crimson); border: 2px solid var(--surface);
}

.view { flex: 1; padding: 24px 26px 60px; max-width: var(--maxw); width: 100%; }

/* ==========================================================================
   PAGE HEADER
   ========================================================================== */
.ph { display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.ph-main { flex: 1; min-width: 260px; }
.ph-eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 6px;
}
.ph-title { font-family: var(--ff-display); font-size: 26px; font-weight: 700; letter-spacing: -.6px; line-height: 1.15; }
.ph-desc { font-size: 13.5px; color: var(--ink-2); margin-top: 6px; max-width: 76ch; line-height: 1.6; }
.ph-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.btn:hover { background: var(--surface-3); border-color: var(--line-str); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--gold), #d08f1c);
  border-color: transparent; color: #1a1205;
  box-shadow: 0 2px 12px rgba(227,169,42,.25);
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hl); color: var(--ink); }
.btn.outline { background: transparent; }
.btn.danger { background: var(--crimson-soft); border-color: var(--crimson-line); color: var(--crimson); }
.btn.danger:hover { background: var(--crimson); color: #fff; border-color: transparent; }
.btn.ok { background: var(--jade-soft); border-color: var(--jade-line); color: var(--jade); }
.btn.ok:hover { background: var(--jade); color: #04120d; border-color: transparent; }
.btn.sky { background: var(--sky-soft); border-color: var(--sky-line); color: var(--sky); }
.btn.sky:hover { background: var(--sky); color: #04101f; border-color: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: var(--r-xs); }
.btn.lg { padding: 11px 20px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn.icon { padding: 7px; width: 32px; }

.btn-group { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-sm); overflow: hidden; }
.btn-group .btn { border: none; border-radius: 0; background: transparent; }
.btn-group .btn + .btn { border-left: 1px solid var(--line-2); }
.btn-group .btn.on { background: var(--gold-soft); color: var(--gold); }

/* ==========================================================================
   CARDS / PANELS
   ========================================================================== */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-1);
}
.card.solid { background: var(--card-solid); }
.card.pad { padding: 18px; }
.card-h {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card-t { font-family: var(--ff-display); font-size: 14.5px; font-weight: 600; letter-spacing: -.2px; }
.card-d { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.card-b { padding: 18px; }
.card-b.flush { padding: 0; }
.card-f { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--hl); font-size: 12px; color: var(--ink-3); }

.grid { display: grid; gap: 16px; }
/* Flex and grid children default to min-width:auto and therefore refuse to
   shrink below their content. Every layout wrapper the modules compose with
   opts out, so a wide table or chart scrolls inside its own card instead of
   widening the page. */
.col, .row, .grow, .card, .card-b { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
.g-3-2 { grid-template-columns: 3fr 2fr; }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.g-auto-lg { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }

/* ==========================================================================
   STAT TILES
   ========================================================================== */
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 16px; position: relative; overflow: hidden;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.stat:hover { border-color: var(--line-2); }
.stat-lbl {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); display: flex; align-items: center; gap: 6px; margin-bottom: 9px;
}
.stat-val {
  font-family: var(--ff-display); font-size: 27px; font-weight: 700;
  letter-spacing: -1px; line-height: 1; color: var(--ink);
}
.stat-val small { font-size: 14px; font-weight: 600; color: var(--ink-2); letter-spacing: 0; margin-left: 3px; }
.stat-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 7px; display: flex; align-items: center; gap: 6px; }
.stat-spark { position: absolute; right: 0; bottom: 0; opacity: .5; pointer-events: none; }
.delta { font-weight: 700; font-size: 11.5px; display: inline-flex; align-items: center; gap: 2px; }
.delta.up { color: var(--jade); } .delta.down { color: var(--crimson); } .delta.flat { color: var(--ink-3); }

/* ==========================================================================
   BADGES / PILLS / STATUS
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  border: 1px solid transparent; line-height: 1.6;
}
.badge.gold   { background: var(--gold-soft);   color: var(--gold);   border-color: var(--gold-line); }
.badge.jade   { background: var(--jade-soft);   color: var(--jade);   border-color: var(--jade-line); }
.badge.sky    { background: var(--sky-soft);    color: var(--sky);    border-color: var(--sky-line); }
.badge.violet { background: var(--violet-soft); color: var(--violet); border-color: var(--violet-line); }
.badge.copper { background: var(--copper-soft); color: var(--copper); border-color: var(--copper-line); }
.badge.crimson{ background: var(--crimson-soft);color: var(--crimson);border-color: var(--crimson-line); }
.badge.grey   { background: var(--line);        color: var(--ink-2);  border-color: var(--line-2); }
.badge.solid-crimson { background: var(--crimson); color: #fff; border-color: transparent; }
.badge.solid-jade    { background: var(--jade); color: #04120d; border-color: transparent; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* RCM mine-site classification — the four-colour scheme is normative */
.rcm { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 11.5px; }
.rcm-chip { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.rcm-GREEN  .rcm-chip { background: var(--jade); }    .rcm-GREEN  { color: var(--jade); }
.rcm-YELLOW .rcm-chip { background: var(--gold); }    .rcm-YELLOW { color: var(--gold); }
.rcm-RED    .rcm-chip { background: var(--crimson); } .rcm-RED    { color: var(--crimson); }
.rcm-BLUE   .rcm-chip { background: var(--sky); }     .rcm-BLUE   { color: var(--sky); }

/* ==========================================================================
   TABLES
   ========================================================================== */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl thead th {
  text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--line-2);
  background: var(--hl); white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
table.tbl thead th.sortable { cursor: pointer; user-select: none; }
table.tbl thead th.sortable:hover { color: var(--ink); }
table.tbl thead th .sort-ind { opacity: .45; margin-left: 4px; font-size: 9px; }
table.tbl tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr { transition: background var(--t-fast); }
table.tbl tbody tr:hover { background: var(--hl); }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tbody tr.sel { background: var(--gold-soft); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl td.num, table.tbl th.num { text-align: right; }
table.tbl tfoot td { padding: 10px 12px; border-top: 1px solid var(--line-2); font-weight: 700; background: var(--hl); }
table.tbl.compact tbody td, table.tbl.compact thead th { padding: 6px 10px; font-size: 12.5px; }

.tbl-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
}
.tbl-pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3);
}

/* ==========================================================================
   FORM CONTROLS
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .lbl {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3);
}
.field .hint { font-size: 11.5px; color: var(--ink-4); }
.field .err  { font-size: 11.5px; color: var(--crimson); }
.req::after { content: ' *'; color: var(--crimson); }

.inp, select.inp, textarea.inp {
  width: 100%; padding: 8px 11px; font-size: 13px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.inp:focus, select.inp:focus, textarea.inp:focus { border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-soft); }
.inp::placeholder { color: var(--ink-4); }
.inp:disabled, .inp[readonly] { opacity: .6; cursor: not-allowed; background: var(--hl); }
.inp.invalid { border-color: var(--crimson); }
textarea.inp { min-height: 84px; resize: vertical; line-height: 1.55; }
select.inp { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 15px) 51%, calc(100% - 10px) 51%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.inp-group { display: flex; }
.inp-group .inp { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.inp-group .addon {
  display: grid; place-items: center; padding: 0 11px; font-size: 12px; font-weight: 600; color: var(--ink-3);
  background: var(--surface-3); border: 1px solid var(--line-2); border-left: none; border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--gold); width: 15px; height: 15px; }

.switch { position: relative; width: 36px; height: 20px; flex: 0 0 36px; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--line-2);
  transition: background var(--t); pointer-events: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform var(--t); box-shadow: var(--shadow-1);
}
.switch input:checked ~ .track { background: var(--jade); }
.switch input:checked ~ .track::after { transform: translateX(16px); }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button {
  padding: 5px 11px; border-radius: var(--r-xs); font-size: 12px; font-weight: 600; color: var(--ink-3);
  transition: background var(--t-fast), color var(--t-fast);
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface-3); color: var(--ink); box-shadow: var(--shadow-1); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 16px; }
.form-grid .span2 { grid-column: 1 / -1; }

/* ==========================================================================
   TABS
   ========================================================================== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--ink-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--gold); border-bottom-color: var(--gold); }
.tab .n { font-size: 10.5px; margin-left: 5px; padding: 1px 5px; border-radius: var(--r-pill); background: var(--line); color: var(--ink-3); }

/* ==========================================================================
   MODAL / DRAWER
   ========================================================================== */
.ovl {
  position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(3px);
  z-index: 100; display: flex; align-items: center; justify-content: center; padding: 22px;
  animation: fade .16s var(--ease);
}
.modal {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); width: 100%; max-width: 560px; max-height: 88vh;
  display: flex; flex-direction: column; animation: pop .2s var(--ease);
}
.modal.wide { max-width: 860px; }
.modal.xwide { max-width: 1160px; }
.modal.narrow { max-width: 420px; }
.modal-h { display: flex; align-items: flex-start; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-t { font-family: var(--ff-display); font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.modal-d { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.modal-b { padding: 20px; overflow-y: auto; flex: 1; }
.modal-f { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--hl); flex-wrap: wrap; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 94vw);
  background: var(--surface); border-left: 1px solid var(--line-2); box-shadow: var(--shadow-3);
  z-index: 100; display: flex; flex-direction: column; animation: slide-in .22s var(--ease);
}
.drawer.wide { width: min(880px, 96vw); }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985) } to { opacity: 1; transform: none } }
@keyframes slide-in { from { transform: translateX(26px); opacity: .4 } to { transform: none; opacity: 1 } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
.rise { animation: rise .26s var(--ease) both; }
.rise-1{animation-delay:.03s}.rise-2{animation-delay:.06s}.rise-3{animation-delay:.09s}.rise-4{animation-delay:.12s}

/* ==========================================================================
   TOAST
   ========================================================================== */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 9px; align-items: flex-end; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 420px;
  padding: 12px 15px; border-radius: var(--r); font-size: 13px;
  background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: var(--shadow-3);
  animation: rise .22s var(--ease);
}
.toast .ti { font-size: 15px; line-height: 1.2; }
.toast.ok    { border-left: 3px solid var(--jade); }
.toast.err   { border-left: 3px solid var(--crimson); }
.toast.warn  { border-left: 3px solid var(--gold); }
.toast.info  { border-left: 3px solid var(--sky); }
.toast .tt { font-weight: 600; }
.toast .td { color: var(--ink-2); font-size: 12px; margin-top: 2px; }

/* ==========================================================================
   TIMELINE / LEDGER
   ========================================================================== */
.tl { position: relative; padding-left: 26px; }
.tl::before { content: ''; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--line-2); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -22px; top: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--ink-3); z-index: 1;
}
.tl-dot.gold { border-color: var(--gold); background: var(--gold); }
.tl-dot.jade { border-color: var(--jade); background: var(--jade); }
.tl-dot.sky  { border-color: var(--sky);  background: var(--sky); }
.tl-dot.crimson { border-color: var(--crimson); background: var(--crimson); }
.tl-dot.violet { border-color: var(--violet); background: var(--violet); }
.tl-t { font-size: 13.5px; font-weight: 600; }
.tl-m { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.tl-body { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }

/* Hash chain link styling */
.hashlink {
  font-family: var(--ff-mono); font-size: 10.5px; color: var(--ink-4);
  display: inline-flex; align-items: center; gap: 4px;
}
.hashlink b { color: var(--jade); font-weight: 600; }
.hashlink.broken b { color: var(--crimson); }

/* ==========================================================================
   MISC
   ========================================================================== */
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 8px 18px; font-size: 13px; }
.kv dt { color: var(--ink-3); font-size: 12px; }
.kv dd { color: var(--ink); font-weight: 500; }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty .ei { font-size: 34px; opacity: .35; margin-bottom: 10px; }
.empty .et { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.empty .ed { font-size: 12.5px; margin-top: 5px; }

.bar { height: 6px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--gold); transition: width .5s var(--ease); }
.bar.jade > i { background: var(--jade); } .bar.crimson > i { background: var(--crimson); }
.bar.sky > i { background: var(--sky); } .bar.violet > i { background: var(--violet); }

.note {
  display: flex; gap: 11px; padding: 12px 14px; border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.6;
  background: var(--sky-soft); border: 1px solid var(--sky-line); color: var(--ink-2);
}
.note b { color: var(--ink); }
.note.warn { background: var(--gold-soft); border-color: var(--gold-line); }
.note.err  { background: var(--crimson-soft); border-color: var(--crimson-line); }
.note.ok   { background: var(--jade-soft); border-color: var(--jade-line); }
.note .ni { font-size: 15px; flex: 0 0 auto; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 11.5px; color: var(--ink-2); }
.legend i { width: 9px; height: 9px; border-radius: 2.5px; display: inline-block; margin-right: 5px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--line-2); font-size: 11.5px; font-weight: 500; color: var(--ink-2);
  transition: border-color var(--t-fast), color var(--t-fast);
}
.chip.on, .chip:hover { border-color: var(--gold-line); color: var(--gold); background: var(--gold-soft); }
.chip .x { opacity: .55; font-size: 13px; }

.divider { height: 1px; background: var(--line); margin: 18px 0; }
.vr { width: 1px; align-self: stretch; background: var(--line); }

.scroll-x { overflow-x: auto; }
.scroll-y { overflow-y: auto; }
.maxh-300 { max-height: 300px; } .maxh-420 { max-height: 420px; } .maxh-560 { max-height: 560px; }

/* Mine-site map canvas */
.map-wrap { position: relative; background: var(--surface-2); border-radius: var(--r); overflow: hidden; }
.map-wrap svg { width: 100%; height: auto; }
.map-pt { cursor: pointer; transition: r .15s var(--ease); }
.map-pt:hover { stroke: var(--ink); stroke-width: 2; }
.map-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface-3); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 8px 11px; font-size: 12px; box-shadow: var(--shadow-2); min-width: 160px;
}

/* Offline / sync indicator */
.sync-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600; border: 1px solid;
}
.sync-pill.online  { background: var(--jade-soft); color: var(--jade); border-color: var(--jade-line); }
.sync-pill.offline { background: var(--copper-soft); color: var(--copper); border-color: var(--copper-line); }
.sync-pill.syncing { background: var(--sky-soft); color: var(--sky); border-color: var(--sky-line); }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
.mobnav { display: none; }

@media (max-width: 1180px) {
  .g4, .g5, .g6 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  /* minmax(0,1fr), not 1fr: a bare 1fr track still floors at the content's
     min-content width, so a wide card blows the grid out past the viewport
     (ToR 2.6 item 11; NFR-11.4). */
  .g-2-1, .g-1-2, .g-3-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  html { font-size: 14.5px; }
  .sb { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform var(--t); box-shadow: var(--shadow-3); }
  .sb.open { transform: none; }
  .view { padding: 18px 15px calc(var(--mobnav-h) + 40px); }
  .g2, .g3, .g4, .g5, .g6 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid { grid-template-columns: minmax(0,1fr); }   /* not 1fr; see the note above */
  .tb-search { flex: 1; }
  .mobnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: var(--mobnav-h);
    background: var(--glass); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
    z-index: 45; padding: 0 6px;
  }
  .mobnav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 9.5px; font-weight: 600; color: var(--ink-3);
  }
  .mobnav button .mi { font-size: 17px; }
  .mobnav button.on { color: var(--gold); }
  .ph-title { font-size: 21px; }
  .modal, .drawer { max-width: 100%; width: 100%; }
  .drawer { width: 100%; }
}
/* ==========================================================================
   TOUCH TARGETS AND LEGIBILITY ON SMALL SCREENS
   SRS NFR-14.4 puts the field client at 44x44 CSS px minimum, because the
   inspector using it is outdoors, one-handed and often wearing gloves. The
   desktop sizes are deliberately dense and do not meet that, so they are
   raised here rather than compromised everywhere. The smallest captions are
   lifted off 10px at the same time: a label that cannot be read in daylight
   is not a label.
   ========================================================================== */
@media (max-width: 900px) {
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn.sm { min-height: 40px; padding: 9px 14px; font-size: 13px; }
  .icon-btn { width: 44px; height: 44px; font-size: 17px; }
  /* Select by element as well as by class: the table toolbar search carries no
     .inp class and was landing at 31x16. */
  .inp, select.inp, textarea.inp,
  input[type="text"], input[type="search"], input[type="number"],
  input[type="date"], input[type="datetime-local"], input[type="password"],
  select, textarea { min-height: 44px; font-size: 16px; }
  /* 16px on inputs is not a style choice: iOS Safari zooms the viewport when a
     focused field is smaller, which breaks the layout mid-entry. */
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  .check { min-height: 44px; display: flex; align-items: center; gap: 9px; }
  .sb-item { min-height: 44px; }
  .chip, .badge { min-height: 28px; display: inline-flex; align-items: center; }

  .sb-sub, .sb-group-t, .card-d, .ph-eyebrow { font-size: 11.5px; }
  .sb-count, .kbd { font-size: 11px; }
  .tbl { font-size: 13px; }

  /* The toolbar wraps, but its search still competed with the filters and
     export button for one row and was crushed to 16px wide. Give it its own
     line and let the controls below it share the next one. */
  .tbl-toolbar { gap: 8px; }
  .tbl-toolbar > input[type="search"],
  .tbl-toolbar > .inp[type="search"] { flex: 1 0 100%; min-width: 0; }
  .tbl-toolbar > select, .tbl-toolbar > .btn { flex: 1 1 auto; }
}

@media (max-width: 560px) {
  .g2, .g3, .g4, .g5, .g6, .g-auto, .g-auto-lg { grid-template-columns: minmax(0, 1fr); }
  .stat-val { font-size: 23px; }
  /* Reclaim topbar width on a phone: the breadcrumb is redundant with the page
     heading, and a keyboard-shortcut hint is meaningless on a touch device. */
  .topbar { padding: 0 12px; gap: 8px; }
  .tb-crumb { display: none; }
  /* Once the icon buttons are at their 44px touch size there is no room left
     for an inline global search, and squeezing it leaves a 31px stub nobody
     can type in. Drop it here: every list keeps its own search in the table
     toolbar, which is where a phone user is actually looking. */
  .tb-search { display: none; }
  .ovl { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 94vh; border-radius: var(--r-lg) var(--r-lg) 0 0; }
}

/* ==========================================================================
   PRINT
   ========================================================================== */
@media print {
  .sb, .topbar, .mobnav, .ph-actions, .tbl-toolbar, .tbl-pager, .toast-wrap, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .view { padding: 0; max-width: none; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  table.tbl thead th { background: #f2f2f2; color: #000; }
  a { color: #000; text-decoration: none; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
