/* 3Dtracking brand (as the sales planner, dashboard and KPI sites): dark teal #00444E, logo blue #00A0BE,
   logo orange #F49600, ink #171B25, light grey #F4F6FA, Inter. */
:root {
  --brand-teal: #00444E; --brand-blue: #00A0BE; --brand-orange: #F49600;
  --bg: #F4F6FA; --surface: #FFFFFF; --sunken: #EBEFF4; --ink: #171B25; --muted: #5A6472; --line: #DCE2EA;
  --field: #FFFFFF; --field-line: #D3DBE4;
  --accent: #00444E; --accent-ink: #FFFFFF; --accent-soft: #DCEFF2; --accent-text: #00707F;
  --red: #C8372D; --red-soft: #F9E0DD; --amber: #C77700; --amber-soft: #FCEBD0; --green: #1D8A55; --green-soft: #DDF1E6;
  --font: "Inter", "Segoe UI", Arial, sans-serif;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0D1518; --surface: #15222A; --sunken: #101B21; --ink: #E6EDF2; --muted: #93A3AE; --line: #263842;
  --field: #1C2B34; --field-line: #3A5062;
  --accent: #2FB8D1; --accent-ink: #0D1518; --accent-soft: #10343D; --accent-text: #5CCDE2;
  --red: #F0766E; --red-soft: #3A1E1F; --amber: #F5A938; --amber-soft: #33281A; --green: #4FC38C; --green-soft: #15302A;
  color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0D1518; --surface: #15222A; --sunken: #101B21; --ink: #E6EDF2; --muted: #93A3AE; --line: #263842;
  --field: #1C2B34; --field-line: #3A5062;
  --accent: #2FB8D1; --accent-ink: #0D1518; --accent-soft: #10343D; --accent-text: #5CCDE2;
  --red: #F0766E; --red-soft: #3A1E1F; --amber: #F5A938; --amber-soft: #33281A; --green: #4FC38C; --green-soft: #15302A;
  color-scheme: dark }

* { box-sizing: border-box }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font) }
.app { max-width: 1180px; margin: 0 auto; padding: 16px 16px 64px }
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.01em; margin: 0 }
button, input, select, textarea { font: inherit; color: inherit }
:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px }
a { color: var(--accent-text) }
code { font: 13px/1.4 ui-monospace, Consolas, monospace; background: var(--sunken); padding: 1px 5px; border-radius: 5px; word-break: break-all }
[hidden] { display: none !important }

/* Brand bar: always the website's dark teal, in both themes, so the reversed logo reads. */
.brandbar { background: var(--brand-teal); color: #FFFFFF; border-bottom: 3px solid var(--brand-blue) }
.brandbar-inner { max-width: 1180px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0 }
.brand img { height: 40px; width: auto; display: block }
.brand .appname { padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, .3); line-height: 1.2 }
.brand h1 { font-size: 18px; font-weight: 600; color: #FFFFFF }
.brand p { margin: 2px 0 0; color: rgba(255, 255, 255, .72); font-size: 12.5px }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-right: auto }
.nav a { color: rgba(255, 255, 255, .8); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-size: 14px; font-weight: 600 }
.nav a:hover { background: rgba(255, 255, 255, .1); color: #FFFFFF }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, .16); color: #FFFFFF }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: rgba(255, 255, 255, .78); flex-wrap: wrap }
.who .me { display: grid; line-height: 1.25; text-align: right }
.who .me b { color: #FFFFFF; font-weight: 600 }
.who .me small { font-size: 12px }
.who .initials { background: var(--brand-blue); color: #FFFFFF }
.who .linkbtn { color: #FFFFFF; opacity: .85 }
.initials { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 700; flex: none }
.linkbtn { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; color: var(--accent-text) }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap }
.btn:hover { border-color: var(--muted) }
.btn.sm { padding: 4px 10px; font-size: 13px }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
.btn.danger { color: var(--red) }
.btn:disabled { opacity: .6; cursor: wait }
.field { border: 1px solid var(--field-line); background: var(--field); border-radius: 8px; padding: 7px 10px; min-width: 0; width: 100% }
.hint { color: var(--muted); font-size: 13px; margin: 0 }
.err { color: var(--red) }
.loading { color: var(--muted) }
.notice { background: var(--amber-soft); border: 1px solid var(--amber); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 12px; font-size: 14px }
.notice.bad { background: var(--red-soft); border-color: var(--red) }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px 20px; text-align: center; color: var(--muted); display: grid; gap: 8px; justify-items: center }
.empty b { color: var(--ink); font-size: 16px }

.signin { max-width: 420px; margin: 48px auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; display: grid; gap: 12px }
.btn.ms { justify-content: center; padding: 10px 14px }
.mslogo { display: grid; grid-template-columns: 8px 8px; gap: 2px }
.mslogo i { width: 8px; height: 8px; display: block }
.form { display: grid; gap: 8px }

.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px }
.pagehead h2 { font-size: 22px }
.pagehead .tools { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap }

/* Access grid: people down the side, apps across the top */
.filters { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin: 0 0 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius) }
.filters .field[type="search"] { width: 260px; max-width: 100% }
.filters label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer }
.filters .count { margin-left: auto; color: var(--muted); font-size: 13px }
.table-wrap { overflow: auto; max-height: calc(100vh - 230px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius) }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle }
thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0 }
tbody tr:hover { background: var(--sunken) }
table.grid th.person { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 240px; font-weight: 400 }
table.grid thead th.person { z-index: 3 }
table.grid tbody tr:hover th.person { background: var(--sunken) }
table.grid td.cell, table.grid th.appcol { text-align: center; width: 1%; min-width: 120px }
table.grid th.appcol b { display: block; color: var(--ink); font-size: 13.5px }
table.grid th.appcol small { font-weight: 400 }
.pname { display: flex; align-items: center; gap: 10px }
.pname b { font-weight: 600 }
.pname small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.3 }
tr.off .pname, tr.hid .pname > :not(.rowact) { opacity: .55 }
.pname .rowact { margin-left: auto; padding-left: 12px; font-size: 12.5px; color: var(--muted) }
@media (hover: hover) { tr:not(.hid):not(:hover) .rowact:not(:focus-visible) { opacity: 0 } }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--sunken); color: var(--muted); white-space: nowrap; vertical-align: 1px }
.tag.green { background: var(--green-soft); color: var(--green) }
.tag.amber { background: var(--amber-soft); color: var(--amber) }
.tag.red { background: var(--red-soft); color: var(--red) }

/* The on/off switch in each cell */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; vertical-align: middle }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--field-line); transition: background .15s }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #FFFFFF; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25) }
.switch input:checked + span { background: var(--green) }
.switch input:checked + span::after { transform: translateX(18px) }
.switch input:focus-visible + span { outline: 2px solid var(--brand-blue); outline-offset: 2px }
.switch input:disabled { cursor: wait }
.switch input:disabled + span { opacity: .5 }

/* Applications */
.apps { display: grid; gap: 12px }
.appcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 8px }
.appcard.off { opacity: .7 }
.appcard header { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap }
.appcard h3 { font-size: 17px }
.appcard header .tools { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 14px }
.facts dt { color: var(--muted) }
.facts dd { margin: 0; min-width: 0 }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; margin-bottom: 16px }
.panel h3 { font-size: 17px }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px }
.fields label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted) }
.fields label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; font-size: 14px }
.fields label.check input { width: auto }
.actions { display: flex; gap: 8px; flex-wrap: wrap }
.keybox { background: var(--green-soft); border: 1px solid var(--green); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px }
.keybox code { font-size: 14px; background: var(--surface); padding: 6px 8px }

/* Change log */
table.log td { vertical-align: top }
table.log td.when { white-space: nowrap; color: var(--muted) }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(560px, calc(100vw - 32px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); z-index: 10 }
.toast.bad { background: var(--red); color: #FFFFFF }

@media (max-width: 640px) {
  .who .me { display: none }
  table.grid th.person { min-width: 180px }
  .filters .count { margin-left: 0 }
}
