/* WISERTrade Express Reports — aligned with admin brand system */
:root {
  color-scheme: light;
  --ink-900: #0a0d12;   /* v1.3 PRIMARY dark: was #1a1d24 */
  --cta-1: #16223a;   /* v1.3 CTA gradient: navy top... */
  --cta-2: #0d1424;   /* ...mid... */
  --cta-3: #0a0d12;   /* ...settling into ink-900 */
  --gold: #d99e2b;
  --gold-hover: #e6b54e;
  --gold-700: #8f6414;
  --gold-soft: #fbf3df;
  --paper: #ffffff;
  --page: #eef0f4;
  --muted: #54596a;
  --soft: #8a93a3;
  --line: #e3e6ec;
  --line-strong: #d5dae3;
  --navy: #0a3161;
  --teal: #155e63;
  --success: #2e7a51;
  --font-head: "Cabin", system-ui, sans-serif;
  --font-body: "Open Sans", system-ui, sans-serif;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 2px 4px rgba(13, 18, 25, 0.05), 0 10px 28px rgba(13, 18, 25, 0.08);
  --shadow-lg: 0 8px 28px rgba(22, 34, 58, 0.12);
  --header-h: 76px;   /* v1.3 header height; sets the brand block */
  --sidebar-w: 268px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink-900);
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(230, 181, 78, 0.14), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(22, 34, 58, 0.06), transparent 50%),
    var(--page);
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -0.02em; margin: 0; }

/* —— Login —— */
/* One centred card, no page furniture around it. The brand panel that used to
   take the left half is gone: this is reached from inside the portal, where the
   client has already met our branding. Centring rather than a page layout means
   the same markup works when the portal shows it in a modal. */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}
.login-panel { width: 100%; display: grid; place-items: center; }
.login-card {
  width: min(440px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.85rem 1.75rem;
  animation: rise 0.45s var(--ease) both;
}
.login-card-logo {
  width: 180px;
  margin-bottom: 1.25rem;
}
.login-card h2 {
  font-size: 1.55rem;
  color: var(--ink-900);
  margin-bottom: 0.25rem;
}
.login-card .subtitle {
  color: var(--muted);
  margin: 0 0 1.35rem;
  font-size: 0.95rem;
}
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--soft);
  margin-bottom: 0.4rem;
}
.form-group input, .field select, .field input {
  width: 100%;
  padding: 0.78rem 0.9rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  font: inherit;
  background: #fff;
  color: var(--ink-900);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus, .field select:focus, .field input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(217, 158, 43, 0.2);
}
.error-msg {
  display: none;
  align-items: center;
  gap: 0.45rem;
  background: #fdeaea;
  border: 1px solid #f5a8a8;
  color: #c53030;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}
.error-msg.show { display: flex; }

/* —— App shell —— */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
}
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 0 1rem 1.25rem;
  display: flex;
  flex-direction: column;
}
/* --header-h is v1.3's own header height, so the brand block's height is the
   design system's number rather than one picked to fit. */
.sidebar-brand {
  height: var(--header-h);
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 0.45rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.85rem;
}
/* Wide lockup (4.36:1), so sized on width and left to keep its own ratio. */
.sidebar-brand img {
  width: 100%;
  max-width: 170px;
  height: auto;
  display: block;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; }

/* Account block, pushed to the bottom. Identity and sign-out came down here when
   the topbar went: it was holding a page name the nav and the page's own hero
   already said. */
.sidebar-foot {
  margin-top: auto;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.account { padding: 0 0.2rem; min-width: 0; }
.account-name {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-block { width: 100%; justify-content: center; }
.nav-section {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--soft);
  padding: 0.65rem 0.7rem 0.35rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.75rem;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.15s var(--ease), color 0.15s;
  white-space: nowrap;
}
.nav-link:hover { background: #f0f2f6; color: var(--ink-900); }
.nav-link.active {
  background: var(--gold-soft);
  color: var(--gold-700);
}
/* Icons sit on the row itself. They used to each carry a grey rounded chip,
   which put five competing boxes in a five-item nav and fought the gold pill
   that marks the active row. */
.nav-ico {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--soft);
}
.nav-ico svg { width: 18px; height: 18px; }
.nav-link:hover .nav-ico { color: var(--muted); }
.nav-link.active .nav-ico { color: var(--gold-700); }

.main { min-width: 0; }
.content {
  padding: 1.5rem 1.75rem 2.5rem;
  animation: rise 0.4s var(--ease) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Flat ink-900. v1.3 names #0a0d12 the PRIMARY dark and uses navy only as the
   top stop of one gradient on the CTA panel — a shading device, not a brand
   colour. It matters here beyond the spec: our reports are house blue #1F5AA8,
   so blue chrome competes with the charts it frames, where near-black lets them
   be the blue thing on the screen. Gold also sits better on it.

   The gold radial that used to sit off the top-right corner is gone. It read as
   a light source nothing explained, and the diagonal navy-to-black gradient
   beneath it made that worse. */
.hero {
  background: var(--ink-900);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 1.6rem 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.35rem;
}
.hero-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-hover);
  margin-bottom: 0.45rem;
}
.hero h2 {
  font-size: clamp(1.55rem, 3vw, 2rem);
  margin-bottom: 0.4rem;
}
.hero p {
  margin: 0;
  color: rgba(255,255,255,0.78);
  max-width: none;
  width: 100%;
  line-height: 1.5;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 960px) { .grid-cards { grid-template-columns: 1fr; } }

.report-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.3rem 1.15rem;
  box-shadow: var(--shadow);
  transition: transform 0.18s var(--ease), border-color 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 168px;
}
.report-card:hover {
  transform: translateY(-3px);
  border-color: rgba(217, 158, 43, 0.55);
  box-shadow: var(--shadow-lg);
}
.report-card .card-ico {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--gold-soft);
  color: var(--gold-700);
}
.report-card .card-ico svg { width: 22px; height: 22px; }
.report-card h3 { color: var(--ink-900); font-size: 1.15rem; }
.report-card p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.45; flex: 1; }
.report-card .card-cta {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gold-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.4rem 1.45rem;
  margin-bottom: 1rem;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.card-head h2 {
  font-size: 1.25rem;
  color: var(--ink-900);
}
.card-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.field { margin-bottom: 0.95rem; }
.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--soft);
  margin-bottom: 0.4rem;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 700px) { .row { grid-template-columns: 1fr; } }
/* Column, not row: each option can now carry a plain-English hint under it.
   Only the three report forms use this; the user-management screens have their
   own .access-grid. */
.checks {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0.35rem 0 0.9rem;
}
.checks label {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.92rem;
}
/* Explains a term rather than assuming it. "Ag-adjusted" meant nothing to
   anyone who had not read the USDA note. */
.field-hint {
  margin: 0 0 0 1.55rem;
  color: var(--soft);
  font-size: 0.82rem;
  line-height: 1.45;
  max-width: none;
  width: 100%;
}
/* Generate button + output-format radios share one row (button left,
   radios right). Radios wrap below the button on narrow screens. */
.generate-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.5rem;
}
/* Strip default fieldset chrome so the radio group blends into the form. */
.output-options {
  border: 0;
  padding: 0;
  margin: 0;
  min-inline-size: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.output-options label {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.92rem;
}
/* Screen-reader-only (visually hidden but announced). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
/* Rollover help icon + tooltip. */
.help-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  font-size: 0.9rem;
  color: var(--soft);
  cursor: help;
}
.help-icon:hover,
.help-icon:focus-visible {
  color: var(--navy);
  outline: none;
}
.help-icon::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 145%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 250px;
  white-space: normal;
  text-align: left;
  font-weight: 500;
  font-size: 0.8rem;
  line-height: 1.35;
  color: #fff;
  background: var(--ink-900);
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s var(--ease);
  pointer-events: none;
  z-index: 30;
}
.help-icon:hover::after,
.help-icon:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 9px;
  padding: 0.78rem 1.2rem;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--gold-hover), var(--gold));
  color: var(--ink-900);
  box-shadow: 0 6px 18px rgba(217, 158, 43, 0.35);
  margin-top: 0.65rem;
}
.btn-primary:hover { background: linear-gradient(180deg, #edc56a, var(--gold-hover)); }
.btn-primary.is-loading {
  cursor: wait;
  pointer-events: none;
  opacity: 0.94;
  box-shadow: 0 4px 14px rgba(217, 158, 43, 0.28);
}
.btn-primary.is-loading:active { transform: none; }
.btn-spinner {
  display: none;
  width: 1.05rem;
  height: 1.05rem;
  border: 2.5px solid rgba(26, 29, 36, 0.18);
  border-top-color: var(--ink-900);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  flex-shrink: 0;
}
.btn-primary.is-loading .btn-spinner { display: inline-block; }

.report-generate-form.is-submitting .field,
.report-generate-form.is-submitting .checks {
  opacity: 0.72;
  pointer-events: none;
}
.card.is-generating {
  position: relative;
  overflow: hidden;
}
.card.is-generating::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 2;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--gold-hover) 35%,
    var(--gold) 50%,
    var(--gold-hover) 65%,
    transparent 100%
  );
  background-size: 220% 100%;
  animation: report-shimmer 1.35s ease-in-out infinite;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}
@keyframes report-shimmer {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}

/* —— Generate status: waiting, then the finished report —— */
.gen-status {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
  margin-top: 1rem;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.gen-status .gen-body { min-width: 0; flex: 1; }
.gen-status strong {
  display: block;
  font-family: var(--font-head);
  color: var(--ink-900);
  font-size: 1rem;
}
.gen-status .gen-sub {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-top: 0.15rem;
}
.gen-status .gen-file { word-break: break-word; }
.gen-status.is-working { border-color: rgba(217, 158, 43, 0.45); background: var(--gold-soft); }
.gen-status.is-done { border-color: #a9d7b8; background: #f2faf4; }
.gen-status.is-error { border-color: #f5a8a8; background: #fdeaea; }
.gen-status.is-error strong { color: #c53030; }

.gen-spinner {
  flex: none;
  width: 1.15rem; height: 1.15rem;
  margin-top: 0.1rem;
  border: 2.5px solid rgba(143, 100, 20, 0.25);
  border-top-color: var(--gold-700);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
.gen-tick, .gen-cross {
  flex: none;
  width: 1.35rem; height: 1.35rem;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}
.gen-tick { background: #3d9a55; }
.gen-cross { background: #c53030; }

.gen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
}
/* Tall enough to read a page of the report, not just prove one exists. */
.gen-preview {
  width: 100%;
  height: 560px;
  margin-top: 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  display: block;
}
@media (max-width: 700px) { .gen-preview { height: 380px; } }

.btn-ghost {
  background: #fff;
  color: var(--muted);
  border: 1.5px solid var(--line-strong);
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}
.btn-ghost:hover { color: var(--ink-900); background: #f5f6f8; }

.notice {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: #eef5ff;
  border: 1px solid #9ec5eb;
  color: #2c5688;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
}
.notice code {
  background: rgba(255,255,255,0.65);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.82rem;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--gold-soft);
  color: var(--gold-700);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.form-error {
  margin-top: 0.85rem;
  padding: 0.75rem 0.9rem;
  border-radius: 9px;
  background: #fdeaea;
  border: 1px solid #f5a8a8;
  color: #c53030;
  font-size: 0.9rem;
  font-weight: 600;
}
.form-error[hidden] { display: none; }

.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.85rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--soft);
  font-weight: 700;
}
.muted-sm { color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }
.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: #eef2f7;
  color: var(--ink-900);
}
.feat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-width: 320px;
}
.chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-700);
  white-space: nowrap;
  line-height: 1.2;
}
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.checks-wrap { flex-wrap: wrap; }
.req-hint { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }
textarea {
  width: 100%;
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  resize: vertical;
  background: #fff;
}
textarea:focus {
  outline: none;
  border-color: rgba(217, 158, 43, 0.7);
  box-shadow: 0 0 0 3px rgba(217, 158, 43, 0.15);
}

/* —— User management —— */
.users-card { padding-bottom: 0.5rem; }
.users-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  margin: -0.35rem 0 1rem;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  background: #f6f7f9;
  color: var(--muted);
  font-size: 0.86rem;
}
.users-summary strong { color: var(--ink-900); font-weight: 700; }
.users-summary .dot { opacity: 0.45; }
.users-table tbody tr:hover { background: #fafbfc; }
.users-table .row-inactive { opacity: 0.62; }
.users-table .col-actions { text-align: right; width: 1%; white-space: nowrap; }
.member-link { font-weight: 600; color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.member-link:hover { color: var(--accent, #0b5); }
.user-cell {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 160px;
}
.user-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #1e3354, #274066);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: var(--font-head);
}
.user-name { color: var(--ink-900); font-size: 0.95rem; }
.login-id {
  font-size: 0.84rem;
  background: #f3f5f8;
  padding: 0.18rem 0.45rem;
  border-radius: 6px;
  color: var(--ink-900);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.role-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
}
.role-admin {
  background: #16223a;
  color: #f0d48a;
}
.role-user {
  background: #eef2f7;
  color: var(--ink-900);
}
.access-all {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #2f6b3a;
  background: #e8f5eb;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
}
.access-all::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #3d9a55;
}
.access-none {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
}
.status-pill.status-on {
  background: #e8f5eb;
  color: #2f6b3a;
}
.status-pill.status-off {
  background: #fdeaea;
  color: #a33;
}
.empty-row {
  text-align: center;
  padding: 2rem 1rem !important;
  color: var(--muted);
}
.empty-row a { font-weight: 700; color: var(--gold-700); }

/* Add / edit user form */
.user-form-card { max-width: none; width: 100%; }
.user-form .form-section {
  margin: 0 0 1.35rem;
  padding: 1.1rem 1.15rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fcfcfd 0%, #fff 40%);
}
.form-section-head {
  margin-bottom: 0.95rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}
.form-section-head h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--ink-900);
  font-family: var(--font-head);
}
.form-section-head p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.25rem;
  padding-top: 0.25rem;
}
.btn-form-primary,
.btn-form-secondary {
  box-sizing: border-box;
  min-width: 118px;
  height: 44px;
  margin: 0;
  padding: 0 1.25rem;
  font-size: 0.95rem;
  font-family: var(--font-head);
  font-weight: 700;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
.btn-form-primary {
  border: 0;
  background: linear-gradient(180deg, var(--gold-hover), var(--gold));
  color: var(--ink-900);
  box-shadow: 0 6px 18px rgba(217, 158, 43, 0.35);
}
.btn-form-primary:hover {
  background: linear-gradient(180deg, #edc56a, var(--gold-hover));
}
.btn-form-secondary {
  background: #fff;
  color: var(--muted);
  border: 1.5px solid var(--line-strong);
}
.btn-form-secondary:hover {
  color: var(--ink-900);
  background: #f5f6f8;
}
.btn-danger {
  border: 0;
  background: #d92d20;
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover {
  background: #b42318;
}
.icon-actions {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: nowrap;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-700, #334155);
  cursor: pointer;
  text-decoration: none;
  line-height: 0;
}
.icon-btn:hover {
  background: #f5f7fa;
  border-color: var(--line-strong);
}
.icon-btn.icon-btn-warn:hover {
  color: #b42318;
  border-color: #fecdca;
  background: #fef3f2;
}
.icon-btn.icon-btn-ok:hover {
  color: #067647;
  border-color: #abefc6;
  background: #ecfdf3;
}
.icon-btn svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}
.status-cell-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
}
.status-toggle-link {
  font-size: 0.78rem;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.status-toggle-link:hover {
  color: var(--ink-900);
}
.status-toggle-link:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  text-decoration: none;
}
.access-banner {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.85rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  background: #eef5ff;
  border: 1px solid #9ec5eb;
  color: #2c5688;
  font-size: 0.86rem;
}
.access-banner strong { font-size: 0.9rem; }
.access-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.access-tile-all {
  grid-column: 1 / -1;
}
.access-ico-all {
  background: #16223a;
  color: #f0d48a;
  font-size: 0.62rem;
}
@media (max-width: 640px) {
  .access-grid { grid-template-columns: 1fr; }
}
.access-tile {
  display: block;
  margin: 0;
  cursor: pointer;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  color: inherit !important;
}
.access-tile input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.access-tile-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 76px;
  padding: 0.85rem 0.95rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.access-tile:hover .access-tile-inner {
  border-color: rgba(217, 158, 43, 0.55);
  box-shadow: 0 2px 10px rgba(22, 34, 58, 0.05);
}
.access-tile input:checked + .access-tile-inner {
  border-color: rgba(217, 158, 43, 0.85);
  background: linear-gradient(180deg, #fffaf0 0%, #fff 100%);
  box-shadow: 0 0 0 3px rgba(217, 158, 43, 0.12);
}
.access-tile input:focus-visible + .access-tile-inner {
  outline: 2px solid rgba(217, 158, 43, 0.7);
  outline-offset: 2px;
}
.access-ico {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--gold-soft);
  color: var(--gold-700);
  font-weight: 800;
  font-size: 0.72rem;
  font-family: var(--font-head);
  letter-spacing: 0.02em;
}
.access-ico-alt {
  background: #eef2f7;
  color: var(--ink-900);
}
.access-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.access-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink-900);
  line-height: 1.25;
  text-transform: none;
  letter-spacing: 0;
}
.access-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.access-check {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  background: #fff;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}
.access-tile input:checked + .access-tile-inner .access-check {
  background: var(--gold-700);
  border-color: var(--gold-700);
}
.access-tile input:checked + .access-tile-inner .access-check::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.form-section-access.is-admin .access-grid {
  opacity: 0.55;
  pointer-events: none;
}
.form-section-access.is-admin .access-tile-inner {
  background: #f7f8fa;
}

/* Users list toolbar / pagination / toggle / modal */
.users-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1rem;
  align-items: flex-end;
  margin-bottom: 0.85rem;
}
.users-search { flex: 1 1 220px; min-width: 200px; }
.users-search input {
  width: 100%;
  height: 42px;
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  padding: 0 0.85rem;
  font: inherit;
  background: #fff;
}
.users-search input:focus {
  outline: none;
  border-color: rgba(217, 158, 43, 0.7);
  box-shadow: 0 0 0 3px rgba(217, 158, 43, 0.15);
}
.users-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--soft);
}
.filter-field select {
  min-width: 120px;
  height: 42px;
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  padding: 0 0.65rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-900);
  background: #fff;
}
.users-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 0 0.35rem;
  border-top: 1px solid var(--line);
  margin-top: 0.35rem;
}
.page-size {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}
.page-size select {
  height: 36px;
  border: 1.5px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 0.45rem;
  font: inherit;
  background: #fff;
}
.page-meta { font-size: 0.85rem; color: var(--muted); }
.page-nav {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1.5px solid var(--line-strong);
  background: #fff;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.icon-btn:hover {
  color: var(--ink-900);
  background: #f5f6f8;
  border-color: rgba(217, 158, 43, 0.55);
}
.status-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.82rem;
}
.status-toggle.is-self { cursor: not-allowed; opacity: 0.7; }
.status-toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.status-toggle-ui {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #d6dbe3;
  position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
}
.status-toggle-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform 0.15s;
}
.status-toggle-input:checked + .status-toggle-ui {
  background: #3d9a55;
}
.status-toggle-input:checked + .status-toggle-ui::after {
  transform: translateX(18px);
}
.status-toggle-input:focus-visible + .status-toggle-ui {
  outline: 2px solid rgba(217, 158, 43, 0.7);
  outline-offset: 2px;
}
.status-toggle-label { min-width: 3.5rem; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(22, 34, 58, 0.45);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-overlay[hidden] { display: none !important; }
.modal-dialog {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  padding: 1.25rem 1.35rem 1.2rem;
  animation: rise 0.2s var(--ease) both;
}
.modal-dialog-wide {
  width: min(680px, 100%);
  max-height: min(90vh, 820px);
  overflow-y: auto;
}
.modal-dialog-confirm {
  width: min(440px, 100%);
}
.modal-dialog h3 {
  margin: 0 0 0.45rem;
  color: var(--ink-900);
  font-size: 1.1rem;
}
.modal-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1.15rem;
}
