.cdm-login-required {
  padding: 22px;
  border: 1px solid #d9e2ec;
  border-radius: 14px;
  background: #f7fafc;
  color: #334e68;
  text-align: center;
}

.cdm-app,
.cdm-app * {
  box-sizing: border-box;
}

.cdm-app {
  --ink: #102a43;
  --muted: #627d98;
  --line: #d9e2ec;
  --paper: #ffffff;
  --background: #f5f8fb;
  --blue: #2563eb;
  --navy: #0f2747;
  font-family: "Noto Sans Thai", "Sarabun", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
  padding: 28px;
  border-radius: 24px;
}

.cdm-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 30px;
  border-radius: 20px;
  background: linear-gradient(135deg, #0f2747 0%, #173f70 58%, #1d5d83 100%);
  color: #ffffff;
  box-shadow: 0 16px 36px rgba(15, 39, 71, 0.16);
}

.cdm-eyebrow {
  margin-bottom: 8px;
  color: #9fdef7;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.cdm-hero h1 {
  margin: 0 0 8px;
  color: #ffffff;
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 800;
  line-height: 1.16;
}

.cdm-hero p {
  margin: 0;
  color: #d8e8f5;
  font-size: 14px;
}

.cdm-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cdm-mode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.cdm-mode span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6ee7b7;
  box-shadow: 0 0 0 4px rgba(110, 231, 183, 0.14);
}

.cdm-add-button {
  min-height: 38px;
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: #ffffff;
  color: #12345a;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.cdm-alert {
  margin-top: 14px;
  padding: 12px 15px;
  border: 1px solid #badbcc;
  border-radius: 12px;
  background: #e9f8f1;
  color: #176b52;
  font-size: 13px;
}

.cdm-alert-error {
  border-color: #f1b7b3;
  background: #fff0ef;
  color: #a62e28;
}

.cdm-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.cdm-kpi {
  padding: 18px 20px;
  border: 1px solid #e5edf4;
  border-top: 4px solid var(--blue);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 8px 22px rgba(15, 39, 71, 0.06);
}

.cdm-kpi span,
.cdm-kpi small {
  display: block;
  color: var(--muted);
}

.cdm-kpi span {
  font-size: 13px;
  font-weight: 700;
}

.cdm-kpi strong {
  display: block;
  margin: 12px 0 8px;
  color: var(--navy);
  font-size: 34px;
  line-height: 1;
}

.cdm-kpi small {
  font-size: 11px;
}

.cdm-kpi-red {
  border-top-color: #ef5350;
}

.cdm-kpi-amber {
  border-top-color: #f59e0b;
}

.cdm-kpi-slate {
  border-top-color: #64748b;
}

.cdm-panel {
  padding: 18px;
  border: 1px solid #e4ebf2;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 10px 30px rgba(15, 39, 71, 0.07);
}

.cdm-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.7fr) repeat(4, minmax(125px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.cdm-toolbar label {
  display: block;
  min-width: 0;
}

.cdm-label {
  display: block;
  margin: 0 0 6px 3px;
  color: #52697f;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.cdm-toolbar input,
.cdm-toolbar select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #ced9e4;
  border-radius: 11px;
  outline: none;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.cdm-toolbar input:focus,
.cdm-toolbar select:focus,
.cdm-form-grid input:focus,
.cdm-form-grid select:focus,
.cdm-form-grid textarea:focus {
  border-color: #4d88ee;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.11);
}

.cdm-reset {
  height: 42px;
  padding: 0 14px;
  border: 1px solid #c9d5e2;
  border-radius: 11px;
  background: #f7f9fc;
  color: #334e68;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.cdm-table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 2px 10px;
  color: var(--muted);
  font-size: 12px;
}

.cdm-contact-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.cdm-contact-toggle input {
  accent-color: var(--blue);
}

.cdm-table-wrap {
  position: relative;
  overflow: auto;
  border: 1px solid #dce5ed;
  border-radius: 14px;
}

.cdm-table {
  width: 100%;
  min-width: 1420px;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
  font-size: 12px;
}

.cdm-table caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.cdm-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid #ccd8e3;
  background: #f0f4f8;
  color: #334e68;
  text-align: left;
  white-space: nowrap;
}

.cdm-table th:first-child {
  left: 0;
  z-index: 3;
}

.cdm-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 180px;
  background: #ffffff;
  color: var(--navy);
  font-weight: 800;
}

.cdm-table th button {
  width: 100%;
  padding: 13px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.cdm-table th button:hover {
  color: var(--blue);
}

.cdm-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf1f5;
  vertical-align: top;
  white-space: nowrap;
}

.cdm-table tbody tr:hover td,
.cdm-table tbody tr:hover td:first-child {
  background: #f8fbff;
}

.cdm-domain {
  color: #1d5fbf;
  font-weight: 700;
  text-decoration: none;
}

.cdm-domain:hover {
  text-decoration: underline;
}

.cdm-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: #526577;
  font-size: 10px;
  font-weight: 800;
}

.cdm-pill::before {
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.cdm-pill-green {
  background: #e6f6f1;
  color: #147d64;
}

.cdm-pill-amber {
  background: #fff4d6;
  color: #9c5b08;
}

.cdm-pill-red {
  background: #fdeceb;
  color: #b3312b;
}

.cdm-pill-gray {
  background: #edf2f6;
  color: #66788a;
}

.cdm-note {
  max-width: 240px;
  color: #627d98;
  white-space: normal !important;
}

.cdm-fee {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cdm-contact-col {
  display: none;
}

.cdm-show-contacts .cdm-contact-col {
  display: table-cell;
}

.cdm-action-col {
  width: 76px;
  text-align: center !important;
}

.cdm-edit-button {
  padding: 6px 10px;
  border: 1px solid #b9cce0;
  border-radius: 8px;
  background: #ffffff;
  color: #1d5fbf;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.cdm-empty {
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
}

.cdm-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.cdm-pagination button {
  padding: 8px 12px;
  border: 1px solid #ced9e4;
  border-radius: 9px;
  background: #ffffff;
  color: #334e68;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.cdm-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

body.cdm-modal-open {
  overflow: hidden;
}

.cdm-modal[hidden] {
  display: none;
}

.cdm-modal {
  position: fixed;
  z-index: 999999;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.cdm-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 25, 45, 0.66);
  backdrop-filter: blur(3px);
}

.cdm-modal-card {
  position: relative;
  z-index: 1;
  width: min(820px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 28px 70px rgba(8, 25, 45, 0.3);
}

.cdm-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  background: #102d50;
  color: #ffffff;
}

.cdm-modal-header h2 {
  margin: 0;
  color: #ffffff;
  font-size: 24px;
}

.cdm-close {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.cdm-modal form {
  padding: 22px 24px 24px;
}

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

.cdm-form-grid label {
  display: block;
  min-width: 0;
}

.cdm-form-grid label > span {
  display: block;
  margin: 0 0 6px 2px;
  color: #334e68;
  font-size: 12px;
  font-weight: 800;
}

.cdm-form-grid input,
.cdm-form-grid select,
.cdm-form-grid textarea {
  width: 100%;
  border: 1px solid #cbd7e2;
  border-radius: 10px;
  outline: none;
  background: #ffffff;
  color: #102a43;
  font: inherit;
  font-size: 13px;
}

.cdm-form-grid input,
.cdm-form-grid select {
  height: 42px;
  padding: 0 11px;
}

.cdm-form-grid textarea {
  padding: 10px 11px;
  resize: vertical;
}

.cdm-form-grid small {
  display: block;
  margin-top: 5px;
  color: #9c5b08;
  font-size: 10px;
}

.cdm-form-wide {
  grid-column: 1 / -1;
}

.cdm-form-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #e5ebf1;
}

.cdm-form-actions button {
  min-height: 40px;
  padding: 8px 15px;
  border-radius: 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.cdm-archive {
  border: 1px solid #efc0bc;
  background: #fff5f4;
  color: #aa332d;
}

.cdm-cancel {
  border: 1px solid #cad5df;
  background: #ffffff;
  color: #52697f;
}

.cdm-save {
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #ffffff;
}

.cdm-form-actions button:disabled {
  opacity: 0.55;
  cursor: wait;
}

@media (max-width: 1024px) {
  .cdm-kpis {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .cdm-search {
    grid-column: 1 / -1;
  }

  .cdm-reset {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .cdm-app {
    padding: 14px;
    border-radius: 16px;
  }

  .cdm-hero {
    display: block;
    padding: 22px;
  }

  .cdm-hero-actions {
    align-items: flex-start;
    margin-top: 16px;
  }

  .cdm-kpis {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .cdm-kpi {
    padding: 14px;
  }

  .cdm-kpi strong {
    font-size: 28px;
  }

  .cdm-toolbar,
  .cdm-form-grid {
    grid-template-columns: 1fr;
  }

  .cdm-search,
  .cdm-form-wide {
    grid-column: auto;
  }

  .cdm-table-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .cdm-pagination {
    justify-content: space-between;
  }

  .cdm-modal {
    padding: 8px;
  }

  .cdm-modal-card {
    max-height: calc(100vh - 16px);
  }

  .cdm-modal form,
  .cdm-modal-header {
    padding: 18px;
  }

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

  .cdm-form-actions > div {
    display: none;
  }
}
