body {
  padding-top: 76px;
  background: #f8f9fa;
}

.app-navbar {
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
}

.nav-button {
  border: 1px solid #dee2e6;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.875rem;
  color: #495057;
}

.nav-pills .nav-link.nav-button.active {
  color: #fff;
  background: #0d6efd;
  border-color: #0d6efd;
}

.nav-button:hover {
  background: #f1f3f5;
}

.nav-pills .nav-link.nav-button.dropdown-toggle.active {
  color: #fff;
}

.page-shell {
  max-width: 1600px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.stat-box {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 12px 14px;
}

.stat-box span {
  display: block;
  color: #6c757d;
  font-size: 0.875rem;
}

.stat-box strong {
  display: block;
  font-size: 1.4rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, auto) minmax(150px, auto) auto auto;
  gap: 8px;
}

.records-filter-card {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 1rem;
}

.records-search-row,
.records-filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.records-search-input {
  flex: 1 1 320px;
  min-width: 220px;
}

.records-filter-form input,
.records-filter-form select,
.records-filter-form button,
.records-filter-form a.btn {
  min-width: 180px;
}

.records-filter-form button,
.records-filter-form a.btn {
  width: auto;
}

.records-table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.records-table {
  min-width: 1400px;
  table-layout: auto;
  background: #fff;
}

.records-table th,
.records-table td {
  vertical-align: middle;
  word-break: normal;
  overflow-wrap: normal;
  white-space: normal;
}

.records-table th {
  white-space: nowrap;
}

.records-table td.comment-cell,
.records-table td.trading-cell,
.records-table td.returned-cell,
.records-table td.extra-info-cell {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
}

.records-table td.date-cell {
  min-width: 140px;
  white-space: nowrap;
}

.records-table td.company-cell {
  min-width: 140px;
}

.records-table td.department-cell {
  min-width: 160px;
}

.records-table td.employee-cell {
  min-width: 160px;
}

.records-table td.comment-cell {
  min-width: 420px;
}

.records-table td.minutes-cell {
  min-width: 80px;
  text-align: center;
  white-space: nowrap;
}

.records-table td.trading-cell,
.records-table td.returned-cell {
  min-width: 180px;
}

.records-table td.extra-info-cell {
  min-width: 160px;
}

.import-preview-table {
  min-width: 1700px;
  table-layout: auto;
}

.import-preview-table th,
.import-preview-table td {
  vertical-align: middle;
  word-break: normal;
  overflow-wrap: normal;
  white-space: normal;
}

.import-preview-table th,
.import-preview-table .row-number-cell,
.import-preview-table .legacy-id-cell,
.import-preview-table .date-cell,
.import-preview-table .minutes-cell,
.import-preview-table .state-cell {
  white-space: nowrap;
}

.import-preview-table .department-cell,
.import-preview-table .employee-cell,
.import-preview-table .user-cell {
  min-width: 160px;
}

.import-preview-table .comment-cell {
  min-width: 420px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.import-preview-table .trading-cell,
.import-preview-table .returned-cell,
.import-preview-table .extra-info-cell,
.import-preview-table .messages-cell {
  min-width: 180px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.clickable-row {
  cursor: pointer;
}

.record-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 16px;
}

.record-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.detail-list {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px 14px;
  margin-bottom: 0;
}

.detail-list dt {
  color: #6c757d;
  font-weight: 500;
}

.detail-list dd {
  margin: 0;
  min-width: 0;
}

.record-text {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.record-extra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.restore-upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.restore-upload-form input[type="file"] {
  flex: 1 1 280px;
}

.backup-count-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.backup-count-grid div {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8f9fa;
}

.backup-count-grid span {
  display: block;
  color: #6c757d;
  font-size: 0.85rem;
}

.backup-count-grid strong {
  display: block;
  font-size: 1.2rem;
}

.record-form,
.detail-grid,
.summary-block {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px 16px;
}

.detail-grid dt {
  color: #6c757d;
}

.detail-grid dd {
  margin: 0;
  white-space: pre-wrap;
}

.summary-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.attachment-upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.attachment-upload-form input[type="file"] {
  min-width: 280px;
}

.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.attachment-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.attachment-thumb {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #dee2e6;
}

.attachment-icon {
  width: 96px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  background: #f8f9fa;
  color: #495057;
  font-weight: 700;
  font-size: 0.85rem;
}

.attachment-meta {
  min-width: 0;
  flex: 1;
}

.attachment-name {
  font-weight: 600;
  overflow-wrap: break-word;
}

.attachment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

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

  .record-detail-grid {
    grid-template-columns: 1fr;
  }

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