/* ============================================================
   Rice Source Registry — Admin UI
   Modern Chinese Admin System Stylesheet
   ============================================================ */

/* ============================================================
   1. CSS Custom Properties
   ============================================================ */
:root {
  /* Colors — Primary */
  --primary:        #1677ff;
  --primary-hover:  #0958d9;
  --primary-soft:   #e6f4ff;

  /* Colors — Semantic */
  --success:        #22c55e;
  --success-soft:   #ecfdf5;
  --warning:        #f59e0b;
  --warning-soft:   #fff7ed;
  --danger:         #ef4444;
  --danger-soft:    #fef2f2;
  --purple:         #8b5cf6;
  --purple-soft:    #f5f3ff;
  --info:           #3b82f6;
  --info-soft:      #eff6ff;

  /* Colors — Neutral */
  --bg:             #f7f9fc;
  --card-bg:        #ffffff;
  --border:         #e8edf5;
  --text:           #111827;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;

  /* Layout */
  --sidebar-width:  220px;
  --topbar-height:  56px;

  /* Typography */
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
                 "Microsoft YaHei", "PingFang SC", sans-serif;
  --font-mono:   ui-monospace, SFMono-Regular, "SF Mono", Consolas,
                 "Liberation Mono", Menlo, monospace;

  /* Border Radius */
  --radius-sm:   8px;
  --radius:      10px;
  --radius-md:   12px;
  --radius-lg:   14px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.05);
}

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

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

/* ============================================================
   3. Layout — Topbar
   ============================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
}

.topbar-brand {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.topbar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #374151;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.topbar-user a {
  color: var(--text-secondary);
  text-decoration: none;
}

.topbar-user a:hover {
  color: var(--primary);
}

.topbar-user .user-name {
  color: var(--text);
  font-weight: 500;
}

.menu-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.15s;
}

.menu-toggle:hover {
  background: #f1f5f9;
}

/* ============================================================
   4. Layout — Sidebar
   ============================================================ */
.sidebar {
  position: fixed;
  left: 0;
  top: var(--topbar-height);
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height));
  background: #ffffff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 90;
  padding: 12px 0;
}

.menu-section {
  margin-bottom: 4px;
}

.menu-section-bottom {
  margin-top: auto;
  padding-top: 8px;
}

.menu-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 16px 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  color: #374151;
  text-decoration: none;
  border-radius: 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.menu-item:hover {
  background: var(--bg);
  color: var(--primary);
}

.menu-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 500;
}

.menu-item .menu-icon {
  width: 16px;
  text-align: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ============================================================
   5. Layout — Main Wrapper & Content
   ============================================================ */
.main-wrapper {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
  background: var(--bg);
}

.content {
  padding: 24px;
  max-width: none;
}

.page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

/* ============================================================
   6. Cards
   ============================================================ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}

.card-header {
  padding: 14px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

/* ============================================================
   7. Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.4;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-outline {
  background: #ffffff;
  color: #374151;
  border-color: #d1d5db;
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.btn-success {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.btn-success:hover {
  background: #16a34a;
  border-color: #16a34a;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 10px 28px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

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

/* ============================================================
   8. Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-approved {
  background: var(--success-soft);
  color: #16a34a;
}

.badge-pending_review {
  background: var(--warning-soft);
  color: #d97706;
}

.badge-rejected {
  background: var(--danger-soft);
  color: #dc2626;
}

.badge-draft {
  background: #f1f5f9;
  color: #64748b;
}

.badge-submitted {
  background: var(--info-soft);
  color: #2563eb;
}

.badge-duplicate {
  background: var(--purple-soft);
  color: #7c3aed;
}

.badge-test {
  background: #f0fdf4;
  color: #15803d;
}

/* ============================================================
   9. Alerts
   ============================================================ */
.alert {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert-success {
  background: var(--success-soft);
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.alert-error {
  background: var(--danger-soft);
  color: #dc2626;
  border: 1px solid #fecaca;
}

.alert-warning {
  background: var(--warning-soft);
  color: #d97706;
  border: 1px solid #fed7aa;
}

.alert-info {
  background: var(--info-soft);
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

/* ============================================================
   10. Forms
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

input,
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text);
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1);
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ============================================================
   11. Tables
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #374151;
  vertical-align: middle;
}

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

tr:hover td {
  background: #f9fafb;
}

td code {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #374151;
}

/* ============================================================
   12. Stats Grid
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-card.stat-primary .stat-value { color: var(--primary); }
.stat-card.stat-success .stat-value { color: var(--success); }
.stat-card.stat-warning .stat-value { color: var(--warning); }
.stat-card.stat-danger  .stat-value { color: var(--danger); }

.stat-card .stat-value.stat-primary { color: var(--primary); }
.stat-card .stat-value.stat-warning { color: var(--warning); }

/* Compact ID display inside stat cards */
.stat-value-id {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

/* Role info block */
.role-item { display: flex; align-items: center; gap: 10px; }
.role-item-mt { margin-top: 10px; }

/* ID info block */
.id-info {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

.id-info-note {
  margin-top: 8px;
  font-size: 0.8rem;
}

/* ============================================================
   13. Status Grid
   ============================================================ */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.status-item {
  background: #f9fafb;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-item .status-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.status-item .status-count {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

/* ============================================================
   14. Page Intro Box
   ============================================================ */
.page-intro-box {
  background: #f9fafb;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  border: 1px solid #f1f5f9;
}

/* ============================================================
   15. Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.15);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
}

.modal-header {
  padding: 18px 24px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 20px 24px;
}

/* ============================================================
   16. Login Page
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  background: #ffffff;
}

.login-left {
  flex: 1;
  background: linear-gradient(135deg, #1677ff 0%, #0958d9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.login-intro {
  max-width: 400px;
  color: #ffffff;
}

.login-intro-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.login-intro h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.3;
}

.login-intro p {
  font-size: 0.95rem;
  opacity: 0.85;
  line-height: 1.6;
  margin-bottom: 20px;
}

.login-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-features li {
  font-size: 0.875rem;
  opacity: 0.8;
  padding-left: 20px;
  position: relative;
}

.login-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: rgba(255, 255, 255, 0.7);
}

.login-right {
  width: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-card-wide {
  max-width: 480px;
}

.required-mark {
  color: var(--danger);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.login-header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.login-form .form-group {
  margin-bottom: 16px;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.login-register-link {
  text-align: center;
  margin-top: 12px;
  font-size: 0.85rem;
}

.login-register-link a {
  color: var(--primary);
}

/* ============================================================
   17. Home Page
   ============================================================ */
.home-page {
  min-height: 100vh;
  background: #ffffff;
  display: flex;
  flex-direction: column;
}

.home-nav {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 48px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
}

.home-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.home-nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.home-nav-links a {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
}

.home-nav-links a:hover {
  color: var(--primary);
}

.home-hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 48px;
  text-align: center;
  background: radial-gradient(
    ellipse 80% 60% at 50% 0%,
    rgba(22, 119, 255, 0.08) 0%,
    transparent 70%
  );
}

.home-hero-content {
  max-width: 640px;
}

.home-hero-content h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 16px;
}

.home-hero-content p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 32px;
}

.home-hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.home-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 0 48px 64px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.home-feature-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s, transform 0.2s;
}

.home-feature-card:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
  transform: translateY(-2px);
}

.home-feature-icon {
  font-size: 1.75rem;
  margin-bottom: 12px;
}

.home-feature-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.home-feature-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.home-footer {
  text-align: center;
  padding: 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid #f1f5f9;
}

/* ============================================================
   18. Utility Classes
   ============================================================ */
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }

.input-narrow { width: 100px; }

/* Result count label */
.result-count-label { font-size: 0.85rem; color: var(--text-secondary); font-weight: 600; }
.result-count-value { color: var(--primary); }

/* Title cell in tables */
.td-title { max-width: 180px; word-break: break-word; }

/* Quick filter bar inside filter card */
.quick-filter-bar {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.quick-filter-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger    { color: var(--danger); }
.text-success   { color: var(--success); }
.text-warning   { color: var(--warning); }
.text-primary   { color: var(--primary); }
.text-dark      { color: var(--text); }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.label-inline { font-size: 0.8rem; white-space: nowrap; color: var(--text-secondary); }

.flex            { display: flex; }
.gap-1           { gap: 8px; }
.gap-2           { gap: 16px; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Table cell helpers ── */
.td-reason   { max-width: 160px; white-space: normal; font-size: 0.8rem; }
.td-note     { max-width: 120px; white-space: normal; font-size: 0.8rem; }
.td-time     { font-size: 0.75rem; white-space: nowrap; }
.td-actions  { display: flex; gap: 4px; flex-wrap: wrap; }

/* ── Card filter bar ── */
.card-filter-bar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.card-header-back {
  float: right;
  font-size: 0.85rem;
}

/* ── Badge with left spacing ── */
.badge-ml { margin-left: 8px; }

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

/* ── Modal helpers ── */
.modal-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-form-group-mt { margin-top: 12px; }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ── Inline form (for action buttons in tables) ── */
.form-inline { display: inline; }

/* ── Danger/success outline button variants ── */
.btn-outline-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-outline-success {
  color: var(--success);
  border-color: var(--success);
}

/* ── Warning text ── */
.text-warning-bold {
  color: var(--danger);
  font-weight: 600;
}

/* ── Form row align-end ── */
.form-group-end {
  display: flex;
  align-items: flex-end;
}

/* ============================================================
   19. Responsive — Mobile (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-220px);
    transition: transform 0.25s;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0;
  }

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

  .home-features {
    grid-template-columns: 1fr;
    padding: 0 24px 48px;
  }

  .home-nav {
    padding: 0 24px;
  }

  .home-hero {
    padding: 48px 24px;
  }

  .home-hero-content h1 {
    font-size: 1.75rem;
  }

  .login-left {
    display: none;
  }

  .login-right {
    width: 100%;
  }

  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Dual-crop additions
   ============================================================ */

/* Crop badges */
.badge-crop-rice  { background: #ecfdf5; color: #16a34a; }
.badge-crop-maize { background: #fff7ed; color: #d97706; }

/* Crop detection hint in submit form */
.crop-detect-hint  { color: var(--primary); }
.crop-detect-warning { color: var(--warning); }

/* Permission table helpers */
.th-center { text-align: center; }
.th-sub    { font-size: 0.72rem; font-weight: 400; }
.td-center { text-align: center; }

/* Permission modal */
.perm-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.perm-modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  min-width: 360px;
  max-width: 480px;
  width: 90%;
}

.perm-modal-title {
  margin: 0 0 16px;
  font-size: 1rem;
}

.hidden-form { display: none; }

/* Utility */
.stats-grid-mt { margin-top: 12px; }
.text-sm { font-size: 0.82rem; }

/* ============================================================
   UI Upgrade — Metric Cards / Info Table / Key-Value Grid
   ============================================================ */

/* Additional variable */
:root { --border-soft: #f1f5f9; }

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

.metric-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.metric-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

.metric-value {
  margin-top: 8px;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.metric-value-id {
  margin-top: 10px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
}

.metric-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.metric-card-success .metric-value { color: var(--success); }
.metric-card-warning .metric-value { color: var(--warning); }
.metric-card-danger  .metric-value { color: var(--danger); }
.metric-card-primary .metric-value { color: var(--primary); }

/* ── info-table ── */
.info-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.info-table th,
.info-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}

.info-table th {
  width: 180px;
  color: var(--text-secondary);
  font-weight: 600;
  background: #fafafa;
  white-space: nowrap;
}

.info-table td {
  color: var(--text);
  font-weight: 600;
}

.info-table tr:last-child th,
.info-table tr:last-child td {
  border-bottom: none;
}

/* ── key-value-grid ── */
.key-value-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
}

.key-value-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}

.key-value-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 5px;
}

.key-value-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  word-break: break-word;
}

/* ── code-pill ── */
.code-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e6f4ff;
  color: #0958d9;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.code-pill-success {
  background: var(--success-soft);
  color: #16a34a;
}

.code-pill-muted {
  background: #f1f5f9;
  color: #64748b;
}

/* ── section-grid ── */
.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

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

/* ── empty-state (enhanced) ── */
.empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-secondary);
  background: #ffffff;
  border: 1px dashed var(--border);
  border-radius: 18px;
  margin: 12px;
}

.empty-state-icon { font-size: 2rem; margin-bottom: 8px; }

.empty-state-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── btn-secondary / btn-warning ── */
.btn-secondary {
  background: #f1f5f9;
  color: #374151;
  border-color: #e2e8f0;
}

.btn-secondary:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.btn-warning {
  background: var(--warning);
  color: #ffffff;
  border-color: var(--warning);
}

.btn-warning:hover {
  background: #d97706;
  border-color: #d97706;
}

/* ── Missing badge variants ── */
.badge-possible_duplicate {
  background: var(--warning-soft);
  color: #b45309;
}

.badge-returned {
  background: #f0f9ff;
  color: #0369a1;
}

.badge-official {
  background: var(--primary-soft);
  color: var(--primary);
}

.info-table-head-rice  { background: #ecfdf5; color: #047857; }
.info-table-head-maize { background: #fff7ed; color: #c2410c; }

/* ── Responsive for new components ── */
@media (max-width: 1366px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1200px) {
  .section-grid,
  .section-grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .metric-grid     { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .key-value-grid  { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .metric-grid { grid-template-columns: 1fr; }
}

/* ── Detail page ── */
.detail-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.detail-title-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.detail-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.detail-title-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}

.card-header-warning { color: var(--warning); }
.card-header-success  { color: var(--success); }

.break-all { word-break: break-all; }
.p-0 { padding: 0 !important; }

/* ── Danger zone ── */
.danger-zone { border: 2px solid var(--danger) !important; }
.danger-zone-header { background: var(--danger) !important; color: #ffffff !important; }
.danger-zone-warning { color: var(--danger); font-weight: 600; margin-bottom: 8px; }

/* ── Returned sources resubmit panel ── */
.returned-detail {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.returned-summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.returned-note {
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 400;
}
.returned-form { margin-top: 12px; }

/* ── detail-section-title color variant ── */
.detail-section-title.text-warning { color: var(--warning); }

@media (max-width: 1024px) {
  .detail-cards-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Responsive — Sidebar mask & mobile/desktop visibility
   ============================================================ */
.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 85;
}

/* Default: mobile-only hidden, desktop-only visible */
.mobile-only  { display: none; }
.desktop-only { display: block; }

@media (max-width: 768px) {
  .sidebar-mask.open { display: block; }

  .mobile-only  { display: block; }
  .desktop-only { display: none !important; }

  .content { padding: 16px; }

  /* 3-col filter rows collapse to 1 col */
  .form-row-3 { grid-template-columns: 1fr; }

  /* ── Review page mobile cards ── */
  .review-mobile-list { }

  .review-mobile-card {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
  }
  .review-mobile-card:last-child { border-bottom: none; }

  .review-mobile-card-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
  }
  .review-mobile-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    word-break: break-word;
    line-height: 1.4;
  }
  .review-mobile-card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 8px;
  }
  .review-mobile-card-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
  }
  .review-mobile-card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }

  /* ── Registration page mobile cards ── */
  .reg-mobile-card {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
  }
  .reg-mobile-card:last-child { border-bottom: none; }

  .reg-mobile-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
  }
  .reg-mobile-card-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
  }
  .reg-mobile-card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 8px;
  }
  .reg-mobile-card-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
  }
  .reg-mobile-card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }

  /* ── Mobile detail panel (review) ── */
  .mobile-detail-panel {
    padding: 16px;
  }
  .mobile-detail-panel .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Home page — navbar login / register buttons
   ============================================================ */
.btn-login {
  color: #ffffff !important;
  background: var(--primary);
  border: 1.5px solid var(--primary);
  box-shadow: 0 4px 12px rgba(22, 119, 255, 0.25);
}
.btn-login:hover {
  color: #ffffff !important;
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-register {
  color: var(--primary) !important;
  background: var(--primary-soft);
  border: 1.5px solid #c7e4ff;
}
.btn-register:hover {
  color: var(--primary-hover) !important;
  background: #d8edff;
  border-color: #91caff;
}
