/* TBM Switchboard — TBM Corporate Identity, Overall Basic Ver. 1 (June 2026).
   Official colours: TBM Red #C8102E, TBM Blue #06038D, Process Black #27251F.
   The grey ramp below is derived for screen work; the CI defines no neutrals. */

:root {
  --tbm-red:       #C8102E;  /* official */
  --tbm-blue:      #06038D;  /* official */
  --tbm-ink:       #27251F;  /* official — Process Black */

  --tbm-blue-tint: #3A37A5;  /* derived tint, hover/selected states */
  --tbm-red-tint:  #A50D26;  /* derived tint, pressed states */

  --tbm-grey-800:  #4A473F;  /* derived */
  --tbm-grey-600:  #6B6862;
  --tbm-grey-400:  #A8A49C;
  --tbm-grey-200:  #DAD7D1;
  --tbm-grey-100:  #F1EFEC;
  --tbm-paper:     #FFFFFF;

  --surface:       var(--tbm-paper);
  --surface-sunk:  var(--tbm-grey-100);
  --border:        var(--tbm-grey-200);
  --text:          var(--tbm-ink);
  --text-muted:    var(--tbm-grey-600);

  /* Functional, not corporate: the CI defines no status colours, so these are
     derived for "this account is on" and checked for contrast. 5.0:1 on white. */
  --state-on:      #15803D;
  --state-on-tint: #E8F5ED;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(39, 37, 31, .06), 0 8px 24px rgba(39, 37, 31, .06);
  --font: "ITC Avant Garde Gothic Std", "Century Gothic", "Poppins",
          "Questrial", "Trebuchet MS", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tbm-blue:     #6E6CC4;   /* full-strength blue is invisible on dark ground */
    --surface:      #211F1C;
    --surface-sunk: #1A1815;
    --border:       #3A3730;
    --text:         #F1EFEC;
    --text-muted:   #A8A49C;
    --state-on:      #4ADE80;   /* 9.4:1 on the dark surface */
    --state-on-tint: #1B3326;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  color: var(--text);
  background: var(--surface-sunk);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--tbm-blue); }

/* ---- header ---- */

.masthead {
  background: var(--tbm-blue);
  color: #FFFFFF;
  border-bottom: 3px solid var(--tbm-red);  /* white-free edge is fine: a rule, not a field */
}

.masthead-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* The logo artboard carries its own clear space — no padding added here. */
.masthead .logo { width: 116px; height: auto; flex: none; display: block; }

.masthead .switchboard-name {
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .02em;
  margin-right: auto;
}

.masthead nav { display: flex; align-items: center; gap: 18px; font-size: .88rem; }
.masthead nav a { color: #FFFFFF; text-decoration: none; opacity: .88; }
.masthead nav a:hover, .masthead nav a:focus-visible { opacity: 1; text-decoration: underline; }
.masthead .whoami { color: #FFFFFF; opacity: .8; font-size: .82rem; }

/* ---- layout ---- */

main { max-width: 1100px; margin: 0 auto; padding: 32px 16px 56px; }

.page-title { font-size: 1.6rem; font-weight: 700; margin: 0 0 4px; letter-spacing: -.01em; }
.page-lede { color: var(--text-muted); margin: 0 0 28px; font-size: .95rem; }

.section-title {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 36px 0 12px;
}

/* ---- module tiles ---- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}

a.tile:hover, a.tile:focus-visible { transform: translateY(-2px); border-color: var(--tbm-blue); }
a.tile:focus-visible { outline: 2px solid var(--tbm-red); outline-offset: 2px; }

.tile-icon { color: var(--tbm-blue); width: 26px; height: 26px; }
.tile-name { font-weight: 700; font-size: 1.02rem; }
.tile-summary { color: var(--text-muted); font-size: .88rem; }

.tile.is-closed { opacity: .62; cursor: default; box-shadow: none; }

.badge {
  align-self: flex-start;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--tbm-grey-100);
  color: var(--tbm-grey-800);
}
.badge-beta { background: var(--tbm-red); color: #FFFFFF; }

/* ---- cards, forms ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.signin { max-width: 420px; margin: 8vh auto; }
.signin .logo { width: 150px; height: auto; display: block; margin: 0 auto 8px; }
.signin h1 { font-size: 1.25rem; font-weight: 700; text-align: center; margin: 0 0 4px; }
.signin .sub { text-align: center; color: var(--text-muted); font-size: .88rem; margin: 0 0 24px; }

label { display: block; font-size: .82rem; font-weight: 600; margin: 0 0 6px; }
.field { margin-bottom: 16px; }

input[type="email"], input[type="password"], input[type="text"], select {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--tbm-grey-400);
  border-radius: 8px;
}
input:focus, select:focus { outline: 2px solid var(--tbm-blue); outline-offset: 1px; border-color: var(--tbm-blue); }

.hint { font-size: .8rem; color: var(--text-muted); margin-top: 6px; }

.btn {
  display: inline-block;
  width: 100%;
  padding: 11px 16px;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--tbm-red);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { background: var(--tbm-red-tint); }
.btn:focus-visible { outline: 2px solid var(--tbm-blue); outline-offset: 2px; }

.notice {
  border-left: 3px solid var(--tbm-red);
  background: var(--surface-sunk);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: .88rem;
  margin-bottom: 18px;
}

/* ---- tables ---- */

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left;
  font-size: .74rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- footer ---- */

footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  color: var(--text-muted);
  font-size: .78rem;
}

@media (max-width: 560px) {
  .masthead-inner { flex-wrap: wrap; gap: 10px; }
  .masthead .switchboard-name { font-size: .85rem; }
  main { padding-top: 24px; }
}

/* ---- settings ---- */

.subnav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 0 0 24px;
}

.subnav a {
  padding: 8px 14px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.subnav a:hover { color: var(--text); }

.subnav a.on {
  color: var(--tbm-blue);
  border-bottom-color: var(--tbm-red);
}

.notice-good {
  border-left-color: var(--tbm-blue);
}

/* A role chip, and the checkbox that grants it. */
.role-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  margin: 0 6px 6px 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .84rem;
  cursor: pointer;
  background: var(--surface);
}

.role-pick:hover { border-color: var(--tbm-blue); }
.role-pick input { accent-color: var(--tbm-blue); margin: 0; }
.role-pick:has(input:checked) {
  border-color: var(--tbm-blue);
  background: color-mix(in srgb, var(--tbm-blue) 8%, var(--surface));
}

.btn-small {
  width: auto;
  padding: 7px 14px;
  font-size: .85rem;
}

.btn-quiet {
  background: transparent;
  color: var(--tbm-grey-600);
  border: 1px solid var(--border);
}
.btn-quiet:hover { background: var(--surface-sunk); color: var(--text); }

.matrix th.rolecol {
  text-align: center;
  white-space: nowrap;
}
.matrix td.pick { text-align: center; }
.matrix td.pick input { accent-color: var(--tbm-blue); width: 17px; height: 17px; }
.matrix td.always { text-align: center; color: var(--text-muted); font-size: .8rem; }

.stack { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.stack .field { margin-bottom: 0; flex: 1; min-width: 150px; }

/* ---- one role to a row ---- */

.role-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.role-row:last-of-type { border-bottom: 0; }

.role-row .c-key   { flex: 0 0 140px; font-size: .84rem; color: var(--text-muted); }
.role-row .c-label { flex: 1 1 180px; min-width: 0; }
.role-row .c-desc  { flex: 2 1 240px; min-width: 0; }
.role-row .c-held  { flex: 0 0 74px; font-size: .82rem; color: var(--text-muted); text-align: right; }
/* Fixed, so Save and Delete line up down the page even on the admin row,
   which has no Delete button. */
.role-row .c-act {
  flex: 0 0 152px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.role-row input { padding: 7px 10px; font-size: .88rem; }
input.c-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.role-head {
  padding-bottom: 8px;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* The add row is part of the same list, but plainly the place to add. */
.role-new {
  border-bottom: 0;
  border-top: 2px solid var(--border);
  margin-top: 4px;
  padding-top: 14px;
}

.btn-danger {
  background: transparent;
  color: var(--tbm-red);
  border: 1px solid color-mix(in srgb, var(--tbm-red) 40%, transparent);
}
.btn-danger:hover { background: var(--tbm-red); color: #FFFFFF; }

@media (max-width: 860px) {
  .role-head { display: none; }
  .role-row .c-act { flex: 1 1 100%; justify-content: flex-start; }
  .role-row { flex-wrap: wrap; align-items: stretch; }
  .role-row .c-key,
  .role-row .c-label,
  .role-row .c-desc { flex: 1 1 100%; }
  .role-row .c-held { text-align: left; flex: 1 1 auto; }
}

/* A wide grid of roles would otherwise be clipped on a narrow screen, with the
   last columns simply unreachable. Scroll the grid, not the page. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll .matrix { min-width: 520px; }

/* The app name stays put while the roles scroll past it, so a tick is never
   in an unlabelled row. Sticky cells need `separate` — with the collapsed
   borders the table otherwise uses, the borders on a pinned cell vanish as
   soon as it detaches. */
.matrix {
  border-collapse: separate;
  border-spacing: 0;
}

.matrix th,
.matrix td {
  border-bottom: 1px solid var(--border);
}

.matrix th:first-child,
.matrix td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 190px;
  /* Opaque, or the scrolling columns show through it. */
  background: var(--surface);
  /* The dividing line and a soft edge beyond it, both drawn as shadows so they
     sit above whatever scrolls underneath. The edge is what makes this read as
     a pinned column rather than as text mysteriously cut off. */
  box-shadow: 1px 0 0 var(--border), 6px 0 8px -6px rgba(39, 37, 31, .28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .matrix th:first-child,
  :root:not([data-theme="light"]) .matrix td:first-child {
    box-shadow: 1px 0 0 var(--border), 6px 0 8px -6px rgba(0, 0, 0, .6);
  }
}

/* ---- one person to a row ---- */

.person-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.person-row:last-of-type { border-bottom: 0; }

.person-row .c-who {
  flex: 0 0 268px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 3px;
}

.person-row .who-sub {
  font-size: .78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.person-row .c-roles { flex: 1 1 auto; min-width: 0; padding-top: 1px; }
.person-row .c-roles .role-pick { margin: 0 6px 4px 0; }

.person-row .c-act {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  margin-left: auto;
  padding-top: 2px;
}

/* A disabled account is still listed, but plainly not in play. */
.person-row.is-off .c-who strong,
.person-row.is-off .c-roles { opacity: .55; }

.person-head {
  padding-bottom: 8px;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---- icon buttons ---- */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

.icon-btn:focus-visible {
  outline: 2px solid var(--tbm-blue);
  outline-offset: 2px;
}

.icon-save:hover {
  background: var(--tbm-blue);
  border-color: var(--tbm-blue);
  color: #FFFFFF;
}

/* The status button reports as well as acts, so its resting state carries the
   colour rather than waiting for a hover. */
.icon-status.is-active {
  color: var(--state-on);
  border-color: color-mix(in srgb, var(--state-on) 45%, transparent);
  background: var(--state-on-tint);
}

.icon-status.is-off {
  color: var(--tbm-grey-600);
  background: var(--surface-sunk);
}

.icon-status.is-active:hover {
  border-color: var(--tbm-red);
  color: var(--tbm-red);
  background: var(--surface);
}

.icon-status.is-off:hover {
  border-color: var(--state-on);
  color: var(--state-on);
  background: var(--state-on-tint);
}

@media (max-width: 760px) {
  .person-head { display: none; }
  .person-row { flex-wrap: wrap; }
  .person-row .c-who { flex: 1 1 100%; }
  .person-row .c-roles { flex: 1 1 100%; }
  .person-row .c-act { margin-left: 0; }
}
