/* ============================================================
   Syllogistics Design System
   Bootstrap 5.3 overrides — no build step required
   ============================================================ */

/* ── Google Fonts (Inter) ──────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Design tokens ─────────────────────────────────────────── */
:root {
    /* Primary — Brand green */
    --sy-primary: #599d83;
    --sy-primary-hover: #5FB495;
    --sy-primary-light: #EAF7F1;
    --sy-primary-ring: rgba(118, 199, 168, 0.35);
    /* Accent — Cyan */
    --sy-accent: #06B6D4;
    /* Surfaces */
    --sy-bg: #F8FAFC;
    --sy-surface: #FFFFFF;
    --sy-surface-raised: #FFFFFF;
    /* Text */
    --sy-text: #0F172A;
    --sy-text-secondary: #64748B;
    --sy-text-muted: #94A3B8;
    /* Borders */
    --sy-border: #E2E8F0;
    --sy-border-strong: #CBD5E1;
    /* Semantic */
    --sy-success: #10B981;
    --sy-success-light: #6EE7B7;
    --sy-success-bg: #ECFDF5;
    --sy-success-text: #065F46;
    --sy-warning: #F59E0B;
    --sy-warning-bg: #FFFBEB;
    --sy-warning-text: #92400E;
    --sy-danger: #EF4444;
    --sy-danger-bg: #FEF2F2;
    --sy-danger-text: #991B1B;
    --sy-info: #3B82F6;
    --sy-info-bg: #EFF6FF;
    --sy-info-text: #1E40AF;
    /* Radius */
    --sy-radius-sm: 4px;
    --sy-radius: 8px;
    --sy-radius-lg: 12px;
    --sy-radius-xl: 16px;
    /* Shadows */
    --sy-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
    --sy-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --sy-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --sy-shadow-md: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
    /* Spacing (multiples of 4px) */
    --sy-space-1: 4px;
    --sy-space-2: 8px;
    --sy-space-3: 12px;
    --sy-space-4: 16px;
    --sy-space-5: 20px;
    --sy-space-6: 24px;
    --sy-space-8: 32px;
    --sy-space-12: 48px;
    /* Payment card visual */
    --sy-payment-card-from: #1d6bb8;
    --sy-payment-card-to: #3b8dde;
    --sy-payment-card-glow: rgba(255, 255, 255, 0.18);
    --sy-payment-card-text: #ffffff;
    --sy-payment-card-muted: rgba(255, 255, 255, 0.72);
    --sy-payment-card-shadow: 0 12px 28px rgba(29, 107, 184, 0.28);
    --sy-payment-card-radius: var(--sy-radius-xl);
    --sy-payment-card-min-height: 220px;
    --sy-payment-card-max-width: 420px;
    --sy-payment-card-glow-size: 180px;
    --sy-payment-card-glow-size-sm: 140px;
    --sy-payment-card-brand-width: 52px;
    --sy-payment-card-brand-height: 34px;
    --sy-modal-backdrop: rgba(15, 23, 42, 0.35);
    --sy-modal-backdrop-blur: 6px;
    /* Bootstrap overrides via BS custom properties */
    --bs-body-font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --bs-body-font-size: 0.9375rem; /* 15px */
    --bs-body-color: var(--sy-text);
    --bs-body-bg: var(--sy-bg);
    --bs-border-color: var(--sy-border);
    --bs-border-radius: var(--sy-radius);
    --bs-border-radius-sm: var(--sy-radius-sm);
    --bs-border-radius-lg: var(--sy-radius-lg);
    --bs-link-color: var(--sy-primary);
    --bs-link-hover-color: var(--sy-primary-hover);
    /* Bootstrap component-level tokens */
    --bs-primary: var(--sy-primary);
    --bs-primary-rgb: 89, 157, 131;
    --bs-success-rgb: 16, 185, 129;
    --bs-warning-rgb: 245, 158, 11;
    --bs-danger-rgb: 239, 68, 68;
    --bs-info-rgb: 59, 130, 246;
}

a {
    color: var(--sy-primary);
}

.dropdown-menu {
    --bs-dropdown-link-hover-color: var(--sy-primary);
    --bs-dropdown-link-hover-bg: var(--sy-primary-light);
    --bs-dropdown-link-active-bg: var(--sy-primary);
    --bs-dropdown-link-active-color: #fff;
}

.pagination {
    --bs-pagination-active-color: #fff;
    --bs-pagination-active-bg: var(--sy-primary);
    --bs-pagination-active-border-color: var(--sy-primary);
    --bs-pagination-focus-box-shadow: 0 0 0 0.25rem var(--sy-primary-ring);
}

.accordion {
    --bs-accordion-bg: white;
}

/* ── Base ───────────────────────────────────────────────────── */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 88px;
  background-color: var(--sy-bg);
  color: var(--sy-text);
  letter-spacing: -0.01em;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-weight: 600;
  color: var(--sy-text);
  letter-spacing: -0.025em;
}

.text-muted { color: var(--sy-text-secondary) !important; }

code {
  font-size: 0.8125rem;
  color: var(--sy-primary);
  background: var(--sy-primary-light);
  padding: 1px 6px;
  border-radius: var(--sy-radius-sm);
  font-weight: 500;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
  background-color: var(--sy-surface) !important;
  border-bottom: 1px solid var(--sy-border) !important;
  box-shadow: var(--sy-shadow-xs) !important;
  padding-top: 0;
  padding-bottom: 0;
  min-height: 56px;
  flex-wrap: wrap;
  align-items: stretch;
}

.navbar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  width: 100%;
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.03em;
  color: var(--sy-primary) !important;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-brand::before {
  content: '';
  display: inline-block;
  width: 40px;
  height: 30px;
  background-color: transparent;
  background-image: url("/img/logo.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  flex-shrink: 0;
}

.nav-link {
  color: var(--sy-text-secondary) !important;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 18px 12px !important;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nav-link:hover {
  color: var(--sy-text) !important;
}

.nav-link.active,
.nav-link:focus-visible {
  color: var(--sy-primary) !important;
  border-bottom-color: var(--sy-primary);
}

.navbar-text {
  font-size: 0.875rem;
  color: var(--sy-text-secondary) !important;
  font-weight: 500;
}

.navbar-sections {
  flex: 1 0 100%;
  width: 100%;
  background-color: var(--sy-surface);
}

.app-section-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  margin-bottom: 0;
  border-bottom: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.app-section-tabs .nav-link {
  margin-bottom: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  white-space: nowrap;
  padding: 12px 16px !important;
  border-bottom: 2px solid transparent;
  color: var(--sy-text-secondary) !important;
}

.app-section-tabs .nav-link:hover {
  color: var(--sy-text) !important;
  border-bottom-color: var(--sy-border-strong);
  isolation: auto;
}

.app-section-tabs .nav-link.active,
.app-section-tabs .nav-link:focus-visible {
  color: var(--sy-primary) !important;
  background: transparent;
  border-bottom-color: var(--sy-primary);
  font-weight: 600;
}

/* ── Footer ─────────────────────────────────────────────────── */
.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  min-height: 56px;
  padding: var(--sy-space-4) 0;
  background-color: var(--sy-surface);
  border-top: 1px solid var(--sy-border) !important;
  color: var(--sy-text-muted);
  font-size: 0.8125rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sy-space-3);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sy-space-4);
}

.footer-links a {
  color: var(--sy-text-secondary);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--sy-primary);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--sy-radius);
  padding: 8px 16px;
  transition: all 0.15s ease;
  letter-spacing: -0.01em;
  border-width: 1px;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 0.8125rem;
  border-radius: var(--sy-radius-sm);
}

.btn-lg {
  padding: 11px 22px;
  font-size: 1rem;
}

.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--sy-primary);
  --bs-btn-border-color: var(--sy-primary);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--sy-primary-hover);
  --bs-btn-hover-border-color: var(--sy-primary-hover);
  --bs-btn-focus-shadow-rgb: 89, 157, 131;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--sy-primary-hover);
  --bs-btn-active-border-color: var(--sy-primary-hover);
  --bs-btn-active-shadow: none;
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: var(--sy-primary);
  --bs-btn-disabled-border-color: var(--sy-primary);
  background-color: var(--sy-primary);
  border-color: var(--sy-primary);
  color: #fff;
  box-shadow: var(--sy-shadow-xs);
}

.btn-primary:hover {
  background-color: var(--sy-primary-hover);
  border-color: var(--sy-primary-hover);
  color: #fff;
  box-shadow: var(--sy-shadow-sm);
  transform: translateY(-1px);
}

.btn-primary:active,
.btn-primary.active,
.btn-check:checked + .btn-primary,
.show > .btn-primary.dropdown-toggle {
  background-color: var(--sy-primary-hover) !important;
  border-color: var(--sy-primary-hover) !important;
  color: #fff !important;
  transform: translateY(0);
  box-shadow: none;
}

.btn-primary:disabled,
.btn-primary.disabled {
  opacity: 0.55;
  transform: none;
}

.btn-outline-primary {
  --bs-btn-color: var(--sy-primary);
  --bs-btn-border-color: var(--sy-primary);
  --bs-btn-hover-color: var(--sy-primary);
  --bs-btn-hover-bg: var(--sy-primary-light);
  --bs-btn-hover-border-color: var(--sy-primary);
  --bs-btn-focus-shadow-rgb: 89, 157, 131;
  --bs-btn-active-color: var(--sy-primary);
  --bs-btn-active-bg: var(--sy-primary-light);
  --bs-btn-active-border-color: var(--sy-primary);
  --bs-btn-disabled-color: var(--sy-primary);
  --bs-btn-disabled-bg: transparent;
  --bs-btn-disabled-border-color: var(--sy-primary);
  color: var(--sy-primary) !important;
  border-color: var(--sy-primary) !important;
  background: var(--sy-surface) !important;
}

.btn-outline-primary:hover {
  background-color: var(--sy-primary-light) !important;
  border-color: var(--sy-primary) !important;
  color: var(--sy-primary) !important;
}

.btn-outline-primary:active,
.btn-outline-primary.active,
.btn-check:checked + .btn-outline-primary,
.show > .btn-outline-primary.dropdown-toggle {
  background-color: var(--sy-primary-light) !important;
  border-color: var(--sy-primary) !important;
  color: var(--sy-primary) !important;
}

.btn-outline-secondary {
  --bs-btn-color: var(--sy-text-secondary);
  --bs-btn-border-color: var(--sy-border-strong);
  --bs-btn-hover-color: var(--sy-text);
  --bs-btn-hover-bg: var(--sy-bg);
  --bs-btn-hover-border-color: var(--sy-border-strong);
  --bs-btn-focus-shadow-rgb: 89, 157, 131;
  --bs-btn-active-color: var(--sy-text);
  --bs-btn-active-bg: var(--sy-bg);
  --bs-btn-active-border-color: var(--sy-border-strong);
  color: var(--sy-text-secondary);
  border-color: var(--sy-border-strong);
  background: var(--sy-surface);
}

.btn-outline-secondary:hover {
  background-color: var(--sy-bg);
  border-color: var(--sy-border-strong);
  color: var(--sy-text);
}

.btn-outline-secondary:active,
.btn-outline-secondary.active,
.btn-check:checked + .btn-outline-secondary,
.show > .btn-outline-secondary.dropdown-toggle {
  background-color: var(--sy-bg) !important;
  border-color: var(--sy-border-strong) !important;
  color: var(--sy-text) !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: var(--sy-primary-light);
  color: var(--sy-primary);
}

.dropdown-item:active,
.dropdown-item.active {
  background-color: var(--sy-primary);
  color: #fff;
}

.dropdown-item:focus-visible {
  background-color: var(--sy-primary-light);
  color: var(--sy-primary);
  outline: none;
}

.tooltip {
  --bs-tooltip-bg: var(--sy-text);
  --bs-tooltip-color: #fff;
  --bs-tooltip-opacity: 1;
  font-size: 0.8125rem;
  font-weight: 500;
}

.btn-link {
  color: var(--sy-text-secondary);
  font-weight: 500;
  text-decoration: none;
  padding-left: 8px;
  padding-right: 8px;
}

.btn-link:hover { color: var(--sy-text); text-decoration: none; }

.btn:focus-visible,
.btn:focus {
  box-shadow: 0 0 0 3px var(--sy-primary-ring) !important;
  outline: none;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--sy-text);
  margin-bottom: 6px;
}

.form-control,
.form-select {
  border-color: var(--sy-border-strong);
  border-radius: var(--sy-radius);
  font-size: 0.9375rem;
  color: var(--sy-text);
  background-color: var(--sy-surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--sy-shadow-xs);
}

.form-control {
  padding: 8px 12px;
}

.form-select {
  /* Extra right padding so text does not collide with the caret */
  padding: 8px 2.25rem 8px 12px;
}

.form-select.form-select-sm {
  padding-top: 5px;
  padding-bottom: 5px;
  padding-left: 11px;
  padding-right: 2rem;
}

.form-control:hover,
.form-select:hover {
  border-color: var(--sy-border-strong);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--sy-primary);
  box-shadow: 0 0 0 3px var(--sy-primary-ring);
  outline: none;
}

.form-control::placeholder { color: var(--sy-text-muted); }

.form-check-input:checked {
  background-color: var(--sy-primary);
  border-color: var(--sy-primary);
}

.form-check-input:focus {
  box-shadow: 0 0 0 3px var(--sy-primary-ring);
}

.form-check-label {
  font-size: 0.875rem;
  color: var(--sy-text-secondary);
}

/* Validation */
.text-danger { color: var(--sy-danger) !important; font-size: 0.8125rem; }
.is-invalid { border-color: var(--sy-danger) !important; }
.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,0.2) !important; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius-lg);
  box-shadow: var(--sy-shadow-sm);
  background: var(--sy-surface);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--sy-border);
  padding: 16px 20px;
  font-weight: 600;
  font-size: 0.9375rem;
}

.card-body { padding: 20px; }

/* ── Tables ─────────────────────────────────────────────────── */
.table {
  --bs-table-striped-bg: #FFFFFF;
  --bs-table-hover-bg:   #F8FAFC;
  --bs-table-bg:         #FFFFFF;
  border-color: var(--sy-border);
  font-size: 0.9375rem;
  background-color: #FFFFFF;
}

.table > :not(caption) > * > * {
  padding: 12px 16px;
  border-bottom-color: var(--sy-border);
}

.table thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sy-text-secondary);
  background-color: var(--sy-bg);
  border-bottom: 1px solid var(--sy-border);
  padding-top: 10px;
  padding-bottom: 10px;
}

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

.table-wrapper {
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius-lg);
  overflow: hidden;
  box-shadow: var(--sy-shadow-sm);
  background: var(--sy-surface);
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
}

.text-bg-success {
  background-color: var(--sy-success-bg) !important;
  color: var(--sy-success-text) !important;
}

.text-bg-warning {
  background-color: var(--sy-warning-bg) !important;
  color: var(--sy-warning-text) !important;
}

.text-bg-danger {
  background-color: var(--sy-danger-bg) !important;
  color: var(--sy-danger-text) !important;
}

.text-bg-info {
  background-color: var(--sy-info-bg) !important;
  color: var(--sy-info-text) !important;
}

.text-bg-secondary {
  background-color: #F1F5F9 !important;
  color: var(--sy-text-secondary) !important;
}

/* Document type badges */
.badge[class*="doc-type-"] {
    font-weight: 600;
    color:#333;
    background:#eee;
}

.badge.doc-type-9, .badge.doc-type-10 {
    background-color: darkred;
    color: white;
}
.badge.doc-type-0, .badge.doc-type-4 {
    background-color: darkgreen;
    color: white;
}

.entry-row-duplicate .entry-title-cell {
    color: var(--sy-text-secondary);
}

.badge.duplicate-entry-badge {
    font-weight: 600;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  border-radius: var(--sy-radius);
  border-width: 1px;
  font-size: 0.9375rem;
  padding: 12px 16px;
}

.alert-danger {
  background-color: var(--sy-danger-bg);
  border-color: #FECACA;
  color: var(--sy-danger-text);
}

.alert-success {
  background-color: var(--sy-success-bg);
  border-color: #A7F3D0;
  color: var(--sy-success-text);
}

.alert-warning {
  background-color: var(--sy-warning-bg);
  border-color: #FDE68A;
  color: var(--sy-warning-text);
}

.alert-info {
  background-color: var(--sy-info-bg);
  border-color: #BFDBFE;
  color: var(--sy-info-text);
}

/* ── Page layout helpers ────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}

.page-header-meta {
  font-size: 0.875rem;
  color: var(--sy-text-secondary);
  margin-top: 4px;
}

.section-heading {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sy-text-secondary);
  margin-bottom: 12px;
}

.page-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--sy-border);
}

.page-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--sy-text);
  letter-spacing: -0.02em;
}

/* ── Upload / drop zone ─────────────────────────────────────── */
.upload-area {
  margin-bottom: var(--sy-space-6);
}

.upload-panel:not(.d-none) {
  animation: upload-panel-in 0.2s ease-out;
}

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

.drop-zone {
  border: 2px dashed var(--sy-border-strong);
  border-radius: var(--sy-radius-lg);
  background: var(--sy-surface);
  padding: 48px 32px;
  text-align: center;
  transition: border-color 0.2s, background-color 0.2s;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--sy-primary);
  background-color: var(--sy-primary-light);
}

.drop-zone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--sy-text-muted);
}

.drop-zone-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--sy-text);
  margin-bottom: 4px;
}

.drop-zone-sub {
  font-size: 0.875rem;
  color: var(--sy-text-secondary);
  margin-bottom: 20px;
}

/* ── Auth / login card ──────────────────────────────────────── */
.auth-card {
  background: var(--sy-surface);
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius-xl);
  box-shadow: var(--sy-shadow-md);
  padding: 40px;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-logo-mark {
  width: 52px;
  height: 58px;
  background-color: transparent;
  background-image: url("/img/logo.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.auth-logo-name {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--sy-primary);
}

.auth-title {
  font-size: 1.375rem;
  font-weight: 700;
  text-align: center;
  color: var(--sy-text);
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}

.auth-subtitle {
  text-align: center;
  color: var(--sy-text-secondary);
  font-size: 0.9375rem;
  margin-bottom: 28px;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--sy-text-secondary);
  font-size: 0.8125rem;
  margin: 24px 0 16px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--sy-border);
}

.auth-divider span {
  padding: 0 12px;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 32px;
  color: var(--sy-text-secondary);
}

.empty-state p { margin-bottom: 20px; font-size: 0.9375rem; }

/* ── Utility overrides ──────────────────────────────────────── */
.bg-light { background-color: var(--sy-bg) !important; }
.border   { border-color: var(--sy-border) !important; }

/* Floating form placeholder alignment */
.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
  color: var(--sy-text-muted);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ── Entry detail panel ─────────────────────────────────────── */
.entry-detail-cell {
  padding: 0 !important;
  background: var(--sy-bg);
  border-bottom: 1px solid var(--sy-border) !important;
}

.entry-detail-panel {
  padding: 20px 24px 24px 52px;
  border-left: 3px solid var(--sy-primary-light);
}

.entry-row-expanded td {
  border-bottom-color: transparent !important;
}

.entry-chevron {
  transition: transform 0.15s ease;
}

.entry-row-expanded .entry-chevron {
  transform: rotate(90deg);
}

.entry-meta-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sy-text-secondary);
  margin-bottom: 4px;
}

.entry-meta-value {
  font-size: 0.9375rem;
  color: var(--sy-text);
  white-space: pre-wrap;
}

 
.json-editor {
  font-size: 0.8125rem;
  line-height: 1.5;
  min-height: 200px;
  resize: vertical;
}

/* ── Docket metadata ─────────────────────────────────────────── */
.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 20px;
  margin: 0;
}

.metadata-item-wide {
  grid-column: 1 / -1;
}

.metadata-item dt {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #333;
  margin-bottom: 2px;
}

.metadata-item dd {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--sy-text-secondary);
}

.metadata-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--sy-border);
}

.metadata-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.metadata-list li + li {
  margin-top: 8px;
}

.secondary-properties-grid {
  margin-top: 0;
}

.secondary-property-no {
  color: var(--sy-text-secondary);
}

.secondary-property-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.related-count-badge {
  font-size: 0.625rem;
  vertical-align: middle;
}

/* ── Related filing links (expand panel) ─────────────────────── */
.related-links-list {
  list-style: none;
  padding: 0;
}

.related-link-item + .related-link-item {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--sy-border);
}

.related-link-jump {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--sy-surface);
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.related-link-jump:hover {
  border-color: var(--sy-primary);
  box-shadow: var(--sy-shadow-xs);
}

.related-link-title {
  display: block;
  font-weight: 600;
  color: var(--sy-text);
  font-size: 0.9375rem;
}

.related-link-date {
  display: block;
  font-size: 0.8125rem;
  color: var(--sy-text-secondary);
  margin-top: 2px;
}

.related-link-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.8125rem;
}

.related-link-explanation {
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--sy-text-secondary);
}

/* ── Filing links diagram ────────────────────────────────────── */
.filing-links-diagram {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filing-link-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.filing-link-node {
  flex: 1 1 0;
  min-width: 0;
  text-align: left;
  background: var(--sy-surface);
  border: 2px solid var(--sy-border);
  border-radius: var(--sy-radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.filing-link-node:hover {
  border-color: var(--sy-primary);
  box-shadow: var(--sy-shadow-sm);
  transform: translateY(-1px);
}

.filing-link-node-source {
  border-color: #BFDBFE;
  background: #F8FAFF;
}

.filing-link-node-ruling {
  border-color: #A7F3D0;
  background: #F0FDF9;
}

.filing-link-node-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sy-text-secondary);
  margin-bottom: 4px;
}

.filing-link-node-title {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--sy-text);
  line-height: 1.35;
}

.filing-link-node-date {
  display: block;
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--sy-text-secondary);
}

.filing-link-arrow {
  flex: 0 0 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 0;
}

.filing-link-arrow-line {
  display: none;
}

.filing-link-arrow-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  color: var(--sy-primary);
  background: var(--sy-primary-light);
  border-radius: 20px;
  padding: 4px 10px;
  white-space: nowrap;
}

.filing-link-duration {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--sy-text);
  white-space: nowrap;
}

.filing-link-arrow-head {
  font-size: 1.25rem;
  color: var(--sy-primary);
  line-height: 1;
}

.entry-row-highlight td {
  animation: entry-highlight 1.8s ease-out;
}

@keyframes entry-highlight {
  0% { background-color: #FEF3C7; }
  100% { background-color: transparent; }
}

@media (max-width: 767.98px) {
  .filing-link-row {
    flex-direction: column;
    align-items: stretch;
  }

  .filing-link-arrow {
    flex-direction: row;
    justify-content: center;
    padding: 0;
  }

  .filing-link-arrow-head {
    transform: rotate(90deg);
  }
}

.font-monospace {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.search-motion-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.35rem 1rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.search-form .card {
  border-color: var(--bs-border-color-translucent);
}

/* ── Case names ─────────────────────────────────────────────── */
.case-name-vs {
  font-style: italic;
  font-weight: 400;
  color: var(--sy-text-secondary);
}

/* ── Judge admin photo ──────────────────────────────────────── */
.judge-photo-card {
  position: sticky;
  top: var(--sy-space-4);
}

.judge-photo-preview {
  aspect-ratio: 1;
  width: 100%;
  max-width: 280px;
  margin-inline: auto;
  border-radius: var(--sy-radius-lg);
  overflow: hidden;
  background: var(--sy-bg);
  border: 1px solid var(--sy-border);
}

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

.judge-photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sy-text-muted);
  font-size: 0.875rem;
}

/* ── App home chart ─────────────────────────────────────────── */
.app-home-chart {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--sy-space-3) var(--sy-space-4);
  align-items: end;
}

.app-home-chart-y-label,
.app-home-chart-x-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sy-text-secondary);
}

.app-home-chart-y-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-home-chart-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(3.5rem, 1fr));
  gap: var(--sy-space-3);
  align-items: end;
  min-height: 18rem;
  padding: var(--sy-space-3);
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius-lg);
  background: linear-gradient(to top, var(--sy-bg), var(--sy-surface));
}

.app-home-chart-column {
  display: grid;
  grid-template-rows: auto minmax(12rem, 1fr) auto;
  gap: var(--sy-space-2);
  align-items: end;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.app-home-chart-column:hover {
  color: inherit;
}

.app-home-chart-column:focus-visible {
  outline: 2px solid var(--sy-primary);
  outline-offset: 2px;
  border-radius: var(--sy-radius);
}

.app-home-chart-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sy-text-secondary);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.app-home-chart-bar-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  min-height: 12rem;
  padding: 0 var(--sy-space-1);
}

.app-home-chart-bar {
  display: block;
  width: 100%;
  min-height: var(--sy-space-2);
  border-radius: var(--sy-radius) var(--sy-radius) 0 0;
  background: linear-gradient(to top, var(--sy-primary), var(--sy-primary-hover));
  box-shadow: var(--sy-shadow-xs);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.app-home-chart-column:hover .app-home-chart-bar,
.app-home-chart-column:focus-visible .app-home-chart-bar {
  transform: translateY(-1px);
  box-shadow: var(--sy-shadow-sm);
  filter: brightness(1.03);
}

.app-home-chart-year {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--sy-text);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.app-home-chart-x-label {
  grid-column: 2;
  text-align: center;
}

/* ── Judges directory ───────────────────────────────────────── */
.judge-directory-search-field {
  position: relative;
}

.judge-directory-search-icon {
  position: absolute;
  left: var(--sy-space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--sy-text-muted);
  pointer-events: none;
}

.judge-directory-search-field .form-control {
  padding-left: calc(var(--sy-space-3) + 1.25rem + var(--sy-space-2));
}

.judge-directory-filters {
  position: sticky;
  top: var(--sy-space-4);
}

.judge-filter-group {
  border-top: 1px solid var(--sy-border);
  padding: var(--sy-space-3) 0;
}

.judge-filter-group:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.judge-filter-heading {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--sy-text);
  margin: 0 0 var(--sy-space-3);
}

.judge-filter-options {
  display: flex;
  flex-direction: column;
  gap: var(--sy-space-2);
  max-height: 14rem;
  overflow-y: auto;
  padding-right: var(--sy-space-1);
}

.judge-filter-options .form-check {
  min-height: auto;
}

/* Select2 (motions attorney/judge autocomplete) */
.judge-directory-filters .select2-container {
  width: 100% !important;
}

.judge-directory-filters .select2-container--default .select2-selection--single {
  height: auto;
  min-height: 2rem;
  padding: var(--sy-space-1) var(--sy-space-2);
  border: 1px solid var(--sy-border-strong);
  border-radius: var(--sy-radius-sm);
  background-color: var(--sy-surface);
}

.judge-directory-filters .select2-container--default .select2-selection--single .select2-selection__rendered {
  padding: 0;
  line-height: 1.4;
  color: var(--sy-text);
}

.judge-directory-filters .select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 100%;
  top: 0;
}

.judge-directory-filters .select2-container--default.select2-container--focus .select2-selection--single,
.judge-directory-filters .select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--sy-primary);
  box-shadow: 0 0 0 0.2rem var(--sy-primary-ring);
}

.select2-dropdown {
  border-color: var(--sy-border-strong);
  border-radius: var(--sy-radius);
  background: var(--sy-surface);
  color: var(--sy-text);
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background-color: var(--sy-primary);
  color: #fff;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid var(--sy-border-strong);
  border-radius: var(--sy-radius-sm);
  color: var(--sy-text);
}

.judge-directory-list {
  display: flex;
  flex-direction: column;
  gap: var(--sy-space-3);
}

.judge-directory-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--sy-space-4);
  align-items: center;
  padding: var(--sy-space-4);
  background: var(--sy-surface);
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius-lg);
  box-shadow: var(--sy-shadow-xs);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.judge-directory-card:hover {
  border-color: var(--sy-primary);
  box-shadow: var(--sy-shadow-sm);
  transform: translateY(-1px);
  color: inherit;
}

.judge-directory-card:focus-visible {
  outline: 2px solid var(--sy-primary);
  outline-offset: 2px;
}

.judge-directory-avatar {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--sy-primary-light);
  border: 1px solid var(--sy-border);
}

.judge-directory-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.judge-directory-avatar-fallback,
.judge-details-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--sy-primary);
  background: var(--sy-primary-light);
}

.judge-details-avatar-fallback {
  font-size: 2rem;
}

.judge-directory-card-name {
  font-weight: 600;
  color: var(--sy-text);
}

.judge-directory-card-meta,
.judge-directory-card-contact,
.judge-directory-card-role {
  min-width: 0;
}

.judge-directory-card-meta {
  color: var(--sy-text-secondary);
  font-size: 0.875rem;
}

.judge-directory-card-overlay {
  position: relative;
  z-index: 2;
}

.judge-directory-card .stretched-link::after {
  z-index: 1;
}

.law-firm-map {
  width: 100%;
  height: 22rem;
  border-radius: 0 0 var(--sy-radius-lg) var(--sy-radius-lg);
  background: var(--sy-primary-light);
}

.judge-details-contact,
.judge-details-grid {
  display: grid;
  gap: var(--sy-space-3);
}

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

.judge-details-contact dt,
.judge-details-grid dt {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sy-text-secondary);
  margin-bottom: var(--sy-space-1);
}

.judge-details-contact dd,
.judge-details-grid dd {
  margin: 0;
  color: var(--sy-text);
  word-break: break-word;
}

/* Judge compare */
.judge-compare-filters {
  position: static;
}

.judge-compare-motions .judge-compare-category-row th {
  background: var(--sy-bg);
  color: var(--sy-text);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  border-bottom-color: var(--sy-border);
  padding-top: var(--sy-space-2);
  padding-bottom: var(--sy-space-2);
}

.judge-compare-rate {
  display: flex;
  align-items: center;
  gap: var(--sy-space-3);
  min-width: 0;
}

.judge-compare-rate-bar {
  flex: 1 1 5.5rem;
  min-width: 4.5rem;
  max-width: 9rem;
}

.judge-compare-rate-label {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--sy-text);
  text-decoration: none;
}

.judge-compare-rate-label:hover {
  color: var(--sy-primary);
  text-decoration: underline;
}

.judge-compare-advantage {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--sy-text-secondary);
  vertical-align: middle;
}

.judge-compare-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sy-space-2);
  color: var(--sy-text-secondary);
}

.judge-compare-arrow-svg {
  display: block;
  flex: 0 0 auto;
  overflow: visible;
}

.judge-compare-arrow-line {
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.judge-compare-arrow-head {
  fill: currentColor;
}

.judge-compare-arrow-delta {
  font-variant-numeric: tabular-nums;
  color: var(--sy-text);
  font-weight: 500;
}

.judge-analytics-headline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sy-space-3);
  margin-bottom: var(--sy-space-4);
}

.judge-analytics-stat {
  background: var(--sy-surface);
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius-lg);
  box-shadow: var(--sy-shadow-xs);
  padding: var(--sy-space-4);
  min-width: 0;
}

.judge-analytics-stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--sy-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.judge-analytics-stat-label {
  margin-top: var(--sy-space-1);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sy-text-secondary);
}

.judge-peer-metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sy-text-secondary);
  margin-bottom: var(--sy-space-2);
}

.judge-peer-metric-values {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sy-space-2) var(--sy-space-4);
  align-items: baseline;
  font-variant-numeric: tabular-nums;
  color: var(--sy-text);
}

.judge-peer-delta {
  font-weight: 600;
  color: var(--sy-primary);
}

.judge-mix-heading {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sy-text-secondary);
  margin-bottom: var(--sy-space-2);
}

.judge-mix-row {
  display: grid;
  grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr) 2.5rem;
  gap: var(--sy-space-2);
  align-items: center;
  margin-bottom: var(--sy-space-2);
}

.judge-mix-label {
  font-size: 0.875rem;
  color: var(--sy-text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.judge-mix-bar-track {
  height: 0.35rem;
  border-radius: 2px;
  background: var(--sy-border);
  overflow: hidden;
}

.judge-mix-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--sy-primary);
  min-width: 2px;
}

.judge-mix-count {
  text-align: right;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--sy-text-secondary);
}

.judge-motion-stats {
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius);
  overflow: hidden;
}

@media (max-width: 767.98px) {
  .judge-analytics-headline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .judge-mix-row {
    grid-template-columns: minmax(0, 5.5rem) minmax(0, 1fr) 2.25rem;
  }
}

/* ── Motion stats ───────────────────────────────────────────── */
.motion-stat-granted {
  color: var(--sy-success-text);
  font-weight: 500;
}

.motion-stat-partial {
  color: var(--sy-success-text);
  font-weight: 500;
  opacity: 0.75;
}

.motion-stat-denied {
  color: var(--sy-danger-text);
  font-weight: 500;
}

.motion-stats-panel {
  padding: 0;
  overflow: hidden;
}

.motion-stats-header,
.motion-stats-group-summary,
.motion-stats-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(7rem, 1fr) 3.25rem;
  gap: var(--sy-space-3);
  align-items: center;
  padding: var(--sy-space-2) var(--sy-space-3);
}

.motion-stats-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sy-text-secondary);
  border-bottom: 1px solid var(--sy-border);
  background: var(--sy-surface);
}

.motion-stats-col-outcome {
  min-width: 0;
}

.motion-stats-col-total {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--sy-text-secondary);
}

.motion-stats-group {
  border-bottom: 1px solid var(--sy-border);
}

.motion-stats-group:last-child {
  border-bottom: 0;
}

.motion-stats-group-summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  color: var(--sy-text);
  background: var(--sy-bg);
}

.motion-stats-group-summary::-webkit-details-marker {
  display: none;
}

.motion-stats-group-summary .motion-stats-label {
  display: flex;
  align-items: center;
  gap: var(--sy-space-2);
  min-width: 0;
}

.motion-stats-group-summary .motion-stats-label::before {
  content: "";
  flex-shrink: 0;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid var(--sy-text-secondary);
  border-bottom: 1.5px solid var(--sy-text-secondary);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  margin-top: -0.15rem;
}

.motion-stats-group[open] > .motion-stats-group-summary .motion-stats-label::before {
  transform: rotate(45deg);
  margin-top: -0.05rem;
}

.motion-stats-group-summary .motion-stats-col-total {
  color: var(--sy-text);
  font-weight: 600;
}

.motion-stats-row {
  border-top: 1px solid var(--sy-border);
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.motion-stats-row .motion-stats-label {
  padding-left: calc(var(--sy-space-2) + 0.4rem + var(--sy-space-2));
  color: var(--sy-text);
  font-size: 0.875rem;
  font-weight: 400;
  min-width: 0;
}


.motion-stats-type-link:hover {
  color: var(--sy-primary);
  text-decoration: underline;
}

.motion-property-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: var(--sy-space-1) var(--sy-space-4);
}

.motion-property-filter {
  margin: 0;
  min-height: 0;
  padding: var(--sy-space-1) 0;
}

.motion-property-filter .form-check-label {
  font-size: 0.875rem;
}

.motion-outcome-bar {
  display: flex;
  width: 100%;
  height: 0.5rem;
  border-radius: 2px;
  overflow: hidden;
  background: var(--sy-border);
}

.motion-outcome-segment {
  display: block;
  height: 100%;
  min-width: 0;
  cursor: default;
}

.motion-outcome-segment:hover {
  filter: brightness(0.92);
}

.motion-outcome-granted {
  background: var(--sy-success);
}

.motion-outcome-partial {
  background: var(--sy-success-light);
}

.motion-outcome-denied {
  background: var(--sy-danger);
}

.motion-outcome-other {
  background: var(--sy-text-muted);
}

.motion-view-toggle .btn.active {
  color: #fff;
  background: var(--sy-primary);
  border-color: var(--sy-primary);
}

#motions-stats-page[data-motion-view="time"] .motion-stats-header,
#motions-stats-page[data-motion-view="time"] .motion-stats-group-summary,
#motions-stats-page[data-motion-view="time"] .motion-stats-row,
#judge-analytics[data-motion-view="time"] .motion-stats-header,
#judge-analytics[data-motion-view="time"] .motion-stats-group-summary,
#judge-analytics[data-motion-view="time"] .motion-stats-row {
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 1.6fr) 3.25rem;
  align-items: center;
}

#motions-stats-page[data-motion-view="time"] .motion-stats-group-summary,
#motions-stats-page[data-motion-view="time"] .motion-stats-row,
#judge-analytics[data-motion-view="time"] .motion-stats-group-summary,
#judge-analytics[data-motion-view="time"] .motion-stats-row {
  min-height: 2.75rem;
  padding-top: var(--sy-space-2);
  padding-bottom: var(--sy-space-2);
}

.motion-duration-axis {
  display: flex;
  flex-direction: column;
  gap: var(--sy-space-1);
  min-width: 0;
  width: 100%;
}

.motion-duration-axis-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sy-text-secondary);
  line-height: 1.2;
}

.motion-duration-axis-scale {
  position: relative;
  height: 0.9rem;
  margin-right: 0.35rem;
}

.motion-duration-axis-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--sy-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1;
}

.motion-duration-axis-tick:first-child {
  transform: translateX(0);
}

.motion-duration-axis-tick:last-child {
  transform: translateX(-100%);
}

.motion-duration-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
  width: 100%;
  min-width: 0;
  min-height: 2.5rem;
  cursor: default;
}

.motion-duration-cell.is-category .motion-duration-stat-value {
  font-weight: 600;
  color: var(--sy-text);
}

.motion-duration-cell.is-category .motion-duration-mid {
  background: var(--sy-text-secondary);
  opacity: 0.55;
}

.motion-duration-cell.is-category .motion-duration-median {
  background: var(--sy-text);
  box-shadow: 0 0 0 1.5px var(--sy-surface);
}

.motion-duration-cell.is-limited {
  opacity: 0.55;
}

.motion-duration-cell.is-limited .motion-duration-limited {
  opacity: 1;
}

.motion-duration-empty {
  color: var(--sy-text-muted);
  font-variant-numeric: tabular-nums;
}

.motion-duration-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.55rem;
  line-height: 1.15;
  min-width: 0;
}

.motion-duration-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  white-space: nowrap;
  font-size: 0.6875rem;
  color: var(--sy-text-secondary);
}

.motion-duration-stat-label {
  font-weight: 500;
}

.motion-duration-stat-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--sy-text);
}

.motion-duration-limited {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--sy-warning-text);
}

.motion-duration-timeline {
  position: relative;
  height: 0.75rem;
  width: 100%;
  margin-right: 0.35rem;
}

.motion-duration-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
  background: var(--sy-border);
}

.motion-duration-mid {
  position: absolute;
  top: 50%;
  height: 0.4rem;
  transform: translateY(-50%);
  border-radius: 1px;
  background: var(--sy-text-secondary);
  opacity: 0.38;
}

.motion-duration-tail {
  position: absolute;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
  background: var(--sy-text-muted);
}

.motion-duration-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-sizing: border-box;
}

.motion-duration-median {
  width: 0.45rem;
  height: 0.45rem;
  background: var(--sy-text);
  box-shadow: 0 0 0 1.5px var(--sy-surface);
  z-index: 2;
}

.motion-duration-p95 {
  width: 0.35rem;
  height: 0.35rem;
  background: var(--sy-surface);
  border: 1.5px solid var(--sy-text-secondary);
  z-index: 1;
}

.motion-duration-marker.is-overflow {
  opacity: 0.85;
}

.motion-duration-overflow-arrow {
  position: absolute;
  right: -0.1rem;
  top: 50%;
  width: 0;
  height: 0;
  transform: translateY(-50%);
  border-top: 0.22rem solid transparent;
  border-bottom: 0.22rem solid transparent;
  border-left: 0.32rem solid var(--sy-text-secondary);
}

/* ── Scan document rules editor ─────────────────────────────── */
.scan-rules-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: var(--sy-space-6);
  align-items: start;
}

.scan-rules-aside {
  display: flex;
  flex-direction: column;
  gap: var(--sy-space-4);
  position: sticky;
  top: var(--sy-space-4);
}

.scan-rules-panel {
  background: var(--sy-surface);
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius-lg);
  box-shadow: var(--sy-shadow-xs);
  padding: var(--sy-space-4);
}

.scan-rules-help {
  padding-left: 1.15rem;
  margin: 0;
  color: var(--sy-text-secondary);
  font-size: 0.875rem;
  line-height: 1.55;
}

.scan-rules-help li + li {
  margin-top: var(--sy-space-2);
}

.scan-rules-list-header {
  display: grid;
  grid-template-columns: 36px 36px minmax(0, 1fr) 168px 108px;
  gap: var(--sy-space-2);
  padding: 0 var(--sy-space-3) var(--sy-space-2);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sy-text-secondary);
}

.scan-rules-list {
  display: flex;
  flex-direction: column;
  gap: var(--sy-space-2);
}

.scan-rule-row {
  display: grid;
  grid-template-columns: 36px 36px minmax(0, 1fr) 168px 108px;
  gap: var(--sy-space-2);
  align-items: center;
  background: var(--sy-surface);
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius-lg);
  padding: var(--sy-space-2) var(--sy-space-3);
  box-shadow: var(--sy-shadow-xs);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.scan-rule-row.is-dragging {
  opacity: 0.55;
  box-shadow: var(--sy-shadow-sm);
}

.scan-rule-row.is-drag-over {
  border-color: var(--sy-primary);
}

.scan-rule-row.is-matched {
  border-color: var(--sy-primary);
  box-shadow: 0 0 0 3px var(--sy-primary-ring);
}

.scan-rule-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--sy-radius-sm);
  background: transparent;
  color: var(--sy-text-muted);
  cursor: grab;
}

.scan-rule-handle:hover {
  background: var(--sy-bg);
  color: var(--sy-text-secondary);
}

.scan-rule-handle:active {
  cursor: grabbing;
}

.scan-rule-index {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--sy-text-secondary);
  text-align: center;
}

.scan-rule-pattern {
  font-size: 0.875rem;
}

.scan-rule-outcome {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 2px;
  background: var(--sy-bg);
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius);
}

.scan-rule-outcome-btn {
  border: 0;
  border-radius: calc(var(--sy-radius) - 2px);
  background: transparent;
  color: var(--sy-text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.375rem 0.5rem;
  line-height: 1.2;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.scan-rule-outcome-btn.is-active.is-skip {
  background: var(--sy-warning-bg);
  color: var(--sy-warning-text);
}

.scan-rule-outcome-btn.is-active.is-process {
  background: var(--sy-success-bg);
  color: var(--sy-success-text);
}

.scan-rule-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.scan-rules-test-result {
  border-top: 1px solid var(--sy-border);
  padding-top: var(--sy-space-3);
}

.scan-rules-test-outcome {
  font-weight: 600;
  font-size: 0.875rem;
  padding: var(--sy-space-2) var(--sy-space-3);
  border-radius: var(--sy-radius);
  margin-bottom: var(--sy-space-3);
}

.scan-rules-test-outcome.is-process {
  background: var(--sy-success-bg);
  color: var(--sy-success-text);
}

.scan-rules-test-outcome.is-skip {
  background: var(--sy-warning-bg);
  color: var(--sy-warning-text);
}

.scan-rules-test-meta {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: var(--sy-space-1) var(--sy-space-2);
  font-size: 0.8125rem;
  margin: 0;
}

.scan-rules-test-meta dt {
  color: var(--sy-text-secondary);
  font-weight: 500;
}

.scan-rules-test-meta dd {
  margin: 0;
  min-width: 0;
  word-break: break-word;
}

.scan-rules-test-errors {
  color: var(--sy-danger-text);
  font-size: 0.8125rem;
}

/* ── Settings ───────────────────────────────────────────────── */
.settings-layout {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  gap: var(--sy-space-6);
  align-items: start;
}

.settings-nav {
  position: sticky;
  top: var(--sy-space-4);
}

.settings-nav-list {
  display: flex;
  flex-direction: column;
  gap: var(--sy-space-1);
  background: var(--sy-surface);
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius-lg);
  box-shadow: var(--sy-shadow-xs);
  padding: var(--sy-space-2);
}

.settings-nav-link {
  display: block;
  padding: var(--sy-space-2) var(--sy-space-3);
  border-radius: var(--sy-radius);
  color: var(--sy-text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.settings-nav-link:hover {
  color: var(--sy-text);
  background: var(--sy-primary-light);
}

.settings-nav-link.active {
  color: var(--sy-primary);
  background: var(--sy-primary-light);
}

.settings-content {
  min-width: 0;
}

/* ── Legal pages ────────────────────────────────────────────── */
.legal-page {
  max-width: 880px;
  margin: 0 auto;
}

.legal-doc-body {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--sy-text);
}

.legal-doc-body h2 {
  margin-top: var(--sy-space-6);
  margin-bottom: var(--sy-space-3);
}

.legal-doc-body h2:first-of-type {
  margin-top: var(--sy-space-4);
}

.legal-doc-body p,
.legal-doc-body ul {
  margin-bottom: var(--sy-space-4);
  color: var(--sy-text-secondary);
}

.legal-doc-body ul {
  padding-left: var(--sy-space-6);
}

.legal-doc-body li + li {
  margin-top: var(--sy-space-2);
}

.legal-doc-body strong {
  color: var(--sy-text);
  font-weight: 600;
}

/* ── Payment card visual ────────────────────────────────────── */
.payment-card-wrap {
  max-width: var(--sy-payment-card-max-width);
}

.payment-card {
  position: relative;
  overflow: hidden;
  color: var(--sy-payment-card-text);
  background: linear-gradient(135deg, var(--sy-payment-card-from), var(--sy-payment-card-to));
  border-radius: var(--sy-payment-card-radius);
  box-shadow: var(--sy-payment-card-shadow);
  padding: var(--sy-space-6);
  min-height: var(--sy-payment-card-min-height);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--sy-space-6);
}

.payment-card-glow {
  position: absolute;
  inset: auto calc(var(--sy-space-8) * -1) auto auto;
  top: calc(var(--sy-space-6) * -1);
  width: var(--sy-payment-card-glow-size);
  height: var(--sy-payment-card-glow-size);
  border-radius: 50%;
  background: radial-gradient(circle, var(--sy-payment-card-glow) 0%, transparent 70%);
  pointer-events: none;
}

.payment-card-glow::after {
  content: "";
  position: absolute;
  right: var(--sy-space-12);
  top: calc(var(--sy-space-12) * 2);
  width: var(--sy-payment-card-glow-size-sm);
  height: var(--sy-payment-card-glow-size-sm);
  border-radius: 50%;
  background: radial-gradient(circle, var(--sy-payment-card-glow) 0%, transparent 70%);
}

.payment-card-top,
.payment-card-meta {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sy-space-4);
}

.payment-card-number-block {
  position: relative;
  z-index: 1;
}

.payment-card-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--sy-payment-card-muted);
  margin-bottom: var(--sy-space-1);
}

.payment-card-name,
.payment-card-meta-value {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.payment-card-number {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.payment-card-brand {
  flex-shrink: 0;
}

.payment-card-brand-icon {
  width: var(--sy-payment-card-brand-width);
  height: var(--sy-payment-card-brand-height);
  display: block;
  border-radius: var(--sy-radius-sm);
}

.payment-card-brand-icon--generic {
  color: var(--sy-payment-card-text);
  opacity: 0.9;
}

.payment-card-meta > div {
  min-width: 4.5rem;
}

.tfa-setup {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sy-space-5);
  align-items: flex-start;
}

.tfa-qr {
  display: block;
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius);
  background: var(--sy-surface);
  padding: var(--sy-space-2);
}

.tfa-shared-key {
  display: inline-block;
  letter-spacing: 0.06em;
  word-break: break-all;
}

/* ── Cart & purchase ────────────────────────────────────────── */
.nav-research,
.nav-cart {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: var(--sy-text-secondary);
  text-decoration: none;
  padding: var(--sy-space-1);
}

.nav-research:hover,
.nav-cart:hover {
  color: var(--sy-primary);
}

.nav-cart-count {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 var(--sy-space-1);
  border-radius: 999px;
  background: var(--sy-primary);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.125rem;
  text-align: center;
}

/* ── Research trail timeline ────────────────────────────────── */
.research-trail-timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sy-space-3);
  padding-left: var(--sy-space-2);
}

.research-trail-step {
  position: relative;
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: var(--sy-space-3);
  align-items: stretch;
}

.research-trail-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: calc(1rem - 1px);
  top: 2rem;
  bottom: calc(-1 * var(--sy-space-3));
  width: 2px;
  background: var(--sy-border);
}

.research-trail-marker {
  display: flex;
  justify-content: center;
  padding-top: var(--sy-space-3);
}

.research-trail-marker-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: var(--sy-primary-light);
  color: var(--sy-primary);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  z-index: 1;
}

.research-trail-step-auth .research-trail-marker-dot {
  background: var(--sy-border);
  color: var(--sy-text-secondary);
  width: 0.75rem;
  height: 0.75rem;
  margin-top: var(--sy-space-2);
}

.research-trail-card {
  box-shadow: var(--sy-shadow-xs);
}

.research-trail-card-main {
  min-width: 0;
  flex: 1 1 12rem;
}

.research-trail-title {
  color: var(--sy-text);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.research-trail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sy-space-2);
}

.case-entry-check-col {
  width: 2.5rem;
  vertical-align: middle;
}

.case-entry-purchased {
  background: var(--sy-bg);
}

.case-purchase-bar {
  position: sticky;
  bottom: var(--sy-space-4);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sy-space-3);
  margin-top: var(--sy-space-4);
  padding: var(--sy-space-3) var(--sy-space-4);
  background: var(--sy-surface);
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius-lg);
  box-shadow: var(--sy-shadow-md);
}

.case-purchase-bar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sy-space-4);
  color: var(--sy-text-secondary);
  font-size: 0.875rem;
}

.case-purchase-bar-total strong {
  color: var(--sy-text);
}

.cart-added-modal .modal-content {
  border: 1px solid var(--sy-border);
  border-radius: var(--sy-radius-lg);
  box-shadow: var(--sy-shadow-md);
}

.modal-backdrop.cart-added-backdrop {
  backdrop-filter: blur(var(--sy-modal-backdrop-blur));
  -webkit-backdrop-filter: blur(var(--sy-modal-backdrop-blur));
  background-color: var(--sy-modal-backdrop);
}

/* ── Responsive tweaks ──────────────────────────────────────── */
@media (max-width: 767.98px) {
  .page-header { flex-direction: column; gap: 12px; }
  .auth-card { padding: 28px 20px; }
  .drop-zone { padding: 32px 16px; }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-nav {
    position: static;
  }

  .settings-nav-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .scan-rules-layout {
    grid-template-columns: 1fr;
  }

  .scan-rules-aside {
    position: static;
  }

  .scan-rule-row,
  .scan-rules-list-header {
    grid-template-columns: 32px 28px minmax(0, 1fr);
  }

  .scan-rule-outcome,
  .scan-rule-actions {
    grid-column: 1 / -1;
  }

  .scan-rule-outcome {
    width: 100%;
  }

  .scan-rule-actions {
    justify-content: flex-start;
  }

  .judge-directory-filters {
    position: static;
  }

  .judge-directory-card {
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--sy-space-3);
  }

  .app-home-chart {
    grid-template-columns: 1fr;
  }

  .app-home-chart-y-label {
    writing-mode: initial;
    transform: none;
    justify-content: flex-start;
  }

  .app-home-chart-bars,
  .app-home-chart-x-label {
    grid-column: auto;
  }

  .app-home-chart-bars {
    grid-template-columns: repeat(auto-fit, minmax(3rem, 1fr));
    min-height: 14rem;
  }

  .judge-directory-card-role,
  .judge-directory-card-contact {
    grid-column: 2;
  }

  .judge-details-grid {
    grid-template-columns: 1fr;
  }
}
