/* =========================================================
   CURRENT AFFAIRS IMPORTER
   Dashboard Styles
========================================================= */

:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e5e7eb;

  --text: #111827;
  --muted: #6b7280;

  --primary: #4f46e5;
  --primary-dark: #4338ca;

  --success: #16a34a;
  --success-bg: #dcfce7;

  --danger: #dc2626;
  --danger-bg: #fee2e2;

  --warning: #d97706;
  --warning-bg: #fef3c7;

  --info: #2563eb;
  --info-bg: #dbeafe;

  --purple: #9333ea;
  --purple-bg: #f3e8ff;

  --sidebar: #111827;
  --sidebar-hover: #1f2937;

  --radius: 14px;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 30px rgba(0, 0, 0, 0.04);
}

/* =========================================================
   RESET
========================================================= */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;

  background: var(--bg);

  color: var(--text);

  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  font-size: 14px;

  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  text-decoration: none;
  color: inherit;
}

/* =========================================================
   APP LAYOUT
========================================================= */

.app {
  min-height: 100vh;

  display: flex;
}

/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
  width: 250px;

  min-height: 100vh;

  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;

  display: flex;
  flex-direction: column;

  background: var(--sidebar);

  color: #ffffff;

  z-index: 100;
}

/* Brand */

.brand {
  height: 82px;

  display: flex;
  align-items: center;

  gap: 12px;

  padding: 0 22px;

  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand-icon {
  width: 40px;
  height: 40px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 10px;

  background: linear-gradient(135deg, #6366f1, #8b5cf6);

  color: white;

  font-size: 13px;
  font-weight: 800;
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 2px;

  color: #9ca3af;

  font-size: 11px;
}

/* Navigation */

.sidebar-nav {
  padding: 22px 12px;

  display: flex;
  flex-direction: column;

  gap: 5px;
}

.nav-item {
  min-height: 44px;

  display: flex;
  align-items: center;

  gap: 12px;

  padding: 0 13px;

  border-radius: 9px;

  color: #9ca3af;

  font-size: 13px;
  font-weight: 500;

  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.18);

  color: #ffffff;
}

.nav-icon {
  width: 20px;

  text-align: center;

  font-size: 16px;
}

/* Sidebar footer */

.sidebar-footer {
  margin-top: auto;

  padding: 18px 16px;

  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.connection-status {
  display: flex;
  align-items: center;

  gap: 10px;

  padding: 10px;

  border-radius: 10px;

  background: rgba(255, 255, 255, 0.04);
}

.connection-status strong {
  display: block;

  color: #e5e7eb;

  font-size: 12px;
}

.connection-status small {
  display: block;

  margin-top: 2px;

  color: #6b7280;

  font-size: 10px;
}

/* =========================================================
   STATUS DOT
========================================================= */

.status-dot {
  width: 8px;
  height: 8px;

  display: inline-block;

  flex-shrink: 0;

  border-radius: 50%;

  background: #22c55e;

  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
}

/* =========================================================
   MAIN CONTENT
========================================================= */

.main {
  width: calc(100% - 250px);

  margin-left: 250px;

  min-height: 100vh;

  padding: 32px;
}

/* =========================================================
   TOP BAR
========================================================= */

.topbar {
  min-height: 65px;

  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  margin-bottom: 25px;
}

.topbar h1 {
  margin: 0;

  font-size: 25px;

  line-height: 1.2;

  letter-spacing: -0.5px;
}

.topbar p {
  margin: 7px 0 0;

  color: var(--muted);

  font-size: 13px;
}

.topbar-date {
  padding: 8px 12px;

  border: 1px solid var(--border);

  border-radius: 8px;

  background: white;

  color: var(--muted);

  font-size: 12px;
}

/* =========================================================
   CARD
========================================================= */

.card {
  margin-bottom: 20px;

  border: 1px solid var(--border);

  border-radius: var(--radius);

  background: var(--card);

  box-shadow: var(--shadow);

  overflow: hidden;
}

.card-header {
  min-height: 74px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 18px 22px;

  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  margin: 0;

  font-size: 15px;

  font-weight: 700;
}

.card-header p {
  margin: 4px 0 0;

  color: var(--muted);

  font-size: 12px;
}

/* =========================================================
   IMPORT FORM
========================================================= */

.import-form {
  display: grid;

  grid-template-columns:
    minmax(160px, 0.8fr)
    minmax(140px, 0.6fr)
    minmax(220px, 1.5fr)
    auto;

  align-items: end;

  gap: 18px;

  padding: 22px;
}

.form-group {
  min-width: 0;
}

.form-group label {
  display: block;

  margin-bottom: 7px;

  color: #374151;

  font-size: 12px;

  font-weight: 600;
}

.form-group input,
.form-group select {
  width: 100%;

  height: 43px;

  padding: 0 12px;

  border: 1px solid #d1d5db;

  border-radius: 8px;

  outline: none;

  background: #ffffff;

  color: var(--text);

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);

  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.readonly-input {
  width: 100%;

  height: 43px;

  display: flex;
  align-items: center;

  padding: 0 12px;

  border: 1px solid var(--border);

  border-radius: 8px;

  background: #f9fafb;

  color: #6b7280;

  font-family: monospace;

  font-size: 11px;

  overflow: hidden;

  white-space: nowrap;

  text-overflow: ellipsis;
}

/* =========================================================
   BUTTONS
========================================================= */

.btn {
  height: 43px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap: 8px;

  padding: 0 18px;

  border: 0;

  border-radius: 8px;

  font-size: 12px;

  font-weight: 600;

  transition:
    background 0.2s ease,
    transform 0.1s ease,
    opacity 0.2s ease;
}

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

.btn:disabled {
  cursor: not-allowed;

  opacity: 0.55;
}

.btn-primary {
  min-width: 145px;

  background: var(--primary);

  color: white;
}

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

.btn-secondary {
  height: 34px;

  padding: 0 12px;

  border: 1px solid var(--border);

  background: white;

  color: #4b5563;
}

.btn-secondary:hover {
  background: #f9fafb;
}

.btn-icon {
  font-size: 15px;
}

/* =========================================================
   API STATUS
========================================================= */

.api-status {
  display: flex;
  align-items: center;

  gap: 8px;

  padding: 6px 10px;

  border-radius: 20px;

  background: var(--success-bg);

  color: #15803d;

  font-size: 11px;

  font-weight: 600;
}

/* =========================================================
   PROGRESS
========================================================= */

.progress-card {
  display: block;
}

.progress-percentage {
  min-width: 50px;

  color: var(--primary);

  font-size: 20px;

  font-weight: 700;

  text-align: right;
}

.progress-container {
  padding: 22px 22px 0;
}

.progress-track {
  width: 100%;

  height: 10px;

  overflow: hidden;

  border-radius: 10px;

  background: #eef0f5;
}

.progress-bar {
  height: 100%;

  position: relative;

  border-radius: inherit;

  background: linear-gradient(90deg, #4f46e5, #7c3aed);

  transition: width 0.35s ease;
}

.progress-bar::after {
  content: "";

  position: absolute;

  inset: 0;

  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.25),
    transparent
  );

  animation: progressShine 1.8s infinite;
}

@keyframes progressShine {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

.progress-details {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 12px 22px 18px;

  color: var(--muted);

  font-size: 11px;
}

.progress-details strong {
  color: var(--text);
}

/* =========================================================
   STATISTICS
========================================================= */

.stats-grid {
  display: grid;

  grid-template-columns: repeat(4, minmax(0, 1fr));

  gap: 15px;

  margin-bottom: 20px;
}

.stat-card {
  min-height: 105px;

  display: flex;
  align-items: center;

  gap: 14px;

  padding: 18px;

  border: 1px solid var(--border);

  border-radius: var(--radius);

  background: white;

  box-shadow: var(--shadow);
}

.stat-icon {
  width: 43px;
  height: 43px;

  display: flex;
  align-items: center;
  justify-content: center;

  flex-shrink: 0;

  border-radius: 11px;

  font-size: 18px;

  font-weight: 700;
}

.stat-icon.blue {
  background: var(--info-bg);
  color: var(--info);
}

.stat-icon.green {
  background: var(--success-bg);
  color: var(--success);
}

.stat-icon.red {
  background: var(--danger-bg);
  color: var(--danger);
}

.stat-icon.purple {
  background: var(--purple-bg);
  color: var(--purple);
}

.stat-label {
  display: block;

  margin-bottom: 4px;

  color: var(--muted);

  font-size: 11px;
}

.stat-value {
  display: block;

  color: var(--text);

  font-size: 22px;

  line-height: 1;
}

/* =========================================================
   CURRENT RECORD
========================================================= */

.current-content {
  display: grid;

  grid-template-columns: 1fr 260px;

  gap: 30px;

  padding: 22px;
}

.current-label {
  margin-bottom: 8px;

  color: #9ca3af;

  font-size: 9px;

  font-weight: 700;

  letter-spacing: 0.8px;
}

.current-main h3 {
  margin: 0;

  max-width: 800px;

  color: #1f2937;

  font-size: 17px;

  font-weight: 600;

  line-height: 1.4;
}

.current-meta {
  display: flex;

  gap: 35px;

  margin-top: 18px;
}

.current-meta div {
  min-width: 120px;
}

.current-meta span {
  display: block;

  margin-bottom: 3px;

  color: #9ca3af;

  font-size: 10px;
}

.current-meta strong {
  display: block;

  max-width: 250px;

  overflow: hidden;

  color: #4b5563;

  font-family: monospace;

  font-size: 11px;

  white-space: nowrap;

  text-overflow: ellipsis;
}

/* Image status */

.image-status {
  padding-left: 25px;

  border-left: 1px solid var(--border);
}

.image-status-value {
  display: flex;
  align-items: center;

  gap: 8px;

  color: #6b7280;

  font-size: 12px;
}

.image-status-icon {
  color: #9ca3af;

  font-size: 17px;
}

/* =========================================================
   BADGES
========================================================= */

.badge {
  display: inline-flex;
  align-items: center;

  min-height: 27px;

  padding: 0 10px;

  border-radius: 20px;

  font-size: 10px;

  font-weight: 600;
}

.badge-waiting {
  background: #f3f4f6;
  color: #6b7280;
}

.badge-processing {
  background: var(--info-bg);
  color: #1d4ed8;
}

.badge-success {
  background: var(--success-bg);
  color: #15803d;
}

.badge-error {
  background: var(--danger-bg);
  color: #b91c1c;
}

/* =========================================================
   IMPORT LOG
========================================================= */

.log-container {
  height: 330px;

  overflow-y: auto;

  padding: 8px 0;

  background: #0f172a;

  color: #cbd5e1;

  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  font-size: 11px;
}

.log-container::-webkit-scrollbar {
  width: 7px;
}

.log-container::-webkit-scrollbar-track {
  background: #111827;
}

.log-container::-webkit-scrollbar-thumb {
  border-radius: 10px;

  background: #374151;
}

.log-empty {
  min-height: 100%;

  display: flex;
  flex-direction: column;

  align-items: center;
  justify-content: center;

  color: #64748b;
}

.log-empty-icon {
  margin-bottom: 10px;

  font-size: 28px;
}

.log-empty p {
  margin: 0;

  font-family: inherit;

  font-size: 11px;
}

/* Log lines */

.log-line {
  display: grid;

  grid-template-columns:
    72px
    65px
    1fr;

  gap: 10px;

  padding: 5px 18px;

  border-bottom: 1px solid rgba(255, 255, 255, 0.025);
}

.log-line:hover {
  background: rgba(255, 255, 255, 0.025);
}

.log-time {
  color: #64748b;
}

.log-type {
  font-weight: 700;
}

.log-message {
  color: #cbd5e1;

  word-break: break-word;
}

.log-info .log-type {
  color: #60a5fa;
}

.log-success .log-type {
  color: #4ade80;
}

.log-warning .log-type {
  color: #fbbf24;
}

.log-error .log-type {
  color: #f87171;
}

/* =========================================================
   RESULT
========================================================= */

.result-card {
  display: flex;
  align-items: center;

  gap: 18px;

  padding: 22px;

  border-color: #bbf7d0;

  background: #f0fdf4;
}

.result-icon {
  width: 50px;
  height: 50px;

  display: flex;
  align-items: center;
  justify-content: center;

  flex-shrink: 0;

  border-radius: 50%;

  background: #dcfce7;

  color: #16a34a;

  font-size: 22px;
  font-weight: 700;
}

.result-content h2 {
  margin: 0;

  color: #166534;

  font-size: 15px;
}

.result-content p {
  margin: 4px 0 10px;

  color: #4b5563;

  font-size: 12px;
}

.result-path {
  color: #6b7280;

  font-size: 11px;
}

.result-path code {
  margin-left: 5px;

  color: #166534;

  font-family: monospace;
}

/* =========================================================
   HIDDEN
========================================================= */

.hidden {
  display: none !important;
}

/* =========================================================
   DISABLED IMPORT STATE
========================================================= */

.importing .btn-primary {
  background: #9ca3af;

  cursor: wait;
}

.importing .progress-bar {
  animation: progressPulse 1.2s infinite;
}

@keyframes progressPulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

/* =========================================================
   RESPONSIVE
========================================================= */

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

  .import-form {
    grid-template-columns: 1fr 1fr;
  }

  .form-action {
    grid-column: 1 / -1;
  }

  .btn-primary {
    width: 100%;
  }
}

@media (max-width: 850px) {
  .sidebar {
    width: 70px;
  }

  .brand {
    justify-content: center;

    padding: 0;
  }

  .brand > div:not(.brand-icon) {
    display: none;
  }

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

  .nav-item {
    position: relative;

    justify-content: center;

    padding: 0;
  }

  .nav-label,
  .nav-section,
  .sidebar-today-title,
  .sidebar-today-source,
  .sidebar-today-status {
    display: none;
  }

  /* Badge becomes a corner bubble on the icon */
  .nav-badge {
    position: absolute;
    top: 3px;
    right: 3px;

    min-width: 16px;
    height: 16px;

    margin: 0;

    font-size: 9px;
  }

  .sidebar-footer {
    padding: 10px;
  }

  .sidebar-today {
    align-items: center;

    padding: 10px 5px;
  }

  .sidebar-today-row {
    justify-content: center;
  }

  .main {
    width: calc(100% - 70px);

    margin-left: 70px;

    padding: 25px;
  }

  .current-content {
    grid-template-columns: 1fr;
  }

  .image-status {
    padding: 15px 0 0;

    border-left: 0;

    border-top: 1px solid var(--border);
  }
}

@media (max-width: 650px) {
  .main {
    padding: 15px;
  }

  .topbar {
    flex-direction: column;

    gap: 12px;
  }

  .topbar h1 {
    font-size: 21px;
  }

  .topbar-date {
    align-self: flex-start;
  }

  .import-form {
    grid-template-columns: 1fr;
  }

  .form-action {
    grid-column: auto;
  }

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

  .card-header {
    align-items: flex-start;

    gap: 12px;
  }

  .current-meta {
    flex-direction: column;

    gap: 12px;
  }

  .log-line {
    grid-template-columns:
      58px
      52px
      1fr;

    gap: 6px;

    padding-left: 10px;
    padding-right: 10px;

    font-size: 10px;
  }
}

/* =========================================================
   DATE INPUT
========================================================= */

input[type="date"] {
  color-scheme: light;
}

/* =========================================================
   SELECTION
========================================================= */

::selection {
  background: rgba(79, 70, 229, 0.2);

  color: var(--text);
}

/* =========================================================
   IMPORT HISTORY
========================================================= */

.badge-warning {
  background: var(--warning-bg);
  color: #b45309;
}

.notice {
  margin-bottom: 20px;

  padding: 12px 16px;

  border-radius: 9px;

  font-size: 12px;

  font-weight: 500;
}

.notice-success {
  background: var(--success-bg);
  color: #15803d;
}

.history-filters {
  display: grid;

  grid-template-columns:
    minmax(150px, 200px)
    minmax(130px, 180px)
    minmax(130px, 180px)
    auto;

  align-items: end;

  gap: 15px;

  padding: 18px 22px;

  border-bottom: 1px solid var(--border);
}

.history-filters select {
  width: 100%;
  height: 43px;

  padding: 0 12px;

  border: 1px solid var(--border);

  border-radius: 8px;

  background: white;

  color: var(--text);

  font: inherit;

  font-size: 13px;
}

.history-filters select:focus {
  outline: none;

  border-color: var(--primary);
}

.history-filter-actions {
  display: flex;

  gap: 8px;
}

.history-filter-actions .btn-primary {
  min-width: 100px;
}

.history-filter-actions .btn-secondary {
  height: 43px;
}

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

.history-table {
  width: 100%;

  border-collapse: collapse;

  font-size: 12px;
}

.history-table th {
  padding: 11px 16px;

  border-bottom: 1px solid var(--border);

  background: #f9fafb;

  color: var(--muted);

  font-size: 10px;

  font-weight: 600;

  letter-spacing: 0.04em;

  text-align: left;

  text-transform: uppercase;

  white-space: nowrap;
}

.history-table td {
  padding: 13px 16px;

  border-bottom: 1px solid var(--border);

  vertical-align: middle;
}

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

.history-table tbody tr:hover {
  background: #fafafa;
}

.history-table .num {
  text-align: right;

  font-variant-numeric: tabular-nums;

  white-space: nowrap;
}

.history-table .nowrap {
  white-space: nowrap;
}

.history-message {
  max-width: 260px;

  margin-top: 5px;

  color: var(--danger);

  font-size: 11px;
}

.history-link {
  color: var(--primary);

  font-weight: 600;
}

.history-link:hover {
  text-decoration: underline;
}

.history-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;

  gap: 6px;

  white-space: nowrap;
}

.history-actions form {
  margin: 0;
}

.btn-icon-only {
  width: 34px;

  padding: 0;
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;

  padding: 50px 20px;

  color: var(--muted);
}

.history-empty p {
  margin: 0;

  font-size: 12px;
}

.history-empty a {
  color: var(--primary);

  font-weight: 600;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;

  gap: 12px;

  padding: 14px 22px;

  border-top: 1px solid var(--border);

  font-size: 12px;
}

.pagination-pages {
  display: flex;
  align-items: center;

  gap: 4px;
}

.page-link {
  min-width: 32px;
  height: 32px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0 8px;

  border: 1px solid var(--border);

  border-radius: 7px;

  background: white;

  color: #4b5563;

  font-weight: 600;
}

a.page-link:hover {
  background: #f9fafb;
}

.page-link.current {
  border-color: var(--primary);

  background: var(--primary);

  color: white;
}

.page-link.disabled {
  color: #d1d5db;
}

.page-gap {
  padding: 0 4px;

  color: var(--muted);
}

.per-page {
  display: flex;
  align-items: center;

  gap: 6px;

  margin: 0;
}

.per-page select {
  height: 32px;

  padding: 0 8px;

  border: 1px solid var(--border);

  border-radius: 7px;

  background: white;

  font: inherit;
}

/* Status counts row */

.status-counts {
  display: flex;
  flex-wrap: wrap;

  gap: 8px;

  padding: 12px 22px;

  border-bottom: 1px solid var(--border);

  background: #fafafa;
}

.status-chip {
  display: inline-flex;
  align-items: center;

  gap: 6px;

  padding: 5px 11px;

  border: 1px solid var(--border);

  border-radius: 20px;

  background: white;

  color: #4b5563;

  font-size: 12px;
}

.status-chip:hover {
  border-color: #c7cbd1;
}

.status-chip strong {
  color: var(--text);
}

.status-chip.active {
  border-color: var(--primary);

  background: rgba(79, 70, 229, 0.08);

  color: var(--primary);
}

.status-chip.empty {
  opacity: 0.55;
}

.status-chip-dot {
  width: 8px;
  height: 8px;

  border-radius: 50%;
}

.status-chip-success .status-chip-dot {
  background: var(--success);
}

.status-chip-partial .status-chip-dot {
  background: var(--warning);
}

.status-chip-no_data .status-chip-dot {
  background: #9ca3af;
}

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

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

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

@media (max-width: 650px) {
  .history-filters {
    grid-template-columns: 1fr;
  }

  .history-filter-actions .btn {
    flex: 1;
  }
}

/* =========================================================
   UPLOAD TO SERVER
========================================================= */

.notice-error {
  background: var(--danger-bg);
  color: #b91c1c;
}

.stat-value-small {
  font-size: 13px;

  line-height: 1.3;

  word-break: break-all;
}

.card-header code {
  padding: 1px 5px;

  border-radius: 4px;

  background: #f3f4f6;

  font-size: 11px;
}

.upload-row {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 20px;

  padding: 16px 22px;

  border-bottom: 1px solid var(--border);
}

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

.upload-info {
  display: flex;
  align-items: center;

  gap: 14px;

  min-width: 0;
}

.upload-info .stat-icon {
  font-size: 13px;
}

.upload-text {
  min-width: 0;
}

.upload-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;

  gap: 8px;

  font-weight: 600;

  word-break: break-all;
}

.upload-meta {
  margin-top: 2px;

  color: var(--muted);

  font-size: 12px;
}

.upload-tags {
  display: flex;
  flex-wrap: wrap;

  gap: 5px;

  margin-top: 7px;
}

.upload-tags .badge {
  min-height: 22px;
}

.upload-actions {
  display: flex;
  align-items: center;

  flex-shrink: 0;

  gap: 8px;
}

.upload-actions .btn-secondary {
  height: 43px;
}

.upload-form {
  margin: 0;
}

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

  .upload-actions .upload-form,
  .upload-actions .btn {
    flex: 1;
  }

  .upload-actions .btn-primary {
    width: 100%;
  }
}

/* =========================================================
   UPLOAD TRACKING
========================================================= */

.notice-warning {
  background: var(--warning-bg);
  color: #b45309;
}

.text-success {
  color: var(--success);
}

.upload-item {
  border-bottom: 1px solid var(--border);
}

.upload-item:last-child {
  border-bottom: 0;
}

.upload-item .upload-row {
  border-bottom: 0;
}

.upload-articles {
  margin: 0 22px 16px;

  border: 1px solid var(--border);

  border-radius: 9px;

  overflow: hidden;
}

.upload-articles summary {
  padding: 10px 14px;

  background: #f9fafb;

  color: #4b5563;

  font-size: 12px;

  font-weight: 600;

  cursor: pointer;
}

.upload-articles[open] summary {
  border-bottom: 1px solid var(--border);
}

.upload-articles .history-table td {
  padding: 10px 14px;
}

.upload-articles .history-table td .muted {
  font-size: 11px;

  word-break: break-all;
}

@media (max-width: 650px) {
  .upload-articles {
    margin: 0 15px 15px;
  }
}

/* =========================================================
   HISTORY SORTING
========================================================= */

.sort-link {
  color: inherit;
}

.sort-link:hover {
  color: var(--text);
}

.history-table th.sorted {
  color: var(--primary);
}

/* =========================================================
   SOURCE COVERAGE
========================================================= */

.text-warning {
  color: var(--warning);

  font-weight: 600;
}

.coverage-table tbody tr.coverage-gap {
  background: #fffbeb;
}

.coverage-table tbody tr.coverage-gap:hover {
  background: #fef3c7;
}

.coverage-missing {
  color: var(--warning);

  font-weight: 600;
}

.coverage-missing:hover {
  text-decoration: underline;
}

a.badge-error:hover {
  text-decoration: underline;
}

.import-coverage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;

  gap: 8px;

  padding: 12px 22px;

  border-top: 1px solid var(--border);

  font-size: 12px;
}

.import-coverage-label {
  color: var(--muted);
}

.coverage-recheck {
  margin-left: 4px;

  padding: 0;

  border: 0;

  background: none;

  color: var(--primary);

  font: inherit;

  font-size: 11px;

  font-weight: 600;

  cursor: pointer;
}

.coverage-recheck:hover {
  text-decoration: underline;
}

.coverage-recheck:disabled {
  color: var(--muted);

  cursor: not-allowed;

  text-decoration: none;
}

/* =========================================================
   IMPORT CALENDAR
========================================================= */

.cal-summary {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.cal-summary .stat-value {
  font-size: 18px;
}

.cal-summary-detail {
  display: block;

  margin-top: 6px;

  color: var(--muted);

  font-size: 11px;
}

.cal-title {
  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 2px;
}

.cal-title h2 {
  font-size: 17px;
}

.cal-title .history-link {
  font-size: 11px;
}

/* Status colours */

.cal-dot {
  width: 9px;
  height: 9px;

  display: inline-block;

  flex-shrink: 0;

  border-radius: 50%;
}

.cal-dot.cal-uploaded {
  background: var(--primary);
}

.cal-dot.cal-imported {
  background: var(--success);
}

.cal-dot.cal-nodata {
  background: #9ca3af;
}

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

.cal-dot.cal-missing {
  border: 2px solid var(--warning);

  background: transparent;
}

/* Legend */

.cal-legend {
  display: flex;
  flex-wrap: wrap;

  gap: 8px 18px;

  padding: 12px 22px;

  border-bottom: 1px solid var(--border);

  color: var(--muted);

  font-size: 11px;
}

.cal-legend > span {
  display: inline-flex;
  align-items: center;

  gap: 6px;
}

.cal-gap-sample {
  width: 14px;
  height: 10px;

  display: inline-block;

  border: 1px solid #fcd34d;

  border-radius: 3px;

  background: #fffbeb;
}

/* Grid */

.cal-grid {
  display: grid;

  grid-template-columns: repeat(7, minmax(0, 1fr));

  gap: 6px;

  padding: 16px;
}

.cal-weekday {
  padding: 4px 0;

  color: var(--muted);

  font-size: 10px;

  font-weight: 600;

  letter-spacing: 0.04em;

  text-align: center;

  text-transform: uppercase;
}

.cal-day {
  min-height: 96px;

  display: flex;
  flex-direction: column;

  gap: 6px;

  padding: 8px;

  border: 1px solid var(--border);

  border-radius: 9px;

  background: white;
}

.cal-empty {
  border: 0;

  background: transparent;
}

.cal-future {
  background: #f9fafb;

  color: #c0c4cc;
}

.cal-today {
  border-color: var(--primary);

  box-shadow: 0 0 0 1px var(--primary);
}

.cal-gap {
  border-color: #fcd34d;

  background: #fffbeb;
}

.cal-day-number {
  display: flex;
  align-items: center;
  justify-content: space-between;

  font-size: 12px;

  font-weight: 700;
}

.cal-today-label {
  padding: 1px 6px;

  border-radius: 10px;

  background: var(--primary);

  color: white;

  font-size: 9px;

  font-weight: 600;
}

.cal-sources {
  display: flex;
  flex-direction: column;

  gap: 3px;
}

.cal-source {
  display: flex;
  align-items: center;

  gap: 5px;

  padding: 2px 4px;

  border-radius: 5px;

  font-size: 11px;
}

.cal-source:hover {
  background: rgba(0, 0, 0, 0.05);
}

.cal-source-name {
  flex: 1;

  min-width: 0;

  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;
}

.cal-source-status {
  font-weight: 700;
}

.cal-source.cal-uploaded .cal-source-status {
  color: var(--primary);
}

.cal-source.cal-imported .cal-source-status {
  color: var(--success);
}

.cal-source.cal-nodata {
  color: var(--muted);
}

.cal-source.cal-failed .cal-source-status {
  color: var(--danger);
}

.cal-source.cal-missing {
  color: #b45309;
}

/* Narrow screens: dots only */

@media (max-width: 850px) {
  .cal-grid {
    gap: 4px;

    padding: 10px;
  }

  .cal-day {
    min-height: 64px;

    padding: 5px;
  }

  .cal-source-name,
  .cal-source-status {
    display: none;
  }

  .cal-sources {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .cal-source {
    padding: 3px;
  }

  .cal-today-label {
    display: none;
  }
}

/* =========================================================
   APPLIED FILTERS
========================================================= */

.applied-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;

  gap: 6px;

  margin-top: 8px;
}

.applied-filter {
  display: inline-flex;
  align-items: center;

  gap: 5px;

  padding: 3px 6px 3px 10px;

  border: 1px solid rgba(79, 70, 229, 0.3);

  border-radius: 20px;

  background: rgba(79, 70, 229, 0.06);

  color: var(--text);

  font-size: 11px;

  font-weight: 600;
}

.applied-filter .muted {
  font-weight: 500;
}

.applied-filter-x {
  width: 16px;
  height: 16px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  color: var(--muted);

  font-size: 9px;
}

.applied-filter:hover .applied-filter-x {
  background: var(--danger-bg);

  color: var(--danger);
}

.applied-filters .history-link {
  font-size: 11px;
}

/* =========================================================
   SIDEBAR SECTIONS, STEPS, BADGES, TODAY
========================================================= */

.nav-section {
  margin: 14px 13px 4px;

  color: #6b7280;

  font-size: 10px;

  font-weight: 600;

  letter-spacing: 0.08em;

  text-transform: uppercase;
}

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

.nav-label {
  flex: 1;
}

/* Numbered workflow steps */

.nav-step {
  width: 20px;
  height: 20px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border: 1.5px solid currentColor;

  border-radius: 50%;

  font-size: 11px;

  font-weight: 700;
}

.nav-item.active .nav-step {
  border-color: #818cf8;

  background: #6366f1;

  color: white;
}

/* Count badges */

.nav-badge {
  min-width: 20px;
  height: 20px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0 6px;

  border-radius: 10px;

  background: #6366f1;

  color: white;

  font-size: 10px;

  font-weight: 700;
}

.nav-badge-warning {
  background: var(--warning);
}

/* Today's status */

.sidebar-today {
  display: flex;
  flex-direction: column;

  gap: 6px;

  padding: 12px;

  border-radius: 10px;

  background: rgba(255, 255, 255, 0.04);

  transition: background 0.2s ease;
}

.sidebar-today:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-today-title {
  margin-bottom: 2px;

  color: #e5e7eb;

  font-size: 11px;

  font-weight: 600;
}

.sidebar-today-row {
  display: flex;
  align-items: center;

  gap: 8px;

  font-size: 11px;
}

.sidebar-today-source {
  flex: 1;

  color: #d1d5db;
}

.sidebar-today-status {
  color: #9ca3af;
}

/* =========================================================
   NEXT-STEP LINKS
========================================================= */

.result-actions {
  display: flex;
  flex-wrap: wrap;

  gap: 8px;

  margin-top: 14px;
}

.result-actions .btn-secondary {
  height: 43px;
}

.notice-link {
  margin-left: 6px;

  color: inherit;

  font-weight: 700;

  text-decoration: underline;
}

/* =========================================================
   ARTICLE FAQS (Publish page)
========================================================= */

.article-faqs {
  margin-top: 6px;
}

.article-faqs summary {
  color: var(--primary);

  font-size: 11px;

  font-weight: 600;

  cursor: pointer;
}

.article-faqs ol {
  margin: 8px 0 0;

  padding-left: 18px;
}

.article-faqs li {
  margin-bottom: 8px;

  font-size: 12px;
}

.faq-lang {
  display: flex;
  align-items: flex-start;

  gap: 6px;

  margin-bottom: 4px;
}

.faq-tag {
  flex-shrink: 0;

  padding: 1px 5px;

  border-radius: 4px;

  background: #f3f4f6;

  color: var(--muted);

  font-size: 9px;

  font-weight: 700;
}

/* =========================================================
   FAQ REVIEW
========================================================= */

.faq-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;

  gap: 16px 24px;

  padding: 18px 22px;
}

.faq-picker .form-group {
  flex: 1;

  min-width: 260px;

  max-width: 520px;
}

.faq-flag-toggle {
  display: inline-flex;
  align-items: center;

  gap: 8px;

  height: 43px;

  color: #4b5563;

  font-size: 12px;

  cursor: pointer;
}

.faq-head,
.faq-row {
  display: grid;

  grid-template-columns: 32px minmax(0, 1fr) minmax(0, 1fr);

  gap: 0 18px;

  padding: 0 22px;
}

.faq-head {
  padding-top: 10px;
  padding-bottom: 10px;

  border-bottom: 1px solid var(--border);

  background: #f9fafb;

  color: var(--muted);

  font-size: 10px;

  font-weight: 600;

  letter-spacing: 0.04em;

  text-transform: uppercase;
}

.faq-head span:first-child {
  grid-column: 2;
}

.faq-row {
  padding-top: 14px;
  padding-bottom: 14px;

  border-bottom: 1px solid var(--border);
}

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

.faq-flagged {
  background: #fffbeb;
}

.faq-number {
  color: var(--muted);

  font-size: 12px;

  font-weight: 700;
}

.faq-q {
  font-size: 13px;

  font-weight: 600;

  line-height: 1.45;
}

.faq-a {
  margin-top: 4px;

  color: var(--success);

  font-size: 13px;
}

.faq-a::before {
  content: "→ ";

  color: var(--muted);
}

.faq-flags {
  grid-column: 2 / -1;

  display: flex;
  flex-wrap: wrap;

  gap: 6px;

  margin-top: 10px;
}

.faq-tag-mobile {
  display: none;
}

@media (max-width: 650px) {
  .faq-head {
    display: none;
  }

  .faq-row {
    grid-template-columns: 24px minmax(0, 1fr);

    gap: 10px;

    padding-left: 15px;
    padding-right: 15px;
  }

  .faq-row .faq-cell + .faq-cell {
    grid-column: 2;
  }

  .faq-tag-mobile {
    display: inline-block;

    margin-bottom: 4px;
  }
}
