/* =========================================================================
   FH Inspection Portal — design system
   Aesthetic: hi-vis industrial operations console.
   Charcoal/steel chrome · safety-amber accent · IBM Plex type · dense data.
   No build step — plain CSS variables, easy to maintain.
   ========================================================================= */

:root {
  /* Brand / chrome */
  --steel-900: #14171c;
  --steel-800: #1c2128;
  --steel-700: #272d36;
  --steel-600: #353d49;
  --steel-500: #4a5462;
  --steel-300: #9aa4b2;

  /* Surfaces */
  --bg:        #eef1f4;
  --surface:   #ffffff;
  --surface-2: #f6f8fa;
  --line:      #dde3ea;
  --ink:       #1c2128;
  --ink-soft:  #5b6675;

  /* Safety accent */
  --amber:      #f2a900;
  --amber-700:  #c98a00;
  --amber-tint: #fff4d6;

  /* Semantic status */
  --done:      #1f8a4c;
  --done-bg:   #e3f4ea;
  --due:       #b9852b;
  --due-bg:    #fbedcf;
  --overdue:   #c0392b;
  --overdue-bg:#fbe3df;
  --note:      #2d6cdf;
  --note-bg:   #e8f0fe;

  --radius: 9px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20,23,28,.06), 0 6px 22px rgba(20,23,28,.07);
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---- App shell ---------------------------------------------------------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--steel-900);
  color: #cdd4dd;
  display: flex; flex-direction: column;
  border-right: 3px solid var(--amber);
  position: sticky; top: 0; height: 100vh;
}
.brand {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--steel-700);
  display: flex; align-items: center; gap: 11px;
}
.brand .mark {
  width: 34px; height: 34px; border-radius: 7px; flex: none;
  background: repeating-linear-gradient(45deg, var(--amber) 0 8px, var(--steel-900) 8px 16px);
  border: 2px solid var(--amber);
}
.brand b { color: #fff; font-weight: 600; letter-spacing: .2px; font-size: 14px; display: block; }
.brand small { color: var(--steel-300); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav .label {
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--steel-500); padding: 14px 12px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm); color: #c2cad4;
  font-size: 13.5px; margin-bottom: 2px;
}
.nav a:hover { background: var(--steel-700); color: #fff; }
.nav a.active { background: var(--steel-700); color: #fff; box-shadow: inset 3px 0 0 var(--amber); }
.nav .dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }

.who {
  padding: 12px 16px; border-top: 1px solid var(--steel-700);
  font-size: 12px; color: var(--steel-300);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.who b { color: #fff; display: block; font-size: 12.5px; }
.who .role-tag {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--amber);
}
.who form { margin: 0; }
.who-actions { display: flex; align-items: center; gap: 6px; }
.who-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  color: var(--steel-300); background: transparent;
  border: 1px solid var(--steel-700); border-radius: var(--radius-sm);
  cursor: pointer;
}
.who-ic svg { width: 16px; height: 16px; }
.who-ic:hover { color: #fff; background: var(--steel-700); border-color: var(--steel-600); }
.who-ic:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

/* ---- Main --------------------------------------------------------------- */
.main { min-width: 0; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 16px 28px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.mobile-logout { display: none; margin: 0; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; letter-spacing: -.01em; }
.topbar .crumb { font-size: 12px; color: var(--ink-soft); font-family: var(--mono); margin-bottom: 2px; }
.content { padding: 24px 28px 56px; max-width: 1280px; }

/* ---- Cards / stats ------------------------------------------------------ */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .n { font-size: 28px; font-weight: 600; font-family: var(--mono); letter-spacing: -.02em; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin-top: 2px; }
.stat.alert .n { color: var(--overdue); }

.site-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(320px,1fr)); gap: 16px; }
.site-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
}
.site-card .head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.site-card .head h3 { margin: 0 0 2px; font-size: 16px; }
.site-card .head .sub { font-size: 12px; color: var(--ink-soft); }
.site-card .metrics { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.site-card .metrics div { flex: 1; padding: 12px 14px; text-align: center; border-right: 1px solid var(--line); }
.site-card .metrics div:last-child { border-right: none; }
.site-card .metrics .n { font-size: 20px; font-weight: 600; font-family: var(--mono); }
.site-card .metrics .k { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); }
.site-card .cats { padding: 12px 18px 16px; }
.cat-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-top: 8px; background: var(--surface-2); font-weight: 500;
  transition: border-color .12s, transform .12s;
}
.cat-link:first-child { margin-top: 0; }
.cat-link:hover { border-color: var(--amber); transform: translateX(2px); }
.cat-link .go { font-family: var(--mono); color: var(--amber-700); font-size: 12px; }

/* ---- Schedule grid ------------------------------------------------------ */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.year-pick { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.year-pick a { padding: 7px 13px; font-family: var(--mono); font-size: 13px; background: var(--surface); }
.year-pick a.active { background: var(--steel-800); color: #fff; }
.year-pick a:hover:not(.active) { background: var(--surface-2); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; font-size: 12px; align-items: center; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.swatch { width: 16px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.12); }
.swatch.due { background: var(--due-bg); border-color: var(--due); }
.swatch.done { background: var(--done-bg); }
.swatch.overdue { background: var(--overdue-bg); border-color: var(--overdue); }

.grid-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table.schedule { border-collapse: collapse; width: 100%; font-size: 12.5px; min-width: 900px; }
table.schedule th, table.schedule td { border-bottom: 1px solid var(--line); }
table.schedule thead th {
  background: var(--steel-800); color: #e7ebf0; position: sticky; top: 0;
  font-weight: 500; font-size: 11px; letter-spacing: .04em; padding: 10px 8px;
  text-align: center; border-bottom: 2px solid var(--amber);
}
table.schedule thead th.l { text-align: left; }
.col-el { width: 70px; }
.col-act { min-width: 320px; }
.col-freq, .col-resp { width: 92px; }
table.schedule td { padding: 9px 8px; vertical-align: top; }
table.schedule tbody tr { cursor: pointer; }
table.schedule tbody tr:hover { background: var(--surface-2); }
.el-no { font-family: var(--mono); font-weight: 600; font-size: 12px; }
.act { line-height: 1.4; }
.act .more { color: var(--ink-soft); }
.pill {
  display: inline-block; font-size: 10.5px; font-family: var(--mono);
  padding: 2px 7px; border-radius: 20px; background: var(--surface-2);
  border: 1px solid var(--line); white-space: nowrap;
}
.pill.resp-powerage { background: var(--amber-tint); border-color: var(--amber); color: var(--amber-700); }

.mcell { width: 30px; text-align: center; padding: 0 !important; border-left: 1px solid var(--line); }
.mcell .cell {
  height: 38px; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 600; font-size: 13px; position: relative;
}
.mcell .cell.done    { background: var(--done-bg); color: var(--done); }
.mcell .cell.due     { background: var(--due-bg); }
.mcell .cell.overdue { background: var(--overdue-bg); color: var(--overdue); }
.note-dot {
  position: absolute; top: 3px; right: 3px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--note); box-shadow: 0 0 0 1.5px var(--surface);
}

.zones { display: flex; flex-wrap: wrap; gap: 7px; margin: 4px 0 18px; }
.zone-chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px;
  padding: 5px 11px 5px 8px; border-radius: 20px; background: var(--surface);
  border: 1px solid var(--line);
}
.zone-chip .sw { width: 11px; height: 11px; border-radius: 50%; flex: none; }

/* ---- Slide-in panel ----------------------------------------------------- */
.panel-overlay {
  position: fixed; inset: 0; background: rgba(20,23,28,.45);
  display: flex; justify-content: flex-end; z-index: 40;
}
.panel {
  width: min(560px, 94vw); background: var(--surface); height: 100%;
  box-shadow: -8px 0 30px rgba(0,0,0,.2); overflow-y: auto;
  animation: slidein .22s ease-out;
}
@keyframes slidein { from { transform: translateX(28px); opacity: .4; } to { transform: none; opacity: 1; } }
.panel .ph { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; position: sticky; top: 0; background: var(--surface); }
.panel .ph h2 { margin: 0; font-size: 16px; }
.panel .ph .x { cursor: pointer; font-size: 22px; color: var(--ink-soft); line-height: 1; background: none; border: none; }
.panel .pb { padding: 20px 22px; }
.panel .meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; margin-bottom: 18px; }
.panel .meta dt { color: var(--ink-soft); }
.panel .meta dd { margin: 0; font-weight: 500; }
.sec-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 18px 0 8px; }
.rec { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; margin-bottom: 8px; }
.rec .rh { display: flex; justify-content: space-between; align-items: center; }
.rec .date { font-family: var(--mono); font-size: 12.5px; }
.doc { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 6px; font-size: 13px; }
.doc .ic { width: 26px; height: 26px; border-radius: 5px; background: var(--amber-tint); border: 1px solid var(--amber); display: grid; place-items: center; font-size: 11px; font-family: var(--mono); color: var(--amber-700); flex: none; }
.doc .acts { margin-left: auto; display: flex; gap: 6px; }

.status-tag { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; padding: 2px 8px; border-radius: 20px; letter-spacing: .04em; }
.status-tag.done { background: var(--done-bg); color: var(--done); }
.status-tag.due { background: var(--due-bg); color: var(--due); }
.status-tag.overdue { background: var(--overdue-bg); color: var(--overdue); }

.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 500; font-family: var(--sans); }
.btn:hover { border-color: var(--steel-500); }
.btn.amber { background: var(--amber); border-color: var(--amber-700); color: var(--steel-900); }
.btn.amber:hover { background: var(--amber-700); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12px; }

.empty { text-align: center; color: var(--ink-soft); padding: 50px 20px; }
.banner { background: var(--amber-tint); border: 1px solid var(--amber); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 18px; }
.readonly-note { font-size: 12px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }

/* ---- Login -------------------------------------------------------------- */
.login-screen {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(242,169,0,.10), transparent),
    var(--steel-900);
  padding: 24px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card .top { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-card .top .mark {
  width: 42px; height: 42px; border-radius: 9px; flex: none;
  background: repeating-linear-gradient(45deg, var(--amber) 0 9px, var(--steel-900) 9px 18px);
  border: 2px solid var(--amber);
}
.login-card .top b { color: #fff; font-size: 17px; display: block; }
.login-card .top small { color: var(--steel-300); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.login-box { background: var(--surface); border-radius: 12px; padding: 26px 24px; box-shadow: 0 18px 50px rgba(0,0,0,.4); }
.login-box h1 { font-size: 17px; margin: 0 0 4px; }
.login-box p.hint { color: var(--ink-soft); font-size: 13px; margin: 0 0 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; }
.field input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 14px; font-family: var(--sans); }
.field input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-tint); }
.login-box .btn.amber { width: 100%; justify-content: center; margin-top: 6px; padding: 12px; }
.err { background: var(--overdue-bg); color: var(--overdue); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.seed-hint { margin-top: 18px; font-size: 12px; color: var(--steel-300); text-align: center; line-height: 1.7; }
.seed-hint code { background: rgba(255,255,255,.08); padding: 1px 6px; border-radius: 4px; font-family: var(--mono); color: var(--amber); }

/* ---- Responsive (mobile / tablet) -------------------------------------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; height: auto; width: 100%;
    flex-direction: row; border-right: none; border-top: 3px solid var(--amber);
    z-index: 30; overflow-x: auto;
  }
  .brand, .who, .nav .label { display: none; }
  .nav { display: flex; padding: 6px; flex: 1; }
  .nav a { flex-direction: column; font-size: 10.5px; gap: 4px; padding: 8px 12px; white-space: nowrap; }
  .nav a.active { box-shadow: inset 0 3px 0 var(--amber); }
  .content { padding: 18px 16px 90px; }
  .topbar { padding: 14px 16px; }
  .mobile-logout { display: inline-flex; }
}

/* Django-rendered auth inputs */
#id_username, #id_password,
.login-box input[type=text], .login-box input[type=password], .login-box input[type=email],
.card .field input[type=password], .card .field input[type=text] { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 14px; font-family: var(--sans); }
#id_username:focus, #id_password:focus,
.login-box input:focus, .card .field input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-tint); }
.field { margin-bottom: 12px; }

/* ---- Phase 2: builder + forms ------------------------------------------ */
.msgs { margin-bottom: 16px; }
.msg { padding: 9px 13px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 8px; border: 1px solid var(--line); background: var(--surface); }
.msg.success { background: var(--done-bg); border-color: var(--done); color: var(--done); }
.msg.error { background: var(--overdue-bg); border-color: var(--overdue); color: var(--overdue); }

.builder-grid { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
@media (max-width: 1024px) { .builder-grid { grid-template-columns: 1fr; } }

.side .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.side .card h3 { margin: 0 0 12px; font-size: 15px; }

.fl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin: 10px 0 4px; }
.inp, select.inp, textarea.inp, input.inp {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 13px; font-family: var(--sans); background: var(--surface);
}
.inp:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-tint); }
textarea.inp { resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 12px; }
.chk input { width: auto; }
.formbtns { display: flex; gap: 8px; margin-top: 14px; }
.hint { font-size: 11.5px; color: var(--ink-soft); margin: 10px 0 0; line-height: 1.5; }

table.schedule.build tbody tr { cursor: default; }
table.schedule.build tbody tr.editing { background: var(--amber-tint); }
table.schedule.build td { vertical-align: middle; }
.movebtns { display: inline-flex; flex-direction: column; gap: 2px; }
.movebtns form { margin: 0; line-height: 0; }
.mv { border: 1px solid var(--line); background: var(--surface); border-radius: 4px; width: 22px; height: 18px; cursor: pointer; font-size: 9px; color: var(--ink-soft); padding: 0; }
.mv:hover:not(:disabled) { border-color: var(--amber); color: var(--amber-700); }
.mv:disabled { opacity: .3; cursor: default; }
.btn.danger { color: var(--overdue); border-color: var(--overdue-bg); }
.btn.danger:hover { background: var(--overdue-bg); border-color: var(--overdue); }
table.schedule.build form { display: inline; margin: 0; }

/* recording controls in the panel */
.rec-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.rec-actions.complete { flex-direction: column; align-items: stretch; gap: 8px; background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 10px; }
.cf { display: flex; align-items: center; gap: 8px; }
.cf label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); white-space: nowrap; }

/* panel view dropdown */
.panel-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 8px; }
.view-pick { max-width: 180px; font-size: 12px; padding: 6px 8px; }
.mcell { cursor: pointer; }
.mcell:hover .cell { outline: 2px solid var(--amber); outline-offset: -2px; }

/* ---- Phase 3: documents + COES ----------------------------------------- */
.nav a.subnav { padding: 6px 12px 6px 30px; font-size: 12.5px; color: #aeb7c2; margin-bottom: 1px; }
.nav a.subnav:hover { background: var(--steel-700); color: #fff; }
.nav a.subnav.active { background: var(--steel-700); color: #fff; box-shadow: inset 3px 0 0 var(--amber); }
.nav .dot.tiny { width: 5px; height: 5px; border-radius: 50%; background: var(--steel-500); }
.ic-inline { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 5px;
  background: var(--amber-tint); border: 1px solid var(--amber); font-size: 10px; font-family: var(--mono);
  color: var(--amber-700); margin-right: 8px; vertical-align: middle; }
.fname { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); margin-top: 3px; }

/* ---- Phase 4: digitised registers -------------------------------------- */
.entry-choice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px; margin-bottom: 10px; background: var(--amber-tint);
  border: 1px solid var(--amber); border-radius: var(--radius); }
.entry-choice .orsep { font-family: var(--mono); font-size: 11px; color: var(--amber-700);
  text-transform: uppercase; letter-spacing: .08em; }
.entry-choice-label { font-size: 12px; color: var(--ink-soft); }

.doc.draft { background: #f4f6f9; border-style: dashed; }
.ic.reg { background: var(--steel-700); color: var(--amber); }

.reg-create-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px; margin-top: 14px; }
.reg-create-grid .card { display: flex; flex-direction: column; gap: 8px; }
.reg-create-grid .card h3 { margin: 0; font-size: 14px; }
.reg-create-grid .inp { width: 100%; }

.attest { margin-bottom: 12px; }
.attest-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.reg-toolbar { display: flex; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.reg-table { font-size: 12px; }
.reg-table th.rownum, .reg-table td.rownum { width: 28px; text-align: right;
  font-family: var(--mono); color: var(--ink-soft); }
.reg-table th.rowacts, .reg-table td.rowacts { white-space: nowrap; width: 1%; }
.reg-table td .cell { width: 100%; min-width: 90px; padding: 4px 6px; font-size: 12px; }
.reg-table td .cell.inp { margin: 0; }

/* ---- Phase 4 follow-up: complete-on-issue + clone row + grid marker ----- */
.gen-group { display: inline-flex; align-items: center; gap: 10px;
  background: var(--amber-tint); border: 1px solid var(--amber);
  border-radius: var(--radius); padding: 6px 10px; }
.chk.inline { margin-top: 0; font-size: 12.5px; white-space: nowrap; }
.formbtns { flex-wrap: wrap; align-items: center; }

/* "REG" badge on schedule rows that support in-app register entry */
.reg-badge { display: inline-block; margin-left: 6px; padding: 1px 5px;
  font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: .05em;
  color: var(--steel-900); background: var(--amber); border-radius: 3px;
  vertical-align: middle; text-transform: uppercase; }

/* ---- Phase 5a: notes timeline ------------------------------------------- */
.note-chip {
  display: inline-block; margin-top: 6px; padding: 2px 9px; cursor: pointer;
  font-size: 11.5px; font-weight: 600; color: var(--note);
  background: var(--note-bg); border: 1px solid var(--note);
  border-radius: 999px; text-decoration: none;
}
.note-chip:hover { background: var(--note); color: #fff; }
.notes { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.note-thread { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.note {
  background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--note); border-radius: var(--radius-sm); padding: 8px 10px;
}
.note-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.note-who { font-weight: 600; font-size: 12px; color: var(--ink); }
.note-when { font-size: 11px; color: var(--ink-soft); font-family: var(--mono); }
.note-del {
  margin-left: auto; border: none; background: none; cursor: pointer;
  color: var(--ink-soft); font-size: 15px; line-height: 1; padding: 0 2px;
}
.note-del:hover { color: var(--overdue); }
.note-body { font-size: 13px; color: var(--ink); white-space: pre-wrap; }
.note-empty { font-size: 12.5px; color: var(--ink-soft); font-style: italic; }
.note-add { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.note-add textarea { width: 100%; resize: vertical; }

/* ===================================================================== */
/* Phase 5c — notifications, lock-out, settings                           */
/* ===================================================================== */

/* --- notify checkbox row (completion forms + settings) --- */
.notify-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--ink-soft);
  margin: 8px 0; cursor: pointer;
}
.notify-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--amber); }
.notify-row.big { font-size: 14px; color: var(--ink); font-weight: 600; }

/* --- lock badge on a record --- */
.lock-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-family: var(--mono);
  background: var(--surface-2); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 3px 8px; margin: 6px 0;
}
.lock-badge.other { background: var(--due-bg); color: var(--due); border-color: var(--due); }
.lock-badge .lk { font-size: 11px; }
.lock-note {
  font-size: 12px; color: var(--due); background: var(--due-bg);
  border-radius: var(--radius-sm); padding: 6px 10px; margin-top: 8px;
}
.rec-actions.lock-req { margin-top: 8px; gap: 8px; }

/* --- owner/admin lock management --- */
.lock-manage { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.lock-manage > summary {
  cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  list-style: none; display: flex; align-items: center; gap: 8px;
}
.lock-manage > summary::-webkit-details-marker { display: none; }
.lock-manage > summary::before { content: "⚙"; }
.req-pill {
  background: var(--amber); color: var(--steel-900); font-weight: 700;
  font-size: 10.5px; border-radius: 10px; padding: 1px 7px;
}
.lock-manage-body { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.req-row { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; }
.req-meta { font-size: 12px; margin-bottom: 6px; }
.req-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.handoff-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* --- notification rail (topbar bell) --- */
.notif-wrap { position: relative; }
.notif-bell {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 6px 10px; cursor: pointer; font-size: 15px;
  line-height: 1;
}
.notif-bell:hover { background: var(--surface-2); }
.notif-count {
  position: absolute; top: -6px; right: -6px;
  background: var(--overdue); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 9px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--sans);
}
.notif-rail {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  width: 340px; max-height: 60vh; overflow-y: auto; z-index: 60;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.notif-rail.open { display: block; }
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface);
}
.notif-list { padding: 4px; }
.notif { padding: 9px 10px; border-radius: var(--radius-sm); border-bottom: 1px solid var(--line); }
.notif:last-child { border-bottom: none; }
.notif.unread { background: var(--amber-tint); }
.notif-row-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; }
.notif-kind {
  font-size: 10px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--ink-soft);
}
.notif-kind.k-completion { background: var(--done-bg); color: var(--done); }
.notif-kind.k-access_request, .notif-kind.k-change_request { background: var(--due-bg); color: var(--due); }
.notif-kind.k-access_granted, .notif-kind.k-handoff { background: var(--note-bg); color: var(--note); }
.notif-kind.k-access_declined { background: var(--overdue-bg); color: var(--overdue); }
.notif-when { font-size: 10.5px; color: var(--ink-soft); font-family: var(--mono); }
.notif-title { font-size: 12.5px; line-height: 1.35; }
.notif-title a { color: var(--ink); text-decoration: none; }
.notif-title a:hover { text-decoration: underline; }
.notif-read { background: none; border: none; color: var(--note); font-size: 11px; cursor: pointer; padding: 4px 0 0; }
.notif-empty { padding: 18px 12px; text-align: center; color: var(--ink-soft); font-size: 12.5px; }

/* --- settings card --- */
.settings-card {
  max-width: 640px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px;
}
.settings-card h3 { font-size: 14px; margin: 0 0 6px; }
.settings-card .muted, .muted { color: var(--ink-soft); font-size: 12px; }
.recip-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }

/* === Phase 5d — Work Orders ============================================= */
.wo-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.wo-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.wo-col-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; background: var(--steel-800); color: #fff;
  font-size: 12px; letter-spacing: .03em; text-transform: uppercase;
}
.wo-col-head .wo-col-count { font-family: var(--mono); background: rgba(255,255,255,.14); padding: 1px 8px; border-radius: 20px; font-size: 11px; }
.wo-col-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.wo-col-empty { color: var(--ink-soft); text-align: center; font-size: 13px; padding: 14px 0; }

.wo-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--steel-500);
  border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer; transition: box-shadow .12s, transform .12s;
}
.wo-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.wo-card.pr-high { border-left-color: var(--amber); }
.wo-card.pr-urgent { border-left-color: var(--overdue); }
.wo-card.closed { opacity: .62; }
.wo-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.wo-id { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); }
.wo-card-title { font-size: 13.5px; font-weight: 600; line-height: 1.3; margin-bottom: 6px; }
.wo-card-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.wo-chip {
  font-size: 10.5px; font-family: var(--mono); padding: 1px 7px; border-radius: 20px;
  background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.wo-chip.assigned { background: var(--note-bg); color: var(--note); border-color: transparent; }
.wo-chip.unassigned { background: var(--due-bg); color: var(--due); border-color: transparent; }
.wo-card-foot { display: flex; align-items: center; justify-content: space-between; font-size: 10.5px; color: var(--ink-soft); }
.wo-pri { font-size: 10px; font-family: var(--mono); text-transform: uppercase; padding: 1px 6px; border-radius: 4px; }
.wo-pri.pr-low { background: var(--surface-2); color: var(--ink-soft); }
.wo-pri.pr-high { background: var(--amber-tint); color: var(--amber-700); }
.wo-pri.pr-urgent { background: var(--overdue-bg); color: var(--overdue); }

.wo-closed { margin-top: 16px; }
.wo-closed summary { cursor: pointer; font-size: 12.5px; color: var(--ink-soft); padding: 6px 0; }
.wo-closed-body { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }

/* status tags (reuse the semantic palette) */
.status-tag.wo-requested { background: var(--due-bg); color: var(--due); }
.status-tag.wo-in_progress { background: var(--note-bg); color: var(--note); }
.status-tag.wo-completed { background: var(--done-bg); color: var(--done); }
.status-tag.wo-declined, .status-tag.wo-cancelled { background: var(--overdue-bg); color: var(--overdue); }

/* notif kinds for WO events */
.notif-kind.k-wo_raised { background: var(--due-bg); color: var(--due); }
.notif-kind.k-wo_updated { background: var(--note-bg); color: var(--note); }
.notif-kind.k-wo_completed { background: var(--done-bg); color: var(--done); }
.notif-kind.k-wo_comment { background: var(--surface-2); color: var(--ink-soft); }

/* panel bits */
.wo-status-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.wo-actions { flex-wrap: wrap; }
.wo-complete { margin-top: 8px; }
.wo-assign-row { display: flex; align-items: center; gap: 7px; font-size: 13px; padding: 3px 0; }
.wo-attachments { display: flex; flex-direction: column; gap: 7px; }
.wo-attach-form { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-top: 6px; }
.wo-attach-form .inp { flex: 1; min-width: 130px; }
.wo-form .cf { margin-bottom: 8px; }
.wo-prefill { background: var(--amber-tint); border: 1px solid var(--amber); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12px; margin-bottom: 12px; }
.form-err { color: var(--overdue); font-size: 12px; margin: -4px 0 8px; }

@media (max-width: 900px) {
  .wo-board, .wo-closed-body { grid-template-columns: 1fr; }
}

/* Phase 5d follow-up — reminder row + mobile change-password reachability */
.wo-reminder-row { gap: 12px; }
.wo-reminder-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); text-transform: none; letter-spacing: 0; white-space: nowrap; }
.wo-reminder-toggle input { margin: 0; }
.wo-reminder-row select.inp { flex: 1; max-width: 170px; }

@media (max-width: 860px) {
  /* keep settings + change-password icons reachable on mobile (the redundant
     topbar Password button has been removed); logout stays in the topbar */
  .who { display: flex; flex: none; padding: 4px 10px; border-top: none; align-items: center; gap: 4px; }
  .who > div:first-child { display: none; }   /* name / role block */
  .who-actions form { display: none; }        /* logout icon (topbar already has Log out) */
}

/* Current-month column highlight (read schedule grid). Body cells get a very
   light blue band; the done/due/overdue boxes paint over it so they're
   unchanged. The dark header just gets an amber label so the column reads
   top-to-bottom. Only applied when viewing the current year. */
table.schedule tbody .mcell.this-month { background: var(--note-bg); }
table.schedule thead th.mcell.this-month { color: var(--amber); }
