/* 锦合 De Luxe Circle: black, gold and cream, the colours of the company logo.
   The same look as the inventory app, so nobody has to learn a second one.

   Two pages.
   Report (index.html): for everybody, mostly on a phone. One column, large buttons, few boxes.
   IT (it.html):        phone: the bar is at the top, the pages at the bottom of the screen;
                        desktop (from 1000px): the bar is a column at the left, tables are real tables.

   Many workers need large print. Every size is in rem, so the text size setting
   (Standard / Large / Extra large, "Large" to start with) scales the whole screen. */

:root {
  color-scheme: light dark;
  --ink: #1f1f1f;
  --gold: #faa805;
  --cream: #fbf8ef;

  --bg: #f4efe2;
  --surface: #ffffff;
  --stripe: #faf6ec;
  --hover: #f3ecd9;
  --text: #1a1a1a;
  --muted: #56514a;
  --border: #ddd5c3;
  --line: #8c8372;          /* edge of inputs and buttons: has to be easy to see */
  --accent: var(--gold);
  --accent-edge: #b87900;
  --on-accent: #1f1f1f;
  --selected: #1f1f1f;
  --on-selected: #ffffff;
  --focus: #1f1f1f;
  --on-solid: #ffffff;
  --in: #0f6b31;
  --in-bg: #dff5e5;
  --out: #b3211b;
  --out-bg: #fde5e2;
  --set: #8a5200;
  --set-bg: #fff0c4;
  --send: #5b21b6;
  --send-bg: #ede8fd;
  --shadow: 0 1px 3px rgba(31, 31, 31, 0.1);

  /* The bar, dialog titles and table headings are black in both themes. */
  --side-bg: #1f1f1f;
  --side-text: #fbf8ef;
  --side-muted: #d6cfbf;
  --side-line: rgba(251, 248, 239, 0.5);

  --brand-font: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  --mono-font: Consolas, "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1f1f1f;
    --stripe: #272727;
    --hover: #33302a;
    --text: #fbf8ef;
    --muted: #cfc8b8;
    --border: #45413a;
    --line: #9a9282;
    --selected: var(--gold);
    --on-selected: #1f1f1f;
    --focus: #faa805;
    --on-solid: #121212;
    --in: #6ee797;
    --in-bg: #123d22;
    --out: #ff9c94;
    --out-bg: #4a1512;
    --set: #ffd166;
    --set-bg: #4a3300;
    --send: #cdbcff;
    --send-bg: #33205f;
    --shadow: none;
    --side-bg: #0b0b0b;
  }
}

* { box-sizing: border-box; }
html { font-size: 112.5%; -webkit-text-size-adjust: 100%; }
html[data-text="normal"] { font-size: 100%; }
html[data-text="xlarge"] { font-size: 131.25%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.45 "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }
/* A label that does not fit on one line breaks between the English and the Chinese, not inside the Chinese. */
button, .btn { cursor: pointer; word-break: keep-all; overflow-wrap: break-word; }
h2 { margin: 1.4rem 0.1rem 0.6rem; font-size: 1.2rem; line-height: 1.25; }
.zh { font-weight: 400; }

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, label:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

input[type="search"], input[type="text"], input[type="password"], input[type="date"], input[type="time"], input[type="email"], select, textarea {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.5rem 0.8rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 1.1rem;
}
::placeholder { color: var(--muted); opacity: 1; font-size: 0.95rem; }
input[type="file"] { flex: 2 1 15rem; max-width: 100%; min-height: 3.25rem; padding: 0.45rem 0.6rem; border: 2px dashed var(--line); border-radius: 12px; background: var(--surface); }
input[type="file"]::file-selector-button { min-height: 2.25rem; margin-right: 0.8rem; padding: 0.3rem 0.9rem; border: 2px solid var(--line); border-radius: 10px; background: var(--stripe); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
textarea { min-height: 6.5rem; line-height: 1.4; resize: vertical; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--selected); }

/* ---------------------------------------------------------------- brand */

/* The company logo (static/logo.png) is black on a clear background, and the bar it sits in is
   black, so it stands on a cream tile. */
.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  padding: 0.2rem;
  border-radius: 12px;
  background: var(--cream);
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-mark.big { width: 7rem; height: 7rem; padding: 0.5rem; border-radius: 20px; }

/* ---------------------------------------------------------------- sign in (IT) */

.login { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.login-brand {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.4rem;
  padding: 1.25rem 1rem 1.1rem;
  border-bottom: 4px solid var(--gold);
  background: var(--side-bg);
  color: var(--side-text);
  text-align: center;
}
.login-brand h1 { margin: 0; font: 700 2rem/1.2 var(--brand-font); }
.login-company { margin: 0.4rem 0 0; color: var(--gold); font: 700 1.15rem/1.2 var(--brand-font); letter-spacing: 0.02em; }

.card { display: grid; gap: 0.9rem; width: min(27rem, 100%); padding: 1.25rem; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.card.wide { width: min(44rem, 100%); }
.login .card { align-self: start; justify-self: center; width: min(27rem, calc(100% - 2rem)); margin: 1.25rem 0 2rem; }

.tools { display: grid; gap: 0.4rem; }
.tools-caption { font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.text-size { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.text-size-btn {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 3.75rem;
  padding: 0.25rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.2;
}
/* The three letters keep their own sizes whatever size is chosen, so the choice is easy to see. */
.text-size-btn b { line-height: 1.1; }
.size-normal b { font-size: 16px; }
.size-large b { font-size: 21px; }
.size-xlarge b { font-size: 27px; }
.text-size-btn[aria-pressed="true"] { border-color: var(--selected); background: var(--selected); color: var(--on-selected); }

/* ---------------------------------------------------------------- the bar */

.side {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.5rem 0.6rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 3px solid var(--gold);
  background: var(--side-bg);
  color: var(--side-text);
}
.side :focus-visible { outline-color: var(--gold); }

.brand { flex: 1 1 0; display: flex; align-items: center; gap: 0.7rem; min-width: 0; height: 3.25rem; }
.brand-text { display: grid; min-width: 0; line-height: 1.2; }
.brand-text strong { font: 700 1.15rem/1.2 var(--brand-font); }
.brand-text span { color: var(--gold); font-size: 0.85rem; font-weight: 600; }
.brand-text strong, .brand-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Who is using the page: on the report page the name that was chosen, on the IT page the account. */
.user-btn {
  flex: none;
  display: grid;
  align-content: center;
  max-width: 55%;
  height: 3.25rem;
  padding: 0.25rem 0.7rem;
  border: 2px solid var(--side-line);
  border-radius: 12px;
  background: none;
  color: inherit;
  text-align: left;
  line-height: 1.2;
}
.user-role { color: var(--side-muted); font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-more, .side-tools { display: none; }

/* The pages of the IT team: a bar at the bottom of the screen. The page that is open is gold. */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 3px solid var(--gold);
  background: var(--side-bg);
}
.tabs button {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 4.25rem;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--side-text);
  font-size: min(0.95rem, 4.4vw);
  font-weight: 700;
  line-height: 1.15;
}
.tab-icon { width: 1.6rem; height: 1.6rem; }
/* English on the first line, Chinese on the second. */
.tab-label span { display: block; font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--gold); color: #1f1f1f; }
.count-badge { display: inline-block; min-width: 1.5rem; padding: 0 0.4rem; border-radius: 999px; background: #c62820; color: #ffffff; font-size: 0.8rem; font-weight: 700; line-height: 1.5rem; text-align: center; }
.tabs .count-badge { position: absolute; top: 4px; left: calc(50% + 0.5rem); }
.segment .count-badge { margin-left: 0.35rem; }

main { max-width: 60rem; margin: 0 auto; padding: 1rem 1rem calc(6.5rem + env(safe-area-inset-bottom)); }
.page-head { display: none; }

/* ---------------------------------------------------------------- shared pieces */

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 0.7rem 0; }
.filters input[type="search"] { flex: 2 1 15rem; }
.filters select, .filters input[type="date"] { flex: 1 1 10rem; width: auto; }

.segments { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.25rem 0 0.8rem; }
.segment { min-height: 3rem; padding: 0.3rem 1rem; border: 2px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 700; line-height: 1.2; }
.segment[aria-pressed="true"] { border-color: var(--selected); background: var(--selected); color: var(--on-selected); }

/* A tick box: the whole line can be tapped. */
.check { display: flex; align-items: center; gap: 0.7rem; min-height: 3.25rem; padding: 0.4rem 0.9rem; border: 2px solid var(--border); border-radius: 12px; background: var(--surface); font-weight: 600; cursor: pointer; }
.check input { flex: none; width: 1.6rem; height: 1.6rem; }
.check:has(input:checked) { border-color: var(--selected); background: var(--stripe); }
.check small { display: block; color: var(--muted); font-size: 0.85rem; font-weight: 400; }
/* "Urgent": red once it is ticked, so nobody ticks it without noticing. */
.check.urgent:has(input:checked) { border-color: var(--out); background: var(--out-bg); color: var(--out); }
.check.urgent input { accent-color: var(--out); }

.count { margin: 0.7rem 0.1rem 0.5rem; color: var(--muted); font-size: 0.95rem; }
.hint { margin: 0; color: var(--muted); font-size: 0.95rem; }
.error { margin: 0; color: var(--out); font-weight: 700; }
.empty { padding: 1.5rem 0.75rem; text-align: center; color: var(--muted); }
.code { font-family: var(--mono-font); font-weight: 700; overflow-wrap: anywhere; }
.desc { overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.meta:empty { display: none; }
.pre { white-space: pre-wrap; font-family: var(--mono-font); font-size: 0.85rem; overflow-wrap: anywhere; }
.link { color: inherit; font-weight: 700; overflow-wrap: anywhere; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 3.25rem;
  padding: 0.5rem 1.1rem;
  border: 2px solid transparent;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  text-align: center;
}
.btn.small { min-height: 2.75rem; padding: 0.3rem 0.8rem; font-size: 1rem; }
.btn.big { min-height: 3.75rem; font-size: 1.2rem; }
.btn.in { background: var(--in); color: var(--on-solid); }
.btn.out { background: var(--out); color: var(--on-solid); }
.btn.primary { border-color: var(--accent-edge); background: var(--accent); color: var(--on-accent); }
.btn.ghost { border-color: var(--line); background: var(--surface); color: var(--text); }
.btn:active { filter: brightness(0.92); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { flex: none; width: 1.5rem; height: 1.5rem; }
.link-btn { min-height: 2.75rem; padding: 0.25rem 0.8rem; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font-weight: 700; }
.row-buttons { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.row-buttons > .btn { flex: 1 1 auto; }

.more { display: block; width: 100%; min-height: 3.25rem; margin-top: 0.8rem; border: 2px dashed var(--line); border-radius: 12px; background: none; color: var(--text); font-weight: 700; }

.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.85rem; font-weight: 700; white-space: nowrap; background: var(--bg); color: var(--muted); }
/* The state of a ticket: red waits for IT, yellow is being worked on, purple waits for something else, green is done. */
.badge.s-NEW { background: var(--out-bg); color: var(--out); }
.badge.s-IN_PROGRESS { background: var(--set-bg); color: var(--set); }
.badge.s-WAITING { background: var(--send-bg); color: var(--send); }
.badge.s-DONE { background: var(--in-bg); color: var(--in); }
.badge.urgent { background: #c62820; color: #ffffff; }
.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* ---------------------------------------------------------------- lists of tickets */

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.card-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.3rem 0.9rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
/* A gold edge at the left: this line can be tapped. An urgent ticket has a red one. */
.card-row.clickable { border-left: 6px solid var(--gold); cursor: pointer; }
.card-row.clickable:hover { background: var(--hover); }
.card-row.urgent { border-left-color: #c62820; }
.card-row strong { font-size: 1.1rem; line-height: 1.3; overflow-wrap: anywhere; }
.card-row > .badge { align-self: start; }
.card-row .desc { grid-column: 1 / -1; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.card-row .meta { grid-column: 1 / -1; }
.list > .empty { border: 2px dashed var(--border); border-radius: 14px; }
.number { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: 0.5rem; margin-bottom: 0.8rem; }
.stat { padding: 0.55rem 0.8rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.stat span { display: block; color: var(--muted); font-size: 0.85rem; line-height: 1.25; }
.stat strong { font-size: 1.6rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat.bad strong { color: var(--out); }

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

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
/* A heading may take two lines (English, then Chinese), so more columns fit on the screen. */
th { min-width: 5.25rem; background: var(--side-bg); color: var(--side-text); font-size: 0.9rem; font-weight: 700; line-height: 1.25; vertical-align: bottom; word-break: keep-all; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }
tbody tr { background: var(--surface); }
tbody tr:nth-child(even) { background: var(--stripe); }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--hover); }
tr.off { color: var(--muted); }
tr.urgent td:first-child { box-shadow: inset 5px 0 0 #c62820; }
td.empty { text-align: center; }
td .desc { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; max-width: 34rem; }

/* A count with a bar behind it: the longest bar is the largest count of the table. */
.bar { display: flex; align-items: center; gap: 0.6rem; min-width: 9rem; }
.bar i { flex: none; height: 0.9rem; min-width: 2px; border-radius: 4px; background: var(--gold); }
.bar b { font-variant-numeric: tabular-nums; }

/* Tickets per month: a column for each of the last twelve months. */
.months { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; gap: 0.35rem; height: 10rem; padding: 0.8rem 0.8rem 0.5rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.month { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; height: 100%; min-width: 0; font-size: 0.8rem; color: var(--muted); }
.month b { color: var(--text); font-variant-numeric: tabular-nums; }
.month i { align-self: end; width: min(2.2rem, 80%); min-height: 2px; border-radius: 5px 5px 0 0; background: var(--gold); }

/* ---------------------------------------------------------------- dialogs and forms */

dialog {
  width: min(40rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-box { display: flex; flex-direction: column; min-height: 100%; }
.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.7rem 0.7rem 1rem;
  border-bottom: 3px solid var(--gold);
  background: var(--side-bg);
  color: var(--side-text);
}
.dialog-head h2 { margin: 0; font-size: 1.2rem; overflow-wrap: anywhere; }
.dialog-head :focus-visible { outline-color: var(--gold); }
.icon-btn { flex: none; width: 3rem; height: 3rem; border: 2px solid var(--side-line); border-radius: 12px; background: none; color: inherit; font-size: 1.9rem; line-height: 1; }
#dialogBody { flex: 1 0 auto; display: flex; flex-direction: column; gap: 0.85rem; padding: 1rem; }
.dialog-actions { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; }
.dialog-actions.single { grid-template-columns: 1fr; }
/* The buttons that finish a form stay at the bottom of the form while it is scrolled. */
#dialogBody > .dialog-actions:last-child {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin: auto -1rem -1rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.field { display: grid; gap: 0.3rem; font-weight: 600; }
.field small { color: var(--muted); font-size: 0.9rem; font-weight: 400; }
.field input, .field select, .field textarea, .field .hint { font-weight: 400; }
.two { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 0.6rem; }
.box { display: grid; gap: 0.6rem; padding: 0.8rem 0.9rem; border: 1px solid var(--border); border-radius: 12px; background: var(--stripe); }
.box > h3 { margin: 0; font-size: 1rem; }

.details { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.3rem 0.9rem; margin: 0; padding: 0.75rem 0.9rem; border-radius: 12px; background: var(--stripe); border: 1px solid var(--border); }
.details:empty { display: none; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

/* What is wrong, in the words of the person: the part of a ticket that is read first. */
.problem { margin: 0; padding: 0.8rem 1rem; border-left: 6px solid var(--gold); border-radius: 12px; background: var(--stripe); font-size: 1.15rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.problem.none { color: var(--muted); font-size: 1rem; }

.picker { display: grid; gap: 0.45rem; font-weight: 400; }
.picker-chosen { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.5rem 0.6rem 0.5rem 0.9rem; border: 2px solid var(--selected); border-radius: 12px; background: var(--stripe); }
.picker-chosen:empty { display: none; }
.picker-chosen strong { font-size: 1.1rem; overflow-wrap: anywhere; }
.picker-results { display: grid; gap: 0.35rem; max-height: 16rem; overflow-y: auto; }
.picker-results:empty { display: none; }
.picker-item { min-height: 3.25rem; padding: 0.4rem 0.8rem; border: 2px solid var(--border); border-radius: 12px; background: var(--stripe); color: var(--text); font-size: 1.05rem; text-align: left; overflow-wrap: anywhere; }
.picker-item:hover { border-color: var(--selected); }

/* Photos */
.thumb { flex: none; width: 5rem; height: 5rem; border: 1px solid var(--border); border-radius: 10px; background: var(--stripe); object-fit: cover; cursor: zoom-in; }
.photo-strip { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.photo-strip:empty { display: none; }
.photo-new { position: relative; }
.photo-new canvas { display: block; width: 6rem; height: 6rem; border: 1px solid var(--border); border-radius: 10px; object-fit: cover; }
.photo-new button { position: absolute; top: -0.5rem; right: -0.5rem; width: 2.2rem; height: 2.2rem; border: 2px solid #ffffff; border-radius: 999px; background: #c62820; color: #ffffff; font-size: 1.3rem; font-weight: 700; line-height: 1; }
.photo-view { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 1rem; background: rgba(0, 0, 0, 0.88); cursor: zoom-out; }
.photo-view img { max-width: 100%; max-height: 100%; border-radius: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); opacity: 0; }

/* What happened to a ticket, the oldest step first. */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.event { display: grid; gap: 0.1rem; padding: 0.5rem 0.8rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow-wrap: anywhere; }
.event .meta { font-size: 0.85rem; }
.event p { margin: 0; white-space: pre-wrap; }
.event.step { padding: 0.3rem 0.8rem; border-style: dashed; background: none; color: var(--muted); }
.event.step b { color: var(--text); }
/* Written by the person who reported it. */
.event.theirs { border-left: 6px solid var(--gold); }
/* A note of IT that the person cannot see. */
.event.internal { border-color: var(--set); background: var(--set-bg); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 70;
  width: max-content;
  max-width: calc(100vw - 1.5rem);
  padding: 0.8rem 1.1rem;
  border: 2px solid var(--gold);
  border-radius: 14px;
  background: #1f1f1f;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.toast.bad { border-color: #ffffff; background: #a31b15; }

/* ---------------------------------------------------------------- the report page */

body.report main { display: flex; flex-direction: column; gap: 0.8rem; max-width: 42rem; padding-bottom: 2.5rem; }
body.report main > h2 { margin: 0.8rem 0.1rem 0; }
body.report .toast { bottom: calc(1.5rem + env(safe-area-inset-bottom)); }
/* The name that was chosen gets the room the title leaves; a long name takes two lines. */
body.report .brand { flex: none; }
body.report .user-btn { flex: 1 1 0; min-width: 0; max-width: 24rem; height: auto; min-height: 3.25rem; margin-left: auto; }
body.report .user-btn strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; font-size: 0.95rem; }
.lead { margin: 0.4rem 0.1rem 0.2rem; font: 700 1.5rem/1.25 var(--brand-font); }
.lead span { display: block; font-size: 1.2rem; font-weight: 400; }

/* The one thing most people come for. */
.hero-btn { width: 100%; min-height: 6.5rem; border-radius: 18px; font-size: 1.6rem; box-shadow: 0 4px 0 var(--accent-edge); }
.hero-btn svg { width: 2.4rem; height: 2.4rem; }
.hero-btn span span { display: block; font-size: 1.35rem; font-weight: 600; }

/* Departments, and then the names of one department. */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: 0.6rem; }
.choice { display: grid; justify-items: center; align-content: center; gap: 0.1rem; min-height: 4.5rem; padding: 0.4rem 0.5rem; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 1.25rem; font-weight: 700; line-height: 1.2; text-align: center; }
.choice small { color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.choice:hover { border-color: var(--selected); background: var(--hover); }
.choice-grid.names { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.choice-grid.names .choice { justify-items: start; min-height: 3.75rem; padding: 0.4rem 1rem; font-size: 1.15rem; text-align: left; }

/* What the problem is with: one tap. */
.cat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
.cat { display: grid; align-content: center; min-height: 4.25rem; padding: 0.4rem 0.7rem; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); font-weight: 700; line-height: 1.25; text-align: left; }
.cat span { display: block; font-weight: 400; }
.cat[aria-pressed="true"] { border-color: var(--gold); background: var(--side-bg); color: var(--side-text); }
.cat[aria-pressed="true"] span { color: var(--gold); }

.device { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.6rem 0.6rem 0.6rem 0.9rem; border: 2px solid var(--in); border-radius: 12px; background: var(--in-bg); color: var(--in); font-weight: 700; overflow-wrap: anywhere; }
.device small { display: block; font-weight: 400; }

.sent { display: grid; justify-items: center; gap: 0.6rem; padding: 2rem 0.5rem 1rem; text-align: center; }
.sent svg { width: 6rem; height: 6rem; color: var(--in); }
.sent strong { font-size: 1.6rem; line-height: 1.3; }
.sent .number { font-size: 1.3rem; }
.foot { display: grid; gap: 0.4rem; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.foot a { color: var(--muted); font-size: 0.9rem; }

/* ---------------------------------------------------------------- the portal: the bar and the pages for everybody

   The bar at the top has the company, the pages and who is using it. On a phone the pages move to
   a bar at the bottom of the screen with large buttons, where a thumb reaches them. The pages are
   made of white panels on the cream background, like the cards of the apps people know. */

body.portal { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem max(0.75rem, calc((100vw - 76rem) / 2));
  border-bottom: 3px solid var(--gold);
  background: var(--side-bg);
  color: var(--side-text);
}
.top :focus-visible { outline-color: var(--gold); }
.top .brand { flex: 0 1 auto; color: inherit; text-decoration: none; }
.top-user { margin-left: auto; min-width: 0; }
.top .user-btn { max-width: 16rem; height: auto; min-height: 3.25rem; }
.user-btn .user-role { color: var(--gold); }

.top-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 3px solid var(--gold);
  background: var(--side-bg);
}
.nav-link {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: 4.25rem;
  padding: 6px 2px;
  color: var(--side-text);
  font-size: min(0.95rem, 4.2vw);
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}
.nav-link svg { width: 1.6rem; height: 1.6rem; }
.nav-link > span > span { display: block; font-weight: 500; }
.nav-link[aria-current="page"] { background: var(--gold); color: #1f1f1f; }
.nav-link:hover:not([aria-current="page"]) { background: rgba(251, 248, 239, 0.12); }

@media (min-width: 900px) {
  body.portal { padding-bottom: 0; }
  .top-nav { position: static; display: flex; gap: 0.35rem; padding: 0; border: 0; background: none; }
  .nav-link { display: flex; gap: 0.5rem; min-height: 2.9rem; padding: 0.3rem 0.9rem; border-radius: 999px; font-size: 1rem; }
  .nav-link svg { width: 1.3rem; height: 1.3rem; }
  .nav-link > span > span { display: inline; margin-left: 0.3rem; }
}
@media (max-width: 899px) {
  body.portal .toast { bottom: calc(6rem + env(safe-area-inset-bottom)); }
}
@media (max-width: 520px) {
  .top .brand-text strong { display: none; }
  .top .brand-text span { color: var(--side-text); font: 700 1.15rem/1.2 var(--brand-font); }
  .top .user-btn { max-width: 12rem; }
}

body.portal main { max-width: 76rem; padding: 1.1rem 1rem 2rem; }
body.portal.home main, body.portal.news main, body.portal.people main { display: flex; flex-direction: column; gap: 1rem; }
@media (min-width: 760px) { body.portal main { padding: 1.5rem 1.5rem 2.5rem; } }

.page-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; }
.page-title h1 { margin: 0; font: 700 1.9rem/1.2 var(--brand-font); }
.page-title h1 span { color: var(--muted); font-weight: 400; }
.section-title { display: flex; align-items: center; gap: 0.6rem; margin: 0.6rem 0.1rem 0.2rem; font-size: 1.15rem; }

/* A white box of the home page with its heading. */
.panel { display: grid; gap: 0.75rem; align-content: start; padding: 1rem 1.1rem 1.15rem; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: 0 1px 2px rgba(31, 31, 31, 0.06), 0 4px 16px rgba(31, 31, 31, 0.05); }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 0.6rem; }
.panel-head h2 { margin: 0; font-size: 1.2rem; word-break: keep-all; }
.more-link { color: var(--accent-edge); font-weight: 700; text-decoration: none; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .more-link { color: var(--gold); } }
p.empty.panel { padding: 1.5rem; }
.panel .agenda-day:last-child { margin-bottom: 0; }

/* Good morning: the date and the name of who is using the page. */
.hello { padding: 0.2rem 0.1rem; }
.hello-date { margin: 0; color: var(--muted); font-weight: 600; }
.hello h1 { margin: 0.1rem 0 0; font: 700 1.7rem/1.25 var(--brand-font); }
.hello h1 span { display: block; color: var(--accent-edge); }
@media (prefers-color-scheme: dark) { .hello h1 span { color: var(--gold); } }

/* The apps of the company: a button each, the picture in a coloured square. */
.apps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
@media (min-width: 640px) { .apps { grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); } }
.app {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 5rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(31, 31, 31, 0.06), 0 4px 16px rgba(31, 31, 31, 0.05);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.app:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(31, 31, 31, 0.12); }
.app:active { transform: none; }
.app-icon { flex: none; display: grid; place-items: center; width: 3.1rem; height: 3.1rem; border-radius: 14px; background: var(--side-bg); color: var(--gold); }
.app-icon svg { width: 1.7rem; height: 1.7rem; }
.app-label { min-width: 0; overflow-wrap: break-word; word-break: keep-all; hyphens: auto; }
.app-label span { display: block; color: var(--muted); font-weight: 500; }
.app.accent { border-color: var(--accent-edge); background: var(--accent); color: #1f1f1f; }
.app.accent .app-icon { background: #1f1f1f; color: var(--gold); }
.app.accent .app-label span { color: #3a2a00; }
/* On a phone two cards share a line: the picture above the words, so a word is never split. */
@media (max-width: 639px) {
  .app { flex-direction: column; justify-content: center; gap: 0.5rem; min-height: 7.5rem; padding: 0.8rem 0.5rem; text-align: center; }
  .app-icon { width: 2.9rem; height: 2.9rem; }
}
@media (min-width: 900px) {
  .app { flex-direction: column; align-items: flex-start; min-height: 8rem; }
}

.home-grid { display: grid; gap: 1rem; align-items: start; }
.home-col { display: grid; gap: 1rem; min-width: 0; }
@media (min-width: 900px) { .home-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); } }

/* Announcements */
.news-list { list-style: none; margin: 0; padding: 0; display: grid; }
.news-item a { display: grid; gap: 0.15rem; padding: 0.65rem 0.2rem; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.news-item:first-child a { border-top: 0; padding-top: 0; }
.news-item a:hover strong { text-decoration: underline; }
.news-item strong { font-size: 1.1rem; line-height: 1.3; overflow-wrap: anywhere; }
.news-body { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; color: var(--muted); white-space: pre-line; }
.news-cards { display: grid; gap: 0.8rem; }
.news-card { display: grid; gap: 0.5rem; padding: 1rem 1.2rem; border: 1px solid var(--border); border-left: 6px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.news-card.pinned { border-left-color: var(--gold); }
.news-card.wanted { outline: 3px solid var(--gold); }
.news-card h2 { margin: 0; font-size: 1.3rem; overflow-wrap: anywhere; }
.news-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.8rem; }
.news-text { margin: 0; font-size: 1.1rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.news-cards.earlier .news-card { opacity: 0.7; }
.badge.pin-badge { background: var(--set-bg); color: var(--set); }

/* The staff directory */
.dept-chips { margin: 0; }
.filters .dept-select { flex: 1 1 100%; }
@media (max-width: 759px) { .dept-chips { display: none; } }
@media (min-width: 760px) { .filters .dept-select { display: none; } }
.people-group { display: grid; gap: 0.5rem; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
@media (min-width: 900px) { .people { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.person { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.4rem 0.8rem; align-items: center; padding: 0.75rem 0.9rem; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.avatar { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 999px; background: var(--side-bg); color: var(--gold); font-weight: 800; letter-spacing: 0.02em; }
.person-main { display: grid; min-width: 0; }
.person-main strong { font-size: 1.1rem; overflow-wrap: anywhere; }
.person-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.person-actions:empty { display: none; }
.person-actions .btn svg { width: 1.2rem; height: 1.2rem; }
.ext { padding: 0.35rem 0.8rem; border-radius: 999px; background: var(--stripe); border: 1px solid var(--border); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- projects */

/* A progress bar: the gold part is done; the small black mark is how much of the time is over. */
.pbar { position: relative; flex: 1 1 auto; height: 0.85rem; min-width: 5rem; border-radius: 999px; background: var(--stripe); box-shadow: inset 0 0 0 1px var(--border); }
.pbar i { display: block; height: 100%; border-radius: 999px; background: var(--gold); }
.pbar b { position: absolute; top: -0.25rem; width: 3px; height: 1.35rem; margin-left: -1px; border-radius: 2px; background: var(--text); }
.progress-line { display: flex; align-items: center; gap: 0.6rem; }
.progress-line > b { min-width: 3rem; text-align: right; font-variant-numeric: tabular-nums; }
.progress-line.small { min-width: 9rem; }
.progress-big { display: flex; align-items: center; gap: 0.8rem; }
.progress-big .pbar { height: 1.3rem; }
.progress-big .pbar b { top: -0.3rem; height: 1.9rem; }
.progress-big > b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }

.badge.pj-PLANNING { background: var(--send-bg); color: var(--send); }
.badge.pj-ACTIVE { background: var(--in-bg); color: var(--in); }
.badge.pj-ON_HOLD, .badge.tk-BLOCKED, .badge.health-warn { background: var(--set-bg); color: var(--set); }
.badge.pj-DONE, .badge.tk-DONE { background: var(--bg); color: var(--muted); }
.badge.pj-CANCELLED, .badge.health-bad { background: var(--out-bg); color: var(--out); }
.badge.tk-TODO { background: var(--bg); color: var(--text); }
.badge.tk-DOING, .badge.health-ok { background: var(--in-bg); color: var(--in); }
.badge.mine { background: var(--side-bg); color: var(--gold); }

.project-cards { display: grid; gap: 0.8rem; }
@media (min-width: 760px) { .project-cards { grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr)); } }
.project-card { display: grid; gap: 0.45rem; padding: 1rem 1.1rem; border: 1px solid var(--border); border-left: 6px solid var(--gold); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); color: inherit; text-decoration: none; }
.project-card:hover { background: var(--hover); }
.project-card.closed { border-left-color: var(--border); opacity: 0.75; }
.project-card > strong { font-size: 1.25rem; line-height: 1.3; overflow-wrap: anywhere; }
.project-head { gap: 0.6rem; }
.project-name { margin: 0; font: 700 1.7rem/1.25 var(--brand-font); overflow-wrap: anywhere; }
.project-name span { color: var(--muted); font-size: 1.1rem; font-weight: 400; }
.stage-list { display: grid; gap: 0.8rem; }

.task-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.task-line { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.4rem 1rem; padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-left: 6px solid var(--gold); border-radius: 14px; background: var(--surface); cursor: pointer; }
.task-line:hover { background: var(--hover); }
.task-line.late { border-left-color: var(--out); }
.task-line.done { border-left-color: var(--border); opacity: 0.7; }
.task-main { display: grid; gap: 0.1rem; min-width: 0; }
.task-main strong { font-size: 1.1rem; overflow-wrap: anywhere; }
.task-side { display: grid; gap: 0.35rem; align-content: center; justify-items: start; }
.task-side .progress-line { width: 100%; }
.late-text { color: var(--out); }
@media (min-width: 760px) {
  .task-line { grid-template-columns: minmax(0, 1fr) 15rem; align-items: center; }
}

/* The timeline (Gantt chart): the names at the left stay while a narrow screen scrolls sideways. */
.gantt-wrap { display: grid; gap: 0.4rem; }
.gantt { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.gantt > * { min-width: 51rem; }
.gantt-row { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 2.6rem; border-bottom: 1px solid var(--border); }
.gantt-row:last-child { border-bottom: 0; }
.gantt-label { position: sticky; left: 0; z-index: 3; display: grid; align-content: center; gap: 0; min-width: 0; padding: 0.3rem 0.7rem; border: 0; border-right: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 0.95rem; line-height: 1.25; text-align: left; }
button.gantt-label { cursor: pointer; }
button.gantt-label:hover { background: var(--hover); }
.gantt-label span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-row.stage { background: var(--stripe); }
.gantt-row.stage .gantt-label { background: var(--stripe); }
.gantt-head { position: relative; z-index: 4; background: var(--side-bg); }
.gantt-head .gantt-label { background: var(--side-bg); border-right-color: transparent; }
.gantt-track { position: relative; min-width: 0; }
.gantt-months span { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; padding: 0 0.5rem; overflow: hidden; border-left: 1px solid rgba(251, 248, 239, 0.25); color: var(--side-text); font-size: 0.85rem; font-weight: 700; white-space: nowrap; }
.gantt-months small { color: var(--gold); font-weight: 500; }
.gantt-body { position: relative; }
/* The lines of the months, today and the target run down behind the bars, right of the names. */
.gantt-lines, .gantt-marks { position: absolute; top: 0; bottom: 0; left: 15rem; right: 0; pointer-events: none; }
.gantt-lines { z-index: 0; }
.gantt-marks { z-index: 2; }
.gantt-lines i, .gantt-marks i { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--border); }
.gantt-marks .today-line { border-left: 2px solid #c62820; }
.gantt-marks .goal-line { border-left: 2px dashed var(--accent-edge); }
.gantt-bar { position: absolute; top: 0.45rem; bottom: 0.45rem; z-index: 1; min-width: 6px; padding: 0; overflow: hidden; border: 1px solid var(--accent-edge); border-radius: 7px; background: color-mix(in srgb, var(--gold) 25%, var(--surface)); cursor: pointer; }
.gantt-bar i { position: absolute; top: 0; left: 0; bottom: 0; background: var(--gold); }
.gantt-bar span { position: relative; padding: 0 0.4rem; font-size: 0.8rem; font-weight: 700; line-height: 1.6rem; color: #1f1f1f; }
.gantt-bar.tk-DONE { border-color: var(--line); background: var(--stripe); }
.gantt-bar.tk-DONE i { background: color-mix(in srgb, var(--in) 45%, var(--surface)); }
.gantt-bar.tk-BLOCKED { border-style: dashed; border-color: var(--set); }
.gantt-bar.late { border: 2px solid #c62820; }
.stage-span { position: absolute; top: 1.05rem; height: 0.5rem; border-radius: 999px; background: var(--line); opacity: 0.45; }
.milestone { position: absolute; top: 50%; z-index: 1; width: 1.1rem; height: 1.1rem; margin: -0.55rem 0 0 -0.55rem; padding: 0; border: 2px solid #1f1f1f; background: var(--gold); transform: rotate(45deg); cursor: pointer; }
.milestone.tk-DONE { background: var(--in); }
.milestone.late { background: #c62820; }
.gantt-key { font-size: 0.85rem; }
@media (max-width: 759px) {
  .gantt > * { min-width: 39.5rem; }
  .gantt-row { grid-template-columns: 9.5rem minmax(0, 1fr); }
  .gantt-lines, .gantt-marks { left: 9.5rem; }
}

/* Admin: the picture of a home button. */
.icon-picks { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.icon-pick { display: grid; place-items: center; width: 3.25rem; height: 3.25rem; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }
.icon-pick svg { width: 1.6rem; height: 1.6rem; }
.icon-pick[aria-pressed="true"] { border-color: var(--gold); background: var(--side-bg); color: var(--gold); }
.link-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.link-line svg { width: 1.4rem; height: 1.4rem; }

.choice-list { display: grid; gap: 0.6rem; }
.choice-list .btn { justify-content: flex-start; }
.lead.small-lead { margin: 0; font-size: 1.25rem; }
.locked.card { width: 100%; max-width: 40rem; margin: 2rem auto; }

/* ---------------------------------------------------------------- the home page: three big buttons */

.tiles { display: grid; gap: 0.6rem; }
.tile {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 5rem;
  padding: 0.6rem 1.1rem;
  border: 2px solid var(--accent-edge);
  border-radius: 18px;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 4px 0 var(--accent-edge);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
}
.tile svg { flex: none; width: 2.4rem; height: 2.4rem; }
.tile span span { display: block; font-size: 1.2rem; font-weight: 600; }
.tile:active { filter: brightness(0.92); }
@media (min-width: 760px) {
  .tiles { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
  .tile { flex-direction: column; justify-content: center; min-height: 8rem; text-align: center; }
}

/* ---------------------------------------------------------------- the calendar */

/* Each kind of event has its colour in --c, set by the script; a soft tint of it fills the
   space, and the text stays in the colour of the page so it is always easy to read. */
.dot { flex: none; display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 999px; background: var(--c, var(--gold)); }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.7rem;
  border: 1px solid var(--c, var(--line));
  border-radius: 999px;
  background: var(--stripe);
  background: color-mix(in srgb, var(--c, transparent) 16%, var(--surface));
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}
.tag::before { content: ""; width: 0.6rem; height: 0.6rem; border-radius: 999px; background: var(--c, var(--gold)); }

.event-card {
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-left: 8px solid var(--c, var(--gold));
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.event-card.clickable { cursor: pointer; }
.event-card.clickable:hover { background: var(--hover); }
.event-card strong { font-size: 1.15rem; line-height: 1.3; overflow-wrap: anywhere; }
.event-when { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.agenda-day { display: grid; gap: 0.45rem; margin-bottom: 0.9rem; }
.agenda-day h3 { margin: 0.2rem 0.1rem 0; font-size: 1.05rem; }
.agenda-day h3.today { color: var(--accent-edge); }
.agenda-day.past { opacity: 0.6; }
@media (prefers-color-scheme: dark) { .agenda-day h3.today { color: var(--gold); } }

body.cal main { max-width: 84rem; padding-bottom: 2.5rem; }
a.brand { color: inherit; text-decoration: none; }

.cal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; margin-bottom: 0.6rem; }
.cal-title { margin: 0; font: 700 1.7rem/1.2 var(--brand-font); }
.cal-title span { margin-left: 0.6rem; font-size: 1.15rem; font-weight: 400; color: var(--muted); }
.cal-nav { display: flex; gap: 0.5rem; }
.cal-nav .btn { min-width: 3.25rem; font-size: 1.3rem; }
.cal-nav .btn:nth-child(2) { font-size: 1.05rem; }
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; }
.cal-bar .segments { margin: 0; flex: 1 1 auto; }
.type-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.7rem 0; }
.type-chip { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 2.75rem; padding: 0.25rem 0.9rem; border: 2px solid var(--c, var(--line)); border-radius: 999px; background: color-mix(in srgb, var(--c, transparent) 16%, var(--surface)); font-weight: 700; }
/* A kind that is switched off: grey and crossed through, but still there to switch on again. */
.type-chip[aria-pressed="false"] { border-color: var(--border); background: var(--surface); color: var(--muted); text-decoration: line-through; }
.type-chip[aria-pressed="false"] .dot { opacity: 0.35; }

.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--border); gap: 1px; }
.month-dow { padding: 0.35rem 0.2rem; background: var(--side-bg); color: var(--side-text); font-size: 0.85rem; font-weight: 700; text-align: center; line-height: 1.2; }
.month-dow span { display: block; color: var(--gold); font-weight: 500; }
.month-day { display: flex; flex-direction: column; gap: 3px; min-width: 0; min-height: 3.6rem; padding: 0.25rem; background: var(--surface); cursor: pointer; }
.month-day:hover { background: var(--hover); }
.month-day.other { background: var(--stripe); }
.month-day.other .month-num { color: var(--muted); font-weight: 400; }
.month-num { align-self: flex-start; min-width: 1.8rem; padding: 0 0.3rem; border-radius: 999px; font-weight: 700; line-height: 1.8rem; text-align: center; font-variant-numeric: tabular-nums; }
.month-day.today .month-num { background: var(--gold); color: #1f1f1f; }
.month-day.selected { box-shadow: inset 0 0 0 3px var(--selected); }
.chip {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0.1rem 0.35rem;
  border: 0;
  border-left: 4px solid var(--c, var(--gold));
  border-radius: 6px;
  background: var(--stripe);
  background: color-mix(in srgb, var(--c, transparent) 18%, var(--surface));
  font-size: 0.8rem;
  line-height: 1.3;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip b { margin-right: 0.3rem; font-variant-numeric: tabular-nums; }
.month-more { color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.day-panel { display: grid; gap: 0.6rem; margin-top: 1rem; }
.day-panel h2 { margin: 0.2rem 0.1rem 0; }
/* On a phone a day of the month is too narrow for words: each event is a coloured line, and the
   events of the day that is tapped are listed under the month. */
@media (max-width: 759px) {
  .chip { height: 0.45rem; padding: 0; border: 0; border-radius: 4px; background: var(--c, var(--gold)); font-size: 0; pointer-events: none; }
  .month-more { font-size: 0.7rem; line-height: 1; }
  .month-dow { padding: 0.3rem 0; font-size: 0.75rem; }
  /* The calendar starts high on the screen: the buttons above it are packed closer. */
  .cal-title { font-size: 1.35rem; }
  .cal-title span { display: block; margin-left: 0; font-size: 1rem; }
  .cal-nav { gap: 0.35rem; }
  .cal-nav .btn { min-width: 2.9rem; padding: 0.3rem 0.6rem; }
  .cal-bar .segment { flex: 1 1 0; padding: 0.3rem 0.4rem; }
  .cal-bar > .btn { flex: 1 1 100%; }
  .type-chips { gap: 0.35rem; }
  .type-chip { min-height: 2.4rem; padding: 0.15rem 0.7rem; font-size: 0.9rem; }
}
@media (min-width: 760px) {
  .month-day { min-height: 7.5rem; padding: 0.35rem; }
  .month-dow { font-size: 0.95rem; }
}

/* The status of an event: "to confirm" has a dashed edge, "done" is quieter, "cancelled" is crossed through. */
.st-TENTATIVE.chip, .st-TENTATIVE.week-event, .st-TENTATIVE.week-bar { border-style: dashed; border-width: 2px 2px 2px 4px; border-color: var(--c, var(--gold)); }
.event-card.st-TENTATIVE { border-style: dashed; border-left-style: solid; }
.st-DONE.chip, .st-DONE.week-event, .st-DONE.week-bar, .event-card.st-DONE { opacity: 0.7; }
.st-CANCELLED.chip, .st-CANCELLED.week-event, .st-CANCELLED.week-bar, .event-card.st-CANCELLED, tr.st-CANCELLED { opacity: 0.55; text-decoration: line-through; }
.badge.ev-TENTATIVE { background: var(--set-bg); color: var(--set); }
.badge.ev-CONFIRMED { background: var(--in-bg); color: var(--in); }
.badge.ev-DONE { background: var(--bg); color: var(--muted); }
.badge.ev-CANCELLED { background: var(--out-bg); color: var(--out); }
.badge.private { background: var(--side-bg); color: var(--side-text); }
.event-when .badge { margin-left: 0.5rem; font-size: 0.8rem; }

/* Dragging, for managers on a computer. */
[draggable="true"] { cursor: grab; }
.dragging { opacity: 0.4; }
.drop { outline: 3px dashed var(--accent-edge); outline-offset: -3px; background: var(--hover) !important; }
.drag-hint { margin: 0 0 0.6rem; }

/* The week: the hours down the left, a column per day, whole-day events as bars in a band at the top. */
.week-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.week { min-width: 44rem; }
.week-row { display: grid; grid-template-columns: 3.6rem repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.week-row > .week-band { grid-column: 2 / -1; }
.week-corner { display: flex; align-items: center; justify-content: center; padding: 0.2rem; color: var(--muted); font-size: 0.75rem; text-align: center; line-height: 1.15; }
.week-head { background: var(--side-bg); }
/* The hours stay at the left while a narrow screen scrolls the days sideways. */
.week-row > .week-corner, .week-row > .week-hours { position: sticky; left: 0; z-index: 3; background: var(--surface); border-right: 1px solid var(--border); }
.week-head > .week-corner { background: var(--side-bg); border-right-color: transparent; }
.week-head .week-corner { background: var(--side-bg); }
.week-day { display: grid; justify-items: center; gap: 0; padding: 0.35rem 0.2rem; border: 0; border-left: 1px solid rgba(251, 248, 239, 0.15); background: var(--side-bg); color: var(--side-text); font-size: 0.85rem; line-height: 1.2; }
.week-day b { font-size: 1.25rem; }
.week-day span { color: var(--gold); font-size: 0.8rem; }
.week-day.today b { min-width: 2rem; border-radius: 999px; background: var(--gold); color: #1f1f1f; }
.week-day.selected { box-shadow: inset 0 -4px 0 var(--gold); }
.week-band { position: relative; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(1.9rem, auto); grid-auto-flow: row dense; gap: 3px; min-height: 2.2rem; padding: 3px; }
.week-band-slots { position: absolute; inset: 3px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.week-band-slot { border-radius: 6px; }
.week-bar { position: relative; z-index: 1; min-width: 0; padding: 0.15rem 0.5rem; border: 0; border-left: 4px solid var(--c, var(--gold)); border-radius: 6px; background: color-mix(in srgb, var(--c, transparent) 22%, var(--surface)); font-size: 0.85rem; font-weight: 700; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-bar b { margin-right: 0.35rem; font-weight: 400; }
.week-body { border-bottom: 0; }
.week-hour { height: 3rem; padding: 0 0.3rem; color: var(--muted); font-size: 0.75rem; text-align: right; transform: translateY(-0.5em); }
.week-hour:first-child { transform: none; }
.week-col { position: relative; border-left: 1px solid var(--border); background-image: repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px 3rem); }
.week-col.today { background-color: color-mix(in srgb, var(--gold) 7%, var(--surface)); }
.week-event { position: absolute; display: grid; align-content: start; gap: 0; min-height: 1.2rem; padding: 0.1rem 0.35rem; overflow: hidden; border: 0; border-left: 4px solid var(--c, var(--gold)); border-radius: 6px; background: color-mix(in srgb, var(--c, transparent) 22%, var(--surface)); box-shadow: 0 0 0 1px var(--surface); font-size: 0.8rem; line-height: 1.25; text-align: left; }
.week-event b { font-weight: 700; font-variant-numeric: tabular-nums; }
.week-event span { overflow-wrap: anywhere; }

/* The board: a column per status, the cards in it. */
.board { display: grid; grid-template-columns: repeat(4, minmax(15rem, 1fr)); gap: 0.8rem; overflow-x: auto; padding-bottom: 0.5rem; }
.board-col { display: grid; align-content: start; gap: 0.6rem; min-height: 10rem; padding: 0.7rem; border: 1px solid var(--border); border-radius: 14px; background: var(--stripe); }
.board-col h3 { display: flex; align-items: center; justify-content: space-between; margin: 0; font-size: 1.05rem; }
.board-count { min-width: 1.8rem; padding: 0 0.5rem; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 0.9rem; text-align: center; }
.col-TENTATIVE h3 { color: var(--set); }
.col-CONFIRMED h3 { color: var(--in); }
.col-CANCELLED h3 { color: var(--out); }
.board .empty { padding: 0.5rem; }

/* The form: people chosen from the staff list, and the to-do list. */
.person-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.person-chips:empty { display: none; }
.person-chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.3rem 0.2rem 0.8rem; border: 2px solid var(--selected); border-radius: 999px; background: var(--stripe); font-weight: 700; }
.person-chip small { color: var(--out); font-size: 0.8rem; font-weight: 400; }
.person-chip button { width: 2rem; height: 2rem; border: 0; border-radius: 999px; background: var(--bg); font-size: 1.2rem; line-height: 1; }
.todo-edit { display: grid; gap: 0.4rem; }
.todo-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.5rem; }
.todo-row input[type="checkbox"] { width: 1.6rem; height: 1.6rem; }
.todos { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.check.todo { min-height: 2.9rem; background: var(--surface); }
.check.todo.done span { color: var(--muted); text-decoration: line-through; }
.lock { font-size: 0.85em; }

.title-cell { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; }
.event-big-when { margin: 0; font-size: 1.2rem; font-weight: 700; }
.cat.type-pick { grid-template-columns: auto 1fr; column-gap: 0.6rem; }
.cat.type-pick .dot { grid-row: 1 / 3; width: 1.1rem; height: 1.1rem; }
.cat.type-pick[aria-pressed="true"] { border-color: var(--c, var(--gold)); }
.cat.type-pick[aria-pressed="true"] span { color: var(--side-muted); }
.steps { display: grid; gap: 0.5rem; margin: 0; padding-left: 1.5rem; font-size: 1.05rem; }
.sign-in { display: grid; gap: 0.85rem; }
.swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.swatch { width: 3rem; height: 3rem; border: 3px solid var(--surface); border-radius: 999px; background: var(--c); box-shadow: 0 0 0 2px var(--border); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--selected); }
.foot .btn { justify-self: start; }
.foot .text-size { max-width: 24rem; }

/* ---------------------------------------------------------------- QR labels and the poster: on paper only */

#printArea { display: none; }
.qr { display: block; background: #fff; }
.qr path { fill: #000; }
/* Labels for the devices, A4: three across, with a dashed line to cut along. */
.labels { grid-template-columns: repeat(3, 1fr); color: #000; font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif; }
.label { display: grid; grid-template-columns: 26mm minmax(0, 1fr); align-items: center; gap: 3mm; height: 36mm; padding: 3mm; border: 0.2mm dashed #999; overflow: hidden; line-height: 1.2; break-inside: avoid; }
.label .qr { width: 26mm; height: 26mm; }
.label-tag { font-size: 14pt; font-weight: 800; }
.label-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 8pt; overflow-wrap: anywhere; }
.label-how { margin-top: 1mm; font-size: 7.5pt; font-weight: 700; }
/* The poster for the wall: one page with the link of the helpdesk as a large code. */
.poster { justify-items: center; align-content: center; gap: 8mm; height: 265mm; color: #000; font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif; text-align: center; }
.poster img { width: 34mm; height: 32mm; }
.poster h1 { margin: 0; font-size: 44pt; line-height: 1.15; }
.poster .qr { width: 120mm; height: 120mm; }
.poster p { margin: 0; font-size: 22pt; font-weight: 700; line-height: 1.4; }
.poster small { font-size: 12pt; font-weight: 400; }
@media print {
  html, body { background: #fff !important; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: grid; }
}

/* ---------------------------------------------------------------- phone: a form fills the screen, a table is a list of cards */

@media (max-width: 759px) {
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }

  .table-wrap:not(.wide) { overflow: visible; border: 0; border-radius: 0; background: none; }
  .table-wrap:not(.wide) table, .table-wrap:not(.wide) tbody, .table-wrap:not(.wide) tr, .table-wrap:not(.wide) td { display: block; }
  .table-wrap:not(.wide) thead { display: none; }
  .table-wrap:not(.wide) tr {
    margin-bottom: 0.6rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .table-wrap:not(.wide) tr.clickable { border-left: 6px solid var(--gold); }
  .table-wrap:not(.wide) tr.urgent { border-left: 6px solid #c62820; }
  .table-wrap:not(.wide) tr.urgent td:first-child { box-shadow: none; }
  /* Each value with its heading in front; a value that is empty is left out. */
  .table-wrap:not(.wide) td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.2rem 0;
    border: 0;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .table-wrap:not(.wide) td::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--muted); font-weight: 400; text-align: left; }
  .table-wrap:not(.wide) td:empty { display: none; }
  .table-wrap:not(.wide) td:first-child { display: block; padding-bottom: 0.35rem; font-size: 1.1rem; font-weight: 700; text-align: left; }
  .table-wrap:not(.wide) td:first-child::before { content: none; }
  .table-wrap:not(.wide) td:first-child .meta, .table-wrap:not(.wide) td:first-child .desc { font-weight: 400; }
  .table-wrap:not(.wide) td.empty { font-size: 1rem; font-weight: 400; text-align: center; }
  .bar { justify-content: flex-end; min-width: 0; }
  .bar i { display: none; }
}

/* Phone and tablet: the choices and buttons above a list fill the line, so they are easy to hit. */
@media (max-width: 999px) {
  .segment { flex: 1 1 auto; }
  /* Two choices share the line half and half, also when one of the names is long. */
  .segment:first-child:nth-last-child(2), .segment:first-child:nth-last-child(2) ~ .segment { flex: 1 1 0; }
  /* Four or more: two on a line. */
  .segment:first-child:nth-last-child(n+4), .segment:first-child:nth-last-child(n+4) ~ .segment { flex: 1 1 40%; }
  .filters > .btn:not(.small) { flex: 1 1 auto; }
}

@media (min-width: 760px) {
  /* In a real table the column with the problem keeps room to be read; the table scrolls sideways if it must. */
  td.main { min-width: 17rem; }
  td.nowrap { white-space: nowrap; }
  body.it .toast { bottom: 1.5rem; }
  main { padding-left: 1.5rem; padding-right: 1.5rem; }
}

/* A ticket, and the report: one column on a phone, two on a desktop (further down). */
.ticket-grid, .report-grid, .ticket-grid > div, .report-grid > div { display: flex; flex-direction: column; gap: 0.85rem; min-width: 0; }

/* ---------------------------------------------------------------- IT on a desktop: the bar is a column at the left */

@media (min-width: 1000px) {
  .shell { display: grid; grid-template-columns: min(17rem, 30vw) minmax(0, 1fr); align-items: start; }
  .shell .side {
    height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: 1.25rem 1rem;
    border-bottom: 0;
    border-right: 4px solid var(--gold);
    overflow-y: auto;
  }
  .shell .brand { flex: none; height: auto; }
  .shell .brand-mark { width: 4.25rem; height: 4.25rem; padding: 0.3rem; border-radius: 14px; }

  .tabs { position: static; flex: 1 0 auto; flex-direction: column; justify-content: flex-start; gap: 0.35rem; padding: 0; border-top: 0; background: none; }
  .tabs button {
    flex: none;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.9rem;
    min-height: 3.6rem;
    padding: 0.4rem 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    text-align: left;
  }
  .tabs button:hover { background: rgba(251, 248, 239, 0.14); }
  .tabs button[aria-selected="true"], .tabs button[aria-selected="true"]:hover { background: var(--gold); }
  .tab-label span { display: inline; margin-left: 0.35rem; }
  .tabs .count-badge { position: static; margin-left: auto; }

  .side-tools { display: grid; }
  .side .tools-caption { color: var(--side-muted); }
  .side .text-size-btn { border-color: var(--side-line); background: none; color: var(--side-text); }
  .side .text-size-btn[aria-pressed="true"] { border-color: var(--gold); background: var(--gold); color: #1f1f1f; }
  .shell .user-btn { max-width: none; height: auto; padding: 0.6rem 0.9rem; }
  .shell .user-btn strong { font-size: 1.1rem; }
  .shell .user-role { font-size: 0.85rem; }
  .user-more { display: block; margin-top: 0.2rem; color: var(--gold); font-size: 0.85rem; font-weight: 600; }

  body.it main { max-width: 100rem; margin: 0; padding: 1.5rem 2rem 3rem; }
  .page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 1rem; margin: 0 0 1.25rem; padding-bottom: 0.8rem; border-bottom: 3px solid var(--gold); }
  .page-head h1 { margin: 0; font: 700 1.9rem/1.2 var(--brand-font); }
  body.it dialog.wide { width: min(58rem, calc(100vw - 3rem)); }
  /* A ticket on a wide screen: the ticket at the left, what happened to it at the right. */
  .ticket-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }

  /* Sign in: the company at the left, the form at the right. */
  .login { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  .login-brand { border-bottom: 0; border-right: 4px solid var(--gold); }
  .login-brand h1 { font-size: 2.6rem; }
  .login-company { font-size: 1.4rem; }
  .login .card { align-self: center; }
  .brand-mark.big { width: 14rem; height: 14rem; padding: 1.1rem; border-radius: 32px; }
}

/* The tables of the report, and the boxes of the settings: two side by side where the screen is wide enough for them. */
@media (min-width: 1400px) {
  .report-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.85rem 1.5rem; align-items: start; }
}

/* A low desktop screen (a laptop): the column at the left is packed closer so the account button
   stays in view. The text size is then chosen in the account dialog. */
@media (min-width: 1000px) and (max-height: 820px) {
  .shell .side { gap: 0.6rem; padding: 0.8rem 1rem; }
  .side-tools { display: none; }
  .shell .brand-mark { width: 3.5rem; height: 3.5rem; }
  .tabs button { min-height: 3.1rem; }
}
