* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: Arial, sans-serif;
  background: #f3f5f8;
  color: #172033;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 430px;
  padding: 38px;
  background: #ffffff;
  border: 1px solid #e2e7ee;
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(15, 31, 54, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 38px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #0b1f3a;
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
}

.brand h1 {
  font-size: 17px;
  line-height: 1.3;
}

.brand p {
  margin-top: 3px;
  color: #718096;
  font-size: 13px;
}

.login-heading {
  margin-bottom: 26px;
}

.login-heading h2 {
  font-size: 25px;
  margin-bottom: 7px;
}

.login-heading p {
  color: #64748b;
  font-size: 14px;
  line-height: 1.5;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
}

.form-group input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid #cfd7e3;
  border-radius: 9px;
  outline: none;
  font-size: 14px;
}

.form-group input:focus {
  border-color: #0b1f3a;
  box-shadow: 0 0 0 3px rgba(11, 31, 58, 0.08);
}

button {
  width: 100%;
  height: 46px;
  margin-top: 4px;
  border: 0;
  border-radius: 9px;
  background: #0b1f3a;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #142f52;
}

.login-message {
  min-height: 20px;
  margin-top: 14px;
  color: #c0392b;
  text-align: center;
  font-size: 13px;
}

.security-note {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid #e8ecf1;
  color: #7a8798;
  text-align: center;
  font-size: 12px;
}

.login-message.success {
  color: #16814b;
}

.login-message.error {
  color: #c0392b;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.hidden {
  display: none !important;
}

.platform-page {
  min-height: 100vh;
  display: flex;
  background: #f4f6f9;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 245px;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  background: #0b1f3a;
  color: #ffffff;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand .brand-icon {
  background: #ffffff;
  color: #0b1f3a;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand strong {
  font-size: 15px;
}

.sidebar-brand span {
  margin-top: 3px;
  color: #aebdd0;
  font-size: 11px;
}

.sidebar-menu {
  display: grid;
  gap: 7px;
  margin-top: 28px;
}

.nav-item {
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  height: auto;
  border-radius: 8px;
  background: transparent;
  color: #bfcbd9;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-item:disabled {
  cursor: default;
  opacity: 0.45;
}

.sidebar-user {
  margin-top: auto;
  padding: 20px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-user strong,
.sidebar-user span {
  display: block;
}

.sidebar-user strong {
  font-size: 14px;
}

.sidebar-user span {
  margin-top: 4px;
  color: #aebdd0;
  font-size: 12px;
}

.logout-button {
  height: 38px;
  margin-top: 15px;
  background: rgba(255, 255, 255, 0.09);
  font-size: 12px;
}

.platform-content {
  width: calc(100% - 245px);
  margin-left: 245px;
  padding: 38px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
}

.eyebrow {
  margin-bottom: 8px;
  color: #58718f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

.page-header h1 {
  font-size: 29px;
}

.page-header > div > p:last-child {
  margin-top: 7px;
  color: #6b7788;
  font-size: 14px;
}

.primary-action {
  width: auto;
  min-width: 150px;
  padding: 0 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 30px;
}

.summary-card {
  padding: 21px;
  background: #ffffff;
  border: 1px solid #e1e6ed;
  border-radius: 12px;
}

.summary-card span {
  display: block;
  color: #6d7988;
  font-size: 12px;
}

.summary-card strong {
  display: block;
  margin-top: 10px;
  color: #15243a;
  font-size: 27px;
}

.table-card {
  margin-top: 22px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #e1e6ed;
  border-radius: 12px;
}

.table-heading {
  padding: 21px 22px;
  border-bottom: 1px solid #e8ecf1;
}

.table-heading h2 {
  font-size: 17px;
}

.table-heading p {
  margin-top: 5px;
  color: #738092;
  font-size: 12px;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid #edf0f4;
  text-align: left;
  font-size: 12px;
}

th {
  background: #fafbfc;
  color: #687588;
  font-weight: 600;
}

td {
  color: #3a4656;
}

.dataset-name strong,
.dataset-name span {
  display: block;
}

.dataset-name strong {
  color: #15243a;
  font-size: 13px;
}

.dataset-name span {
  margin-top: 4px;
  color: #8a95a4;
  font-size: 11px;
}

.source-badge,
.status-badge {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 20px;
  background: #eef3f8;
  color: #405c79;
  font-size: 11px;
}

.status-badge {
  background: #e9f7ef;
  color: #177245;
}

.table-message {
  height: 100px;
  color: #7c8796;
  text-align: center;
}

@media (max-width: 950px) {
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .sidebar {
    position: static;
    width: 100%;
  }

  .platform-page {
    display: block;
  }

  .platform-content {
    width: 100%;
    margin-left: 0;
    padding: 24px;
  }

  .sidebar-menu {
    display: none;
  }

  .sidebar-user {
    margin-top: 22px;
  }

  .page-header {
    display: block;
  }

  .primary-action {
    margin-top: 20px;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 20, 38, 0.65);
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 28px;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}

.modal-header h2 {
  font-size: 23px;
}

.modal-header > div > p:last-child {
  margin-top: 7px;
  color: #6b7788;
  font-size: 13px;
}

.close-button {
  width: 35px;
  min-width: 35px;
  height: 35px;
  margin: 0;
  padding: 0;
  background: #eef1f5;
  color: #39485b;
  font-size: 23px;
  line-height: 1;
}

.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #cfd7e3;
  border-radius: 9px;
  outline: none;
  background: #ffffff;
  font: inherit;
  font-size: 14px;
}

.form-group select:focus,
.form-group textarea:focus {
  border-color: #0b1f3a;
  box-shadow: 0 0 0 3px rgba(11, 31, 58, 0.08);
}

.form-group textarea {
  resize: vertical;
}

.optional-label {
  color: #8b96a4;
  font-size: 11px;
  font-weight: 400;
}

.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.file-drop-area {
  display: grid !important;
  gap: 7px;
  place-items: center;
  min-height: 105px;
  padding: 20px;
  border: 1px dashed #9eacbd;
  border-radius: 10px;
  background: #f8fafc;
  color: #263b55;
  text-align: center;
  cursor: pointer;
}

.file-drop-area span {
  color: #788596;
  font-size: 12px;
  font-weight: 400;
}

.upload-notice {
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff8e8;
  color: #765512;
  font-size: 12px;
  line-height: 1.5;
}

.upload-message {
  min-height: 20px;
  margin-top: 14px;
  font-size: 13px;
}

.upload-message.success {
  color: #16814b;
}

.upload-message.error {
  color: #c0392b;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.modal-actions button {
  width: auto;
  min-width: 115px;
  padding: 0 17px;
}

.secondary-button {
  border: 1px solid #cfd7e3;
  background: #ffffff;
  color: #37475b;
}

.secondary-button:hover {
  background: #f3f5f8;
}

.submit-upload-button {
  background: #0b1f3a;
}

.cleaning-modal-card {
  max-width: 680px;
}

.cleaning-section {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  padding: 18px 0;
  border-bottom: 1px solid #e8ecf1;
}

.section-number {
  width: 29px;
  min-width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #0b1f3a;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

.cleaning-section-content {
  flex: 1;
}

.cleaning-section-content > label {
  display: block;
  color: #172033;
  font-size: 14px;
  font-weight: 700;
}

.cleaning-section-content > p {
  margin: 5px 0 13px;
  color: #748092;
  font-size: 12px;
}

.cleaning-section-content select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #cfd7e3;
  border-radius: 8px;
  background: #ffffff;
  font-size: 13px;
}

.reference-list {
  max-height: 230px;
  overflow-y: auto;
  border: 1px solid #dbe1e9;
  border-radius: 9px;
}

.reference-message {
  padding: 25px;
  color: #7c8796;
  text-align: center;
  font-size: 12px;
}

.reference-option {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px;
  border-bottom: 1px solid #edf0f4;
  cursor: pointer;
}

.reference-option:last-child {
  border-bottom: 0;
}

.reference-option:hover {
  background: #f7f9fb;
}

.reference-option input {
  width: 16px;
  height: 16px;
}

.reference-details {
  flex: 1;
}

.reference-details strong,
.reference-details span {
  display: block;
}

.reference-details strong {
  color: #25364c;
  font-size: 13px;
}

.reference-details span {
  margin-top: 4px;
  color: #7c8796;
  font-size: 11px;
}

.matching-rule-box {
  display: grid;
  gap: 5px;
  margin-top: 19px;
  padding: 13px 15px;
  border-radius: 8px;
  background: #eef4fa;
  color: #35516f;
}

.matching-rule-box strong {
  font-size: 12px;
}

.matching-rule-box span {
  font-size: 12px;
  line-height: 1.5;
}

.cleaning-results {
  margin-top: 20px;
}

.cleaning-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.cleaning-summary article {
  padding: 13px;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #f8fafc;
}

.cleaning-summary span,
.cleaning-summary strong {
  display: block;
}

.cleaning-summary span {
  color: #758195;
  font-size: 11px;
}

.cleaning-summary strong {
  margin-top: 6px;
  color: #172a43;
  font-size: 20px;
}

.preview-table-wrapper {
  max-height: 250px;
  margin-top: 12px;
  overflow: auto;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
}

.preview-table {
  min-width: 750px;
}

.preview-table th,
.preview-table td {
  padding: 11px 12px;
  font-size: 11px;
}

.preview-result {
  display: inline-block;
  padding: 4px 7px;
  border-radius: 20px;
  font-size: 10px;
}

.preview-result.cleaned {
  background: #e7f7ee;
  color: #177245;
}

.preview-result.excluded {
  background: #fdecec;
  color: #b33a3a;
}

.result-download-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.result-download-actions button {
  width: auto;
  min-width: 165px;
  padding: 0 15px;
}

.history-download {
    display: flex;
    gap: 6px;
}

.history-download-button {
    width: auto;
    height: 29px;
    margin: 0;
    padding: 0 9px;
    border: 1px solod #ccd6e2;
    border-radius: 6px;
    background: #ffffff;
    color: #29425f;
    font-size: 10px;
}

.history-download-button:hover {
    background: #eef3f8;
}

.no-result-files {
    color: #929ca9;
    font-size: 11px;
}

.dataset-action-button {
  width: auto;
  height: 30px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid #ccd6e2;
  border-radius: 6px;
  background: #ffffff;
  color: #29425f;
  font-size: 10px;
}

.dataset-action-button:hover {
  background: #eef3f8;
}

.dataset-actions {
  display: flex;
  gap: 6px;
}

.versions-modal-card {
  max-width: 850px;
}

.versions-table-wrapper {
  max-height: 420px;
  border: 1px solid #e1e6ed;
  border-radius: 9px;
}

.version-label strong,
.version-label span {
  display: block;
}

.version-label span {
  margin-top: 4px;
  color: #16814b;
  font-size: 10px;
}

.version-download-button {
  width: auto;
  height: 29px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid #ccd6e2;
  background: #ffffff;
  color: #29425f;
  font-size: 10px;
}

.version-download-button:hover {
  background: #eef3f8;
}

/* Upload source chooser */

.upload-choice-modal {
  max-width: 620px;
}

.upload-source-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 24px;
}

.upload-source-option {
  width: 100%;
  height: auto;
  min-height: 125px;
  margin: 0;
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  border: 1px solid #d7dee8;
  background: #ffffff;
  color: #172a43;
  text-align: left;
}

.upload-source-option:hover {
  border-color: #8fa2b9;
  background: #f7f9fc;
}

.upload-source-option strong {
  font-size: 15px;
}

.upload-source-option span {
  color: #6f7d8e;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}


/* Vertically center table content and actions */

th,
td {
  vertical-align: middle;
}

.dataset-actions {
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

#libraryTable th:last-child,
#libraryTable td:last-child {
  min-width: 360px;
  text-align: center !important;
  vertical-align: middle;
}

#libraryTable .dataset-actions {
  width: max-content;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Small-screen upload chooser */

@media (max-width: 600px) {
  .upload-source-options {
    grid-template-columns: 1fr;
  }
}