/* ==========================================================================
   Complaint & Commendation Portal — design system
   Light and dark themes, no external fonts or frameworks.
   ========================================================================== */

/* ---------- tokens ---------- */
:root {
  --brand: #D6001C;
  --brand-dark: #A80016;
  --brand-soft: #FEF2F3;
  --brand-ring: rgba(214, 0, 28, .28);

  --bg: #F1F5F9;
  --bg-soft: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #F1F5F9;

  --text: #0F172A;
  --text-2: #475569;
  --text-3: #64748B;
  --text-inv: #FFFFFF;

  --line: #E2E8F0;
  --line-2: #CBD5E1;

  --blue: #1D4ED8;    --blue-soft: #EFF6FF;
  --emerald: #047857; --emerald-soft: #ECFDF5;
  --amber: #B45309;   --amber-soft: #FFFBEB;
  --orange: #C2410C;  --orange-soft: #FFF7ED;
  --red: #B91C1C;     --red-soft: #FEF2F2;
  --violet: #6D28D9;  --violet-soft: #F5F3FF;
  --teal: #0F766E;    --teal-soft: #F0FDFA;
  --cyan: #0E7490;    --cyan-soft: #ECFEFF;
  --pink: #BE185D;    --pink-soft: #FDF2F8;
  --indigo: #4338CA;  --indigo-soft: #EEF2FF;
  --slate: #475569;   --slate-soft: #F1F5F9;

  --r-sm: 7px; --r: 11px; --r-lg: 15px; --r-xl: 20px;
  --sh-1: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
  --sh-2: 0 2px 6px rgba(15,23,42,.06), 0 8px 20px -8px rgba(15,23,42,.12);
  --sh-3: 0 12px 40px -12px rgba(15,23,42,.28);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --topbar-h: 62px;
  --maxw: 1400px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1120;
    --bg-soft: #0F172A;
    --surface: #131C2E;
    --surface-2: #182236;
    --surface-3: #1E293B;

    --text: #F1F5F9;
    --text-2: #B6C2D4;
    --text-3: #8B9AB0;

    --line: #263449;
    --line-2: #33455E;

    --brand-soft: #2A1116;
    --blue-soft: #14213D;   --blue: #7EA6FF;
    --emerald-soft: #0B2A22; --emerald: #5EE9B5;
    --amber-soft: #2A2110;  --amber: #FBBF24;
    --orange-soft: #2C1B10; --orange: #FB923C;
    --red-soft: #2C1418;    --red: #FCA5A5;
    --violet-soft: #1F1A38; --violet: #C4B5FD;
    --teal-soft: #0A2723;   --teal: #5EEAD4;
    --cyan-soft: #0A2530;   --cyan: #67E8F9;
    --pink-soft: #2C1524;   --pink: #F9A8D4;
    --indigo-soft: #1A1D3D; --indigo: #A5B4FC;
    --slate-soft: #1B2739;  --slate: #94A3B8;

    --sh-1: 0 1px 2px rgba(0,0,0,.4);
    --sh-2: 0 2px 8px rgba(0,0,0,.4), 0 10px 24px -10px rgba(0,0,0,.6);
    --sh-3: 0 16px 48px -12px rgba(0,0,0,.7);
  }
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { margin: 0; font-weight: 700; letter-spacing: -.018em; line-height: 1.25; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-3); padding: .12em .4em; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 999;
  background: var(--surface); color: var(--text); padding: .6rem 1rem;
  border-radius: var(--r-sm); box-shadow: var(--sh-2);
}
.skip-link:focus { left: 12px; }

.icon { flex: none; vertical-align: middle; }
.muted { color: var(--text-3); }
.link { color: var(--brand); font-weight: 600; }
.req { color: var(--brand); }
.hide-sm { display: inline; }
.rule { border-top: 1px solid var(--line); margin: 1.25rem 0; }
.warn-text { color: var(--amber); font-weight: 600; }

/* ==========================================================================
   Top bar
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  min-height: var(--topbar-h);
  padding: 0 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}

.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(140deg, var(--brand), var(--brand-dark));
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 3px 10px -2px var(--brand-ring);
}
.brand-mark-lg { width: 48px; height: 48px; border-radius: 13px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: .98rem; letter-spacing: -.02em; }
.brand-sub { font-size: .72rem; color: var(--text-3); font-weight: 500; }

.nav-toggle {
  display: none; background: none; border: 0; color: var(--text-2);
  padding: .45rem; border-radius: var(--r-sm); cursor: pointer;
}

.mainnav { display: flex; align-items: center; gap: .15rem; flex: 1; }
.navlink {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .7rem; border-radius: var(--r-sm);
  color: var(--text-2); font-weight: 600; font-size: .875rem;
  white-space: nowrap; transition: background .14s, color .14s;
}
.navlink:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.navlink.is-active { background: var(--brand-soft); color: var(--brand); }
.navlink.is-active .icon { color: var(--brand); }

.navpill {
  font-size: .68rem; font-weight: 800; line-height: 1;
  padding: .2rem .38rem; border-radius: 999px; min-width: 18px; text-align: center;
}
.navpill-danger { background: var(--red); color: #fff; }
.navpill-warn { background: var(--amber); color: #fff; }
.navpill-brand { background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) {
  .navpill-danger, .navpill-warn { color: #0B1120; }
}

.topbar-actions { display: flex; align-items: center; gap: .6rem; flex: none; }

.quicksearch { position: relative; display: flex; align-items: center; }
.quicksearch .icon { position: absolute; left: .6rem; color: var(--text-3); pointer-events: none; }
.quicksearch input {
  width: 230px; padding: .5rem .7rem .5rem 2rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: .85rem; font-family: inherit;
  transition: width .18s, border-color .14s;
}
.quicksearch input:focus { width: 290px; outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }

/* user menu */
.usermenu { position: relative; }
.usermenu-trigger {
  display: flex; align-items: center; gap: .5rem;
  background: none; border: 1px solid transparent; border-radius: 999px;
  padding: .28rem .55rem .28rem .28rem; cursor: pointer; color: var(--text);
  font-family: inherit;
}
.usermenu-trigger:hover { background: var(--surface-3); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: linear-gradient(140deg, var(--slate), var(--text-2));
  color: #fff; display: grid; place-items: center;
  font-size: .74rem; font-weight: 800; letter-spacing: .02em;
}
.avatar-sm { width: 26px; height: 26px; font-size: .64rem; }
.usermenu-name { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.usermenu-label { font-size: .82rem; font-weight: 700; }
.usermenu-role { font-size: .68rem; color: var(--text-3); }

.usermenu-panel {
  position: absolute; right: 0; top: calc(100% + .5rem); min-width: 250px; z-index: 80;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-3); padding: .35rem; overflow: hidden;
}
.usermenu-head { padding: .7rem .75rem .6rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; }
.usermenu-head-name { font-weight: 700; font-size: .9rem; }
.usermenu-head-mail { font-size: .76rem; color: var(--text-3); word-break: break-all; }
.usermenu-head-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.usermenu-item {
  display: flex; align-items: center; gap: .55rem; width: 100%;
  padding: .55rem .7rem; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text); font: inherit; font-size: .87rem; font-weight: 600;
  cursor: pointer; text-align: left;
}
.usermenu-item:hover { background: var(--surface-3); text-decoration: none; }
.usermenu-item-danger { color: var(--red); }
.usermenu-item-danger:hover { background: var(--red-soft); }

/* ==========================================================================
   Page frame
   ========================================================================== */
.page { max-width: var(--maxw); margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }

.pagehead {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.pagehead-title { font-size: 1.65rem; }
.pagehead-sub { color: var(--text-3); margin: .3rem 0 0; font-size: .92rem; max-width: 68ch; }
.pagehead-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.backlink {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .84rem; font-weight: 600; color: var(--text-3); margin-bottom: 1rem;
}
.backlink:hover { color: var(--brand); text-decoration: none; }

.footer {
  max-width: var(--maxw); margin: 0 auto; padding: 1.25rem;
  color: var(--text-3); font-size: .78rem; display: flex; gap: .5rem; flex-wrap: wrap;
  border-top: 1px solid var(--line);
}
.footer-dot { opacity: .5; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1rem; border-radius: var(--r-sm); border: 1px solid transparent;
  font: inherit; font-size: .88rem; font-weight: 650; line-height: 1.2;
  cursor: pointer; white-space: nowrap; transition: background .14s, border-color .14s, transform .06s, box-shadow .14s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: .45rem .75rem; font-size: .83rem; }
.btn-block { width: 100%; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.14); }
.btn-primary:hover { background: var(--brand-dark); }

.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--line-2); }

.btn-success { background: var(--emerald); color: #fff; }
.btn-success:hover { filter: brightness(.93); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }

.btn-danger-ghost { background: transparent; color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.btn-danger-ghost:hover { background: var(--red-soft); }

/* Certificate action — gold, so it reads as a reward rather than an alert. */
.btn-award { background: linear-gradient(140deg, #C79A33, #A6822B); color: #fff; border-color: #A6822B; }
.btn-award:hover { background: linear-gradient(140deg, #B8891F, #8F6F22); color: #fff; }

@media (prefers-color-scheme: dark) {
  .btn-success, .btn-danger { color: #0B1120; }
}

.iconbtn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text-3); cursor: pointer;
}
.iconbtn:hover { background: var(--surface-3); color: var(--text); }
.iconbtn-danger:hover { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .2rem .5rem; border-radius: 999px;
  font-size: .715rem; font-weight: 700; line-height: 1.5;
  white-space: nowrap; border: 1px solid transparent;
}
.badge-xs { font-size: .64rem; padding: .1rem .38rem; }

.badge-slate   { background: var(--slate-soft);   color: var(--slate); }
.badge-blue    { background: var(--blue-soft);    color: var(--blue); }
.badge-emerald { background: var(--emerald-soft); color: var(--emerald); }
.badge-amber   { background: var(--amber-soft);   color: var(--amber); }
.badge-orange  { background: var(--orange-soft);  color: var(--orange); }
.badge-red     { background: var(--red-soft);     color: var(--red); }
.badge-violet  { background: var(--violet-soft);  color: var(--violet); }
.badge-teal    { background: var(--teal-soft);    color: var(--teal); }
.badge-cyan    { background: var(--cyan-soft);    color: var(--cyan); }
.badge-pink    { background: var(--pink-soft);    color: var(--pink); }
.badge-indigo  { background: var(--indigo-soft);  color: var(--indigo); }

.badge-outline { background: transparent; border-color: currentColor; }
.badge-solid.badge-red     { background: var(--brand); color: #fff; }
.badge-solid.badge-emerald { background: var(--emerald); color: #fff; }
@media (prefers-color-scheme: dark) { .badge-solid.badge-emerald { color: #0B1120; } }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
  margin-bottom: 1.15rem; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .9rem 1.15rem; border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.card-head h2 {
  display: flex; align-items: center; gap: .5rem;
  font-size: .93rem; font-weight: 700; letter-spacing: -.01em;
}
.card-head .icon { color: var(--text-3); }
.card-count {
  margin-left: auto; font-size: .74rem; font-weight: 700; color: var(--text-3);
  background: var(--surface-3); border-radius: 999px; padding: .12rem .5rem;
}
.card-byline { margin-left: auto; font-size: .78rem; color: var(--text-3); }
.card-body { padding: 1.15rem; }
.card-accent { border-color: color-mix(in srgb, var(--brand) 22%, var(--line)); }
.card-accent > .card-head { background: var(--brand-soft); }
.card-review > .card-head { background: var(--surface-2); }

.subhead {
  font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); margin: 1.25rem 0 .55rem;
  display: flex; align-items: center; gap: .35rem;
}
.subhead:first-child { margin-top: 0; }

/* ==========================================================================
   Stats
   ========================================================================== */
.statgrid {
  display: grid; gap: .75rem; margin-bottom: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.stat {
  display: flex; align-items: center; gap: .75rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: .85rem .95rem; box-shadow: var(--sh-1);
  color: var(--text); transition: transform .12s, box-shadow .14s, border-color .14s;
}
.stat-link:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--sh-2); border-color: var(--line-2); }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.stat-icon-blue    { background: var(--blue-soft);    color: var(--blue); }
.stat-icon-red     { background: var(--red-soft);     color: var(--red); }
.stat-icon-amber   { background: var(--amber-soft);   color: var(--amber); }
.stat-icon-orange  { background: var(--orange-soft);  color: var(--orange); }
.stat-icon-emerald { background: var(--emerald-soft); color: var(--emerald); }
.stat-icon-slate   { background: var(--slate-soft);   color: var(--slate); }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat-label { font-size: .75rem; color: var(--text-3); font-weight: 600; }
.stat-danger { border-color: color-mix(in srgb, var(--red) 38%, transparent); background: var(--red-soft); }

/* ==========================================================================
   Banners
   ========================================================================== */
.banner {
  display: flex; align-items: center; gap: .85rem;
  padding: .85rem 1rem; border-radius: var(--r); border: 1px solid;
  margin-bottom: .75rem; color: var(--text);
}
.banner:hover { text-decoration: none; filter: brightness(.985); }
.banner-icon { flex: none; display: grid; place-items: center; }
.banner-body { display: flex; flex-direction: column; gap: .1rem; flex: 1; min-width: 0; }
.banner-body strong { font-size: .91rem; }
.banner-body span { font-size: .82rem; color: var(--text-2); }
.banner-action { display: inline-flex; align-items: center; gap: .2rem; font-size: .82rem; font-weight: 700; flex: none; }

.banner-danger { background: var(--red-soft);    border-color: color-mix(in srgb, var(--red) 32%, transparent); }
.banner-danger .banner-icon, .banner-danger .banner-action { color: var(--red); }
.banner-warn   { background: var(--orange-soft); border-color: color-mix(in srgb, var(--orange) 32%, transparent); }
.banner-warn .banner-icon, .banner-warn .banner-action { color: var(--orange); }
.banner-info   { background: var(--blue-soft);   border-color: color-mix(in srgb, var(--blue) 32%, transparent); }
.banner-info .banner-icon, .banner-info .banner-action { color: var(--blue); }

/* callouts inside a page */
.callout {
  display: flex; gap: .85rem; padding: 1rem 1.15rem;
  border-radius: var(--r); border: 1px solid; margin-bottom: 1.15rem;
}
.callout h3 { font-size: .95rem; margin-bottom: .3rem; }
.callout p { font-size: .88rem; color: var(--text-2); }
.callout-note { font-size: .8rem !important; color: var(--text-3) !important; margin-top: .4rem; }
.callout-icon { flex: none; }
.callout-danger { background: var(--red-soft);  border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.callout-danger .callout-icon, .callout-danger h3 { color: var(--red); }
.callout-info   { background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 30%, transparent); }
.callout-info .callout-icon, .callout-info h3 { color: var(--blue); }

/* ==========================================================================
   Flash / toast
   ========================================================================== */
.flash-stack { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.15rem; }
.flash {
  display: flex; align-items: flex-start; gap: .65rem;
  padding: .75rem .9rem; border-radius: var(--r); border: 1px solid;
  font-size: .88rem; animation: flashIn .22s ease-out;
}
@keyframes flashIn { from { opacity: 0; transform: translateY(-5px); } }
.flash-body { flex: 1; }
.flash-icon { flex: none; margin-top: 1px; }
.flash-close {
  background: none; border: 0; font-size: 1.15rem; line-height: 1;
  color: inherit; opacity: .5; cursor: pointer; padding: 0 .15rem;
}
.flash-close:hover { opacity: 1; }
.flash-success { background: var(--emerald-soft); border-color: color-mix(in srgb, var(--emerald) 30%, transparent); color: var(--emerald); }
.flash-error   { background: var(--red-soft);     border-color: color-mix(in srgb, var(--red) 30%, transparent);     color: var(--red); }
.flash-warning { background: var(--amber-soft);   border-color: color-mix(in srgb, var(--amber) 32%, transparent);   color: var(--amber); }
.flash-info    { background: var(--blue-soft);    border-color: color-mix(in srgb, var(--blue) 30%, transparent);    color: var(--blue); }
.flash a { color: inherit; text-decoration: underline; }

.toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; }

/* ==========================================================================
   Forms
   ========================================================================== */
.stack { display: flex; flex-direction: column; gap: .95rem; }
.formgrid { display: grid; gap: .95rem; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); margin-bottom: .95rem; }
.field-pair { display: grid; gap: .95rem; grid-template-columns: 1fr 1fr; }

.field-group { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field-label { font-size: .8rem; font-weight: 650; color: var(--text-2); }
.field-hint { font-size: .755rem; color: var(--text-3); line-height: 1.45; }
.field-narrow { max-width: 240px; }
.field-grow { flex: 1; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="search"], input[type="date"], input[type="datetime-local"], input[type="number"],
input[type="tel"], select, textarea {
  width: 100%; padding: .58rem .7rem;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .88rem;
  transition: border-color .14s, box-shadow .14s;
}
textarea { resize: vertical; min-height: 76px; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring);
}
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: .75; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .55rem center; padding-right: 2rem;
}

.field-with-button { position: relative; display: flex; }
.field-with-button input { padding-right: 2.6rem; }
.field-button {
  position: absolute; right: .3rem; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--text-3); cursor: pointer;
  padding: .35rem; border-radius: var(--r-sm);
}
.field-button:hover { color: var(--text); background: var(--surface-3); }

.field-check { display: flex; align-items: center; gap: .5rem; font-size: .86rem; cursor: pointer; }
.field-check input { width: 16px; height: 16px; accent-color: var(--brand); flex: none; cursor: pointer; }

.field-inline { flex-direction: row; align-items: center; gap: .5rem; }
.field-inline .field-label { white-space: nowrap; }
.inline-form { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.form-actions { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.form-note { font-size: .78rem; color: var(--text-3); }

.formbar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; justify-content: flex-end; gap: .6rem;
  padding: .85rem 1.15rem; margin-top: .5rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-2);
}

.strength { display: flex; align-items: center; gap: .5rem; font-size: .74rem; }
.strength-bar { flex: 1; height: 4px; border-radius: 3px; background: var(--surface-3); overflow: hidden; position: relative; }
.strength-bar::after {
  content: ''; position: absolute; inset: 0 auto 0 0; width: var(--w, 0%);
  background: var(--c, var(--amber)); transition: width .2s, background .2s;
}
.strength-text { color: var(--text-3); font-weight: 600; min-width: 60px; }

/* type picker */
.typepick { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.typecard { position: relative; cursor: pointer; }
.typecard input { position: absolute; opacity: 0; }
.typecard-body {
  display: flex; align-items: center; gap: .75rem;
  padding: .9rem 1rem; border: 2px solid var(--line); border-radius: var(--r);
  background: var(--surface-2); transition: border-color .14s, background .14s;
}
.typecard input:checked + .typecard-body { border-color: var(--brand); background: var(--brand-soft); }
.typecard input:focus-visible + .typecard-body { box-shadow: 0 0 0 3px var(--brand-ring); }
.typecard-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.typecard-icon-red { background: var(--red-soft); color: var(--red); }
.typecard-icon-emerald { background: var(--emerald-soft); color: var(--emerald); }
.typecard-text { display: flex; flex-direction: column; }
.typecard-text strong { font-size: .95rem; }
.typecard-text small { font-size: .77rem; color: var(--text-3); }

/* dropzone */
.dropzone { position: relative; border: 2px dashed var(--line-2); border-radius: var(--r); background: var(--surface-2); transition: border-color .14s, background .14s; }
.dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: 1.5rem 1rem; text-align: center; pointer-events: none; }
.dropzone-inner .icon { color: var(--text-3); }
.dropzone-inner strong { font-size: .88rem; }
.dropzone-inner small { font-size: .76rem; color: var(--text-3); }
.dropzone-list { list-style: none; margin: .55rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.dropzone-list li {
  display: flex; align-items: center; gap: .5rem; font-size: .8rem;
  background: var(--surface-3); border-radius: var(--r-sm); padding: .4rem .6rem;
}
.dropzone-list .size { margin-left: auto; color: var(--text-3); font-size: .74rem; }

/* assignment picker */
.assign { display: flex; flex-direction: column; gap: 1.15rem; }
.assign-head { display: flex; flex-direction: column; gap: .15rem; margin-bottom: .6rem; }
.checkgrid { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); }
.checkcard { position: relative; cursor: pointer; }
.checkcard input { position: absolute; opacity: 0; }
.checkcard-body {
  display: flex; flex-direction: column; gap: .1rem;
  padding: .6rem .75rem; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); transition: border-color .14s, background .14s;
}
.checkcard input:checked + .checkcard-body { border-color: var(--brand); background: var(--brand-soft); }
.checkcard input:focus-visible + .checkcard-body { box-shadow: 0 0 0 3px var(--brand-ring); }
.checkcard-name { font-size: .85rem; font-weight: 650; }
.checkcard-meta { font-size: .72rem; color: var(--text-3); }
.checkcard.is-empty .checkcard-body { opacity: .72; }

.assign-people > summary, .reassign > summary { cursor: pointer; list-style: none; }
.assign-people > summary::-webkit-details-marker, .reassign > summary::-webkit-details-marker { display: none; }
.assign-people > summary { display: flex; flex-direction: column; gap: .1rem; padding: .5rem 0; }
.reassign { margin-top: .85rem; border-top: 1px solid var(--line); padding-top: .85rem; }
.reassign > summary { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 650; color: var(--text-2); }
.reassign > summary:hover { color: var(--brand); }
.reassign form { margin-top: .85rem; }

.peoplelist { display: flex; flex-direction: column; gap: .85rem; margin-top: .6rem; max-height: 340px; overflow-y: auto; padding-right: .3rem; }
.peoplegroup-head {
  font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); padding: .2rem 0 .3rem;
}
.peoplerow { display: flex; align-items: center; gap: .55rem; padding: .4rem .5rem; border-radius: var(--r-sm); cursor: pointer; }
.peoplerow:hover { background: var(--surface-3); }
.peoplerow input { width: 16px; height: 16px; accent-color: var(--brand); flex: none; }
.peoplerow-body { display: flex; flex-direction: column; min-width: 0; }
.peoplerow-name { font-size: .85rem; font-weight: 600; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.peoplerow-mail { font-size: .73rem; color: var(--text-3); }

/* ==========================================================================
   Filters
   ========================================================================== */
.filters {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: .8rem; margin-bottom: 1.15rem; box-shadow: var(--sh-1);
}
.filters-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.field-search { position: relative; display: flex; align-items: center; flex: 1; min-width: 220px; }
.field-search .icon { position: absolute; left: .65rem; color: var(--text-3); pointer-events: none; }
.field-search input { padding-left: 2.1rem; }
.filters-more { position: relative; }
.filters-grid {
  display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--line);
  align-items: end;
}

/* ==========================================================================
   Entry list
   ========================================================================== */
.entry-list { display: flex; flex-direction: column; gap: .65rem; }

.entry-card {
  position: relative; display: flex; align-items: stretch;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--sh-1); overflow: hidden;
  transition: box-shadow .15s, border-color .15s, transform .1s;
}
.entry-card:hover { box-shadow: var(--sh-2); border-color: var(--line-2); }
.entry-card-bar { width: 4px; flex: none; background: var(--brand); }
.entry-card.is-commendation .entry-card-bar { background: var(--emerald); }
.entry-card.is-overdue { border-color: color-mix(in srgb, var(--red) 42%, transparent); }
.entry-card.is-overdue .entry-card-bar { background: var(--red); }

.entry-card-body { flex: 1; padding: .85rem 1rem; min-width: 0; display: flex; flex-direction: column; gap: .5rem; }
.entry-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.entry-card-ident { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.entry-wf { font-size: 1.02rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.entry-wf:hover { color: var(--brand); text-decoration: none; }
.entry-card-summary { font-size: .87rem; color: var(--text-2); margin: 0; line-height: 1.5; }
.entry-card-meta { display: flex; gap: .85rem; flex-wrap: wrap; }
.meta { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; color: var(--text-3); }
.meta .icon { color: var(--text-3); opacity: .8; }

.entry-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; padding-top: .5rem; border-top: 1px dashed var(--line);
}
.entry-card-assign { display: flex; gap: .3rem; flex-wrap: wrap; }
.entry-card-status { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-left: auto; }
.entry-card-age { font-size: .74rem; color: var(--text-3); }

.seen { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600; }
.seen-done  { color: var(--emerald); }
.seen-open  { color: var(--amber); }
.seen-none  { color: var(--text-3); }
/* Opened repeatedly and still not actioned. */
.seen-stale {
  color: var(--red); background: var(--red-soft);
  border-radius: 999px; padding: .12rem .5rem;
  border: 1px solid color-mix(in srgb, var(--red) 28%, transparent);
}

.entry-card-open {
  display: grid; place-items: center; width: 42px; flex: none;
  color: var(--text-3); border-left: 1px solid var(--line); background: var(--surface-2);
}
.entry-card-open:hover { background: var(--surface-3); color: var(--brand); text-decoration: none; }

.countdown {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .55rem; border-radius: 999px;
  font-size: .755rem; font-weight: 700; border: 1px solid transparent;
}
.countdown-ok      { background: var(--surface-3); color: var(--text-3); }
.countdown-warning { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 30%, transparent); }
.countdown-overdue { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 34%, transparent); }
.countdown-lg { padding: .5rem .8rem; border-radius: var(--r-sm); font-size: .82rem; }
.countdown-lg span { display: flex; flex-direction: column; line-height: 1.25; }
.countdown-lg small { font-weight: 500; opacity: .82; font-size: .72rem; }

/* ==========================================================================
   Entry detail
   ========================================================================== */
.entryhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.entryhead-badges { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .5rem; }
.entryhead-title { font-size: 1.85rem; letter-spacing: -.03em; }
.entryhead-meta { font-size: .84rem; color: var(--text-3); margin: .35rem 0 0; }
.entryhead-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.detail-grid { display: grid; gap: 1.15rem; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.detail-main { min-width: 0; }
.detail-side { position: sticky; top: calc(var(--topbar-h) + 1rem); }

.kv { margin: 0; display: grid; gap: 0; }
.kv-row { display: grid; grid-template-columns: 190px 1fr; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.kv-row:last-child { border-bottom: 0; }
.kv dt { font-size: .8rem; color: var(--text-3); font-weight: 600; }
.kv dd { margin: 0; font-size: .88rem; font-weight: 600; }
.kv-hidden { color: var(--text-3); font-weight: 500; display: inline-flex; align-items: center; gap: .3rem; }

.prose { font-size: .9rem; line-height: 1.65; color: var(--text-2); word-break: break-word; }
.prose a { text-decoration: underline; }
.prose-quote {
  background: var(--surface-2); border-left: 3px solid var(--brand);
  border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: .85rem 1rem;
}
.linkrow { display: flex; align-items: center; gap: .4rem; font-size: .85rem; margin-top: .75rem; word-break: break-all; }

/* Verbatim customer feedback */
.quote {
  position: relative; margin: 0; padding: .35rem 0 .35rem 2.4rem;
  font-size: 1rem; line-height: 1.65; font-style: italic; color: var(--text);
}
.quote::before {
  content: "\201C"; position: absolute; left: 0; top: -.35rem;
  font-family: Georgia, serif; font-size: 3rem; line-height: 1; color: var(--brand); opacity: .35;
}
.quote cite {
  display: block; margin-top: .55rem; font-style: normal;
  font-size: .8rem; font-weight: 650; color: var(--text-3); letter-spacing: .02em;
}

.field-optional { font-weight: 500; color: var(--text-3); }

.emptynote {
  display: flex; align-items: center; gap: .55rem;
  padding: .8rem .9rem; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text-3); font-size: .85rem;
}
.emptynote-warn { background: var(--amber-soft); color: var(--amber); }
.emptynote-danger { background: var(--red-soft); color: var(--red); align-items: flex-start; }

/* "Opened N times" counter on the record page */
.openstat {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem .85rem; margin-bottom: .85rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.openstat-num { font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--text); }
.openstat-label { font-size: .8rem; color: var(--text-2); line-height: 1.35; }
.openstat-sub { display: block; font-size: .73rem; color: var(--text-3); }
.openstat-alert { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.openstat-alert .openstat-num { color: var(--red); }
.investigate-form { margin-top: 1.35rem; padding-top: 1.35rem; border-top: 1px solid var(--line); }

.review-split { display: grid; gap: 1.25rem; grid-template-columns: 1fr 1fr; }
.review-approve, .review-reject { padding: 1rem; border-radius: var(--r); border: 1px solid var(--line); }
.review-approve { background: var(--emerald-soft); border-color: color-mix(in srgb, var(--emerald) 24%, transparent); }
.review-reject  { background: var(--red-soft);     border-color: color-mix(in srgb, var(--red) 24%, transparent); }
.review-approve .subhead { color: var(--emerald); }
.review-reject  .subhead { color: var(--red); }
.review-approve textarea, .review-approve input, .review-reject textarea { background: var(--surface); }

.chiprow { display: flex; gap: .35rem; flex-wrap: wrap; }

/* files */
.filelist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.filelist li { display: flex; align-items: center; gap: .4rem; }
.filelist-link {
  flex: 1; display: flex; align-items: center; gap: .6rem;
  padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text); min-width: 0;
}
.filelist-link:hover { background: var(--surface-3); border-color: var(--line-2); text-decoration: none; }
.filelist-ico { color: var(--text-3); flex: none; }
.filelist-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.filelist-name { font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist-meta { font-size: .73rem; color: var(--text-3); }
.filelist-dl { color: var(--text-3); flex: none; }
.filelist-compact .filelist-link { padding: .4rem .6rem; }

.thumbgrid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.thumb {
  display: flex; flex-direction: column; border: 1px solid var(--line);
  border-radius: var(--r-sm); overflow: hidden; background: var(--surface-2); color: var(--text);
}
.thumb:hover { border-color: var(--brand); text-decoration: none; }
.thumb img { width: 100%; height: 108px; object-fit: cover; background: var(--surface-3); }
.thumb-name { font-size: .73rem; padding: .4rem .5rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-file { align-items: center; justify-content: center; padding-top: 1rem; }
.thumb-ico { color: var(--text-3); }

.lightbox {
  position: fixed; inset: 0; z-index: 300; background: rgba(2,6,23,.9);
  display: grid; place-items: center; padding: 2rem;
}
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; gap: .6rem; }
.lightbox img { max-width: 92vw; max-height: 80vh; object-fit: contain; border-radius: var(--r-sm); }
.lightbox figcaption { color: #E2E8F0; font-size: .82rem; text-align: center; }
.lightbox-close {
  position: absolute; top: 1rem; right: 1.25rem; background: none; border: 0;
  color: #fff; font-size: 2rem; line-height: 1; cursor: pointer; opacity: .8;
}
.lightbox-close:hover { opacity: 1; }

/* comments */
.commentlist { list-style: none; margin: 0 0 1.15rem; padding: 0; display: flex; flex-direction: column; gap: .85rem; }
.comment { display: flex; gap: .6rem; }
.comment-body { flex: 1; background: var(--surface-2); border-radius: var(--r-sm); padding: .6rem .8rem; min-width: 0; }
.comment-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .2rem; }
.comment-head strong { font-size: .85rem; }
.comment-time { font-size: .73rem; color: var(--text-3); }
.comment-text { font-size: .87rem; color: var(--text-2); line-height: 1.55; word-break: break-word; }
.comment-form { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.comment-form textarea { width: 100%; }

/* viewers */
.viewerlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.viewerlist li { display: flex; gap: .55rem; align-items: flex-start; }
.viewerlist strong { font-size: .85rem; display: block; }
.viewer-dept { font-size: .73rem; color: var(--text-3); display: block; }
.viewer-time { font-size: .73rem; color: var(--text-3); display: block; margin-top: .1rem; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 1.5px; background: var(--line); }
.timeline-item { position: relative; display: flex; gap: .7rem; padding-bottom: .95rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: relative; z-index: 1; flex: none;
  width: 23px; height: 23px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-3);
  border: 2px solid var(--surface);
}
.timeline-blue .timeline-dot    { background: var(--blue-soft); color: var(--blue); }
.timeline-emerald .timeline-dot { background: var(--emerald-soft); color: var(--emerald); }
.timeline-red .timeline-dot     { background: var(--red-soft); color: var(--red); }
.timeline-amber .timeline-dot   { background: var(--amber-soft); color: var(--amber); }
.timeline-orange .timeline-dot  { background: var(--orange-soft); color: var(--orange); }
.timeline-violet .timeline-dot  { background: var(--violet-soft); color: var(--violet); }
.timeline-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; padding-top: .1rem; }
.timeline-body strong { font-size: .83rem; }
.timeline-detail { font-size: .79rem; color: var(--text-2); word-break: break-word; }
.timeline-time { font-size: .72rem; color: var(--text-3); }

/* ==========================================================================
   Tables
   ========================================================================== */
.tablewrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 560px; }
table.data th, table.data td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data thead th {
  background: var(--surface-2); font-size: .73rem; font-weight: 750;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--line); }

/* ==========================================================================
   Empty states
   ========================================================================== */
.emptystate {
  text-align: center; padding: 3rem 1.5rem;
  background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r-lg);
}
.emptystate-page { max-width: 560px; margin: 3rem auto; }
.emptystate-icon {
  display: inline-grid; place-items: center; width: 62px; height: 62px;
  border-radius: 50%; background: var(--surface-3); color: var(--text-3); margin-bottom: 1rem;
}
.emptystate-icon-danger { background: var(--red-soft); color: var(--red); }
.emptystate h1, .emptystate h2 { font-size: 1.15rem; margin-bottom: .4rem; }
.emptystate p { color: var(--text-3); font-size: .88rem; max-width: 46ch; margin-inline: auto; }
.emptystate-note { font-size: .8rem !important; margin-top: .75rem !important; }
.emptystate .btn { margin-top: 1.15rem; }

/* ==========================================================================
   Pagination
   ========================================================================== */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 1.25rem; }
.pager-summary { font-size: .8rem; color: var(--text-3); margin: 0; }
.pager-links { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.pager-btn, .pager-num {
  display: inline-flex; align-items: center; gap: .2rem;
  padding: .4rem .65rem; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface);
  font-size: .82rem; font-weight: 600; color: var(--text-2);
}
.pager-btn:hover, .pager-num:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.pager-num.is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager-btn.is-disabled { opacity: .45; pointer-events: none; }
.pager-gap { color: var(--text-3); padding: 0 .2rem; }

/* ==========================================================================
   Auth screens
   ========================================================================== */
.auth-body { background: var(--bg); }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-aside {
  background: linear-gradient(150deg, var(--brand) 0%, var(--brand-dark) 55%, #6B0010 100%);
  color: #fff; display: flex; align-items: center; padding: 3rem;
}
.auth-aside-inner { max-width: 440px; }
.auth-logo { display: flex; align-items: center; gap: .85rem; margin-bottom: 2.5rem; }
.auth-logo .brand-mark { background: rgba(255,255,255,.16); box-shadow: none; }
.auth-logo-name { font-size: 1.2rem; font-weight: 800; letter-spacing: -.02em; }
.auth-logo-org { font-size: .8rem; opacity: .8; }
.auth-aside-title { font-size: 2rem; line-height: 1.25; margin-bottom: 2rem; letter-spacing: -.03em; }
.auth-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.15rem; }
.auth-points li { display: flex; gap: .8rem; align-items: flex-start; }
.auth-points .icon { flex: none; margin-top: 2px; opacity: .9; }
.auth-points strong { display: block; font-size: .92rem; }
.auth-points span { display: block; font-size: .82rem; opacity: .82; line-height: 1.5; }

.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1.5rem; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--sh-2); padding: 2rem;
}
.auth-title { font-size: 1.5rem; margin-bottom: .35rem; }
.auth-sub { color: var(--text-3); font-size: .88rem; margin-bottom: 1.5rem; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: .84rem; }
.auth-help { max-width: 400px; font-size: .8rem; color: var(--text-3); text-align: center; margin-top: 1.25rem; }
.auth-foot { font-size: .76rem; color: var(--text-3); margin-top: 1.5rem; }
.auth-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 1rem; }
.auth-icon-warn { background: var(--amber-soft); color: var(--amber); }
.invite-summary { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1.5rem; }

/* ==========================================================================
   Admin
   ========================================================================== */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; overflow-x: auto; }
.tab {
  padding: .6rem .85rem; font-size: .86rem; font-weight: 650; color: var(--text-3);
  border-bottom: 2px solid transparent; white-space: nowrap;
  display: inline-flex; align-items: center; gap: .4rem;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }

.userlist { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.usercard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: .85rem; box-shadow: var(--sh-1); display: flex; flex-direction: column; gap: .6rem;
}
.usercard.is-pending { border-style: dashed; border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); }
.usercard.is-inactive { opacity: .62; }
.usercard-top { display: flex; gap: .65rem; align-items: flex-start; }
.usercard-id { flex: 1; min-width: 0; }
.usercard-name { font-size: .93rem; font-weight: 700; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.usercard-mail { font-size: .78rem; color: var(--text-3); word-break: break-all; }
.usercard-tags { display: flex; gap: .3rem; flex-wrap: wrap; }
.usercard-foot { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding-top: .55rem; border-top: 1px solid var(--line); }
.usercard-meta { font-size: .73rem; color: var(--text-3); margin-right: auto; }

.settings-grid { display: grid; gap: 1.15rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }

.listgrid { display: grid; gap: 1.15rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.lookuprow { display: flex; align-items: center; gap: .5rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.lookuprow:last-of-type { border-bottom: 0; }
.lookuprow-name { flex: 1; font-size: .86rem; font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.lookuprow.is-off .lookuprow-name { color: var(--text-3); text-decoration: line-through; }
.lookuprow-actions { display: flex; gap: .25rem; }
.addrow { display: flex; gap: .4rem; margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--line); }

.mailrow-sent   { color: var(--emerald); }
.mailrow-failed { color: var(--red); }
.mailrow-queued { color: var(--amber); }

/* ==========================================================================
   Analytics
   ========================================================================== */
.report-nav { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.report-chip {
  padding: .42rem .75rem; border-radius: 999px; font-size: .82rem; font-weight: 650;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
}
.report-chip:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.report-chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

.kpigrid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1.15rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 1rem; box-shadow: var(--sh-1);
}
.kpi-label { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.kpi-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.035em; line-height: 1.15; margin: .25rem 0 .1rem; }
.kpi-sub { font-size: .77rem; color: var(--text-3); }
.kpi-good .kpi-value { color: var(--emerald); }
.kpi-bad .kpi-value  { color: var(--red); }
.kpi-warn .kpi-value { color: var(--amber); }

.chart { width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; gap: .85rem; flex-wrap: wrap; margin-top: .75rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; color: var(--text-2); }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }

.bars { display: flex; flex-direction: column; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 190px) 1fr auto; gap: .7rem; align-items: center; }
.bar-label { font-size: .82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 9px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: var(--brand); transition: width .4s ease-out; }
.bar-value { font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; }

.scorepill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 46px; padding: .18rem .45rem; border-radius: var(--r-sm);
  font-size: .8rem; font-weight: 800; font-variant-numeric: tabular-nums;
}
.score-a { background: var(--emerald-soft); color: var(--emerald); }
.score-b { background: var(--blue-soft); color: var(--blue); }
.score-c { background: var(--amber-soft); color: var(--amber); }
.score-d { background: var(--red-soft); color: var(--red); }

.podium { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 1.15rem; }
.podium-card {
  background: linear-gradient(150deg, var(--emerald-soft), var(--surface));
  border: 1px solid color-mix(in srgb, var(--emerald) 26%, transparent);
  border-radius: var(--r); padding: 1.15rem; text-align: center;
}
.podium-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--emerald); color: #fff; margin-bottom: .6rem; }
.podium-name { font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; }
.podium-meta { font-size: .8rem; color: var(--text-3); }

details.drill { border-top: 1px solid var(--line); }
details.drill > summary {
  cursor: pointer; padding: .55rem .2rem; font-size: .82rem; font-weight: 650; color: var(--text-2);
  display: flex; align-items: center; gap: .35rem; list-style: none;
}
details.drill > summary::-webkit-details-marker { display: none; }
details.drill > summary:hover { color: var(--brand); }
details.drill[open] > summary { color: var(--brand); }
.drill-body { padding: .25rem 0 .85rem; }

/* ==========================================================================
   Print
   ========================================================================== */
.print-body { background: var(--surface-3); }
.print-toolbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.print-toolbar-title { font-weight: 700; font-size: .9rem; }
.print-sheet {
  max-width: 940px; margin: 1.5rem auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); padding: 2.5rem; box-shadow: var(--sh-1);
}
.print-head { display: flex; justify-content: space-between; gap: 1.5rem; align-items: flex-start; padding-bottom: 1.15rem; border-bottom: 3px solid var(--brand); margin-bottom: 1.75rem; }
.print-org { font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .09em; color: var(--brand); }
.print-title { font-size: 1.6rem; margin-top: .25rem; }
.print-meta { font-size: .78rem; color: var(--text-3); text-align: right; }
.print-foot { margin-top: 2.25rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .73rem; color: var(--text-3); text-align: center; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .review-split { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

@media (max-width: 900px) {
  .nav-toggle { display: grid; place-items: center; order: 3; }
  .mainnav {
    order: 5; flex-basis: 100%; flex-direction: column; align-items: stretch;
    gap: .15rem; padding: .5rem 0 .75rem; border-top: 1px solid var(--line); margin-top: .25rem;
  }
  .mainnav[hidden] { display: none; }
  .topbar-inner { flex-wrap: wrap; padding: .55rem 1rem; }
  .topbar-actions { order: 4; margin-left: auto; }
  .quicksearch { display: none; }
  .kv-row { grid-template-columns: 1fr; gap: .1rem; }
  .field-pair { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .page { padding: 1.15rem .85rem 3rem; }
  .hide-sm { display: none; }
  .usermenu-name { display: none; }
  .entryhead-title { font-size: 1.45rem; }
  .pagehead-title { font-size: 1.35rem; }
  .entry-card-open { display: none; }
  .card-body { padding: .95rem; }
  .auth-card { padding: 1.5rem; }
  .print-sheet { padding: 1.25rem; margin: .75rem; }
  .bar-row { grid-template-columns: 1fr; gap: .2rem; }
  .bar-value { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
