/* =====================================================================
   Birat Doctor Profile Manager — Clean Light SaaS UI
   Modern design system: white surfaces, Pixo pink/orange accent, Inter type.
   ===================================================================== */

:root {
  /* layout */
  --sidebar-open: 264px;
  --sidebar-closed: 78px;

  /* surfaces */
  --bg: #f4f5f8;
  --bg-grad-1: #eef1f6;
  --bg-grad-2: #f6f7fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #f1f3f8;

  /* ink */
  --ink: #0f1729;
  --ink-soft: #2d3748;
  --muted: #64708a;
  --muted-2: #9aa3b6;

  /* lines */
  --border: #e6e8ef;
  --border-strong: #d6dae4;

  /* brand / accent — matches the Pixo Studio logo (pink #FF2E74 + orange #FF7A3D) */
  --accent: #ff2e74;
  --accent-hover: #ea1f68;
  --accent-press: #c81659;
  --accent-soft: #ffe7f0;
  --accent-soft-2: #ffd1e1;
  --accent-ink: #c31760;
  --accent-2: #ff7a3d;

  /* status */
  --danger: #e11d48;
  --danger-hover: #be123c;
  --danger-soft: #fff1f3;
  --success: #16a34a;
  --success-soft: #ecfdf3;

  /* radii */
  --r-xl: 22px;
  --r-lg: 16px;
  --r-md: 11px;
  --r-sm: 8px;
  --r-pill: 999px;

  /* shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 41, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 41, 0.07), 0 1px 2px rgba(15, 23, 41, 0.04);
  --shadow-md: 0 6px 18px rgba(15, 23, 41, 0.08);
  --shadow-lg: 0 18px 44px rgba(15, 23, 41, 0.13);
  --ring: 0 0 0 3px rgba(255, 46, 116, 0.2);

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden; /* the app shell owns the viewport; only inner regions scroll */
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(255, 46, 116, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(255, 122, 61, 0.06), transparent 55%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  letter-spacing: -0.014em;
}

/* ============================= shell ============================= */

.app-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  display: grid;
  grid-template-columns: var(--sidebar-open) 1fr;
  grid-template-rows: 100%; /* single full-height row so the workspace fills, no dead space */
  background: var(--surface);
  overflow: hidden;
  transition: grid-template-columns 0.32s var(--ease);
}

.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-closed) 1fr;
}

/* ============================ sidebar ============================ */

.sidebar {
  background: linear-gradient(180deg, #fbfbfe, #f6f7fb);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 0;
  overflow-y: auto; /* if nav ever exceeds height, the sidebar scrolls itself, not the page */
  transition: padding 0.24s var(--ease);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px;
  min-width: 0;
}

.brand-mark {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 6px 16px rgba(255, 46, 116, 0.35);
}

.brand-logo {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  object-fit: contain;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s var(--ease);
}

.brand-text strong {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--ink);
}

.brand-text span {
  font-size: 0.72rem;
  color: var(--muted-2);
  font-weight: 500;
}

.sidebar-section-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 0 10px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s var(--ease);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  position: relative;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}

.nav-btn:hover {
  background: var(--surface-3);
  color: var(--ink-soft);
}

.nav-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.nav-btn.is-active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 22px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.nav-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
}

.nav-icon svg {
  width: 19px;
  height: 19px;
  display: block;
}

.nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.18s var(--ease);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.sidebar-user:hover {
  background: var(--surface-2);
  color: var(--ink-soft);
}

.sidebar-user-avatar {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.8rem;
}

.sidebar-user-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-logout {
  flex-shrink: 0;
}

/* login page */
.login-page {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 30px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
}

.login-sub {
  margin: 1px 0 0;
  color: var(--muted-2);
  font-size: 0.78rem;
}

.login-card .field {
  margin-bottom: 14px;
}

.login-card .primary-btn {
  margin-top: 6px;
}

.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 0.86rem;
  margin-bottom: 16px;
}

/* collapsed state */
.app-shell.sidebar-collapsed .sidebar {
  padding: 18px 12px;
}

.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .sidebar-section-label,
.app-shell.sidebar-collapsed .nav-text {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

.app-shell.sidebar-collapsed .nav-btn,
.app-shell.sidebar-collapsed .brand,
.app-shell.sidebar-collapsed #quickAddBtn,
.app-shell.sidebar-collapsed .sidebar-user {
  justify-content: center;
  padding-inline: 0;
}

.app-shell.sidebar-collapsed .sidebar-user-logout {
  display: none;
}

.app-shell.sidebar-collapsed .brand {
  padding: 4px 0;
}

/* =========================== workspace =========================== */

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(800px 400px at 100% 0%, rgba(255, 46, 116, 0.035), transparent 60%),
    var(--bg);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 800;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.stat-strip {
  display: flex;
  gap: 10px;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  min-width: 96px;
}

.stat-label {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.stat-chip strong {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.workspace-body {
  padding: 26px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

/* ============================= views ============================= */

.view {
  display: none;
}

.view.is-visible {
  display: block;
  animation: viewIn 0.28s var(--ease);
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================= cards ============================= */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card + .card {
  margin-top: 18px;
}

.card-header {
  margin-bottom: 16px;
}

.card-header.with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header h3 {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 700;
}

.card-header p {
  margin: 3px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

/* ============================ toolbar ============================ */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-field svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--muted-2);
  pointer-events: none;
}

.search-field input {
  padding-left: 40px;
}

/* ============================= table ============================= */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

thead th {
  position: sticky;
  top: 0;
  text-align: left;
  padding: 13px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
  color: var(--ink-soft);
}

tbody tr {
  transition: background 0.14s var(--ease);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: var(--surface-2);
}

.cell-name {
  display: flex;
  align-items: center;
  gap: 11px;
}

.avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-2);
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--r-pill);
}

@media (max-width: 760px) {
  .hide-sm {
    display: none;
  }
}

.cell-name strong {
  font-weight: 650;
  color: var(--ink);
  display: block;
}

.cell-sub {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 1px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--ink-soft);
  border: 1px solid var(--border);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px !important;
  font-size: 0.92rem;
}

.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ============================== forms ============================ */

#doctorForm {
  max-width: 1000px;
}

.field-grid {
  display: grid;
  gap: 16px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

input,
textarea,
button {
  font-family: inherit;
  font-size: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 13px;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

input:hover,
textarea:hover {
  border-color: #c2c8d4;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

textarea {
  resize: vertical;
  min-height: 64px;
}

.field-hint {
  display: block;
  margin-top: 5px;
  font-size: 0.76rem;
  color: var(--muted);
}

/* dynamic degree rows */
.dynamic-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.degree-row {
  display: grid;
  grid-template-columns: auto 1.3fr 1.3fr 0.7fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

/* drag-style reorder handle (up/down) */
.degree-reorder {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.degree-move {
  width: 26px;
  height: 18px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}

.degree-move:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent-soft-2);
}

.degree-move:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.degree-order {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.74rem;
  font-weight: 700;
}

/* Select2-style multi-select (departments) */
.dept-field {
  margin-top: 16px;
}

.ms-select {
  position: relative;
}

.ms-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: text;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.ms-select.is-open .ms-control {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.ms-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--accent-soft-2);
}

.ms-chip-remove {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: var(--r-pill);
  background: rgba(255, 46, 116, 0.14);
  color: var(--accent-ink);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background 0.14s var(--ease);
}

.ms-chip-remove:hover {
  background: var(--accent);
  color: #fff;
}

.ms-input {
  flex: 1;
  min-width: 120px;
  border: 0 !important;
  background: transparent;
  padding: 4px 2px;
  font-size: 0.9rem;
}

.ms-input:focus {
  outline: none;
  box-shadow: none !important;
}

.ms-dropdown {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}

.ms-dropdown[hidden] {
  display: none;
}

.ms-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  font-size: 0.88rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.ms-option:hover,
.ms-option.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.ms-option .ms-check {
  opacity: 0;
  color: var(--accent);
  font-weight: 700;
}

.ms-option.is-selected {
  color: var(--accent-ink);
  font-weight: 600;
}

.ms-option.is-selected .ms-check {
  opacity: 1;
}

.ms-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.84rem;
  padding: 14px;
}

/* Departments management page */
.dept-admin-table {
  margin-top: 4px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.range-info {
  font-size: 0.82rem;
  color: var(--muted);
}

.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--r-sm);
  font: inherit;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}

.page-btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.page-btn.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* modal */
.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 41, 0.5);
}

.modal-card {
  position: relative;
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  animation: viewIn 0.18s var(--ease);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.modal-close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* B / I / U format toolbar inside field modal */
.fmt-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 4px;
}

.fmt-bar-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-right: 4px;
  white-space: nowrap;
}

.fmt-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--ink-soft);
  transition: background 0.13s, border-color 0.13s, color 0.13s;
  user-select: none;
}

.fmt-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.fmt-btn input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.fmt-btn:has(input:checked) {
  background: var(--accent-soft-2);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}



.dept-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  border-radius: var(--r-pill);
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.dept-count-badge.is-zero {
  background: var(--surface-3);
  color: var(--muted);
}

/* upload */
.upload {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
  margin: 0;
}

.upload:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
}

.upload-icon svg {
  width: 22px;
  height: 22px;
}

.upload-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--r-sm);
}

.upload-thumb[hidden] {
  display: none;
}

.upload-icon.has-thumb {
  padding: 0;
  background: transparent;
  overflow: hidden;
}

.upload-icon.has-thumb .upload-icon-svg {
  display: none;
}

.upload-text strong {
  display: block;
  font-size: 0.9rem;
  color: var(--ink);
}

.upload-text span {
  font-size: 0.8rem;
  color: var(--muted);
}

.upload input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.form-actions .danger {
  margin-left: auto;
}

/* ============================= buttons =========================== */

.primary-btn,
.ghost-btn,
.template-btn {
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease), transform 0.1s var(--ease), color 0.16s var(--ease);
}

.primary-btn svg,
.ghost-btn svg {
  width: 17px;
  height: 17px;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 46, 116, 0.28);
}

.primary-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 16px rgba(255, 46, 116, 0.34);
}

.primary-btn:active {
  background: var(--accent-press);
  transform: translateY(1px);
}

.ghost-btn {
  background: var(--surface);
  color: var(--ink-soft);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.ghost-btn:hover {
  background: var(--surface-2);
  border-color: #c2c8d4;
}

.ghost-btn:active {
  transform: translateY(1px);
}

.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
  box-shadow: none;
}

.danger:hover {
  background: #ffe4e9;
  color: var(--danger-hover);
  border-color: transparent;
}

.tiny {
  padding: 6px 12px;
  font-size: 0.79rem;
  border-radius: var(--r-sm);
}

.full {
  width: 100%;
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  padding: 0;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* ========================= preview view ========================= */

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}

.preview-toolbar h3 {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 700;
}

.preview-toolbar p {
  margin: 3px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

/* segmented control */
.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  flex-wrap: wrap;
}

.template-btn {
  background: transparent;
  color: var(--muted);
  border: 0;
  box-shadow: none;
  padding: 8px 14px;
  font-size: 0.84rem;
}

.template-btn:hover {
  color: var(--ink-soft);
}

.template-btn.is-active {
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: var(--shadow-xs);
}

/* the exportable profile card */
.profile-card {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #eef2f6;
  box-shadow: var(--shadow-md);
}

#templateCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 255, 255, 0.78) 40%,
    rgba(255, 255, 255, 0.12) 100%
  );
}

.card-content {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 26% 1fr;
  gap: 1.4rem;
  padding: clamp(0.9rem, 2.4vw, 1.8rem);
}

.photo-box {
  border-radius: 14px;
  overflow: hidden;
  background: #dfe6ee;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 8px 22px rgba(15, 23, 41, 0.18);
}

.photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.details {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  gap: 0.28rem;
  min-width: 0;
}

.institute {
  margin: 0;
  font-size: clamp(0.6rem, 1vw, 0.78rem);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--accent);
}

.details h3 {
  margin: 0.1rem 0 0;
  font-weight: 800;
  font-size: clamp(1.1rem, 2.4vw, 2.1rem);
  color: var(--ink);
}

.details p {
  margin: 0;
}

#previewDesignation {
  font-weight: 700;
  color: var(--ink-soft);
  font-size: clamp(0.78rem, 1.3vw, 1.05rem);
}

#previewDepartment {
  font-weight: 600;
  color: var(--muted);
  font-size: clamp(0.72rem, 1.1vw, 0.95rem);
}

.info-grid {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem 0.9rem;
}

.info-grid h4 {
  margin: 0 0 0.12rem;
  font-size: clamp(0.56rem, 0.85vw, 0.7rem);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--accent);
}

.info-grid p {
  font-size: clamp(0.66rem, 1vw, 0.84rem);
  line-height: 1.3;
  color: var(--ink-soft);
  font-weight: 500;
}

.bottom-row {
  margin-top: auto;
  display: grid;
  gap: 0.26rem;
  font-size: clamp(0.64rem, 0.95vw, 0.82rem);
  color: var(--ink-soft);
  padding-top: 0.5rem;
  border-top: 1px solid rgba(15, 23, 41, 0.1);
}

.export-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ================== database-driven template poster ================== */

.preview-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-doctor-select {
  width: auto;
  min-width: 200px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.poster-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 0 2px;
}

.poster {
  position: relative;
  width: 100%;
  max-width: 660px;
  aspect-ratio: 1 / 1;
  container-type: inline-size;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.poster-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.poster-fields {
  position: absolute;
  inset: 0;
}

.pf {
  position: absolute;
  box-sizing: border-box;
}

.pf-image {
  overflow: hidden;
}

/* drag-and-drop editing on the template editor poster */
#tplPoster .pf[data-index] {
  cursor: move;
  touch-action: none;
  user-select: none;
}

#tplPoster .pf-image {
  overflow: visible; /* so resize handles aren't clipped */
}

#tplPoster .pf img {
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none; /* let drags hit the field, not the image */
}

.pf-selected {
  outline: 2px solid var(--accent);
  z-index: 999 !important;
}

.pf-handle {
  position: absolute;
  width: 15px;
  height: 15px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 3px;
  z-index: 1000;
}

.pf-handle-nw { left: -8px; top: -8px; cursor: nwse-resize; }
.pf-handle-ne { right: -8px; top: -8px; cursor: nesw-resize; }
.pf-handle-sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.pf-handle-se { right: -8px; bottom: -8px; cursor: nwse-resize; }

.tpl-field-row.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.editor-tip {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
}

.pf-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top; /* keep the head; crop the lower body if needed */
  display: block;
}

.pf-asset {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* dynamic "Key Areas of Expertise" cluster */
/* Expertise logo: positioned by its centre (left/top) then centred with the
   transform; kept square via aspect-ratio. Circle outline is baked into the
   background image, so only the icon overlays. */
.pf-exp-icon {
  position: absolute;
  transform: translate(-50%, -50%);
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
}

.pf-exp-label {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.1;
  overflow: hidden;
}

.pf-exp-frame {
  background: rgba(255, 46, 116, 0.05);
  border: 1.5px dashed var(--accent);
  border-radius: 8px;
}

.pf-exp-frame-tag {
  position: absolute;
  top: -10px;
  left: 8px;
  font: 600 11px/1.4 "Inter", sans-serif;
  color: #fff;
  background: var(--accent);
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
}

/* click-to-edit affordance while customizing a poster */
.poster.is-editable .pf[data-index] {
  cursor: pointer;
}

.poster.is-editable .pf[data-index]:hover {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: rgba(255, 46, 116, 0.07);
}

/* editor-only placeholder for empty fields */
.pf-ph {
  display: flex !important;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px dashed rgba(99, 102, 120, 0.55);
  background: rgba(99, 102, 120, 0.08);
  color: rgba(99, 102, 120, 0.9) !important;
  font-style: italic;
  font-weight: 500 !important;
  overflow: hidden;
}

.pf-photo.clip-hexagon {
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.pf-photo.clip-blob {
  border-radius: 44% 46% 44% 46% / 46% 44% 46% 44%;
}

.pf-name {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.pf-name-prefix {
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.1;
}

.pf-name-main {
  font-weight: 800;
  letter-spacing: 0.005em;
  line-height: 1.0;
}

.pf-block .pf-line {
  white-space: normal;
}

.pf-light {
  font-weight: 400;
}

/* Editable helpline pill: coloured frame + label, inset white number box. */
.pf-helpline {
  display: flex;
  align-items: stretch;
  box-sizing: border-box;
  border-radius: 9999px;
  overflow: hidden;
  white-space: nowrap;
  line-height: 1;
}

.pf-helpline .pf-hl-label {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  padding: 0 0.7em 0 0.9em;
}

.pf-helpline .pf-hl-num {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  margin: 0.16em;
  padding: 0 0.6em;
  background: #ffffff;
  color: #111111;
  border-radius: 9999px;
}

.expertise-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.exp-icon-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--accent-ink);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.exp-icon-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.exp-icon-btn svg {
  width: 100%;
  height: 100%;
}

.exp-icon-plus {
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--muted-2);
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
  padding: 4px 2px;
}

.icon-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.14s var(--ease), color 0.14s var(--ease), border-color 0.14s var(--ease);
}

.icon-cell:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent-soft-2);
}

.icon-cell.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.icon-cell svg,
.icon-cell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* icon library page */
.icon-lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.icon-lib-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.icon-lib-glyph {
  width: 44px;
  height: 44px;
  color: var(--ink-soft);
}

.icon-lib-glyph svg,
.icon-lib-glyph img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.icon-lib-name {
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-lib-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.14s var(--ease), background 0.14s var(--ease);
}

.icon-lib-cell:hover .icon-lib-del {
  opacity: 1;
}

.icon-lib-del:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.add-icon-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  margin-top: 4px;
  color: var(--ink-soft);
}

.add-icon-preview svg {
  width: 48px;
  height: 48px;
}

/* ===== template editor ===== */
.tpl-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.seg-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.tpl-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
  gap: 18px;
  align-items: start;
}

/* Landscape templates are short and wide, so the 2-column layout leaves the
   poster tiny. Stack the editor and let the poster use the full width. */
.tpl-editor.is-wide {
  grid-template-columns: minmax(0, 1fr);
}

.tpl-editor.is-wide .tpl-preview-card {
  position: static;
}

.tpl-editor.is-wide #tplPoster {
  max-width: min(100%, 1100px);
}

.tpl-preview-card {
  position: sticky;
  top: 0;
}

.tpl-elements-head {
  margin-top: 16px;
}

.tpl-fields-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tpl-field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "main btn" "detail btn";
  gap: 2px 10px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.tpl-field-main {
  grid-area: main;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tpl-field-tag {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 1px 8px;
}

.tpl-field-detail {
  grid-area: detail;
  font-size: 0.76rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpl-field-row .ghost-btn {
  grid-area: btn;
}

.upload.sm {
  padding: 10px 12px;
  gap: 10px;
}

.upload.sm span {
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.field-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.modal-card-lg {
  width: min(620px, 100%);
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 26px 0 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.check-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.modal-actions .spacer {
  flex: 1;
}

@media (max-width: 1100px) {
  .tpl-editor {
    grid-template-columns: 1fr;
  }
  .tpl-preview-card {
    position: static;
  }
}

@media (max-width: 560px) {
  .field-grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ========================== responsive ========================== */

@media (max-width: 1200px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar,
  .app-shell.sidebar-collapsed .sidebar {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .sidebar-section-label {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    flex: 1;
    gap: 6px;
  }

  .nav-btn.is-active::before {
    display: none;
  }

  .sidebar-foot {
    margin-top: 0;
  }

  .app-shell.sidebar-collapsed .brand-text,
  .app-shell.sidebar-collapsed .nav-text {
    opacity: 1;
    width: auto;
    pointer-events: auto;
  }

  .app-shell.sidebar-collapsed .nav-btn,
  .app-shell.sidebar-collapsed .brand,
  .app-shell.sidebar-collapsed #quickAddBtn {
    justify-content: center;
    padding-inline: 12px;
  }

  #sidebarToggleBtn {
    display: none;
  }
}

@media (max-width: 900px) {
  .stat-strip {
    display: none;
  }

  .topbar {
    padding: 14px 18px;
  }

  .workspace-body {
    padding: 16px;
  }

  .field-grid.two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
  }

  .nav-text {
    display: none;
  }

  .sidebar .nav-btn {
    padding: 10px;
  }

  .degree-row {
    grid-template-columns: 1fr;
  }

  .card-content {
    grid-template-columns: 30% 1fr;
    gap: 0.7rem;
  }

  .info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.3rem 0.5rem;
  }

  .form-actions .danger {
    margin-left: 0;
  }
}

/* =====================================================================
   Pixostudio shell: module launcher, shared sidebar groups (Setup)
   ===================================================================== */

/* module tones */
.tone-pink { --tone: var(--accent); --tone-soft: var(--accent-soft); --tone-ink: var(--accent-ink); }
.tone-navy { --tone: #213968; --tone-soft: #e8edf7; --tone-ink: #213968; }

/* pages that scroll as a document (launcher) instead of the fixed app shell */
body.page-scroll {
  height: auto;
  min-height: 100%;
  overflow: auto;
}

a.brand,
a.nav-btn {
  text-decoration: none;
  color: inherit;
}

a.nav-btn {
  color: var(--muted);
}

a.nav-btn.is-active {
  color: var(--accent-ink);
}

a.brand:hover .brand-text strong {
  color: var(--accent-ink);
}

.sidebar-user-name small {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted-2);
}

/* ---- collapsible group (Setup) ---- */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.nav-group-toggle {
  width: 100%;
}

.nav-group.has-active > .nav-group-toggle {
  color: var(--ink-soft);
}

.nav-chevron {
  margin-left: auto;
  display: grid;
  place-items: center;
  transition: transform 0.2s var(--ease);
}

.nav-chevron svg {
  width: 15px;
  height: 15px;
}

.nav-group.is-open .nav-chevron {
  transform: rotate(90deg);
}

.nav-group-items {
  display: none;
  flex-direction: column;
  gap: 2px;
  margin-left: 21px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.nav-group.is-open .nav-group-items {
  display: flex;
}

.nav-group-items .nav-btn {
  padding: 8px 10px;
  font-size: 0.87rem;
}

.nav-group-items .nav-btn.is-active::before {
  left: -11px;
  height: 18px;
}

.app-shell.sidebar-collapsed .nav-chevron {
  display: none;
}

.app-shell.sidebar-collapsed .nav-group-items {
  margin-left: 0;
  padding-left: 0;
  border-left: 0;
}

.app-shell.sidebar-collapsed .nav-group-items .nav-btn.is-active::before {
  left: -12px;
}

/* ---- empty state ---- */
.empty-state {
  text-align: center;
  padding: 44px 24px;
}

.empty-state h3 {
  margin: 14px 0 6px;
  font-size: 1.15rem;
}

.empty-state p {
  margin: 0 auto;
  max-width: 520px;
  color: var(--muted);
}

.empty-state .module-icon {
  margin: 0 auto;
}

.planned-list {
  list-style: none;
  margin: 22px auto 0;
  padding: 0;
  max-width: 560px;
  text-align: left;
  display: grid;
  gap: 8px;
}

.planned-list li {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.planned-list span {
  color: var(--muted);
  font-size: 0.86rem;
}

.login-foot {
  margin: 18px 0 0;
  text-align: center;
  color: var(--muted-2);
  font-size: 0.75rem;
}

/* horizontal (top-bar) sidebar on tablets/phones: the Setup items sit inline */
@media (max-width: 1200px) {
  .nav-group,
  .nav-group-items,
  .nav-group.is-open .nav-group-items {
    display: contents;
  }

  .nav-group-toggle {
    display: none;
  }

  .nav-group-items .nav-btn {
    padding: 10px 12px;
    font-size: 0.92rem;
  }
}

/* icon tile used in module empty states */
.module-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--tone-soft, var(--accent-soft));
  color: var(--tone-ink, var(--accent-ink));
}

.module-icon svg {
  width: 26px;
  height: 26px;
}

/* =====================================================================
   Module launcher (index.php)
   ===================================================================== */

body.launcher-body {
  background: #f7f8fa;
}

.lx-top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 58px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.lx-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.lx-brand img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.lx-org {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  margin-left: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.lx-org svg {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.lx-top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.lx-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 260px;
  height: 36px;
  padding: 0 8px 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--muted-2);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}

.lx-search:focus-within {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.lx-search > svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.lx-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-size: 0.86rem;
  color: var(--ink);
}

.lx-search input::-webkit-search-cancel-button {
  display: none;
}

.lx-search kbd {
  flex-shrink: 0;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  font: 600 0.68rem/1.5 "Inter", system-ui, sans-serif;
  color: var(--muted);
}

.lx-user {
  position: relative;
}

.lx-user-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px 4px 4px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: var(--muted);
}

.lx-user-btn:hover,
.lx-user-btn[aria-expanded="true"] {
  background: var(--surface-3);
}

.lx-user-btn > svg {
  width: 15px;
  height: 15px;
}

.lx-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.78rem;
}

.lx-user-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.lx-user-text strong {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.lx-user-text span {
  font-size: 0.72rem;
  color: var(--muted-2);
}

/* shared popover (module page menu, search results, user menu) */
.lx-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: 290px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: lxPop 0.14s var(--ease);
}

.lx-popover[hidden] {
  display: none;
}

@keyframes lxPop {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.lx-popover ul {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 290px;
  overflow-y: auto;
}

.lx-popover li[hidden] {
  display: none;
}

.lx-popover li a,
.lx-user-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  font-size: 0.87rem;
  text-decoration: none;
  outline: none;
}

.lx-popover li a:hover,
.lx-popover li a:focus-visible,
.lx-user-menu a:hover,
.lx-user-menu a:focus-visible {
  background: var(--surface-3);
  color: var(--ink);
}

.lx-popover li a svg,
.lx-user-menu a svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--muted-2);
}

.lx-menu-label {
  padding: 10px 10px 4px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.lx-menu-empty {
  margin: 0;
  padding: 10px;
  font-size: 0.84rem;
  color: var(--muted);
}

.lx-card-menu input {
  width: 100%;
  height: 34px;
  margin-bottom: 6px;
  padding: 0 10px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 0.85rem;
  outline: none;
  box-shadow: none;
}

.lx-card-menu input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.lx-search-results {
  left: 0;
  right: auto;
  width: max(100%, 320px);
}

.lx-search-results li a {
  justify-content: space-between;
}

.lx-search-results li a small {
  color: var(--muted-2);
  font-size: 0.74rem;
  white-space: nowrap;
}

.lx-user-menu {
  width: 190px;
  padding: 6px;
}

/* page body */
.lx-main {
  padding: 30px 28px 48px;
}

.lx-greeting {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.lx-date {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.lx-rule {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 26px 0 18px;
}

.lx-rule span {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.lx-rule i {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.lx-rule small {
  font-size: 0.74rem;
  color: var(--muted-2);
}

.lx-empty {
  color: var(--muted);
}

.lx-columns {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
  align-items: start;
}

.lx-column h2 {
  margin: 0 0 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #3d4a66;
}

.lx-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 58px;
  margin-bottom: 9px;
  padding: 0 8px 0 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.lx-card:hover,
.lx-card.is-open {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.lx-card.is-open {
  z-index: 35;
}

.lx-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 4px 11px 12px;
  border-radius: var(--r-md) 0 0 var(--r-md);
  color: inherit;
  text-decoration: none;
  outline: none;
}

.lx-card-main:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.lx-card-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--tone-soft);
  color: var(--tone-ink);
}

.lx-card-icon svg {
  width: 17px;
  height: 17px;
}

.lx-card-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.lx-card-text strong {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.lx-card-text span {
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lx-card:hover .lx-card-text strong {
  color: var(--tone-ink);
}

.lx-card-num {
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted-2);
}

.lx-card-toggle {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.lx-card-toggle:hover,
.lx-card-toggle[aria-expanded="true"] {
  background: var(--surface-3);
  color: var(--ink);
}

.lx-card-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 0.18s var(--ease);
}

.lx-card-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.lx-card-menu {
  top: calc(100% + 4px);
}

@media (max-width: 1280px) {
  .lx-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .lx-top {
    padding: 0 16px;
    gap: 10px;
  }

  .lx-org,
  .lx-user-text,
  .lx-search kbd {
    display: none;
  }

  .lx-search {
    width: 100%;
  }

  .lx-top-right {
    flex: 1;
    justify-content: flex-end;
  }

  .lx-main {
    padding: 22px 16px 36px;
  }

  .lx-columns {
    grid-template-columns: 1fr;
  }

  .lx-popover {
    max-width: calc(100vw - 32px);
  }
}

/* =====================================================================
   Branding Works & server-rendered module pages (body.bw)
   ===================================================================== */

.tone-slate { --tone: #475569; --tone-soft: #eef1f5; --tone-ink: #334155; }

.bw select {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364708a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.bw select:hover {
  border-color: #c2c8d4;
}

.bw select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.bw input[type="date"],
.bw input[type="number"],
.bw input[type="tel"],
.bw input[type="search"],
.bw input:not([type]) {
  height: 42px;
}

.bw input[type="file"] {
  padding: 8px 10px;
  background: var(--surface-2);
}

.bw input[type="color"] {
  width: 64px;
  height: 42px;
  padding: 4px;
  cursor: pointer;
}

.bw input:disabled {
  background: var(--surface-3);
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions a,
.table-actions a,
.form-actions a,
.copy-row a {
  text-decoration: none;
}

.muted { color: var(--muted); }
.text-danger { color: var(--danger) !important; }
.text-accent { color: var(--accent-ink) !important; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.req { color: var(--danger); font-weight: 700; }

/* ---- alerts ---- */
.alert {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 0.9rem;
}

.alert a { color: inherit; }
.alert-success { background: var(--success-soft); border-color: #c8ecd6; color: #166534; }
.alert-error { background: var(--danger-soft); border-color: #fecdd6; color: #9f1239; }
.alert-warning { background: #fff8e6; border-color: #f7e1a8; color: #7a4d00; }
.alert-info { background: #eef4ff; border-color: #d5e2fb; color: #1e3a6e; }

/* ---- badges ---- */
.st-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--c) 12%, white);
  color: var(--c);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.st-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c);
}

.mat-badge {
  display: inline-block;
  color: var(--c);
  font-weight: 700;
  font-size: 0.85rem;
}

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
}

.pill-ok { background: var(--success-soft); color: #166534; }

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--c);
  vertical-align: -2px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.nav-count {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}

.app-shell.sidebar-collapsed .nav-count {
  position: absolute;
  top: 4px;
  right: 8px;
  min-width: 16px;
  padding: 0 4px;
}

/* ---- tables ---- */
.data-table td,
.data-table th {
  padding: 11px 14px;
}

.data-table.compact {
  min-width: 560px;
}

.data-table.clickable tbody tr[data-href] {
  cursor: pointer;
}

.data-table .row-link {
  color: var(--ink);
  text-decoration: none;
}

.data-table .row-link:hover {
  color: var(--accent-ink);
}

.data-table tr.is-inactive td {
  color: var(--muted-2);
}

.data-table tr.is-overdue td:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}

.data-table tr.is-overdue .row-link strong {
  color: var(--danger);
}

.data-table .actions-col {
  width: 1%;
  white-space: nowrap;
}

.data-table .table-actions form {
  margin: 0;
}

.wrap-cell {
  white-space: normal;
  max-width: 320px;
}

.register-table {
  min-width: 1480px;
  font-size: 0.86rem;
}

.register-table td {
  font-size: 0.86rem;
}

.table-note {
  margin: 12px 2px 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot-danger { background: var(--danger); }

/* ---- tabs & filters ---- */
.toolbar.wrap {
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-md);
  background: var(--surface-3);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 0.87rem;
  font-weight: 600;
  text-decoration: none;
}

.tab span {
  padding: 0 7px;
  border-radius: var(--r-pill);
  background: rgba(15, 23, 41, 0.06);
  font-size: 0.74rem;
}

.tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

.toolbar .search-field {
  min-width: 240px;
}

.filter-card {
  padding: 16px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  align-items: end;
}

.filter-grid .search-field {
  grid-column: span 2;
}

.date-filter {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.date-filter span {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 3px;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

/* ---- form layout ---- */
.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-grid.one {
  grid-template-columns: minmax(0, 1fr);
}

.field-grid.auto {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.field-grid + .field-grid,
.field-grid + .field {
  margin-top: 16px;
}

.field .label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
}

.field-error {
  display: block;
  margin-top: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--danger);
}

.field-check {
  justify-content: flex-end;
}

.field-check .check-label {
  margin: 0;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-field .field-hint {
  margin: 0;
}

.choice-row {
  display: flex;
  gap: 8px;
}

.choice-row.wrap {
  flex-wrap: wrap;
}

.choice {
  position: relative;
  margin: 0;
  cursor: pointer;
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice span {
  display: inline-flex;
  align-items: center;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.choice:hover span {
  border-color: #c2c8d4;
}

.choice input:checked + span {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.choice input:focus-visible + span {
  box-shadow: var(--ring);
}

.size-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr 96px;
  align-items: center;
  gap: 6px;
}

.size-row span {
  color: var(--muted);
}

.hp {
  position: absolute !important;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---- request form ---- */
.request-form {
  max-width: 1080px;
}

.form-section + .form-section {
  margin-top: 18px;
}

.form-section-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.form-section-head h3 {
  margin: 0;
  font-size: 1.06rem;
}

.form-section-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.sec-letter {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: #213968;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
}

.items-list {
  display: grid;
  gap: 16px;
}

.item-card {
  margin: 0;
  padding: 0 18px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  min-width: 0;
}

.item-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 14px 0 4px;
  float: left;
}

.item-card-head + * {
  clear: both;
}

.item-no {
  font-weight: 800;
  font-size: 0.95rem;
  color: #213968;
}

.item-section {
  clear: both;
  padding-top: 14px;
}

.item-section + .item-section {
  margin-top: 14px;
  border-top: 1px dashed var(--border-strong);
}

.item-section h4 {
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.add-item-btn {
  margin-top: 14px;
  text-decoration: none;
}

.add-item-btn svg {
  width: 15px;
  height: 15px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 4;
  padding: 14px 0;
  margin-top: 18px;
  background: linear-gradient(180deg, rgba(244, 245, 248, 0), var(--bg) 35%);
}

.primary-btn.danger-solid {
  background: var(--danger);
  box-shadow: none;
}

.primary-btn.danger-solid:hover {
  background: var(--danger-hover);
}

.primary-btn,
.ghost-btn {
  text-decoration: none;
}

/* ---- setup forms ---- */
.setup-form {
  margin-bottom: 18px;
  border-color: var(--accent-soft-2);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
}

/* ---- review screen ---- */
.review-head {
  margin-bottom: 18px;
}

.review-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 0.86rem;
}

.kv-row,
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin: 0;
}

.kv-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.kv-row dt,
.kv-grid dt {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.kv-row dd,
.kv-grid dd {
  margin: 2px 0 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}

.kv-row dd a,
.kv-grid dd a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent-ink);
}

.kv-row svg,
.kv-grid svg {
  width: 14px;
  height: 14px;
}

.kv-grid .cell-sub {
  font-weight: 500;
}

.review-head .alert {
  margin: 14px 0 0;
}

.decision-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  border-left: 4px solid var(--accent);
}

.decision-bar h3 {
  margin: 0;
  font-size: 1rem;
}

.decision-bar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.decision-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.decision-actions form {
  margin: 0;
}

.reject-box {
  position: relative;
}

.reject-box summary {
  list-style: none;
}

.reject-box summary::-webkit-details-marker {
  display: none;
}

.reject-form {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  width: 320px;
  display: grid;
  gap: 6px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}

.reject-form label {
  margin: 4px 0 0;
}

.reject-form button {
  margin-top: 8px;
}

/* ---- request view ---- */
.item-view {
  scroll-margin-top: 20px;
}

.item-view:target {
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
  border-color: var(--accent-soft-2);
}

.item-view.is-overdue {
  border-left: 4px solid var(--danger);
}

.item-view-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.item-view-head h3 {
  margin: 0;
  font-size: 1.08rem;
}

.item-view-head p {
  margin: 3px 0 0;
}

.item-view-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.content-box {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.content-box p {
  margin: 4px 0 0;
  white-space: pre-line;
}

.content-box .label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.remarks {
  margin: 14px 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

/* ---- overview ---- */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.stat-tile:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.stat-tile span {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-tile strong {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.stat-tile small {
  font-size: 0.78rem;
  color: var(--muted-2);
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 18px;
  margin-bottom: 18px;
}

.overview-grid .card + .card {
  margin-top: 0;
}

.stage-list,
.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.stage-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--ink);
  text-decoration: none;
}

.stage-list a:hover {
  background: var(--surface-2);
}

.recent-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

.recent-list a {
  color: var(--ink);
}

.recent-list span {
  color: var(--muted);
  font-size: 0.86rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.share-card h3 {
  margin: 0;
}

.share-card p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  max-width: 520px;
}

.copy-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.copy-row input {
  width: 320px;
  max-width: 100%;
  height: 40px;
  background: var(--surface-2);
  font-size: 0.85rem;
}

/* ---- public pages ---- */
body.public-body {
  background: #f7f8fa;
}

.pub-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 58px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.pub-top-org {
  font-size: 0.82rem;
  color: var(--muted);
}

.pub-main {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 30px 24px 20px;
}

.pub-intro {
  margin-bottom: 22px;
}

.pub-intro h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 800;
}

.pub-intro p {
  max-width: 760px;
  margin: 6px 0 0;
  color: var(--muted);
}

.pub-intro .launcher-eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.pub-intro-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 0.88rem;
}

.pub-intro-links svg {
  width: 15px;
  height: 15px;
}

.pub-foot {
  padding: 18px 24px 26px;
  text-align: center;
  color: var(--muted-2);
  font-size: 0.76rem;
}

.pub-back {
  text-align: center;
}

.pub-back a {
  color: var(--accent-ink);
  font-weight: 600;
}

.public-body .sticky-actions {
  background: linear-gradient(180deg, rgba(247, 248, 250, 0), #f7f8fa 35%);
}

.track-card h1 {
  margin: 0;
  font-size: 1.5rem;
}

.track-card .launcher-eyebrow {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.track-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.track-head p {
  margin: 4px 0 0;
}

.track-sub {
  margin: 22px 0 10px;
  font-size: 1rem;
}

.track-link {
  margin-top: 20px;
}

.stepper {
  display: flex;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: none;
}

.stepper li {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 3px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}

.stepper li span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  font-size: 0.78rem;
}

.stepper li.done {
  border-color: #2e7d4f;
  color: #2e7d4f;
}

.stepper li.done span {
  background: #2e7d4f;
  color: #fff;
}

.stepper li.current {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.stepper li.current span {
  background: var(--accent);
  color: #fff;
}

/* ---- printable request form ---- */
.print-body {
  background: #e9ebf0;
}

.print-toolbar {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 16px;
}

.pf-sheet {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto 30px;
  padding: 0 16mm 12mm;
  background: #fff;
  color: #1f2937;
  font-size: 10.5pt;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.pf-band {
  display: flex;
  justify-content: space-between;
  margin: 0 -16mm 8mm;
  padding: 5mm 16mm;
  background: #213968;
  color: #fff;
  border-bottom: 4px solid #c0262d;
  font-size: 9.5pt;
}

.pf-sheet h1 {
  margin: 0;
  color: #213968;
  font-size: 22pt;
}

.pf-lede {
  margin: 2mm 0 5mm;
  color: #64708a;
}

.pf-h {
  margin: 4mm 0 0;
  padding: 2mm 3mm;
  background: #213968;
  color: #fff;
  font-size: 10.5pt;
  letter-spacing: 0.02em;
}

.pf-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

.pf-table td {
  height: 12mm;
  padding: 1.5mm 2.5mm;
  border: 1px solid #cfd5e1;
  vertical-align: top;
  font-size: 8.5pt;
  color: #64708a;
}

.pf-office td {
  height: 11mm;
}

.pf-opts {
  color: #1f2937 !important;
  font-size: 9.5pt !important;
  line-height: 1.9;
}

.pf-box {
  display: inline-block;
  margin-right: 5mm;
  white-space: nowrap;
}

.pf-label {
  display: block;
}

.pf-tall {
  height: 26mm !important;
}

.pf-sign {
  height: 16mm !important;
}

.pf-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 6mm;
  padding-top: 2mm;
  border-top: 1px solid #e3e6ee;
  color: #8a93a6;
  font-size: 8pt;
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  .print-body {
    background: #fff;
  }

  .print-toolbar {
    display: none;
  }

  .pf-sheet {
    margin: 0;
    box-shadow: none;
  }

  .pf-band,
  .pf-h {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .stat-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .field-grid.three,
  .field-grid.two {
    grid-template-columns: 1fr;
  }

  .item-card {
    padding: 0 12px 14px;
  }

  .pub-top-org {
    display: none;
  }

  .pub-main {
    padding: 22px 16px 16px;
  }

  .filter-grid .search-field {
    grid-column: 1 / -1;
  }

  .reject-form {
    position: static;
    width: 100%;
    margin-top: 8px;
  }

  .track-head {
    flex-direction: column;
  }

  .stepper li {
    font-size: 0.76rem;
    padding: 8px 6px;
  }

  .copy-row input {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .stat-tiles {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-tile strong {
    font-size: 1.5rem;
  }

  .choice span {
    padding: 0 12px;
  }
}

/* =====================================================================
   Components (shared by every module page)
   ===================================================================== */

.tone-teal { --tone: #2A8A8A; --tone-soft: #e3f3f2; --tone-ink: #1f6d6d; }

/* ---- SearchSelect (assets/components/select.js) ---- */
.ss {
  position: relative;
  width: 100%;
  min-width: 0;
}

.ss .ss-native {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: -1;
}

.ss-trigger {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.ss-trigger:hover {
  border-color: #c2c8d4;
}

.ss-trigger:focus-visible,
.ss.is-open .ss-trigger {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.ss-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ss.is-placeholder .ss-text {
  color: var(--muted-2);
}

.ss-caret {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.18s var(--ease);
}

.ss.is-open .ss-caret {
  transform: rotate(180deg);
}

.ss.is-disabled .ss-trigger {
  background: var(--surface-3);
  color: var(--muted);
  cursor: not-allowed;
}

.ss.is-invalid .ss-trigger,
.field.has-error .ss-trigger {
  border-color: var(--danger);
}

.ss-sm .ss-trigger {
  height: 36px;
  font-size: 0.85rem;
}

.ss-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  min-width: 220px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: lxPop 0.12s var(--ease);
}

.ss.drop-up .ss-panel {
  top: auto;
  bottom: calc(100% + 4px);
}

.ss-panel[hidden] {
  display: none;
}

.ss-sheet-head {
  display: none;
}

.ss-search {
  padding: 2px 2px 6px;
}

.ss-search[hidden] {
  display: none;
}

.ss-search input {
  height: 36px;
  padding: 0 10px;
  font-size: 0.88rem;
}

.ss-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 264px;
  overflow-y: auto;
  outline: none;
}

.ss-list li {
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 0.88rem;
  color: var(--ink-soft);
  cursor: pointer;
  line-height: 1.35;
}

.ss-list li.in-group {
  padding-left: 18px;
}

.ss-list li.is-active,
.ss-list li:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.ss-list li[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

.ss-list li.is-placeholder {
  color: var(--muted);
}

.ss-list li.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ss-list li.ss-group {
  padding: 10px 10px 4px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  cursor: default;
  background: none;
}

.ss-empty {
  margin: 0;
  padding: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* phones: bottom sheet */
@media (max-width: 640px) {
  body.ss-sheet-open {
    overflow: hidden;
  }

  .ss.as-sheet .ss-panel {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 40px rgba(15, 23, 41, 0.25);
  }

  .ss.as-sheet::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(15, 23, 41, 0.35);
  }

  .ss.as-sheet .ss-sheet-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 4px 10px;
    font-weight: 700;
  }

  .ss-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: var(--surface-3);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
  }

  .ss.as-sheet .ss-search input {
    height: 44px;
    font-size: 16px; /* no zoom on iOS */
  }

  .ss.as-sheet .ss-list {
    max-height: none;
    flex: 1;
  }

  .ss.as-sheet .ss-list li {
    padding: 12px;
    font-size: 0.95rem;
  }
}

/* ---- KPI tiles ---- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-row.compact {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}

a.kpi:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.kpi-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--muted);
}

.kpi-icon svg {
  width: 17px;
  height: 17px;
}

.kpi-label {
  padding-right: 40px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--muted-2);
}

.kpi-accent .kpi-value { color: var(--accent-ink); }
.kpi-accent .kpi-icon { background: var(--accent-soft); color: var(--accent-ink); }
.kpi-danger .kpi-value { color: var(--danger); }
.kpi-danger .kpi-icon { background: var(--danger-soft); color: var(--danger); }
.kpi-success .kpi-value { color: #2e7d4f; }
.kpi-success .kpi-icon { background: var(--success-soft); color: #2e7d4f; }
.kpi-warning .kpi-value { color: #9a5b00; }
.kpi-warning .kpi-icon { background: #fff4dc; color: #9a5b00; }

/* ---- charts ---- */
.chart-card {
  min-width: 0;
}

.chart-box {
  position: relative;
  width: 100%;
}

.chart-box.is-empty canvas {
  display: none;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.dash-grid > * {
  grid-column: span 6;
  min-width: 0;
}

.dash-grid > .span-4 { grid-column: span 4; }
.dash-grid > .span-5 { grid-column: span 5; }
.dash-grid > .span-7 { grid-column: span 7; }
.dash-grid > .span-8 { grid-column: span 8; }
.dash-grid > .span-12 { grid-column: span 12; }

.dash-grid .card + .card {
  margin-top: 0;
}

/* ---- meter ---- */
.meter {
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #213968;
}

.meter-danger span { background: var(--danger); }
.meter-success span { background: #2e7d4f; }
.meter-accent span { background: var(--accent); }

.meter-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.meter-row:last-child {
  border-bottom: 0;
}

.spend-box {
  display: grid;
  gap: 10px;
}

.spend-box .spend-figures {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.spend-box strong {
  font-size: 1.6rem;
  font-weight: 800;
}

/* ---- section titles & setup tiles ---- */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #3d4a66;
}

.section-title:first-child {
  margin-top: 0;
}

.section-title span {
  color: var(--muted-2);
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.list-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.list-tile:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.list-tile-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.list-tile-text strong {
  font-size: 0.92rem;
}

.list-tile-text span {
  font-size: 0.76rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.list-tile-count {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}

.list-tile-count strong {
  font-size: 1.3rem;
  font-weight: 800;
}

.list-tile-count small {
  font-size: 0.7rem;
  color: var(--muted-2);
}

/* ---- pagination ---- */
.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

.pager-size {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pager-size .ss {
  width: 84px;
}

.pager-size label {
  margin: 0;
  font-weight: 500;
  color: var(--muted);
}

.pager-pages {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.pager-pages a,
.pager-pages span {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 600;
  text-decoration: none;
}

.pager-pages a:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.pager-pages .is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pager-pages .is-gap {
  border: 0;
  background: none;
  min-width: 18px;
  padding: 0;
}

.pager-pages .is-disabled {
  opacity: 0.4;
}

/* ---- item page ---- */
.status-card {
  margin-bottom: 18px;
}

.status-card.is-overdue {
  border-left: 4px solid var(--danger);
}

.status-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.status-card-head > div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stage-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

.stage-bar li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
  white-space: nowrap;
  overflow: hidden;
}

.stage-bar li:first-child {
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}

.stage-bar li span {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(15, 23, 41, 0.08);
  font-size: 0.7rem;
}

.stage-bar li.done {
  background: color-mix(in srgb, var(--c) 14%, white);
  color: var(--c);
}

.stage-bar li.current {
  background: var(--c);
  color: #fff;
}

.stage-bar li.current span {
  background: rgba(255, 255, 255, 0.25);
}

.stage-bar.is-paused li {
  opacity: 0.6;
}

.move-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}

.move {
  position: relative;
}

.move > summary {
  list-style: none;
}

.move > summary::-webkit-details-marker {
  display: none;
}

.move[open] {
  flex-basis: 100%;
}

.move[open] > summary {
  margin-bottom: 10px;
}

.move-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.move-warn .move-form {
  border-color: #f7e1a8;
  background: #fffbf0;
}

.move-title {
  margin: 0;
  font-weight: 700;
}

.move-none {
  margin: 0;
}

.req-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.req-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.req-list svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  padding: 2px;
  border-radius: 50%;
}

.req-list .ok { color: #2e7d4f; }
.req-list .ok svg { background: var(--success-soft); }
.req-list .todo { color: var(--danger); }
.req-list .todo svg { background: var(--danger-soft); }

.item-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.item-main .card + .card,
.item-side .card + .card {
  margin-top: 18px;
}

.item-side {
  position: sticky;
  top: 0;
}

.form-sub {
  margin: 18px 0 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ro {
  min-height: 42px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--ink);
}

.ro .cell-sub {
  width: 100%;
  margin: 0;
}

.field.is-muted {
  opacity: 0.5;
}

.kv-list {
  margin: 0;
  display: grid;
  gap: 12px;
}

.kv-list dt {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.kv-list dd {
  margin: 2px 0 0;
  font-weight: 600;
}

.kv-list a {
  color: var(--accent-ink);
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 18px;
  border-left: 2px solid var(--border);
  display: grid;
  gap: 14px;
}

.timeline li {
  position: relative;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--c);
}

.tl-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.88rem;
}

.tl-head span {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.tl-note {
  margin: 4px 0 0;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 0.84rem;
}

.render-preview {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.render-preview img {
  width: 180px;
  max-width: 40vw;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.render-preview > div {
  display: grid;
  gap: 6px;
}

.attach-form {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.render-pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.render-option {
  position: relative;
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 6px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 500;
}

.render-option input {
  position: absolute;
  opacity: 0;
}

.render-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.render-option img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.render-option span {
  font-size: 0.78rem;
  display: grid;
}

.render-option small {
  color: var(--muted);
}

.upload-form {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border-strong);
}

.upload-form .form-actions {
  align-items: center;
  margin-top: 12px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.photo {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}

.photo img,
.photo-pdf {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--surface-3);
}

.photo-pdf {
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--muted);
}

.photo figcaption {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
}

.photo figcaption form {
  margin: 0;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.danger-link {
  color: var(--danger);
}

/* ---- studio artwork banner & toast ---- */
.artwork-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: #e8edf7;
  border: 1px solid #c9d4ea;
  color: #213968;
}

.artwork-banner div {
  display: grid;
  gap: 2px;
}

.artwork-banner span {
  font-size: 0.86rem;
}

.artwork-banner a {
  text-decoration: none;
}

.studio-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 2000;
  display: flex;
  gap: 14px;
  align-items: center;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: var(--r-md);
  background: #0f1729;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.studio-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.studio-toast a {
  color: #ffd1e1;
  font-weight: 700;
  white-space: nowrap;
}

/* ---- my jobs ---- */
.job-group + .job-group {
  margin-top: 8px;
}

.job-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}

.job-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.job-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.job-card.is-overdue {
  border-left: 4px solid var(--danger);
}

.job-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
}

.job-card-top strong {
  font-size: 0.95rem;
}

.job-card p {
  margin: 0;
}

.job-card-title {
  font-weight: 650;
}

.job-card-where {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: 0.86rem;
  color: var(--muted);
}

.job-card-where svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin-top: 2px;
}

.job-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
}

.job-card-hint {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-ink);
}

/* ---- misc tables ---- */
.sort-link {
  color: inherit;
  text-decoration: none;
}

.data-table tr.is-soon td:first-child {
  box-shadow: inset 3px 0 0 #d9a21b;
}

.filter-note {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.empty-actions {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tiny.primary-btn {
  padding: 6px 12px;
  font-size: 0.79rem;
}

/* ---- responsive ---- */
@media (max-width: 1200px) {
  .item-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .item-side {
    position: static;
  }

  .dash-grid > *,
  .dash-grid > .span-4,
  .dash-grid > .span-5,
  .dash-grid > .span-7,
  .dash-grid > .span-8 {
    grid-column: span 6;
  }

  .dash-grid > .span-12 {
    grid-column: span 12;
  }
}

@media (max-width: 860px) {
  .dash-grid > *,
  .dash-grid > [class*="span-"] {
    grid-column: span 12;
  }

  .stage-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stage-bar li,
  .stage-bar li:first-child {
    clip-path: none;
    border-radius: var(--r-sm);
  }
}

@media (max-width: 640px) {
  .kpi-row,
  .kpi-row.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .kpi {
    padding: 12px 14px;
  }

  .kpi-value {
    font-size: 1.35rem;
  }

  .kpi-icon {
    display: none;
  }

  .kpi-label {
    padding-right: 0;
  }

  .stage-bar li {
    padding: 8px;
    font-size: 0.74rem;
  }

  .move-list > .move:not([open]) {
    flex: 1 1 calc(50% - 10px);
  }

  .move-list > .move > summary {
    width: 100%;
  }

  .render-preview {
    flex-direction: column;
  }

  .meter-row {
    grid-template-columns: 1fr auto;
  }

  .meter-row .meter {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .pager {
    justify-content: center;
  }

  .job-cards {
    grid-template-columns: 1fr;
  }
}

/* =====================================================================
   Theme v2 — refreshed design tokens, light & dark.
   Dark follows the system unless the user picks a theme (data-theme on <html>).
   ===================================================================== */

:root {
  color-scheme: light;
  /* chart palette: brand pink & orange first (logo), then harmonised accents */
  --chart-1: #ff2e74;
  --chart-2: #ff7a3d;
  --chart-3: #8b2d6b;
  --chart-4: #213968;
  --chart-5: #f5a524;
  --chart-6: #64748b;
  --chart-7: #ffb3cb;
  --chart-8: #c2410c;
  --chart-soft: #ffd6e5;

  --bg: #f5f6f8;
  --bg-grad-1: #f5f6f8;
  --bg-grad-2: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f2f4f7;
  --sidebar-bg: #fcfcfd;
  --ink: #101828;
  --ink-soft: #344054;
  --muted: #667085;
  --muted-2: #98a2b3;
  --border: #eaecf0;
  --border-strong: #d0d5dd;
  --heading-muted: #475467;
  --brand-navy: #213968;
  --brand-navy-soft: #eef2fa;

  --accent: #ff2e74;
  --accent-hover: #f0186a;
  --accent-press: #d1145c;
  --accent-soft: #fff0f5;
  --accent-soft-2: #ffd6e5;
  --accent-ink: #c4155c;

  --danger: #e5484d;
  --danger-hover: #ce2c31;
  --danger-soft: #fff0f0;
  --success: #30a46c;
  --success-soft: #ebf9f1;
  --success-ink: #18794e;
  --warning-soft: #fff7e6;
  --warning-ink: #9a5b00;
  --info-soft: #eef4ff;
  --info-ink: #1e3a8a;

  --r-xl: 18px;
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 8px;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.03);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 16px 32px -8px rgba(16, 24, 40, 0.14), 0 4px 8px -4px rgba(16, 24, 40, 0.05);
  --ring: 0 0 0 4px rgba(255, 46, 116, 0.14);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --chart-3: #c45b9c;
  --chart-4: #6f8fd8;
  --chart-6: #94a3b8;
  --chart-soft: rgba(255, 46, 116, 0.28);

  --bg: #0b0e14;
  --bg-grad-1: #0b0e14;
  --bg-grad-2: #0b0e14;
  --surface: #12161f;
  --surface-2: #171c27;
  --surface-3: #1e2431;
  --sidebar-bg: #0f131b;
  --ink: #edf0f5;
  --ink-soft: #c9cfda;
  --muted: #8d96a8;
  --muted-2: #697386;
  --border: #232a38;
  --border-strong: #303949;
  --heading-muted: #a3acbd;
  --brand-navy: #9db4ec;
  --brand-navy-soft: rgba(110, 140, 220, 0.14);
  --accent-soft: rgba(255, 46, 116, 0.14);
  --accent-soft-2: rgba(255, 46, 116, 0.3);
  --accent-ink: #ff7eaa;
  --danger-soft: rgba(229, 72, 77, 0.14);
  --success-soft: rgba(48, 164, 108, 0.16);
  --success-ink: #5bd49a;
  --warning-soft: rgba(245, 165, 36, 0.14);
  --warning-ink: #f5c86a;
  --info-soft: rgba(80, 130, 240, 0.14);
  --info-ink: #a9c3ff;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --chart-3: #c45b9c;
    --chart-4: #6f8fd8;
    --chart-6: #94a3b8;
    --chart-soft: rgba(255, 46, 116, 0.28);
    --bg: #0b0e14;
    --bg-grad-1: #0b0e14;
    --bg-grad-2: #0b0e14;
    --surface: #12161f;
    --surface-2: #171c27;
    --surface-3: #1e2431;
    --sidebar-bg: #0f131b;
    --ink: #edf0f5;
    --ink-soft: #c9cfda;
    --muted: #8d96a8;
    --muted-2: #697386;
    --border: #232a38;
    --border-strong: #303949;
    --heading-muted: #a3acbd;
    --brand-navy: #9db4ec;
    --brand-navy-soft: rgba(110, 140, 220, 0.14);
    --accent-soft: rgba(255, 46, 116, 0.14);
    --accent-soft-2: rgba(255, 46, 116, 0.3);
    --accent-ink: #ff7eaa;
    --danger-soft: rgba(229, 72, 77, 0.14);
    --success-soft: rgba(48, 164, 108, 0.16);
    --success-ink: #5bd49a;
    --warning-soft: rgba(245, 165, 36, 0.14);
    --warning-ink: #f5c86a;
    --info-soft: rgba(80, 130, 240, 0.14);
    --info-ink: #a9c3ff;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5);
  }
}

/* ---- base refresh ---- */
body {
  background: var(--bg);
  font-feature-settings: "cv11", "ss01", "ss03";
  letter-spacing: -0.006em;
}

.workspace {
  background: var(--bg);
}

.sidebar {
  background: var(--sidebar-bg);
}

.topbar {
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
}

.topbar h1 {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card,
.kpi,
.lx-card,
.job-card,
.list-tile,
.stat-tile {
  box-shadow: var(--shadow-xs);
}

.card-header h3 {
  font-weight: 650;
  letter-spacing: -0.01em;
}

.nav-btn {
  font-weight: 550;
}

.nav-btn.is-active {
  font-weight: 650;
}

.primary-btn {
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08), inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

.primary-btn:hover {
  box-shadow: 0 4px 12px -2px rgba(255, 46, 116, 0.35);
}

.ghost-btn {
  color: var(--ink-soft);
}

.danger:hover {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
}

body.launcher-body,
body.public-body {
  background: var(--bg);
}

.lx-column h2,
.section-title {
  color: var(--heading-muted);
}

.sec-letter {
  background: var(--brand-navy);
  color: var(--surface);
}

.item-no {
  color: var(--brand-navy);
}

.tone-navy { --tone: var(--brand-navy); --tone-soft: var(--brand-navy-soft); --tone-ink: var(--brand-navy); }
.tone-slate { --tone-soft: color-mix(in srgb, #64748b 14%, transparent); --tone-ink: var(--ink-soft); }
.tone-teal { --tone-soft: color-mix(in srgb, #12a594 16%, transparent); --tone-ink: #12a594; }
.tone-pink { --tone-soft: var(--accent-soft); --tone-ink: var(--accent-ink); }

/* badges and alerts follow the theme */
.st-badge {
  background: color-mix(in srgb, var(--c) 13%, transparent);
  color: color-mix(in srgb, var(--c) 82%, var(--ink));
}

.mat-badge {
  color: color-mix(in srgb, var(--c) 85%, var(--ink));
}

.stage-bar li.done {
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: color-mix(in srgb, var(--c) 82%, var(--ink));
}

.pill-ok { background: var(--success-soft); color: var(--success-ink); }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: var(--success-ink); }
.alert-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, #f5a524 35%, transparent); color: var(--warning-ink); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, #3b82f6 25%, transparent); color: var(--info-ink); }
.kpi-warning .kpi-value { color: var(--warning-ink); }
.kpi-warning .kpi-icon { background: var(--warning-soft); color: var(--warning-ink); }
.kpi-success .kpi-value { color: var(--success-ink); }
.kpi-success .kpi-icon { background: var(--success-soft); color: var(--success-ink); }
.module-badge { background: var(--warning-soft); color: var(--warning-ink); }
.move-warn .move-form { background: var(--warning-soft); border-color: color-mix(in srgb, #f5a524 30%, transparent); }
.req-list .ok { color: var(--success-ink); }
.artwork-banner { background: var(--brand-navy-soft); border-color: color-mix(in srgb, var(--brand-navy) 30%, transparent); color: var(--brand-navy); }
.decision-bar { border-left-color: var(--accent); }
.meter span { background: var(--brand-navy); }

/* KPI tiles: a subtle accent stripe on hover */
.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: transparent;
  transition: background 0.15s var(--ease);
}

a.kpi:hover::before { background: var(--accent); }
.kpi-danger::before { background: var(--danger); }

.chart-card .chart-box {
  margin: 0 -6px -8px;
}

.apexcharts-tooltip {
  border-radius: 10px !important;
  box-shadow: var(--shadow-lg) !important;
  border: 1px solid var(--border) !important;
}

.apexcharts-legend-text {
  font-family: "Inter", system-ui, sans-serif !important;
}

/* ---- theme toggle ---- */
.theme-toggle {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.theme-toggle:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

.sidebar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-tools .sidebar-user {
  flex: 1;
  min-width: 0;
}

.app-shell.sidebar-collapsed .sidebar-tools {
  flex-direction: column;
}

.pub-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* inputs on dark surfaces */
:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea {
  background: var(--surface-2);
}

:root[data-theme="dark"] .bw select {
  background-color: var(--surface-2);
}

/* paper documents stay light in any theme */
.report-sheet,
.pf-sheet {
  color-scheme: light;
}

@media (max-width: 1200px) {
  .sidebar-tools {
    flex-direction: row;
  }
}

/* ---- studio selects (searchable) keep their compact width ---- */
.preview-controls .ss,
.tpl-toolbar .ss {
  width: auto;
  min-width: 240px;
}

.preview-controls .ss-trigger,
.tpl-toolbar .ss-trigger {
  height: 40px;
}

/* ---- month switch ---- */
.month-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.month-switch label {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.month-switch .ss {
  min-width: 170px;
}

.topbar-actions .month-switch .ss {
  width: 170px;
}

/* ---- chart empty (div charts) ---- */
.chart-box.is-empty {
  display: grid;
  place-items: center;
}

.chart-box.is-empty .chart-empty {
  position: static;
  width: 100%;
  height: 100%;
}

/* ---- Monthly Summary report sheet (always paper-light) ---- */
.report-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.report-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.report-scroll {
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 18px;
}

.report-sheet {
  --ink: #101828;
  --ink-soft: #344054;
  --muted: #667085;
  --border: #e4e7ec;
  --surface: #ffffff;
  --chart-3: #8b2d6b;
  --chart-4: #213968;
  --chart-6: #64748b;
  width: 1180px;
  min-height: 820px;
  margin: 0 auto;
  background: #fff;
  color: #101828;
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rs-band {
  display: flex;
  justify-content: space-between;
  padding: 14px 36px;
  background: #213968;
  color: #fff;
  border-bottom: 4px solid #c0262d;
  font-size: 0.82rem;
}

.rs-body {
  flex: 1;
  padding: 22px 36px 10px;
}

.rs-kicker {
  margin: 0;
  color: #c0262d;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.report-sheet h1 {
  margin: 4px 0 16px;
  color: #213968;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.report-sheet h2 {
  margin: 0 0 8px;
  color: #213968;
  font-size: 0.92rem;
  font-weight: 800;
}

.rs-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.rs-kpis div {
  padding: 12px 14px;
  background: #eef1f7;
}

.rs-kpis strong {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.rs-kpis span {
  font-size: 0.78rem;
  color: #667085;
}

.c-navy { color: #213968; }
.c-red { color: #c0262d; }
.c-teal { color: #2a8a8a; }
.c-amber { color: #d9a21b; }

.rs-row {
  display: grid;
  gap: 24px;
  margin-bottom: 16px;
}

.rs-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rs-row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rs-row.two-one { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.rs-row section {
  min-width: 0;
}

.rs-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.rs-table th {
  position: static;
  padding: 7px 8px;
  background: #213968;
  color: #fff;
  font-size: 0.7rem;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  border: 0;
}

.rs-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e4e7ec;
  color: #344054;
  font-size: 0.76rem;
}

.rs-table tbody tr:nth-child(even) td {
  background: #f6f8fc;
}

.rs-table tbody tr:hover {
  background: none;
}

.rs-table tr.is-late td:first-child {
  color: #c0262d;
  font-weight: 700;
}

.rs-note-box {
  min-height: 150px;
  padding: 12px 16px;
  background: #eef1f7;
  font-size: 0.82rem;
  color: #344054;
}

.rs-note-box ul {
  margin: 0;
  padding-left: 16px;
  display: grid;
  gap: 6px;
}

.rs-note-box ul.is-draft {
  color: #667085;
}

.rs-note-box ul.is-draft::before {
  content: "Suggested from the figures (not saved yet)";
  display: block;
  margin: 0 0 6px -16px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #98a2b3;
}

.rs-foot {
  display: flex;
  justify-content: space-between;
  padding: 10px 36px 14px;
  border-top: 1px solid #e4e7ec;
  color: #98a2b3;
  font-size: 0.72rem;
}

.report-sheet .muted {
  color: #667085;
}

.report-sheet .apexcharts-text,
.report-sheet .apexcharts-legend-text {
  fill: #344054 !important;
  color: #344054 !important;
}

.report-sheet.is-exporting {
  box-shadow: none;
  border-radius: 0;
}

.notes-card textarea {
  min-height: 140px;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }

  body.bw {
    height: auto;
    overflow: visible;
    background: #fff;
  }

  .bw .sidebar,
  .bw .topbar,
  .no-print,
  .alert {
    display: none !important;
  }

  .bw .app-shell,
  .bw .workspace,
  .bw .workspace-body,
  .report-scroll {
    display: block;
    height: auto;
    overflow: visible;
    padding: 0;
    margin: 0;
    background: #fff;
  }

  .report-sheet {
    width: 100%;
    min-height: 0;
    box-shadow: none;
    zoom: 0.82;
  }

  .rs-band,
  .rs-kpis div,
  .rs-table th,
  .rs-note-box,
  .rs-table tbody tr:nth-child(even) td {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ---- requester portal ---- */
.portal-list {
  display: grid;
  gap: 14px;
}

.portal-list .card + .card {
  margin-top: 0;
}

.portal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.portal-head h3 {
  margin: 0;
  font-size: 1.02rem;
}

.portal-head p {
  margin: 2px 0 0;
  font-size: 0.85rem;
}

.portal-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.portal-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.portal-items li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

/* ---- phone polish for module pages ---- */
@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 10px;
  }

  .topbar h1 {
    font-size: 1.15rem;
  }

  .topbar .subtitle {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions > * {
    flex: 1 1 auto;
  }

  .workspace-body {
    padding: 14px;
  }

  .card {
    padding: 16px;
  }

  .card-header.with-action {
    flex-wrap: wrap;
  }

  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-actions .primary-btn,
  .form-actions .ghost-btn {
    flex: 1 1 auto;
  }

  .report-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .portal-items li {
    flex-direction: column;
    align-items: flex-start;
  }

  .kv-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 420px) {
  .filter-grid {
    grid-template-columns: 1fr;
  }
}

/* printable form: fit the A4 sheet on phone screens (prints at full size) */
@media screen and (max-width: 840px) {
  .pf-sheet {
    width: 100%;
    min-height: 0;
    padding: 0 14px 14px;
    font-size: 9pt;
  }

  .pf-band {
    margin: 0 -14px 14px;
    padding: 12px 14px;
    flex-direction: column;
    gap: 2px;
  }

  .pf-sheet h1 {
    font-size: 18pt;
  }

  .pf-box {
    margin-right: 10px;
  }
}

/* layout fixes: charts sit inside their cards, KPI rows of four */
.chart-card .chart-box {
  margin: 0;
}

.kpi-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-value {
  font-size: clamp(1.2rem, 1.9vw, 1.7rem);
  padding-right: 44px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1100px) {
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .kpi-value {
    padding-right: 0;
  }
}

/* =====================================================================
   Modal (assets/components/modal.js) & row actions
   ===================================================================== */
dialog.mx {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

dialog.mx[data-size="sm"] { width: min(460px, calc(100vw - 32px)); }
dialog.mx[data-size="lg"] { width: min(880px, calc(100vw - 32px)); }

dialog.mx[open] {
  animation: mxIn 0.18s var(--ease);
}

dialog.mx::backdrop {
  background: rgba(10, 14, 22, 0.45);
  backdrop-filter: blur(2px);
}

@keyframes mxIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

body.mx-open {
  overflow: hidden;
}

.mx-card {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}

.mx-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.mx-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.mx-close {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.mx-close:hover {
  color: var(--ink);
}

.mx-body {
  padding: 18px 20px 20px;
  overflow-y: auto;
}

.mx-body > div > .card,
.mx-body .setup-form {
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.mx-body .setup-form .card-header {
  display: none;
}

.mx-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 0;
  color: var(--muted);
}

.mx-loading span {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: mxSpin 0.7s linear infinite;
}

@keyframes mxSpin {
  to { transform: rotate(360deg); }
}

.mx-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.mx-summary + .stage-bar {
  margin-bottom: 16px;
}

.mx-body .kv-row {
  margin-bottom: 14px;
}

.mx-items {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.mx-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.mx-item .field-grid {
  margin-top: 8px;
}

.mx-item-meta {
  font-size: 0.84rem;
  color: var(--muted);
}

.mx-item-content {
  margin: 4px 0 0;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 0.86rem;
}

.mx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.mx-actions form {
  margin: 0;
}

.mx-form .field + .field {
  margin-top: 12px;
}

.mx-foot-link {
  margin: 16px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.mx-foot-link a {
  color: var(--accent-ink);
  font-weight: 600;
}

.move-list.in-modal {
  flex-direction: column;
  align-items: stretch;
}

.move-list.in-modal .move > summary {
  width: 100%;
}

.quick-upload {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px dashed var(--accent-soft-2);
  border-radius: var(--r-md);
  background: var(--accent-soft);
}

.quick-upload label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--accent-ink);
}

.quick-upload label svg {
  width: 16px;
  height: 16px;
}

.quick-upload-row {
  display: flex;
  gap: 8px;
}

.quick-upload-row input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
}

.move-confirm {
  display: grid;
  gap: 12px;
}

.assign-form .form-actions {
  margin-top: 14px;
}

/* row action buttons */
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.row-actions .tiny svg {
  width: 13px;
  height: 13px;
}

.ghost-btn.icon-only {
  padding: 6px 8px;
}

.data-table .sticky-col {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: -8px 0 12px -10px rgba(16, 24, 40, 0.25);
}

.data-table thead .sticky-col {
  background: var(--surface-2);
  z-index: 2;
}

.data-table tbody tr:hover .sticky-col {
  background: var(--surface-2);
}

.data-table tr.is-clickable {
  cursor: pointer;
}

.job-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.job-card-actions > * {
  flex: 1;
}

@media (max-width: 640px) {
  dialog.mx,
  dialog.mx[data-size] {
    width: 100vw;
    max-width: 100vw;
    max-height: 92vh;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
  }

  .mx-card {
    max-height: 92vh;
  }

  .mx-body {
    padding: 16px;
  }

  .mx-actions > * {
    flex: 1 1 auto;
  }

  .quick-upload-row {
    flex-direction: column;
  }
}

/* stage bar inside modals: compact labels, no truncation */
.mx-body .stage-bar li {
  padding: 8px 6px 8px 14px;
  font-size: 0.74rem;
  gap: 5px;
}

.mx-body .stage-bar li:first-child {
  padding-left: 8px;
}

.mx-body .stage-bar li span {
  display: none;
}

/* SearchSelect list floats in a fixed layer (never clipped by modals/tables) */
.ss-panel {
  position: fixed;
  right: auto;
  z-index: 1200;
  display: flex;
  flex-direction: column;
}

.ss-panel .ss-list {
  max-height: none;
  flex: 1;
  min-height: 0;
}

.ss.drop-up .ss-panel {
  top: auto;
}

/* =====================================================================
   Action menu (assets/components/menu.js)
   ===================================================================== */
.am {
  display: inline-block;
}

.am-btn {
  gap: 6px;
}

.am-btn svg {
  width: 13px !important;
  height: 13px !important;
  transition: transform 0.15s var(--ease);
}

.am.is-open .am-btn {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.am.is-open .am-btn svg {
  transform: rotate(180deg);
}

.am-menu {
  position: fixed;
  z-index: 1100;
  min-width: 190px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: lxPop 0.12s var(--ease);
}

.am-menu[hidden] {
  display: none;
}

.am-menu form {
  margin: 0;
}

.am-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 550;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.am-item:hover,
.am-item:focus-visible {
  outline: none;
  background: var(--surface-3);
  color: var(--ink);
}

.am-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--muted);
}

.am-item.is-danger,
.am-item.is-danger svg {
  color: var(--danger);
}

.am-item.is-danger:hover {
  background: var(--danger-soft);
}

.am-dot {
  width: 15px;
}

.am-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--border);
}

/* ---- "Move to" status picker ---- */
.move-switch {
  display: grid;
  gap: 12px;
}

.move-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  align-items: end;
}

.move-picker label {
  grid-column: 1 / -1;
  margin: 0;
}

.move-from {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  padding-bottom: 10px;
}

.move-form[hidden] {
  display: none;
}

.move-back {
  border-color: color-mix(in srgb, var(--brand-navy) 25%, transparent);
}

.move-confirm button[type="submit"] {
  justify-self: start;
}

.mx-body .move-confirm button[type="submit"] {
  width: 100%;
}

/* ---- top bar: theme toggle sits with the page actions ---- */
.topbar-actions {
  margin-left: auto;
}

.topbar > .theme-toggle {
  margin-left: 10px;
}

/* =====================================================================
   Phones & tablets: sidebar becomes a slide-in drawer (☰)
   (replaces the old horizontal icon bar)
   ===================================================================== */
.shell-overlay {
  display: none;
}

@media (max-width: 1200px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 100%;
  }

  .sidebar,
  .app-shell.sidebar-collapsed .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 950;
    width: min(300px, 86vw);
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
    border-right: 1px solid var(--border);
    border-bottom: 0;
    overflow-x: hidden;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 0.26s var(--ease), box-shadow 0.26s var(--ease);
  }

  .app-shell.nav-open .sidebar {
    transform: none;
    box-shadow: var(--shadow-lg);
  }

  .shell-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 940;
    background: rgba(10, 14, 22, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease);
  }

  .app-shell.nav-open .shell-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  body.drawer-open {
    overflow: hidden;
  }

  .sidebar-section-label {
    display: block;
  }

  .sidebar-nav {
    flex: none;
    flex-direction: column;
    gap: 4px;
  }

  .nav-text,
  .app-shell.sidebar-collapsed .nav-text,
  .app-shell.sidebar-collapsed .brand-text,
  .app-shell.sidebar-collapsed .sidebar-section-label {
    display: inline;
    opacity: 1;
    width: auto;
    pointer-events: auto;
  }

  .sidebar-section-label,
  .app-shell.sidebar-collapsed .sidebar-section-label {
    display: block;
  }

  .sidebar .nav-btn,
  .app-shell.sidebar-collapsed .nav-btn,
  .app-shell.sidebar-collapsed .brand,
  .app-shell.sidebar-collapsed #quickAddBtn,
  .app-shell.sidebar-collapsed .sidebar-user {
    justify-content: flex-start;
    padding: 10px 12px;
  }

  .app-shell.sidebar-collapsed #quickAddBtn {
    justify-content: center;
  }

  .nav-btn.is-active::before {
    display: block;
  }

  .nav-group {
    display: flex;
  }

  .nav-group-toggle {
    display: flex;
  }

  .nav-group-items {
    display: none;
  }

  .nav-group.is-open .nav-group-items {
    display: flex;
  }

  .app-shell.sidebar-collapsed .nav-chevron,
  .app-shell.sidebar-collapsed .sidebar-user-logout {
    display: grid;
  }

  .sidebar-foot {
    margin-top: auto;
  }

  .sidebar-tools,
  .app-shell.sidebar-collapsed .sidebar-tools {
    flex-direction: row;
  }

  #sidebarToggleBtn {
    display: grid !important;
  }

  .workspace {
    min-height: 0;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: sticky;
    top: 0;
  }

  .topbar-left {
    flex: 1;
    min-width: 0;
  }

  .topbar-actions {
    width: auto;
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .topbar-actions > .theme-toggle {
    flex: 0 0 auto;
    margin-left: auto;
    order: 99;
  }

  .move-picker {
    grid-template-columns: 1fr;
  }

  .move-from {
    padding-bottom: 0;
  }
}

/* collapsible filters (phones) */
.filter-details > summary {
  list-style: none;
}

.filter-details > summary::-webkit-details-marker {
  display: none;
}

.filter-summary {
  display: none;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  cursor: pointer;
}

.filter-summary svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .filter-summary {
    display: flex;
  }

  .filter-details[open] > .filter-summary {
    margin-bottom: 12px;
  }

  .filter-card {
    padding: 12px 14px;
  }
}

/* register: compact columns, actions always visible; no sticky column overlap */
.register-table {
  min-width: 1080px;
}

.data-table .actions-col {
  text-align: right;
}

.data-table .cell-sub.nowrap {
  white-space: nowrap;
}

/* inbox tabs scroll sideways on phones instead of overflowing */
.tabs {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
}

@media (max-width: 760px) {
  .toolbar.wrap {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .search-field {
    min-width: 0;
  }

  .toolbar .tabs {
    align-self: stretch;
  }
}

/* =====================================================================
   Toasts (assets/components/toast.js)
   ===================================================================== */
.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 3000;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 12px 12px 14px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  line-height: 1.4;
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.toast.is-in {
  opacity: 1;
  transform: none;
}

.toast.is-out {
  opacity: 0;
  transform: translateX(16px);
}

.toast-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.toast-icon svg {
  width: 14px;
  height: 14px;
}

.toast-success .toast-icon { background: var(--success-soft); color: var(--success-ink); }
.toast-error .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast-warning .toast-icon { background: var(--warning-soft); color: var(--warning-ink); }
.toast-info .toast-icon { background: var(--info-soft); color: var(--info-ink); }

.toast-msg {
  padding-top: 2px;
  font-weight: 550;
}

.toast-link {
  color: var(--accent-ink);
  font-weight: 700;
  white-space: nowrap;
}

.toast-x {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.toast-x:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.toast-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  transform-origin: left;
  animation: toastBar var(--toast-ms, 4500ms) linear forwards;
}

.toast.is-paused .toast-bar {
  animation-play-state: paused;
}

.toast-success .toast-bar { background: var(--success); }
.toast-error .toast-bar { background: var(--danger); }
.toast-warning .toast-bar { background: #f5a524; }
.toast-info .toast-bar { background: #3b82f6; }

@keyframes toastBar {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (max-width: 640px) {
  .toast-stack {
    top: auto;
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 16px;
  }
}

/* the old studio toast is replaced by PixoToast */
.studio-toast {
  display: none !important;
}

@media (max-width: 640px) {
  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar .search-field {
    flex: 1 1 100%;
  }
}

/* Monthly Summary: sheet fits the content area; scrolls only on narrow screens */
.report-sheet {
  width: 100%;
  max-width: 1180px;
  min-width: 980px;
}

.rs-band {
  gap: 16px;
}

.rs-band span {
  text-align: right;
}

.rs-table td:first-child,
.rs-table th:first-child {
  white-space: nowrap;
}

.rs-row.three section .chart-box {
  height: 230px !important;
}

/* phones: theme toggle pinned to the header's top-right corner */
@media (max-width: 760px) {
  .topbar {
    padding-right: 62px;
  }

  .topbar-actions > .theme-toggle,
  .topbar > .theme-toggle {
    position: absolute;
    top: 12px;
    right: 14px;
    margin: 0;
  }

  .topbar-actions:not(:has(> :not(.theme-toggle))) {
    display: contents;
  }
}

/* inbox: references and dates stay on one line */
.data-table td:first-child .row-link strong,
.data-table td:first-child > .cell-sub {
  white-space: nowrap;
}

.data-table.clickable td:nth-child(2) {
  white-space: nowrap;
}

/* anything marked hidden stays hidden, whatever its layout class */
[hidden] {
  display: none !important;
}

/* phones: the sticky submit bar is a solid strip */
@media (max-width: 760px) {
  .sticky-actions {
    margin: 18px -16px 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 16px -10px rgba(16, 24, 40, 0.25);
  }

  .sticky-actions .primary-btn {
    flex: 1;
  }
}

/* =====================================================================
   Responsive tables: phones show each row as a labelled card
   ===================================================================== */
@media (max-width: 640px) {
  .table-wrap:has(> table.is-stackable) {
    border: 0;
    border-radius: 0;
    overflow: visible;
  }

  table.is-stackable {
    min-width: 0 !important;
  }

  table.is-stackable thead {
    display: none;
  }

  table.is-stackable tbody tr {
    display: block;
    margin-bottom: 10px;
    padding: 6px 2px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
  }

  table.is-stackable tbody tr:hover {
    background: var(--surface);
  }

  table.is-stackable tbody td {
    display: grid;
    grid-template-columns: minmax(84px, 36%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 7px 12px;
    border: 0;
    text-align: left;
    white-space: normal;
    font-size: 0.88rem;
  }

  table.is-stackable tbody td::before {
    content: attr(data-label);
    padding-top: 2px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted-2);
  }

  table.is-stackable tbody td:first-child {
    padding-top: 10px;
    font-size: 0.95rem;
  }

  table.is-stackable tbody td.actions-col,
  table.is-stackable tbody td.empty {
    grid-template-columns: minmax(0, 1fr);
    width: auto;
    white-space: normal;
  }

  table.is-stackable tbody td.actions-col::before,
  table.is-stackable tbody td.empty::before,
  table.is-stackable tbody td:not([data-label])::before {
    display: none;
  }

  table.is-stackable tbody td.actions-col {
    padding: 8px 12px 10px;
    border-top: 1px dashed var(--border);
    margin-top: 4px;
  }

  table.is-stackable .am,
  table.is-stackable .am-btn,
  table.is-stackable .table-actions {
    width: 100%;
  }

  table.is-stackable .am-btn {
    justify-content: center;
    padding: 9px 12px;
  }

  table.is-stackable tr.is-overdue {
    border-left: 3px solid var(--danger);
  }

  table.is-stackable tr.is-overdue td:first-child,
  table.is-stackable tr.is-soon td:first-child {
    box-shadow: none;
  }

  table.is-stackable tr.is-soon {
    border-left: 3px solid #d9a21b;
  }

  table.is-stackable .cell-name {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  table.is-stackable tbody td {
    column-gap: 10px;
    row-gap: 2px;
  }

  /* every value (and its secondary line) stays in the right-hand column */
  table.is-stackable tbody td[data-label] > * {
    grid-column: 2;
  }

  table.is-stackable tbody td[data-label]::before {
    grid-row: 1 / span 3;
  }

  table.is-stackable tbody td .cell-sub {
    margin-top: 0;
  }
}

/* register fits the content width on laptops; actions always visible */
.register-table {
  min-width: 940px;
}

.register-table th,
.register-table td {
  padding: 10px 10px;
}

.register-table td:nth-child(6) .mat-badge {
  display: inline-block;
  min-width: 90px;
}

@media (min-width: 1201px) {
  .table-wrap:has(> .register-table) {
    overflow-x: auto;
  }
}

/* (scoped) only the inbox keeps its received date on one line */
.data-table.clickable td:nth-child(2) {
  white-space: normal;
}

.inbox-table td:nth-child(2) {
  white-space: nowrap;
}

.register-table td:first-child > .cell-sub {
  white-space: normal;
  max-width: 130px;
}

@media (max-width: 1440px) {
  .register-table th,
  .register-table td {
    padding: 9px 7px;
    font-size: 0.83rem;
  }

  .register-table th {
    font-size: 0.66rem;
  }

  .register-table .am-btn {
    padding: 6px 9px;
  }

  .register-table .st-badge {
    padding: 2px 8px 2px 6px;
    font-size: 0.72rem;
  }
}

/* =====================================================================
   Jobs: view switch + Kanban board
   ===================================================================== */
.jobs-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 12px 14px;
}

.view-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: var(--r-md);
  background: var(--surface-3);
  gap: 4px;
}

.view-switch a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 0.87rem;
  font-weight: 650;
  text-decoration: none;
}

.view-switch a svg {
  width: 15px;
  height: 15px;
}

.view-switch a.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

.jobs-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
  margin: 0;
}

.jobs-filters .search-field {
  flex: 1 1 240px;
}

.jobs-filters .ss {
  width: 200px;
}

.inline-check {
  margin: 0 !important;
  white-space: nowrap;
}

.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 10px;
  align-items: start;
}

.kanban-col {
  display: flex;
  flex-direction: column;
  min-height: 320px;
  max-height: calc(100vh - 290px);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.kanban-col.is-over {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 8%, var(--surface-2));
}

.kanban-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.kanban-head h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
}

.kanban-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
}

.kanban-count {
  margin-left: auto;
  min-width: 24px;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.74rem;
  font-weight: 700;
  text-align: center;
  color: var(--muted);
}

.kanban-cards {
  display: grid;
  gap: 10px;
  padding: 10px;
  overflow-y: auto;
  align-content: start;
  flex: 1;
}

.kanban-empty {
  display: none;
  margin: 0;
  padding: 18px 8px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted-2);
}

.kanban-cards > .kanban-empty:first-child {
  display: block;
}

.kcard {
  display: grid;
  gap: 6px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--c, var(--border));
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  cursor: grab;
  transition: box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}

.kcard:hover {
  box-shadow: var(--shadow-md);
}

.kcard.is-dragging {
  opacity: 0.5;
  transform: rotate(1.5deg);
  cursor: grabbing;
}

.kcard.is-overdue {
  border-left-color: var(--danger);
}

.kcard-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.kcard-top strong {
  font-size: 0.9rem;
}

.kcard-due {
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.kcard-due.is-late {
  background: var(--danger-soft);
  color: var(--danger);
}

.kcard p {
  margin: 0;
}

.kcard-title {
  font-weight: 650;
  font-size: 0.9rem;
}

.kcard-where {
  display: flex;
  gap: 5px;
  align-items: flex-start;
  font-size: 0.8rem;
  color: var(--muted);
}

.kcard-where svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  margin-top: 3px;
}

.kcard-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
}

.kcard-meta .mat-badge {
  font-size: 0.78rem;
}

.kcard-hint {
  font-size: 0.76rem;
  font-weight: 650;
  color: var(--accent-ink);
}

.kcard-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.kcard-avatar {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.66rem;
  font-weight: 700;
}

@media (max-width: 760px) {
  .jobs-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .view-switch {
    align-self: stretch;
  }

  .view-switch a {
    flex: 1;
    justify-content: center;
  }

  .jobs-filters .ss {
    width: 100%;
  }

  .kanban {
    grid-auto-columns: 84vw;
    scroll-snap-type: x mandatory;
  }

  .kanban-col {
    scroll-snap-align: start;
    max-height: none;
  }
}

.optional-tag {
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kcard .row-link {
  color: var(--ink);
  text-decoration: none;
}

.kcard .row-link:hover {
  color: var(--accent-ink);
}

/* =====================================================================
   Job details (View details modal)
   ===================================================================== */
.details-view {
  display: grid;
  gap: 14px;
}

.dv-section {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.dv-section h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--heading-muted);
}

.dv-section h4 svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.dv-link {
  margin-left: auto;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.82rem;
  color: var(--accent-ink);
}

.dv-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 0;
}

.dv-grid dt {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.dv-grid dd {
  margin: 2px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.dv-grid dd a {
  color: var(--accent-ink);
}

.dv-grid .cell-sub {
  display: block;
  font-weight: 500;
}

.dv-note {
  margin: 12px 0 0;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 0.86rem;
}

.details-view .content-box {
  margin-top: 12px;
}

.dv-media {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.dv-thumb {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  text-decoration: none;
}

.dv-thumb img,
.dv-pdf {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-3);
}

.dv-thumb.is-render img {
  aspect-ratio: 3 / 4;
  object-fit: contain;
}

.dv-pdf {
  display: grid;
  place-items: center;
  font-weight: 800;
}

.details-view .timeline {
  margin-left: 6px;
}

.kcard:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft-2);
}

@media (max-width: 760px) {
  .dv-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .dv-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* =====================================================================
   Running time + overdue (jobClock chips, rows, cards)
   ===================================================================== */
.clock-cell {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.age-chip,
.due-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.age-chip svg,
.due-chip svg,
.od-badge svg {
  width: 12px;
  height: 12px;
  flex: none;
}

.age-chip b {
  font-weight: 800;
}

.age-chip.tone-soon,
.due-chip.is-soon {
  background: var(--warning-soft);
  color: var(--warning-ink);
}

.age-chip.tone-late {
  background: var(--danger-soft);
  color: var(--danger);
}

.age-chip.is-done,
.due-chip.is-ok {
  background: var(--success-soft);
  color: var(--success-ink);
}

.age-chip.is-done.is-late,
.age-chip.is-muted {
  background: var(--surface-3);
  color: var(--muted);
}

.due-chip {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
}

.due-chip.is-soon,
.due-chip.is-ok {
  border-color: transparent;
}

.due-chip.is-late {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  background: var(--danger-soft);
  color: var(--danger);
}

/* The loud one: solid red, pulsing dot. */
.od-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--danger) 40%, transparent);
}

.od-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: od-pulse 1.6s ease-out infinite;
}

.od-badge.is-static {
  padding: 1px 8px;
  box-shadow: none;
}

@keyframes od-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.8); }
  70% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .od-pulse { animation: none; }
}

/* Rows */
.data-table tr.is-overdue td {
  background: color-mix(in srgb, var(--danger) 6%, var(--surface));
}

.data-table tr.is-overdue:hover td {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}

.data-table tr.is-overdue td:first-child {
  box-shadow: inset 4px 0 0 var(--danger);
}

.data-table tr.is-due-soon td:first-child {
  box-shadow: inset 4px 0 0 #f5a524;
}

/* Kanban cards */
.kcard.is-overdue {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  border-left: 4px solid var(--danger);
  background: linear-gradient(180deg, var(--danger-soft), var(--surface) 70%);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--danger) 14%, transparent);
}

.kcard.is-due-soon {
  border-left: 4px solid #f5a524;
}

.kcard-alert {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 700;
}

.kcard-alert svg {
  width: 13px;
  height: 13px;
}

.kcard-foot-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Modal summary, request page, item page */
.mx-summary.is-overdue {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  background: var(--danger-soft);
}

.mx-summary.is-due-soon {
  border-color: color-mix(in srgb, #f5a524 45%, var(--border));
}

.mx-summary-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.item-view.is-due-soon {
  border-left: 4px solid #f5a524;
}

.status-card-head .clock-cell {
  margin-left: 6px;
  vertical-align: middle;
}

@media (max-width: 640px) {
  table.is-stackable tr.is-overdue {
    border-left: 4px solid var(--danger);
    background: color-mix(in srgb, var(--danger) 6%, var(--surface));
  }

  table.is-stackable tr.is-overdue td {
    background: transparent;
  }

  table.is-stackable tr.is-due-soon {
    border-left: 4px solid #f5a524;
  }

  table.is-stackable tr.is-due-soon td:first-child {
    box-shadow: none;
  }

  .mx-summary-side {
    align-items: flex-start;
  }
}

/* =====================================================================
   Department & User reports
   ===================================================================== */
.report-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
}

.rf-field {
  display: grid;
  gap: 4px;
  min-width: 200px;
}

.rf-field > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metrics-table th.num,
.metrics-table td.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.metrics-table tfoot th {
  padding: 12px 14px;
  border-top: 2px solid var(--border-strong);
  background: var(--surface-2);
  font-weight: 800;
  text-align: left;
}

.metrics-table tfoot th.num {
  text-align: right;
}

.metrics-table tr.has-overdue td:first-child {
  box-shadow: inset 4px 0 0 var(--danger);
}

.metric-pill {
  display: inline-block;
  min-width: 44px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
}

.metric-pill.is-good { background: var(--success-soft); color: var(--success-ink); }
.metric-pill.is-ok { background: var(--warning-soft); color: var(--warning-ink); }
.metric-pill.is-bad { background: var(--danger-soft); color: var(--danger); }

.score-badge {
  --pct: 0;
  --tone: var(--muted-2);
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--surface) 76%, transparent 78%),
    conic-gradient(var(--tone) calc(var(--pct) * 1%), var(--surface-3) 0);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
}

.score-badge.is-good { --tone: var(--success); }
.score-badge.is-ok { --tone: #f5a524; }
.score-badge.is-bad { --tone: var(--danger); }
.score-badge.is-none { color: var(--muted-2); background: var(--surface-3); }

.person-card {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}

.person-avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
}

.person-avatar.sm {
  width: 32px;
  height: 32px;
  font-size: 0.75rem;
}

.person-main {
  flex: 1;
  min-width: 0;
}

.person-main h2 {
  margin: 0;
  font-size: 1.25rem;
}

.person-main p {
  margin: 2px 0 8px;
}

.person-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

.person-facts strong {
  color: var(--ink);
}

.person-score {
  display: grid;
  justify-items: center;
  gap: 4px;
  font-size: 0.72rem;
}

.person-score .score-badge {
  width: 76px;
  height: 76px;
  font-size: 1.4rem;
}

.person-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.eval-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.eval-list > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}

.eval-list dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.eval-list dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.data-table tr.is-late-row td:first-child {
  box-shadow: inset 4px 0 0 color-mix(in srgb, var(--danger) 55%, transparent);
}

@media (max-width: 640px) {
  .rf-field {
    min-width: 0;
    flex: 1 1 100%;
  }

  .person-card {
    flex-wrap: wrap;
  }

  .person-score {
    margin-left: auto;
  }

  .eval-list > div {
    flex-wrap: wrap;
  }
}

@media print {
  .bw .dash-grid {
    display: block;
  }

  .bw .chart-card,
  .bw .card {
    break-inside: avoid;
    margin-bottom: 10px;
  }
}

.status-cell {
  min-width: 128px;
}

.status-cell .clock-cell {
  display: flex;
  margin-top: 5px;
}

/* Setup: tick-several fields (e.g. a block's floors) */
.field.field-span {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.check-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-chip {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.check-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check-chip span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.check-chip input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.check-chip input:checked + span::before {
  content: "✓";
  margin-right: 6px;
  font-weight: 800;
}

.check-chip input:focus-visible + span {
  box-shadow: var(--ring);
}

.link-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* =====================================================================
   Request form: full width, items as tabs, sq ft size
   ===================================================================== */
.workspace .request-form {
  max-width: none;
}

.item-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-3);
}

.item-tab-list {
  display: contents;
}

.item-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.item-tab:hover {
  color: var(--ink);
  background: var(--surface);
}

.item-tab.is-active {
  border-color: var(--border);
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: var(--shadow-xs);
}

.item-tab-name {
  max-width: 160px;
  overflow: hidden;
  color: var(--muted);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-tab.has-error::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

.item-tab-add {
  margin-left: auto;
  border: 1px dashed var(--border-strong);
  color: var(--accent-ink);
}

.item-tab-add svg {
  width: 14px;
  height: 14px;
}

.unit-input {
  display: flex;
  align-items: stretch;
}

.unit-input input {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.unit-input span {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-left: 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Searchable select: "+ Add …" entry */
.ss-list li.ss-create {
  border-top: 1px dashed var(--border);
  color: var(--accent-ink);
  font-weight: 700;
}

@media (max-width: 640px) {
  .item-tab {
    flex: 1 1 auto;
    justify-content: center;
  }

  .item-tab-add {
    margin-left: 0;
    flex-basis: 100%;
  }
}
