/* ==========================================================================
   Apex x InFrame Portal - THE design system. Every page draws from this file.
   Visual doctrine and its rationale: DESIGN.md.

   Recreated from design_handoff_partner_dashboard (Dashboard.dc.html).
   Square, rack-mount aesthetic: radius 0 everywhere except pill chips.
   Dark by default, with a real token-swapped light theme.

   The prototype used inline styles and a filter:invert() light mode. Both are
   translated here into real CSS with real light-theme tokens, per the handoff's
   own recommendation - inverting hue-rotates the cyan into orange and makes
   photographs and YouTube thumbnails render as negatives.

   DO NOT introduce a second palette, a second typeface, or a border-radius.
   ========================================================================== */

:root {
  --bg:        #141518;   /* page */
  --surface:   #212327;   /* widget/card */
  --header:    #1C1D20;   /* top bar */
  --tile:      #26282D;   /* inner tiles */
  --tile-hi:   #2A2C31;   /* tile hover / gradient top */
  --field:     #32353C;   /* form input fill - a clear step above the card so
                             text wells read as distinct, not sunken */

  --title:     #FFFFFF;
  --body:      #E8E6DF;
  --muted-70:  rgba(232,230,223,0.70);
  --muted-65:  rgba(232,230,223,0.65);
  --muted-50:  rgba(232,230,223,0.50);
  --muted-45:  rgba(232,230,223,0.45);
  --muted-40:  rgba(232,230,223,0.40);
  --muted-30:  rgba(232,230,223,0.30);

  --accent:    #38B6D9;   /* cyan */
  --accent-12: rgba(56,182,217,0.12);
  --accent-35: rgba(56,182,217,0.35);
  --accent-40: rgba(56,182,217,0.40);
  --accent-55: rgba(56,182,217,0.55);
  --accent-glow: rgba(56,182,217,0.80);
  --on-accent: #08191F;   /* text on a filled accent button */

  --magenta:    #C9337A;
  --magenta-12: rgba(201,51,122,0.12);
  --magenta-40: rgba(201,51,122,0.40);
  --amber:      #E47835;
  --amber-12:   rgba(228,120,53,0.12);
  --amber-40:   rgba(228,120,53,0.40);
  --danger:     #DC4438;
  --danger-12:  rgba(220,68,56,0.12);
  --danger-40:  rgba(220,68,56,0.40);
  --danger-60:  rgba(220,68,56,0.60);

  /* Role icon colours. A deliberate exception to the cyan-only accent rule -
     the four roles are colour-coded so a role set reads at a glance. Three map
     to existing brand hues (which re-resolve per theme); qc gets its own green.*/
  --role-inframe: var(--magenta);
  --role-tech:    var(--amber);
  --role-qc:      #3FC08A;
  --role-staff:   var(--accent);

  --line:      rgba(255,255,255,0.10);
  --line-str:  rgba(255,255,255,0.16);
  --line-soft: rgba(255,255,255,0.06);
  --line-12:   rgba(255,255,255,0.12);
  --line-28:   rgba(255,255,255,0.28);
  --top-hair:  inset 0 1px 0 rgba(255,255,255,0.04);
  --scroll:    rgba(255,255,255,0.12);

  --sans: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Light theme: real token swap, not an invert. Same structure, same accent
   hue, surfaces stepped the other way so hierarchy still reads. */
:root[data-theme="light"] {
  --bg:        #EEEFF1;
  --surface:   #FFFFFF;
  --header:    #FFFFFF;
  --tile:      #F4F5F7;
  --tile-hi:   #EAECEF;
  --field:     #ECEEF1;   /* grey well - a touch darker than the white card so it reads */

  --title:     #101114;
  --body:      #24262B;
  --muted-70:  rgba(36,38,43,0.78);
  --muted-65:  rgba(36,38,43,0.70);
  --muted-50:  rgba(36,38,43,0.58);
  --muted-45:  rgba(36,38,43,0.55);
  --muted-40:  rgba(36,38,43,0.50);
  --muted-30:  rgba(36,38,43,0.38);

  --accent:    #0E7C9B;   /* darkened for contrast on white */
  --accent-12: rgba(14,124,155,0.10);
  --accent-35: rgba(14,124,155,0.35);
  --accent-40: rgba(14,124,155,0.40);
  --accent-55: rgba(14,124,155,0.55);
  --accent-glow: rgba(14,124,155,0.55);
  --on-accent: #FFFFFF;

  --magenta:    #A81F60;
  --magenta-12: rgba(168,31,96,0.10);
  --magenta-40: rgba(168,31,96,0.40);
  --amber:      #B45A15;
  --amber-12:   rgba(180,90,21,0.10);
  --amber-40:   rgba(180,90,21,0.40);
  --danger:     #C0392B;
  --danger-12:  rgba(192,57,43,0.10);
  --danger-40:  rgba(192,57,43,0.40);
  --danger-60:  rgba(192,57,43,0.60);

  /* qc green, darkened for contrast on white; the other role hues re-resolve
     from --magenta / --amber / --accent above. */
  --role-qc:    #1E8F63;

  --line:      rgba(16,17,20,0.14);
  --line-str:  rgba(16,17,20,0.22);
  --line-soft: rgba(16,17,20,0.08);
  --line-12:   rgba(16,17,20,0.14);
  --line-28:   rgba(16,17,20,0.30);
  --top-hair:  inset 0 1px 0 rgba(255,255,255,0.9);
  --scroll:    rgba(16,17,20,0.20);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--body);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--body); text-decoration: none; transition: color 120ms; }
a:hover { color: var(--accent); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scroll); }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }

/* --- shell ---------------------------------------------------------------- */

.pp {
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden; background: var(--bg);
}

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

.pp-head {
  display: flex; align-items: center; gap: 16px 20px;
  min-height: 60px; padding: 6px 24px; flex-wrap: wrap; flex: none;
  background: var(--header); border-bottom: 1px solid var(--line);
}
.pp-brand { display: flex; flex-direction: column; gap: 4px; }
.pp-brand .mark {
  font-weight: 900; font-size: 18px; letter-spacing: .02em;
  color: var(--title); line-height: 1;
}
.pp-brand .mark span { color: var(--muted-40); font-weight: 700; padding: 0 3px; }
.pp-brand .sub {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted-45); line-height: 1;
}

.pp-nav {
  display: flex; gap: 18px; font-size: 13.5px; font-weight: 600;
  white-space: nowrap; margin-left: 28px;
}
.pp-nav a { color: var(--muted-65); padding: 19px 0; }
.pp-nav a:hover { color: var(--body); }
.pp-nav a.on {
  color: var(--accent); border-bottom: 2px solid var(--accent); padding-bottom: 17px;
}

.pp-spacer { flex: 1; }
.pp-user { display: flex; align-items: center; gap: 10px; white-space: nowrap; flex: none; }
.pp-user .who { text-align: right; line-height: 1; }
.pp-user .who .n { font-size: 13px; font-weight: 700; color: var(--title); }
.pp-user .who .r { font-size: 11px; color: var(--muted-45); margin-top: 4px; }

.pp-btn {
  width: 32px; height: 32px; background: var(--tile-hi);
  border: 1px solid var(--line-str); display: flex; align-items: center;
  justify-content: center; cursor: pointer; padding: 0; color: var(--body);
  transition: border-color 120ms, color 120ms;
}
.pp-btn:hover { border-color: var(--line-28); }
.pp-btn.out { color: var(--muted-70); }
.pp-btn.out:hover { border-color: var(--danger-60); color: var(--danger); }
.pp-btn:active { transform: translateY(1px); }

/* --- greeting strip ------------------------------------------------------- */

.pp-greet {
  display: flex; align-items: flex-end; gap: 36px;
  padding: 22px 28px 18px; flex: none; flex-wrap: wrap;
}
.pp-greet .eyebrow {
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted-45); font-weight: 600; margin-bottom: 6px;
}
.pp-greet h1 {
  margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.02em;
  line-height: 1; color: var(--title);
}
.pp-clock {
  font-family: var(--mono); font-size: 26px; font-weight: 500;
  color: var(--body); line-height: 1; font-variant-numeric: tabular-nums;
}
.pp-stat { border-left: 1px solid var(--line); padding-left: 36px; }
.pp-stat .k {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted-45); font-weight: 600;
}
.pp-stat .v {
  font-family: var(--mono); font-size: 22px; color: var(--body);
  margin-top: 5px; line-height: 1;
}
.pp-stat .v.cyan { color: var(--accent); }
.pp-stat .s, .pp-sub { font-size: 11.5px; color: var(--muted-45); margin-top: 4px; }
.pp-wx { display: flex; align-items: center; gap: 12px; border-left: 1px solid var(--line); padding-left: 36px; }
.pp-wx .t { font-size: 19px; font-weight: 700; line-height: 1; }

/* --- board ---------------------------------------------------------------- */

.pp-board {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: 1.15fr 1fr;
  gap: 14px; padding: 0 28px 24px;
}

.w {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--top-hair);
}
.w.span2 { grid-column: span 2; }
.w.live  { border-color: var(--accent-35); }

.w-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--line); flex: none;
}
.w-head h3 {
  margin: 0; font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
  font-weight: 700; color: var(--body);
}
.w-head h3.cyan { color: var(--accent); display: flex; align-items: center; gap: 8px; }
.w-head a { font-size: 12px; color: var(--accent); }
.dot {
  width: 7px; height: 7px; background: var(--accent); border-radius: 999px;
  box-shadow: 0 0 8px var(--accent-glow); flex: none;
}
.w-body { flex: 1; overflow-y: auto; }
.w-empty { padding: 22px 18px; font-size: 12.5px; color: var(--muted-45); }

/* announcements */
.ann { padding: 4px 18px 14px; }
.ann .row {
  display: flex; gap: 14px; padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}
.ann .row:last-child { border-bottom: none; }
.ann .bar { width: 3px; flex: none; background: rgba(255,255,255,0.2); }
:root[data-theme="light"] .ann .bar { background: rgba(16,17,20,0.2); }
.ann .bar.pin { background: var(--accent); }
.ann .t { font-size: 14.5px; font-weight: 700; color: var(--title); }
.ann .p { margin: 5px 0 0; font-size: 13px; line-height: 1.55; color: var(--muted-70); }
.ann .m { margin-top: 6px; font-size: 11.5px; color: var(--muted-40); }
.pill {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 700; color: var(--accent); border: 1px solid var(--accent-40);
  padding: 2px 8px; border-radius: 999px;
}

/* latest activity */
.feed { padding: 4px 18px 14px; }
.feed a, .feed .row {
  display: flex; gap: 11px; padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.feed a:last-child, .feed .row:last-child { border-bottom: none; }
.feed .ic {
  width: 22px; height: 22px; flex: none; margin-top: 1px;
  border: 1px solid var(--line-12); background: var(--tile);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted-65);
}
.feed .ic.cyan    { color: var(--accent); }
.feed .ic.magenta { color: var(--magenta); }
.feed .txt { min-width: 0; }
.feed .txt .l { display: block; font-size: 13px; line-height: 1.4; color: var(--body); }
.feed .txt .l strong { color: var(--title); font-weight: 700; }
.feed .txt .m {
  display: flex; gap: 8px; margin-top: 4px; font-size: 11.5px; color: var(--muted-45);
}
.feed .txt .m .ref { font-family: var(--mono); color: var(--muted-65); }
.feed a:hover .txt .l { color: var(--accent); }

/* quick links */
.qgrid {
  padding: 14px 18px; display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px; align-content: start;
}
.qtile {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  border: 1px solid var(--line); border-top: 2px solid var(--line-str);
  padding: 12px 14px 13px;
  background: linear-gradient(180deg, var(--tile-hi) 0%, var(--tile) 100%);
  transition: border-color 120ms, transform 120ms;
}
.qtile.primary { border-top-color: var(--accent); }
.qtile:hover { border-color: var(--accent-55); border-top-color: var(--accent); }
.qtile:active { transform: translateY(1px); }
.qtile .top { display: flex; align-items: center; justify-content: space-between; }
.qtile .top svg { color: var(--accent); }
.qtile .idx {
  font-family: var(--mono); font-size: 9px; letter-spacing: .12em; color: var(--muted-30);
}
.qtile .lab { display: flex; flex-direction: column; gap: 3px; }
.qtile .lab .t {
  font-size: 13.5px; font-weight: 700; color: var(--title); letter-spacing: .01em;
}
.qtile .lab .s {
  font-size: 11px; font-family: var(--mono); color: var(--muted-50);
  text-transform: uppercase;
}
.qtile:hover .lab .t { color: var(--title); }

/* documents */
.dgrid {
  padding: 14px 18px; display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; align-content: start;
}
.dtile {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); padding: 10px 12px; background: var(--tile);
  transition: border-color 120ms, background 120ms;
}
.dtile:hover { border-color: var(--line-28); background: var(--tile-hi); }
.dtile svg { flex: none; color: var(--muted-50); }
.dtile .t {
  font-size: 13px; font-weight: 600; color: var(--body); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dtile .z { font-family: var(--mono); font-size: 10.5px; color: var(--muted-40); flex: none; }

/* videos */
.vlist { padding: 12px 18px; display: flex; flex-direction: column; gap: 8px; }
.vlist a { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.vlist .thumb {
  width: 58px; height: 34px; flex: none; background: var(--tile-hi);
  border: 1px solid var(--line); display: flex; align-items: center;
  justify-content: center; object-fit: cover; color: var(--muted-65);
}
.vlist .t { font-size: 13px; font-weight: 600; color: var(--body); line-height: 1.35; }

/* directory */
.dir { padding: 6px 18px 14px; }
.dir .row { padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.dir .row:last-child { border-bottom: none; }
.dir .n { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dir .n b { font-size: 13.5px; font-weight: 700; color: var(--title); }
.dir .chip {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em;
  padding: 2px 7px; border-radius: 999px;
  color: var(--accent); border: 1px solid var(--accent-40);
}
.dir .chip.inframe { color: var(--magenta); border-color: var(--magenta-40); }
.dir .r, .dir .c { margin-top: 4px; font-size: 11.5px; color: var(--muted-45); }
.dir .c a { color: var(--accent); }

/* --- responsive ----------------------------------------------------------- */
/* The single-screen rule holds on a real 16:9 display. Below that, let the
   page scroll rather than crushing six widgets into unreadable slivers. */
@media (max-width: 1180px), (max-height: 620px) {
  .pp { height: auto; overflow: visible; }
  /* `html .pp.fixed` (0,2,1) is deliberate: the base `.pp.fixed` rule lives
     LATER in the file, so an equal-specificity override here would lose to it.
     The extra `html` lets the small-screen release win and the dashboard scroll
     instead of staying locked to 100vh and crushing the widgets. */
  html .pp.fixed { height: auto; overflow: visible; }
  html, body { height: auto; }
  .pp-board {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: none; grid-auto-rows: minmax(230px, auto);
  }
}
@media (max-width: 720px) {
  .pp-board { grid-template-columns: 1fr; padding: 0 16px 20px; }
  .w.span2 { grid-column: span 1; }
  .pp-head { padding: 10px 16px; }
  .pp-nav { margin-left: 0; gap: 14px; }
  .pp-nav a, .pp-nav a.on { padding: 8px 0; }
  .pp-greet { padding: 16px 16px 12px; gap: 20px; }
  .pp-greet h1 { font-size: 24px; }
  .pp-stat, .pp-wx { border-left: none; padding-left: 0; }
}

/* ==========================================================================
   SHARED CHROME + COMPONENTS
   Everything below styles the rest of the portal - tickets, ledger, QC, docs,
   admin, login - in the same language as the dashboard above.
   ========================================================================== */

.pp { min-height: 100vh; height: auto; overflow: visible; }
.pp.fixed { height: 100vh; overflow: hidden; }

.page { max-width: 1240px; margin: 0 auto; padding: 26px 28px 48px; width: 100%; }
.page.narrow { max-width: 780px; }

h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; color: var(--title); }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 12px; color: var(--title); }
.lede { color: var(--muted-65); font-size: 13.5px; margin: 0 0 22px; max-width: 78ch; }
code { font-family: var(--mono); font-size: .92em; }

.eyebrow, .card > h3 {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .16em; color: var(--body); margin: 0 0 14px;
}
.crumb {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .14em; color: var(--muted-45); margin-bottom: 12px;
}
.crumb a { color: var(--muted-45); }
hr.rule { border: none; border-top: 1px solid var(--line); margin: 22px 0; }
.foot {
  font-family: var(--mono); font-size: 10px; color: var(--muted-40); text-align: center;
  text-transform: uppercase; letter-spacing: .14em; padding: 26px 0 8px;
}

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--top-hair); padding: 18px 20px; margin-bottom: 16px;
}
.card.accent  { border-top: 2px solid var(--accent); }
.card.inkline { border-top: 2px solid var(--line-str); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr !important; } }

/* forms */
label {
  display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted-45); margin: 0 0 6px;
}
.hint {
  font-size: 12px; color: var(--muted-45); margin: 5px 0 0; font-weight: 400;
  text-transform: none; letter-spacing: 0; line-height: 1.5;
}
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], select, textarea {
  width: 100%; padding: 10px 12px; font-size: 14px; border-radius: 0;
  border: 1px solid var(--line-str); background: var(--field); color: var(--body);
  font-family: inherit; transition: border-color 120ms;
}
input::placeholder, textarea::placeholder { color: var(--muted-30); }
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-12);
}
input[type=file] {
  width: 100%; font-size: 12.5px; padding: 10px;
  border: 1px dashed var(--line-str); background: var(--field); color: var(--muted-65);
}
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
.field { margin-bottom: 15px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .row2, .row3 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: flex-start; gap: 9px; margin: 12px 0; }
.check input { width: auto; margin-top: 3px; }
.check label {
  margin: 0; text-transform: none; letter-spacing: 0; font-size: 13px;
  font-weight: 400; color: var(--body); cursor: pointer; line-height: 1.5;
}

/* buttons */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 18px; cursor: pointer; border-radius: 0;
  font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  font-family: var(--sans); text-decoration: none;
  border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent);
  transition: border-color 120ms, background 120ms, color 120ms, transform 120ms;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
.btn.ghost, button.ghost { background: var(--tile); color: var(--body); border-color: var(--line-str); }
.btn.ghost:hover, button.ghost:hover { border-color: var(--accent-55); color: var(--title); filter: none; }
.btn.teal { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger, button.danger { background: transparent; border-color: var(--danger-40); color: var(--danger); }
.btn.danger:hover, button.danger:hover { border-color: var(--danger); background: var(--danger-12); filter: none; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 10px; letter-spacing: .1em; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-family: var(--mono); font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .14em; color: var(--muted-45);
  padding: 0 12px 10px 0; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
tbody tr:hover { background: var(--tile); }
.rowlink { color: var(--body); text-decoration: none; font-weight: 700; }
.rowlink:hover { color: var(--accent); text-decoration: none; }

/* chips */
.chip {
  display: inline-block; font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .1em; padding: 3px 8px;
  border-radius: 999px; border: 1px solid var(--line-str); color: var(--muted-65);
  white-space: nowrap;
}
.chip.open        { color: var(--amber);   border-color: var(--amber-40); }
.chip.in_progress { color: var(--accent);  border-color: var(--accent-40); }
.chip.resolved    { color: var(--accent);  border-color: var(--accent-40); background: var(--accent-12); }
.chip.closed      { color: var(--muted-45); }
.chip.active      { color: var(--amber);   border-color: var(--amber-40); }
.chip.billed      { color: var(--accent);  border-color: var(--accent-40); }
.chip.internal    { color: var(--magenta); border-color: var(--magenta-40); }
/* removed = admin took the account off the users list. Distinct from the
   neutral "disabled" chip so the two states never read the same. */
.chip.removed     { color: var(--danger);  border-color: var(--danger-40); }

/* Role icons. Colour-coded (a deliberate exception to cyan-only) AND told apart
   by shape, so they read with or without colour. NO container (square doctrine -
   a bare inline SVG next to the text, consistent gap). The svg strokes with
   currentColor, so each per-role class just sets the text colour it inherits. */
.role-ics { display: inline-flex; align-items: center; gap: 5px; vertical-align: middle; }
.role-ic  { display: inline-flex; cursor: help; }
.role-ic svg { display: block; width: 15px; height: 15px; }
.role-ic--inframe { color: var(--role-inframe); }
.role-ic--tech    { color: var(--role-tech); }
.role-ic--qc      { color: var(--role-qc); }
.role-ic--staff   { color: var(--role-staff); }

/* notices */
.notice {
  padding: 12px 16px; font-size: 13px; margin-bottom: 16px; line-height: 1.55;
  border: 1px solid var(--accent-40); border-left-width: 3px;
  background: var(--accent-12); color: var(--body);
}
.notice.err  { border-color: var(--danger-40); background: var(--danger-12); }
.notice.warn { border-color: var(--amber-40);  background: var(--amber-12); }
.empty { text-align: center; color: var(--muted-45); font-size: 13px; padding: 30px 12px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 13px; }
.kv dt {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted-45); font-weight: 500; padding-top: 2px;
}
.kv dd { margin: 0; color: var(--body); }
.bignum {
  font-family: var(--mono); font-size: 30px; font-weight: 500;
  letter-spacing: -.01em; color: var(--title); line-height: 1.1;
}

/* login gate */
.gate {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.gatecard {
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--top-hair);
  padding: 34px 32px; max-width: 400px; width: 100%; text-align: center;
}
.gatemark { font-size: 20px; font-weight: 900; letter-spacing: .02em; color: var(--title); margin-bottom: 6px; }
.gatemark span { color: var(--muted-40); font-weight: 700; padding: 0 3px; }
.gatesub {
  font-family: var(--mono); font-size: 9.5px; text-transform: uppercase;
  letter-spacing: .14em; color: var(--muted-45); margin-bottom: 26px;
}
.gatecard .field { text-align: left; }
.gatecard button { width: 100%; margin-top: 6px; }
.gatever {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted-30); margin-top: 22px;
}
/* The lockup subtitle IS the version tag (doctrine: the login screen carries
   the version). Carrying both classes keeps that element named .gatever while
   it sits under the brand mark rather than in a footer, so reset the
   footer-specific spacing and use the subtitle's colour. */
.gatesub.gatever { margin-top: 0; margin-bottom: 26px; color: var(--muted-45); }
/* Context line on the secondary gates - "Reset password", "Set a new
   password". Sits under the lockup so those pages still say what they are. */
.gatectx {
  font-size: 14px; font-weight: 700; color: var(--title);
  margin: -14px 0 20px;
}
.gatelinks { margin-top: 16px; font-size: 12px; }
.gatelinks a { color: var(--muted-45); }

/* ticket thread */
.thread { list-style: none; margin: 0; padding: 0; }
.msg { border-left: 3px solid var(--line-str); padding: 2px 0 16px 16px; margin-bottom: 16px; }
.msg.apex     { border-left-color: var(--accent); }
.msg.inframe  { border-left-color: var(--magenta); }
.msg.internal { border-left-color: var(--magenta); background: var(--magenta-12); padding: 10px 14px 12px 16px; }
.msg.system   { border-left-color: var(--line); }
.msg .meta {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted-45); margin-bottom: 7px;
  display: flex; gap: 9px; align-items: center; flex-wrap: wrap;
}
.msg .meta b { color: var(--title); font-weight: 700; letter-spacing: .06em; }
.msg .body { font-size: 14px; line-height: 1.65; color: var(--body); }
.msg.system .body { font-size: 12.5px; color: var(--muted-45); font-style: italic; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.att {
  display: block; border: 1px solid var(--line-str); background: var(--tile);
  overflow: hidden; text-decoration: none; color: var(--body); transition: border-color 120ms;
}
.att:hover { border-color: var(--accent-55); text-decoration: none; }
.att img { display: block; width: 116px; height: 84px; object-fit: cover; }
.att .fname {
  display: block; font-family: var(--mono); font-size: 10px; padding: 6px 8px;
  max-width: 116px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted-65);
}
.att.purged { opacity: .55; padding: 10px 12px; font-size: 11px; font-style: italic; }

@media (max-width: 720px) {
  .page { padding: 20px 16px 40px; }
  .dgrid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   MOBILE / TOUCH
   Additive only. Every rule below sits behind a media query, so the desktop
   layout above is untouched — nothing here can regress a pointer+keyboard
   session. Detection is automatic: viewport width for layout, `pointer:
   coarse` for touch ergonomics. No user-agent sniffing, no JS.
   ========================================================================== */

/* --- touch ergonomics (any screen size with a coarse pointer) -------------- */
@media (pointer: coarse) {
  /* 16px is not a style choice. iOS Safari auto-zooms any focused input whose
     font-size is under 16px, and the zoom does not undo itself - the user is
     left on a page wider than the screen. Every text control must clear it. */
  input[type=text], input[type=email], input[type=password], input[type=number],
  input[type=date], input[type=url], select, textarea {
    font-size: 16px;
    padding: 12px 13px;
  }

  /* ~44px minimum hit target. Small ghost buttons in table rows are the worst
     offenders - they sit inches from a Delete. */
  button, .btn { min-height: 44px; padding: 0 20px; }
  .btn.sm { min-height: 38px; padding: 0 14px; }
  .pp-btn { width: 42px; height: 42px; }

  /* Checkboxes are used for role assignment and ledger line selection, where a
     mis-tap has consequences. */
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .check { gap: 12px; margin: 16px 0; }
  .check label { line-height: 1.6; }

  /* Nav and list links get real vertical room. */
  .pp-nav a, .pp-nav a.on { padding: 14px 0; }
  .mini a, .feed a, .vlist a, .dtile { min-height: 44px; }

  /* Hover states never resolve on touch; make the pressed state do the work. */
  .qtile:active, .dtile:active, .att:active { border-color: var(--accent); }
}

/* --- phones and small tablets --------------------------------------------- */
@media (max-width: 720px) {

  /* Header becomes two stacked bands: brand + controls, then nav. The nav
     scrolls sideways rather than wrapping to three ragged lines. */
  .pp-head {
    padding: 10px 14px 0;
    gap: 10px;
    align-items: flex-start;
    position: sticky; top: 0; z-index: 20;
  }
  .pp-brand { flex: 1 1 auto; }
  .pp-brand .mark { font-size: 16px; }
  .pp-spacer { display: none; }
  .pp-user { order: 2; margin-left: auto; }
  /* The name/role block is the first thing to go - the avatar buttons carry
     the function, and the user knows who they are. */
  .pp-user .who { display: none; }

  .pp-nav {
    order: 3; width: 100%; margin: 0 -14px; padding: 0 14px;
    gap: 20px; overflow-x: auto; flex-wrap: nowrap;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .pp-nav::-webkit-scrollbar { display: none; }

  /* Greeting strip: headline stays, the stat rail becomes a scrollable row so
     it never squeezes the greeting to two words per line. */
  .pp-greet { padding: 16px 14px 14px; gap: 14px; align-items: flex-start; }
  .pp-greet h1 { font-size: 22px; }
  .pp-greet .eyebrow { font-size: 10px; }
  .pp-clock { font-size: 20px; }
  .pp-stat, .pp-wx {
    border-left: none; padding-left: 0;
    border-top: 1px solid var(--line); padding-top: 12px; width: 100%;
  }
  .pp-stat .v { font-size: 20px; }

  /* Page shell */
  .page { padding: 18px 14px 40px; }
  h1 { font-size: 21px; }
  .lede { font-size: 13px; margin-bottom: 18px; }
  .card { padding: 16px 14px; }

  /* Any desktop two/three-column split collapses. The inline `style` on some
     grids is why these need !important - they are set per-page, not in CSS. */
  .grid2, .grid3 { grid-template-columns: 1fr !important; }
  .row2, .row3   { grid-template-columns: 1fr !important; }

  .actions { gap: 8px; }
  .actions .btn, .actions button { flex: 1 1 100%; }

  /* ---- tables become stacked records --------------------------------------
     A 7-column ledger row cannot be read on a 390px screen, and a horizontal
     scrollbar hides the columns that matter. Tables carrying `data-label` on
     their cells restack as labelled rows; anything else keeps the old
     side-scroll, so no table is left broken. */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr {
    border: 1px solid var(--line); background: var(--surface);
    padding: 12px 14px; margin-bottom: 10px;
  }
  table.stack tr:hover { background: var(--surface); }
  table.stack td {
    border: none; padding: 5px 0; text-align: left !important;
    display: flex; gap: 12px; align-items: baseline; justify-content: space-between;
  }
  table.stack td::before {
    content: attr(data-label);
    font-family: var(--mono); font-size: 9.5px; text-transform: uppercase;
    letter-spacing: .12em; color: var(--muted-45); flex: none;
  }
  table.stack td:empty, table.stack td[data-label=""]:empty { display: none; }
  /* The first cell reads as the record's title. */
  table.stack td:first-child { padding-top: 0; font-size: 15px; }
  table.stack td:first-child::before { display: none; }
  table.stack td:first-child .rowlink { font-size: 15px; }

  /* Ticket detail: sidebar drops under the thread. */
  .msg { padding-left: 12px; }
  .att img { width: 96px; height: 70px; }

  /* Dashboard board */
  .pp-board { grid-template-columns: 1fr; padding: 0 14px 20px; gap: 10px; }
  .w.span2 { grid-column: span 1; }
  .w-body { max-height: 62vh; }   /* keep any one widget from owning the page */
  .qgrid { grid-template-columns: 1fr 1fr; }
  .dgrid { grid-template-columns: 1fr; }

  /* Login */
  .gate { padding: 16px; align-items: flex-start; padding-top: 8vh; }
  .gatecard { padding: 26px 20px; }
}

/* --- very small phones ---------------------------------------------------- */
@media (max-width: 380px) {
  .qgrid { grid-template-columns: 1fr; }
  .pp-greet h1 { font-size: 19px; }
  .pp-brand .sub { display: none; }
}

/* --- landscape phone ------------------------------------------------------ */
/* Short and wide: the greeting strip eats the whole screen. Trim it rather
   than let the board start below the fold. */
@media (max-height: 480px) and (orientation: landscape) {
  .pp-greet { padding: 10px 14px 8px; }
  .pp-greet h1 { font-size: 18px; }
  .pp-greet .eyebrow, .pp-sub { display: none; }
}

/* --- printing ------------------------------------------------------------- */
/* Ledger and ticket pages do get printed. Force the light palette so a printer
   isn't asked to lay down a full page of #141518. */
@media print {
  :root {
    --bg: #fff; --surface: #fff; --header: #fff; --tile: #fff; --tile-hi: #fff;
    --title: #000; --body: #111; --accent: #000;
    --line: #ccc; --line-soft: #e5e5e5; --line-str: #bbb; --top-hair: none;
  }
  .pp-head, .pp-nav, .pp-user, .actions, .pp-btn, form { display: none !important; }
  .page { max-width: none; padding: 0; }
  .card { border: 1px solid #ccc; break-inside: avoid; }
  a { text-decoration: none; color: #000; }
}
