/* =========================================================================
   Phillips Mushroom Farms — IT Help Desk
   One stylesheet for every page. Mobile first, no build step, no frameworks.
   Brand colors come from Admin → Branding and are injected as CSS variables
   at runtime by js/common.js.
   ========================================================================= */

:root {
  --brand-primary: #5b3a24;
  --brand-accent: #c9822f;
  --header-from: #3d2517;
  --header-to: #6b4526;
  --surface-tint: #f7f2ea;

  --bg: #f4efe6;
  --bg-2: #ece4d6;
  --surface: #fffdf9;
  --surface-2: #f8f3ea;
  --line: #e2d7c5;
  --line-strong: #cdbda4;

  --ink: #241a13;
  --ink-2: #5d4d3f;
  --ink-3: #8c7a68;
  --on-brand: #fff8ef;

  --ok: #3f7d58;
  --warn: #c9822f;
  --danger: #b3341f;
  --info: #2f6f9f;

  --radius-s: 8px;
  --radius: 14px;
  --radius-l: 22px;
  --shadow-1: 0 1px 2px rgba(58, 38, 22, .06), 0 2px 8px rgba(58, 38, 22, .05);
  --shadow-2: 0 4px 12px rgba(58, 38, 22, .09), 0 14px 34px rgba(58, 38, 22, .09);
  --shadow-3: 0 18px 50px rgba(35, 22, 12, .28);

  --tap: 46px;
  --wrap: 1180px;
  --ease: cubic-bezier(.22, .68, .36, 1);

  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16110d;
    --bg-2: #1d1712;
    --surface: #221b15;
    --surface-2: #2a221a;
    --line: #382d23;
    --line-strong: #4b3c2e;
    --ink: #f4ece1;
    --ink-2: #cdbda9;
    --ink-3: #9d8b77;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 4px 12px rgba(0, 0, 0, .45), 0 14px 34px rgba(0, 0, 0, .35);
    --shadow-3: 0 18px 50px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

/* Our display rules must never resurrect an element the markup hid. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 12% -8%, color-mix(in srgb, var(--brand-accent) 12%, transparent), transparent 70%),
    radial-gradient(760px 460px at 92% 6%, color-mix(in srgb, var(--brand-primary) 12%, transparent), transparent 72%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-wrap: break-word;
}

img { max-width: 100%; height: auto; display: block; }
a { color: color-mix(in srgb, var(--brand-primary) 72%, var(--info)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

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

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(14px, 4vw, 30px);
}

.wrap--narrow { max-width: 820px; }
.stack > * + * { margin-top: 18px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

.masthead {
  position: relative;
  color: var(--on-brand);
  background: linear-gradient(135deg, var(--header-from) 0%, var(--header-to) 62%, color-mix(in srgb, var(--brand-accent) 55%, var(--header-to)) 100%);
  overflow: hidden;
  isolation: isolate;
}

.masthead::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .5;
  background-image:
    radial-gradient(circle at 18% 120%, rgba(255, 255, 255, .16), transparent 45%),
    radial-gradient(circle at 88% -20%, rgba(255, 255, 255, .12), transparent 42%);
}

.masthead__bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-block: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand__mark {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22);
  backdrop-filter: blur(6px);
}

.brand__mark svg { width: 27px; height: 27px; }

.brand__text {
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.brand__mark {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .18s var(--ease);
}
.brand__org, .brand__dept { display: block; }
.brand__org {
  font-family: var(--font-display);
  font-size: clamp(1.02rem, 2.6vw, 1.3rem);
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand__dept {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: color-mix(in srgb, var(--on-brand) 76%, transparent);
}

.masthead__nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.navlink {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 999px;
  color: color-mix(in srgb, var(--on-brand) 88%, transparent);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.navlink:hover { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .18); }
.navlink[aria-current="page"] { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .28); color: #fff; }
.navlink--user {
  background: rgba(28, 16, 8, .34);
  border-color: rgba(255, 255, 255, .22);
  color: #fff;
  padding-left: 6px;
}
.navlink--user:hover { background: rgba(28, 16, 8, .5); }

.hero {
  padding-block: clamp(22px, 5vw, 44px) clamp(26px, 6vw, 52px);
  max-width: 720px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 6vw, 2.85rem);
  line-height: 1.1;
  margin: 0 0 10px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.hero p {
  margin: 0;
  font-size: clamp(.98rem, 2.4vw, 1.1rem);
  color: color-mix(in srgb, var(--on-brand) 84%, transparent);
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 18px;
  font-size: .85rem;
  color: color-mix(in srgb, var(--on-brand) 78%, transparent);
}
.hero__meta span { display: inline-flex; align-items: center; gap: 7px; }

.masthead__wave {
  display: block;
  width: 100%;
  height: 26px;
  color: var(--bg);
}

/* ----------------------------------------------------------------- cards */

main { padding-bottom: 64px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
  padding: clamp(18px, 3.4vw, 28px);
}

.card--flush { padding: 0; overflow: hidden; }
.card--lift { box-shadow: var(--shadow-2); }

.card__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.card__head h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin: 0;
  font-weight: 600;
}
.card__head p { margin: 4px 0 0; color: var(--ink-3); font-size: .9rem; }
.card__head .spacer { flex: 1 1 auto; }

.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 12px;
}
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.step-number {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--on-brand);
  background: linear-gradient(140deg, var(--brand-primary), var(--brand-accent));
}

/* ----------------------------------------------------------------- forms */

label { display: block; }

.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }

.field__label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 650;
  font-size: .93rem;
  margin-bottom: 7px;
}
.field__hint { font-weight: 400; font-size: .82rem; color: var(--ink-3); }
.req { color: var(--danger); font-weight: 700; }

input[type="text"], input[type="email"], input[type="tel"], input[type="search"],
input[type="password"], input[type="number"], input[type="url"], input[type="date"],
select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 14px;
  font: inherit;
  font-size: 1rem; /* keeps iOS from zooming on focus */
  color: var(--ink);
  background: var(--surface-2);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
  appearance: none;
}

textarea { min-height: 132px; resize: vertical; line-height: 1.6; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238c7a68' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 40px;
}

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible,
[tabindex]:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand-accent) 55%, transparent);
  outline-offset: 2px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand-accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-accent) 15%, transparent);
}

input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 12%, transparent);
}

.field__error {
  display: none;
  margin-top: 6px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--danger);
}
.field__error.show { display: block; }

.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-3 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.char-count { font-size: .78rem; color: var(--ink-3); text-align: right; margin-top: 5px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: var(--tap);
  padding: 11px 22px;
  font: inherit;
  font-weight: 650;
  font-size: .95rem;
  line-height: 1;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .14s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease), border-color .18s var(--ease), opacity .18s var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-1); }
.btn:active { transform: translateY(0) scale(.985); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn--primary {
  color: var(--on-brand);
  background: linear-gradient(135deg, var(--brand-primary), color-mix(in srgb, var(--brand-accent) 78%, var(--brand-primary)));
  border-color: transparent;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--brand-primary) 30%, transparent);
}
.btn--primary:hover { box-shadow: 0 6px 18px color-mix(in srgb, var(--brand-primary) 34%, transparent); }

.btn--ghost { background: transparent; border-color: var(--line-strong); }
.btn--quiet { background: transparent; border-color: transparent; color: var(--ink-2); padding-inline: 12px; }
.btn--quiet:hover { background: var(--surface-2); box-shadow: none; }
.btn--danger { color: #fff; background: var(--danger); border-color: transparent; }
.btn--sm { min-height: 36px; padding: 6px 14px; font-size: .85rem; }
.btn--lg { min-height: 54px; padding: 15px 34px; font-size: 1.05rem; }
.btn--block { width: 100%; }
.btn--icon { padding: 8px; min-height: 38px; width: 38px; border-radius: 12px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn-row--end { justify-content: flex-end; }

/* --------------------------------------------------------- choice tiles */

.tiles {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
}

.tile {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .16s var(--ease), background .16s var(--ease), transform .14s var(--ease), box-shadow .16s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.tile:hover { border-color: var(--brand-accent); transform: translateY(-1px); }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile__icon { font-size: 1.35rem; line-height: 1.1; flex: none; }
.tile__name { display: block; font-weight: 650; font-size: .92rem; line-height: 1.3; }
.tile__desc { display: block; font-size: .78rem; color: var(--ink-3); margin-top: 3px; line-height: 1.35; }
.tile:has(input:checked) {
  border-color: var(--brand-accent);
  background: color-mix(in srgb, var(--brand-accent) 12%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-accent) 18%, transparent);
}
.tile:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--brand-accent) 55%, transparent); outline-offset: 2px; }

.crit-list { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .crit-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .crit-list { grid-template-columns: repeat(4, 1fr); } }

.crit {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 15px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .16s var(--ease), background .16s var(--ease), transform .14s var(--ease);
}
.crit:hover { transform: translateY(-1px); }
.crit input { position: absolute; opacity: 0; pointer-events: none; }
.crit__dot {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  background: var(--dot, var(--ink-3));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot, var(--ink-3)) 22%, transparent);
}
.crit__name { display: block; font-weight: 700; font-size: .95rem; }
.crit__blurb { display: block; font-size: .78rem; color: var(--ink-3); line-height: 1.35; }
.crit:has(input:checked) {
  border-color: var(--dot);
  background: color-mix(in srgb, var(--dot) 12%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 18%, transparent);
}

/* --------------------------------------------------------------- uploads */

.dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-l);
  background: var(--surface-2);
  padding: 22px 18px;
  text-align: center;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.dropzone.is-over { border-color: var(--brand-accent); background: color-mix(in srgb, var(--brand-accent) 10%, var(--surface)); }
.dropzone__icon { font-size: 1.9rem; }
.dropzone__hint { font-size: .84rem; color: var(--ink-3); margin-top: 4px; }
.dropzone .btn-row { justify-content: center; margin-top: 12px; }

.thumbs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); margin-top: 14px; }
.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
  box-shadow: var(--shadow-1);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb__remove {
  position: absolute; top: 5px; right: 5px;
  width: 30px; height: 30px; border-radius: 50%;
  border: none; cursor: pointer;
  background: rgba(20, 12, 6, .74);
  color: #fff; font-size: 1rem; line-height: 1;
  display: grid; place-items: center;
  backdrop-filter: blur(3px);
}
.thumb--file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 8px;
  text-align: center;
  aspect-ratio: 1;
}
.thumb__icon { font-size: 1.9rem; line-height: 1; }
.thumb__label {
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink-2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.thumb__size { font-size: .68rem; color: var(--ink-3); }

.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: .88rem;
  text-decoration: none;
  color: inherit;
}
.file-row:hover { border-color: var(--line-strong); background: var(--surface); }
.file-row__icon { font-size: 1.25rem; flex: none; }
.file-row__name { font-weight: 600; overflow-wrap: anywhere; }
.file-row__meta { font-size: .76rem; color: var(--ink-3); }

.thumb__name {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 7px 5px;
  font-size: .68rem;
  color: #fff;
  background: linear-gradient(transparent, rgba(20, 12, 6, .82));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--badge, var(--ink-3)) 40%, transparent);
  color: color-mix(in srgb, var(--badge, var(--ink-3)) 82%, var(--ink));
  background: color-mix(in srgb, var(--badge, var(--ink-3)) 13%, transparent);
}
.badge__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--badge, var(--ink-3)); flex: none; }
.badge--solid { color: #fff; background: var(--badge); border-color: transparent; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink-2);
}

.tag-mono { font-family: var(--font-mono); font-size: .82rem; letter-spacing: .02em; }

/* ------------------------------------------------------------- callouts */

.callout {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--tone, var(--info)) 34%, transparent);
  background: color-mix(in srgb, var(--tone, var(--info)) 10%, var(--surface));
  font-size: .92rem;
}
.callout__icon { font-size: 1.15rem; line-height: 1.3; flex: none; }
.callout--warn { --tone: var(--warn); }
.callout--danger { --tone: var(--danger); }
.callout--ok { --tone: var(--ok); }

.banner {
  padding: 11px 0;
  font-size: .9rem;
  font-weight: 600;
  text-align: center;
  color: #fff;
  background: var(--info);
}
.banner--warning { background: var(--warn); }
.banner--outage { background: var(--danger); }

/* --------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(430px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius);
  background: #2a1d12;
  color: #fdf6ec;
  box-shadow: var(--shadow-3);
  font-size: .92rem;
  font-weight: 550;
  animation: toast-in .28s var(--ease);
  pointer-events: auto;
}
.toast--ok { background: #1f5138; }
.toast--error { background: #7d2415; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

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

.board-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-block: 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.stat-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
}
@media (min-width: 620px) { .stat-row { gap: 10px; grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 980px) { .stat-row { grid-template-columns: repeat(6, 1fr); } }

.stat {
  padding: 13px 15px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--tone, var(--brand-accent));
}
.stat__value { font-family: var(--font-display); font-size: 1.65rem; font-weight: 600; line-height: 1.05; }
.stat__label { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin-top: 3px; }

@media (max-width: 619px) {
  .stat { padding: 9px 10px; }
  .stat__value { font-size: 1.3rem; }
  .stat__label { font-size: .62rem; letter-spacing: .06em; }
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.filters select, .filters input[type="search"] { min-height: 40px; width: auto; min-width: 130px; flex: 0 1 auto; padding-block: 7px; font-size: .9rem; }
.filters input[type="search"] { flex: 1 1 200px; min-width: 160px; }
.filters input[type="date"] { flex: 0 0 auto; width: auto; min-height: 40px; padding-block: 7px; font-size: .9rem; }

.filters__toggle { display: none; }
@media (max-width: 799px) {
  .filters__toggle { display: inline-flex; }
  #advancedFilters { display: none; margin-top: 8px; }
  #advancedFilters.is-open { display: flex; }
  #advancedFilters select { flex: 1 1 46%; min-width: 0; }
  .masthead__bar { gap: 10px; padding-block: 11px; }
  .brand__mark { width: 38px; height: 38px; border-radius: 11px; }
  .brand__mark svg { width: 23px; height: 23px; }
  .masthead__nav { gap: 4px; width: 100%; margin-left: 0; }
  .navlink { font-size: .82rem; padding: 5px 11px; min-height: 34px; }
  .navlink .avatar { width: 21px; height: 21px; font-size: .6rem; }
}

.chip-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.chip {
  flex: none;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: .86rem;
  font-weight: 620;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s var(--ease);
}
.chip[aria-pressed="true"] {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--on-brand);
}

.ticket-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  margin-top: 18px;
}
@media (min-width: 760px) { .ticket-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1180px) { .ticket-grid { grid-template-columns: repeat(3, 1fr); } }

.ticket {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 17px 15px;
  border-radius: var(--radius-l);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
  transition: transform .16s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
  overflow: hidden;
}
.ticket::before {
  content: "";
  position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--crit, var(--ink-3));
}
.ticket:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.ticket.is-overdue { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }

.ticket__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ticket__num { font-family: var(--font-mono); font-size: .78rem; font-weight: 600; color: var(--ink-3); }
.ticket__subject { font-weight: 680; font-size: 1.02rem; line-height: 1.32; margin: 0; }
.ticket__meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--ink-3); }
.ticket__meta span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.ticket__foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding-top: 10px; margin-top: auto;
  border-top: 1px dashed var(--line);
  font-size: .8rem; color: var(--ink-3);
}
.avatar {
  width: 25px; height: 25px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .68rem; font-weight: 800; letter-spacing: .02em;
  color: var(--on-brand);
  background: linear-gradient(140deg, var(--brand-primary), var(--brand-accent));
  flex: none;
}
.avatar--empty { background: var(--surface-2); color: var(--ink-3); border: 1px dashed var(--line-strong); }

.empty-state {
  text-align: center;
  padding: 52px 20px;
  color: var(--ink-3);
}
.empty-state__icon { font-size: 2.6rem; opacity: .8; }
.empty-state h3 { font-family: var(--font-display); color: var(--ink-2); margin: 12px 0 4px; }

/* ---------------------------------------------------------------- drawer */

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(28, 18, 10, .5);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity .22s var(--ease);
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; z-index: 61;
  background: var(--bg);
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  transition: transform .3s var(--ease);
  overscroll-behavior: contain;
}
/* Phone: bottom sheet. Desktop: right rail. */
@media (max-width: 799px) {
  .drawer {
    left: 0; right: 0; bottom: 0;
    max-height: 92dvh;
    border-radius: var(--radius-l) var(--radius-l) 0 0;
    transform: translateY(102%);
  }
  .drawer.open { transform: none; }
  .drawer__grip {
    width: 42px; height: 4px; border-radius: 999px;
    background: var(--line-strong);
    margin: 9px auto 0;
    flex: none;
  }
}
@media (min-width: 800px) {
  .drawer {
    top: 0; right: 0; bottom: 0;
    width: min(640px, 100vw);
    transform: translateX(102%);
    border-left: 1px solid var(--line);
  }
  .drawer.open { transform: none; }
  .drawer__grip { display: none; }
}

.drawer__head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px clamp(16px, 3vw, 24px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.drawer__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: clamp(16px, 3vw, 24px);
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}
.drawer__body > * + * { margin-top: 20px; }

.detail-grid {
  display: grid;
  gap: 12px 20px;
  grid-template-columns: 1fr;
}
@media (min-width: 480px) { .detail-grid { grid-template-columns: 1fr 1fr; } }
.detail dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.detail dd { margin: 2px 0 0; font-weight: 600; font-size: .95rem; }

.control-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 520px) { .control-grid { grid-template-columns: 1fr 1fr; } }

.thread { display: flex; flex-direction: column; gap: 12px; }
.msg {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.msg--staff { background: color-mix(in srgb, var(--info) 8%, var(--surface)); border-color: color-mix(in srgb, var(--info) 24%, var(--line)); }
.msg--internal { background: color-mix(in srgb, var(--warn) 11%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 32%, var(--line)); border-style: dashed; }
.msg__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .8rem; color: var(--ink-3); margin-bottom: 5px; }
.msg__author { font-weight: 700; color: var(--ink-2); }
.msg__body { white-space: pre-wrap; font-size: .94rem; line-height: 1.55; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 20px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 14px; font-size: .86rem; color: var(--ink-2); }
.timeline li::before {
  content: ""; position: absolute; left: -21px; top: 6px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--brand-accent); border: 2px solid var(--bg);
}
.timeline time { display: block; font-size: .74rem; color: var(--ink-3); }

.photo-strip { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.photo-strip a { display: block; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.photo-strip img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s var(--ease); }
.photo-strip a:hover img { transform: scale(1.06); }

/* ----------------------------------------------------------------- table */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--surface); }
thead th {
  position: sticky; top: 0;
  text-align: left;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.nowrap, th.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------------ tabs */

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  -webkit-overflow-scrolling: touch;
}
.tab {
  flex: none;
  min-height: 42px;
  padding: 9px 16px;
  border: none;
  background: none;
  font: inherit;
  font-size: .92rem;
  font-weight: 650;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  border-radius: var(--radius-s) var(--radius-s) 0 0;
  white-space: nowrap;
  transition: color .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease);
}
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab[aria-selected="true"] { color: var(--brand-primary); border-bottom-color: var(--brand-accent); }
@media (prefers-color-scheme: dark) { .tab[aria-selected="true"] { color: var(--brand-accent); } }

.tabpanel[hidden] { display: none; }
.tabpanel > * + * { margin-top: 20px; }

/* --------------------------------------------------------- editable rows */

.rows { display: flex; flex-direction: column; gap: 10px; }
.row-item {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  grid-template-columns: 1fr;
}
@media (min-width: 760px) {
  .row-item { grid-template-columns: auto 130px 1fr 1fr auto; align-items: center; }
  /* Each list sets its own columns; below this width every row stacks. */
  .row-item--wide { grid-template-columns: var(--row-cols, auto 110px 1fr 90px 70px 80px auto); }
}
.row-item input, .row-item select { min-height: 40px; padding-block: 7px; font-size: .9rem; }
.row-item > * { min-width: 0; }
.row-item .switch { gap: 7px; white-space: nowrap; padding-right: 6px; }
.row-item .switch__text { font-size: .74rem; }
.row-item .btn--icon { justify-self: end; }
.row-item input[type="color"] { padding: 3px; height: 40px; min-height: 40px; cursor: pointer; }
.row-grip {
  align-self: center;
  cursor: grab;
  color: var(--ink-3);
  font-size: 1.1rem;
  line-height: 1;
  padding: 6px 2px;
  user-select: none;
  touch-action: none;
}
.row-grip:active { cursor: grabbing; }
.row-tools { display: flex; gap: 3px; align-items: center; justify-self: end; white-space: nowrap; }
@media (max-width: 759px) {
  /* Stacked rows: the tools get their own line, thumb-sized and right-aligned. */
  .row-tools { justify-self: stretch; justify-content: flex-end; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
  .row-tools .btn--icon { width: 44px; min-width: 44px; height: 40px; }
}
.row-tools .btn--icon { justify-self: auto; width: 36px; min-width: 36px; padding: 0; }
.row-tools .btn[disabled] { opacity: .3; pointer-events: none; }
.row-item--dragging { opacity: .45; }
.row-item--over { border-color: var(--brand-primary); box-shadow: 0 0 0 2px var(--brand-primary) inset; }

/* The grip is a mouse affordance; on a touch screen the arrows do the work. */
@media (hover: none) {
  .row-grip { display: none; }
}

.mini-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); display: block; margin-bottom: 3px; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 0; min-height: var(--tap); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  width: 46px; height: 27px; border-radius: 999px; flex: none;
  background: var(--line-strong);
  position: relative;
  transition: background .2s var(--ease);
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .2s var(--ease);
}
.switch input:checked + .switch__track { background: var(--ok); }
.switch input:checked + .switch__track::after { transform: translateX(19px); }
.switch input:focus-visible + .switch__track { outline: 3px solid color-mix(in srgb, var(--brand-accent) 55%, transparent); outline-offset: 2px; }
.switch__text { font-size: .92rem; font-weight: 600; }
.switch__text small { display: block; font-weight: 400; font-size: .8rem; color: var(--ink-3); }

/* ----------------------------------------------------------- auth screen */

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 5vw, 40px);
}
.auth-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-2);
  padding: clamp(24px, 5vw, 38px);
}
.auth-card__mark {
  width: 62px; height: 62px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 19px;
  color: var(--on-brand);
  background: linear-gradient(140deg, var(--header-from), var(--brand-accent));
  box-shadow: var(--shadow-2);
}
.auth-card__mark svg { width: 36px; height: 36px; }

/* --------------------------------------------------------------- receipt */

.receipt {
  text-align: center;
  padding: clamp(24px, 6vw, 44px) clamp(18px, 5vw, 40px);
}
.receipt__check {
  width: 76px; height: 76px; margin: 0 auto 18px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(140deg, var(--ok), color-mix(in srgb, var(--ok) 60%, var(--brand-accent)));
  box-shadow: 0 10px 30px color-mix(in srgb, var(--ok) 34%, transparent);
  animation: pop .45s var(--ease);
}
.receipt__check svg { width: 40px; height: 40px; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }

.ticket-number {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  font-weight: 700;
  letter-spacing: .06em;
  padding: 10px 22px;
  margin: 6px 0 4px;
  border-radius: var(--radius);
  color: var(--brand-primary);
  background: color-mix(in srgb, var(--brand-accent) 14%, var(--surface));
  border: 1.5px dashed color-mix(in srgb, var(--brand-accent) 45%, transparent);
}
@media (prefers-color-scheme: dark) { .ticket-number { color: var(--brand-accent); } }

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

.site-footer {
  padding-block: 26px 34px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: .85rem;
  margin-top: 40px;
}
.site-footer .btn-row { margin-top: 10px; }

/* ------------------------------------------------------------ spore pong */
/* The easter egg: five taps on the mushroom. See js/pong.js. */

.pong {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2vw, 24px);
  padding-bottom: max(clamp(8px, 2vw, 24px), env(safe-area-inset-bottom));
  background: rgba(12, 7, 4, .82);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .22s var(--ease);
}
.pong.is-open { opacity: 1; }

.pong__frame {
  width: min(100%, 1000px);
  touch-action: none;      /* dragging moves the paddle, not the page */
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform: translateY(12px) scale(.98);
  transition: transform .26s var(--ease);
}
.pong.is-open .pong__frame { transform: none; }

.pong__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff8ef;
}
.pong__title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.pong__score {
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: .08em;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
}
.pong__btn {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .08);
  color: #fff8ef;
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.pong__btn:hover { background: rgba(255, 255, 255, .18); }

.pong canvas {
  width: 100%;
  aspect-ratio: 5 / 3;
  max-height: calc(100dvh - 140px);
  border-radius: var(--radius-l);
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: var(--shadow-3);
  background: #150f0a;
  touch-action: none;      /* dragging moves the paddle, not the page */
  cursor: none;
  display: block;
}

.pong__hint {
  margin: 0;
  text-align: center;
  font-size: .82rem;
  color: rgba(255, 248, 239, .55);
}

@media (max-width: 560px) {
  .pong__title { font-size: .95rem; }
  .pong__hint { font-size: .74rem; }
  /* A 5:3 field on a portrait phone is a letterbox slit — give it more room
     and let the drag surface extend past the canvas. */
  .pong canvas { aspect-ratio: 4 / 3; }
}

/* -------------------------------------------------------------- spinners */

.spinner {
  width: 17px; height: 17px;
  border-radius: 50%;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite;
  height: 118px;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.hidden { display: none !important; }
.flex-spacer { flex: 1 1 auto; }

@media print {
  .masthead__nav, .board-toolbar, .btn, .site-footer { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}
