/* ============================================================
   BookCatalog Admin — Design System
   Light glassmorphism, soft muted palette, compact admin feel.
   Pure CSS, no frameworks. CSS custom properties as tokens.
   ============================================================ */

/* --- 1. Design Tokens --- */
:root {
  /* Palette – soft muted blues & neutrals */
  --c-blue-50:  #f0f5ff;
  --c-blue-100: #e0eafc;
  --c-blue-200: #c3d5f7;
  --c-blue-400: #6b9cf0;
  --c-blue-500: #4a7ee0;
  --c-blue-600: #3666c4;
  --c-blue-700: #2a50a0;

  --c-slate-50:  #f8f9fb;
  --c-slate-100: #f1f3f6;
  --c-slate-200: #e3e7ed;
  --c-slate-300: #cdd3dc;
  --c-slate-400: #9aa3b2;
  --c-slate-500: #6b7688;
  --c-slate-600: #4e5769;
  --c-slate-700: #364050;
  --c-slate-800: #232b38;
  --c-slate-900: #131820;

  --c-green-50:  #ecfdf3;
  --c-green-100: #d1fae0;
  --c-green-500: #22a85a;
  --c-green-700: #137a3e;

  --c-red-50:  #fef2f2;
  --c-red-100: #fee2e2;
  --c-red-500: #e5453a;
  --c-red-700: #b22e25;

  --c-amber-50:  #fffbeb;
  --c-amber-100: #fef3c7;
  --c-amber-600: #d97706;

  --c-purple-50:  #f5f0ff;
  --c-purple-100: #ede5ff;
  --c-purple-600: #7c3aed;

  --c-teal-50:  #f0fdfa;
  --c-teal-100: #ccfbf1;
  --c-teal-600: #0d9488;

  /* Semantic tokens */
  --bg:            var(--c-slate-50);
  --bg-subtle:     var(--c-slate-100);
  --surface:       #ffffff;
  --surface-glass:  rgba(255, 255, 255, 0.68);
  --surface-glass-solid: rgba(255, 255, 255, 0.88);
  --text:          var(--c-slate-800);
  --text-secondary: var(--c-slate-500);
  --text-tertiary:  var(--c-slate-400);
  --primary:       var(--c-blue-500);
  --primary-hover: var(--c-blue-600);
  --primary-subtle: var(--c-blue-50);
  --danger:        var(--c-red-500);
  --danger-hover:  var(--c-red-700);
  --success:       var(--c-green-500);
  --border:        var(--c-slate-200);
  --border-subtle: var(--c-slate-100);

  /* Elevation */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.07);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.10);
  --shadow-glass: 0 2px 16px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,0.6);

  /* Radius */
  --radius-xs:  6px;
  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "JetBrains Mono", monospace;
  --text-xs:  11px;
  --text-sm:  12px;
  --text-base: 13px;
  --text-md:  14px;
  --text-lg:  16px;
  --text-xl:  18px;
  --text-2xl: 22px;
  --leading:  1.5;
  --leading-tight: 1.3;

  /* Spacing (4px system) */
  --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;
  --sp-4: 16px;  --sp-5: 20px;  --sp-6: 24px;
  --sp-8: 32px;  --sp-10: 40px; --sp-12: 48px;

  /* Transition */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 280ms;

  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-modal:    1000;
  --z-toast:    2000;

  /* Layout */
  --sidebar-w: 230px;
}

/* --- 2. Reset & Base --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--leading);
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- 3. Shell Layout --- */
.shell {
  display: flex;
  min-height: 100dvh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface-glass-solid);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-right: 1px solid var(--border);
  padding: var(--sp-5) 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  z-index: var(--z-sticky);
}

.sidebar-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  padding: 0 var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--sp-2);
  letter-spacing: -0.01em;
}

.nav-section {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--sp-4) var(--sp-5) var(--sp-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-5);
  font-size: var(--text-base);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 0;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  position: relative;
}

.nav-item:hover {
  background: var(--primary-subtle);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-subtle);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--sp-1);
  bottom: var(--sp-1);
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}

/* Main content area */
.main {
  flex: 1;
  min-width: 0;
  padding: var(--sp-6) var(--sp-8);
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-6);
}

.topbar h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.topbar-user {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.topbar-user a {
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
}

/* --- 4. Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
  user-select: none;
  outline: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-subtle); color: var(--text); border-color: var(--c-slate-300); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); }

.btn-sm {
  padding: var(--sp-1) var(--sp-3);
  min-height: 28px;
  font-size: var(--text-sm);
}

.btn-xs {
  padding: 1px var(--sp-2);
  min-height: 22px;
  font-size: var(--text-xs);
}

.btn-lg {
  padding: var(--sp-3) var(--sp-6);
  min-height: 44px;
  font-size: var(--text-md);
}

.btn-block { width: 100%; }

/* --- 5. Form Controls --- */
.field {
  margin-bottom: var(--sp-4);
}

.field label,
.field-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--sp-1);
}

.field input,
.field select,
.field textarea,
.input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 126, 224, 0.12);
}

.field input::placeholder,
.input::placeholder {
  color: var(--text-tertiary);
}

.field input:disabled,
.input:disabled {
  background: var(--bg-subtle);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7688'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.field textarea {
  resize: vertical;
  min-height: 80px;
  line-height: var(--leading);
}

.field-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--sp-1);
}

.field-error {
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: var(--sp-1);
}

/* Search input with icon feel */
.search-input {
  padding-left: var(--sp-3);
  background-image: none;
}

/* Checkbox / toggle — global size reset */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
  vertical-align: middle;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-base);
  cursor: pointer;
  user-select: none;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* Small variant inputs */
.input-sm {
  padding: var(--sp-1) var(--sp-3);
  min-height: 28px;
  font-size: var(--text-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.input-sm:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 126, 224, 0.12);
}

/* Inline form */
.inline-form {
  display: block;
}

/* Required indicator */
.req {
  color: var(--danger);
  font-weight: 400;
}

/* Inline field row */
.field-row {
  display: flex;
  gap: var(--sp-4);
  align-items: flex-end;
}

.field-row .field { flex: 1; margin-bottom: 0; }

/* --- 6. Table --- */
.table-wrap {
  background: var(--surface-glass-solid);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass);
  overflow-x: auto;
  overflow-y: hidden;
}

.table-wrap-scroll {
  overflow-x: auto;
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.tbl th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.tbl td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.tbl tbody tr:last-child td { border-bottom: none; }

.tbl tbody tr {
  transition: background var(--dur-fast) var(--ease);
}

.tbl tbody tr:hover {
  background: rgba(74, 126, 224, 0.03);
}

.tbl .mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text);
}

.tbl .muted { color: var(--text-secondary); }
.tbl .center { text-align: center; }
.tbl .right { text-align: right; }
.tbl .nowrap { white-space: nowrap; }
.tbl .actions { white-space: nowrap; text-align: right; }

/* Action links in tables */
.act {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  padding: var(--sp-1) 0;
  margin-right: var(--sp-3);
  transition: color var(--dur-fast) var(--ease);
}

.act:hover { color: var(--primary-hover); text-decoration: underline; }
.act:last-child { margin-right: 0; }
.act-danger { color: var(--danger); }
.act-danger:hover { color: var(--danger-hover); }

/* Empty state row */
.empty-state {
  text-align: center;
  padding: var(--sp-10) var(--sp-4);
  color: var(--text-tertiary);
  font-size: var(--text-md);
}

.empty-state-icon {
  font-size: var(--text-2xl);
  margin-bottom: var(--sp-2);
  opacity: 0.4;
}

/* --- 7. Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px var(--sp-2);
  border-radius: var(--radius-full);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.badge-ok      { background: var(--c-green-50);  color: var(--c-green-700); }
.badge-off     { background: var(--c-red-50);    color: var(--c-red-700); }
.badge-warn    { background: var(--c-amber-50);  color: var(--c-amber-600); }
.badge-info    { background: var(--c-blue-50);   color: var(--c-blue-700); }
.badge-default { background: var(--c-slate-100); color: var(--c-slate-600); }

/* Audit action badges */
.audit-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px var(--sp-2);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.audit-badge-blue   { background: var(--c-blue-100);   color: var(--c-blue-700); }
.audit-badge-gray   { background: var(--c-slate-100);  color: var(--c-slate-600); }
.audit-badge-green  { background: var(--c-green-100);  color: var(--c-green-700); }
.audit-badge-orange { background: var(--c-amber-100);  color: var(--c-amber-600); }
.audit-badge-purple { background: var(--c-purple-100); color: var(--c-purple-600); }
.audit-badge-teal   { background: var(--c-teal-100);   color: var(--c-teal-600); }
.audit-badge-red    { background: var(--c-red-100);    color: var(--c-red-700); }

/* --- 8. Cards --- */
.card {
  background: var(--surface-glass-solid);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass);
  padding: var(--sp-5);
}

.card-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-3);
}

/* Stat cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-4);
}

.stat-card {
  background: var(--surface-glass-solid);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  box-shadow: var(--shadow-glass);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
}

.stat-card .label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--sp-1);
}

.stat-card .value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-card .sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--sp-1);
}

/* Settings hub cards (clickable navigation cards) */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-4);
}

.hub-card {
  display: block;
  background: var(--surface-glass-solid);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  box-shadow: var(--shadow-glass);
  text-decoration: none;
  color: var(--text);
  transition: all var(--dur) var(--ease);
}

.hub-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--c-blue-200);
  transform: translateY(-1px);
  text-decoration: none;
}

.hub-card-title {
  font-size: var(--text-md);
  font-weight: 600;
  margin-bottom: var(--sp-1);
}

.hub-card-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading);
}

/* --- 9. Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  animation: fadeIn var(--dur) var(--ease);
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6);
  width: 100%;
  max-width: 460px;
  max-height: 90dvh;
  overflow-y: auto;
  animation: modalSlide var(--dur-slow) var(--ease);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-4);
  letter-spacing: -0.01em;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-subtle);
}

.modal-wide { max-width: 600px; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

/* --- 10. Toast --- */
.toast {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--c-slate-800);
  color: #fff;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: 500;
  z-index: var(--z-toast);
  opacity: 0;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  pointer-events: none;
  box-shadow: var(--shadow-md);
  max-width: 400px;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success { background: var(--c-green-700); }
.toast-error   { background: var(--c-red-700); }

/* --- 11. Login Page --- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--sp-4);
  background: linear-gradient(135deg, var(--c-blue-50) 0%, var(--bg) 50%, var(--c-slate-100) 100%);
}

.login-card {
  background: var(--surface-glass-solid);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-8);
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--sp-6);
  color: var(--text);
  letter-spacing: -0.01em;
}

.error-msg {
  color: var(--danger);
  font-size: var(--text-sm);
  text-align: center;
  margin-bottom: var(--sp-3);
  min-height: 20px;
}

/* --- 12. Toolbar / Filters --- */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}

.toolbar-spacer { flex: 1; }

.toolbar .field {
  margin-bottom: 0;
}

/* Bare inputs and selects in toolbar — match .input-sm look */
.toolbar input[type="text"],
.toolbar input[type="search"],
.toolbar select:not(.btn) {
  padding: var(--sp-1) var(--sp-3);
  min-height: 28px;
  font-size: var(--text-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.toolbar input[type="text"]:focus,
.toolbar input[type="search"]:focus,
.toolbar select:not(.btn):focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 126, 224, 0.12);
}

.toolbar input::placeholder {
  color: var(--text-tertiary);
}

.toolbar select:not(.btn) {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7688'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* Filter pills */
.filter-pills {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.filter-pill {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}

.filter-pill:hover { border-color: var(--c-blue-200); color: var(--text); background: var(--primary-subtle); }
.filter-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* --- 13. Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-4) 0;
  font-size: var(--text-sm);
}

.pagination-btn {
  padding: var(--sp-1) var(--sp-3);
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}

.pagination-btn:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--c-slate-300);
  color: var(--text);
}

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

.pagination-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pagination-info {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

/* --- 14. Section / Config panels --- */
.section {
  margin-bottom: var(--sp-6);
}

.section-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-4);
}

.config-panel {
  background: var(--surface-glass-solid);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  box-shadow: var(--shadow-glass);
  margin-bottom: var(--sp-4);
}

.config-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
}

.config-row:not(:last-child) {
  border-bottom: 1px solid var(--border-subtle);
}

.config-label {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 120px;
}

/* --- 15. Detail view / info cards --- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.info-row {
  display: flex;
  padding: var(--sp-2) 0;
  font-size: var(--text-base);
}

.info-row:not(:last-child) {
  border-bottom: 1px solid var(--border-subtle);
}

.info-label {
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 120px;
  flex-shrink: 0;
}

.info-value {
  color: var(--text);
}

/* --- 16. Utilities --- */
.muted  { color: var(--text-secondary); }
.mono   { font-family: var(--font-mono); font-size: var(--text-sm); }
.center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-sm    { font-size: var(--text-sm); }
.text-xs    { font-size: var(--text-xs); }
.text-mono  { font-family: var(--font-mono); font-size: var(--text-sm); }
.text-right { text-align: right; }
.text-center { text-align: center; }

.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.gap-2 { gap: var(--sp-2); }
.gap-4 { gap: var(--sp-4); }

.flex     { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1   { flex: 1; }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* Tabular numbers for data */
.tabular { font-variant-numeric: tabular-nums; }

/* --- 17. Responsive --- */
@media (max-width: 768px) {
  .shell { flex-direction: column; overflow-x: hidden; }

  .sidebar {
    width: 100%;
    max-width: 100vw;
    height: auto;
    position: static;
    flex-direction: row;
    overflow-x: auto;
    padding: var(--sp-2) 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-title {
    padding: 0 var(--sp-4);
    border-bottom: none;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }

  .nav-section { display: none; }

  .nav-item {
    flex-shrink: 0;
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
  }

  .nav-item.active::before { display: none; }

  .main {
    padding: var(--sp-4);
  }

  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .hub-grid  { grid-template-columns: 1fr; }

  .topbar { flex-direction: column; align-items: flex-start; gap: var(--sp-2); }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar > * { margin-left: 0 !important; margin-right: 0 !important; }
  .toolbar-spacer { display: none; }

  .modal-card { padding: var(--sp-5); margin: var(--sp-2); }
}

@media (max-width: 480px) {
  .card-grid { grid-template-columns: 1fr; }
  .field-row { flex-direction: column; }
}

/* --- 18. Print --- */
@media print {
  .sidebar, .topbar-user, .toolbar, .modal-backdrop, .toast { display: none; }
  .main { padding: 0; }
  .table-wrap { box-shadow: none; border: 1px solid #ddd; }
}

/* --- 19. Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
