.papers-page {
  padding-top: 28px;
}

.papers-hero {
  min-height: 220px;
}

.paper-stats-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  min-height: 116px;
  padding: 18px 19px;
  border: 1px solid rgba(220, 231, 227, 0.92);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.stat-card span,
.stat-card strong,
.stat-card small {
  display: block;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stat-card strong {
  margin-top: 6px;
  color: var(--ink);
  font-size: 27px;
  line-height: 1.2;
  letter-spacing: -0.04em;
}

.stat-card small {
  margin-top: 7px;
  color: #91a19d;
  font-size: 11px;
}

.paper-query-card,
.paper-table-card,
.papers-note-card {
  margin-top: 20px;
}

.query-mode {
  margin: 0 22px 16px;
  padding: 4px;
  width: fit-content;
  display: flex;
  gap: 3px;
  border-radius: 10px;
  background: #eef4f2;
}

.mode-button {
  min-width: 88px;
  padding: 7px 12px;
  border: 0;
  border-radius: 8px;
  color: #62736f;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.mode-button.active {
  color: var(--primary-dark);
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(31, 63, 56, 0.09);
}

.paper-search-row {
  padding: 0 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 10px;
}

.search-field,
.paper-filter-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-field input,
.paper-filter-grid select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #ceddd8;
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: #ffffff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-field input:focus,
.paper-filter-grid select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 127, 111, 0.12);
}

.paper-query-card > .field-hint {
  margin: 9px 22px 0;
}

.paper-filter-grid {
  margin: 18px 22px 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.paper-manage-actions {
  padding: 18px 22px 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.paper-manage-actions .button {
  text-decoration: none;
}

.table-card-header {
  align-items: center;
}

.table-header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.result-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.paper-table-wrap {
  position: relative;
  min-height: 280px;
  margin: 0 16px;
  overflow-x: auto;
  border: 1px solid #e2ece9;
  border-radius: 15px;
  background: #ffffff;
}

.paper-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  table-layout: fixed;
}

.paper-table th,
.paper-table td {
  padding: 13px 11px;
  border-bottom: 1px solid #edf2f0;
  vertical-align: top;
  text-align: left;
  font-size: 12px;
}

.paper-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #4c615c;
  background: #f5f9f8;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

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

.paper-table tbody tr:hover {
  background: #fbfdfc;
}

.paper-table th:nth-child(1),
.paper-table td:nth-child(1) {
  width: 64px;
}

.paper-table th:nth-child(2),
.paper-table td:nth-child(2) {
  width: 280px;
}

.paper-table th:nth-child(3),
.paper-table td:nth-child(3) {
  width: 150px;
}

.paper-table th:nth-child(4),
.paper-table td:nth-child(4),
.paper-table th:nth-child(5),
.paper-table td:nth-child(5) {
  width: 78px;
}

.paper-table th:nth-child(6),
.paper-table td:nth-child(6) {
  width: 180px;
}

.paper-table th:nth-child(7),
.paper-table td:nth-child(7) {
  width: 110px;
}

.paper-table th:nth-child(8),
.paper-table td:nth-child(8) {
  width: 86px;
}

.paper-table th:nth-child(9),
.paper-table td:nth-child(9) {
  width: 180px;
}

.paper-title-button {
  padding: 0;
  text-decoration: none;
  border: 0;
  color: var(--primary-dark);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.55;
  text-align: left;
}

.paper-title-button:hover {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.paper-table .muted {
  color: #93a29e;
}

.author-cell {
  color: #5c706b;
  line-height: 1.55;
}

.keyword-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.keyword-chip {
  max-width: 160px;
  padding: 3px 7px;
  overflow: hidden;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  padding: 3px 8px;
  display: inline-block;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.active {
  color: #087354;
  background: #e0f5e9;
}

.status-badge.pending {
  color: #9a650e;
  background: #fff3d8;
}

.status-badge.failed {
  color: #a33e2d;
  background: #ffebe6;
}

.table-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mini-link {
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

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

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.row-action {
  display: inline-flex;
  align-items: center;
  padding: 4px 7px;
  text-decoration: none;
  border: 1px solid #d8e5e1;
  border-radius: 7px;
  color: #506762;
  background: #ffffff;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.row-action:hover {
  border-color: #a9d3c9;
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.row-action.danger:hover {
  border-color: #f0b6a8;
  color: #a33e2d;
  background: #fff0eb;
}

.table-loading,
.empty-block {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: rgba(255, 255, 255, 0.94);
}

.pagination-bar {
  padding: 18px 20px 20px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.page-size-control {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.page-size-control select {
  height: 34px;
  padding: 0 8px;
  border: 1px solid #d4e2de;
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
}

.page-info {
  color: var(--muted);
  font-size: 12px;
}

.page-buttons {
  display: flex;
  align-items: center;
  gap: 5px;
}

.page-button {
  min-width: 33px;
  height: 33px;
  padding: 0 8px;
  border: 1px solid #d7e5e1;
  border-radius: 8px;
  color: #536762;
  background: #ffffff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.page-button:hover:not(:disabled),
.page-button.active {
  border-color: #9ecdbd;
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.page-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(18, 39, 35, 0.42);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: min(86vh, 860px);
  overflow: auto;
  border: 1px solid rgba(220, 231, 227, 0.95);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(13, 47, 40, 0.24);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: #667a75;
  background: #f0f5f3;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.modal-header {
  padding: 24px 56px 15px 24px;
  border-bottom: 1px solid #e7efec;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.025em;
}

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

.modal-footer {
  padding: 0 24px 23px;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.form-field {
  display: grid;
  gap: 6px;
  color: #536762;
  font-size: 12px;
  font-weight: 700;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #ceddd8;
  border-radius: 9px;
  outline: none;
  color: var(--ink);
  background: #ffffff;
  font-size: 13px;
}

.form-field textarea {
  min-height: 94px;
  resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 127, 111, 0.12);
}

.form-help {
  color: #8a9b97;
  font-size: 11px;
  font-weight: 400;
}

.modal-message {
  margin: 0;
  color: #526762;
  font-size: 13px;
  line-height: 1.8;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-block {
  padding: 12px 13px;
  border: 1px solid #e3ece9;
  border-radius: 11px;
  background: #f8fbfa;
}

.detail-block.full {
  grid-column: 1 / -1;
}

.detail-block span,
.detail-block strong {
  display: block;
}

.detail-block span {
  color: var(--muted);
  font-size: 11px;
}

.detail-block strong {
  margin-top: 3px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.7;
}

.batch-result {
  margin-top: 16px;
  display: grid;
  gap: 9px;
}

.batch-summary {
  padding: 12px 13px;
  border-radius: 11px;
  background: #f4f8f7;
  color: #526762;
  font-size: 12px;
}

.batch-item {
  padding: 9px 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #e5eeeb;
  border-radius: 9px;
  font-size: 11px;
}

.batch-item span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-status.success {
  color: #087354;
}

.batch-status.duplicate {
  color: #9a650e;
}

.batch-status.failed {
  color: #a33e2d;
}

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

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

@media (max-width: 720px) {
  .paper-stats-grid,
  .paper-filter-grid,
  .papers-note-grid,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .full,
  .detail-block.full {
    grid-column: auto;
  }

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

  .paper-search-row .button {
    width: 100%;
  }

  .paper-manage-actions .button {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
  }

  .pagination-bar {
    align-items: flex-start;
    flex-direction: column;
  }
}
