.rate-main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px;
}

.account-panel,
.account-header,
.services-panel {
  margin-top: 20px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.account-search {
  display: grid;
  grid-template-columns:
    minmax(260px, .8fr)
    minmax(360px, 1.4fr);
  gap: 18px;
}

.account-search label,
.rate-modal label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.account-search input,
.account-search select,
.rate-modal input,
.rate-modal select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.account-header {
  display: grid;
  grid-template-columns: minmax(260px, .6fr) 1.6fr;
  align-items: start;
  gap: 24px;
}

.account-header h2 {
  margin: 5px 0;
}

.account-header p {
  margin: 0;
  color: var(--muted);
}

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

.kpi-row article {
  min-height: 112px;
  padding: 16px;
  border-radius: 12px;
  background: #f5f8fb;
}

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

.kpi-row strong {
  display: block;
  margin: 8px 0 5px;
  font-size: 1.5rem;
  color: var(--navy);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
}

.panel-heading h3 {
  margin: 0 0 4px;
}

.panel-heading p {
  margin: 0;
  color: var(--muted);
}

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

.rate-table {
  width: 100%;
  border-collapse: collapse;
}

.rate-table th,
.rate-table td {
  padding: 13px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.rate-table th {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.rate-table td.number,
.rate-table th.number {
  text-align: right;
}

.rate-table td.strong {
  font-weight: 800;
}

.service-id {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.edit-button {
  padding: 8px 12px;
  white-space: nowrap;
}

.status-pill {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-pill.active {
  color: #08754f;
  background: #e6f7f0;
}

.status-pill.inactive {
  color: #7a271a;
  background: #feeceb;
}

.inactive-row {
  opacity: .58;
}

.rate-message {
  margin-top: 18px;
  padding: 13px 16px;
  border-radius: 10px;
  color: #08754f;
  background: #e6f7f0;
}

.rate-message.error {
  color: #b42318;
  background: #feeceb;
}

.rate-modal {
  width: min(760px, 100%);
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .account-search,
  .account-header,
  .kpi-row,
  .form-grid.three {
    grid-template-columns: 1fr;
  }
}


/* =========================================================
   RATE CARD MODAL / WINDOW FIX
   ========================================================= */

.modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1000 !important;

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

  width: 100vw !important;
  height: 100vh !important;

  padding: 24px !important;

  overflow: auto !important;

  background: rgba(10, 27, 52, 0.55) !important;
  backdrop-filter: blur(2px);
}

.modal.hidden {
  display: none !important;
}

.modal-card {
  position: relative;

  width: min(760px, 95vw);
  max-height: 90vh;

  padding: 26px;

  overflow-y: auto;

  border-radius: 18px;
  background: #fff;

  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.28);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  gap: 20px;

  margin-bottom: 22px;
}

.modal-heading h2 {
  margin: 4px 0 0;
}

.close-button,
#closeAddService,
#closeMasterProducts,
#closeMasterProductEdit {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 40px;
  height: 40px;

  padding: 0;

  border: 0;
  border-radius: 9px;

  font-size: 24px;
  line-height: 1;

  cursor: pointer;
}

.rate-modal form {
  display: grid;
  gap: 18px;
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;

  margin-top: 8px;
  padding-top: 18px;

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


/* MASTER PRODUCTS = LARGE WINDOW */

.master-products-modal {
  z-index: 1000 !important;
}

.master-products-window {
  position: relative;

  display: flex;
  flex-direction: column;

  width: min(1500px, 96vw) !important;
  height: min(850px, 92vh) !important;

  margin: 0 !important;

  overflow: hidden;

  border-radius: 18px;
  background: #fff;

  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.30);
}

.master-window-header {
  flex: 0 0 auto;
}

.master-toolbar {
  flex: 0 0 auto;
}

.master-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}


/* Product editor must appear above Master Products */

.master-edit-modal {
  z-index: 1200 !important;
}


/* Stop page scrolling while a window is open */

body.modal-open {
  overflow: hidden;
}


@media (max-width: 800px) {

  .modal {
    padding: 10px !important;
  }

  .modal-card {
    width: 100%;
    max-height: 96vh;
  }

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

  .master-products-window {
    width: 100% !important;
    height: 96vh !important;
  }

}


/* =========================================================
   MASTER PRODUCTS - POLISHED APPLICATION WINDOW
   ========================================================= */

.master-products-modal {
  padding: 32px !important;
  background: rgba(17, 35, 58, .62) !important;
}

.master-products-window {
  width: min(1440px, 96vw) !important;
  height: min(860px, 92vh) !important;

  border: 1px solid #d9e2ec;
  border-radius: 16px !important;

  background: #ffffff;

  box-shadow:
    0 32px 90px rgba(15, 35, 60, .32) !important;
}


/* Header */

.master-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  min-height: 92px;

  padding: 20px 26px !important;

  border-bottom: 1px solid #dfe7ef;

  background:
    linear-gradient(
      180deg,
      #ffffff 0%,
      #fbfcfe 100%
    );
}

.master-window-header .eyebrow {
  display: block;

  margin-bottom: 5px;

  color: #00a6c7;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

.master-window-header h2 {
  margin: 0 !important;

  color: #112d4f;
  font-size: 23px;
  font-weight: 800;
}

.master-window-header p {
  margin-top: 6px !important;

  color: #64748b;
  font-size: 13px;
}


/* Close button */

#closeMasterProducts {
  flex: 0 0 auto;

  width: 38px !important;
  height: 38px !important;

  margin-left: 20px;

  border: 1px solid #d9e2ec !important;
  border-radius: 9px !important;

  background: #ffffff !important;
  color: #466078 !important;

  font-size: 22px !important;
  font-weight: 500;

  box-shadow: none !important;
}

#closeMasterProducts:hover {
  border-color: #b7c6d5 !important;

  background: #f2f6fa !important;
  color: #102f55 !important;
}


/* Toolbar */

.master-toolbar {
  display: grid !important;
  grid-template-columns: minmax(300px, 1fr) auto;
  align-items: center;

  gap: 14px;

  padding: 16px 26px !important;

  border-bottom: 1px solid #e3eaf1;

  background: #f7f9fc;
}

.master-toolbar input {
  width: 100% !important;
  height: 42px;

  padding: 0 14px !important;

  border: 1px solid #cdd8e3 !important;
  border-radius: 8px !important;

  background: #ffffff;

  font-size: 14px;

  outline: none;
}

.master-toolbar input:focus {
  border-color: #1473e6 !important;

  box-shadow:
    0 0 0 3px rgba(20, 115, 230, .10);
}

#masterAddProduct {
  height: 42px;

  padding: 0 18px;

  border: 0;
  border-radius: 8px;

  background: #1267d6;
  color: #ffffff;

  font-weight: 700;
}

#masterAddProduct:hover {
  background: #0d58ba;
}


/* Table area */

.master-table-wrap {
  padding: 0 !important;

  background: #ffffff;
}

.master-table-wrap .rate-table {
  width: 100%;
  min-width: 1100px;

  border-collapse: separate;
  border-spacing: 0;
}

.master-table-wrap .rate-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;

  height: 46px;

  padding: 0 16px;

  border-bottom: 1px solid #dbe4ed;

  background: #f5f8fb;

  color: #50657a;

  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;

  text-transform: uppercase;
}

.master-table-wrap .rate-table tbody td {
  padding: 13px 16px;

  border-bottom: 1px solid #edf1f5;

  color: #21384f;
  font-size: 13px;

  vertical-align: middle;
}

.master-table-wrap .rate-table tbody tr:hover td {
  background: #f8fbff;
}

.master-table-wrap .rate-table tbody strong {
  color: #102f55;
  font-weight: 750;
}

.master-table-wrap .service-id {
  display: block;

  margin-top: 4px;

  color: #8495a6;
  font-size: 11px;
}


/* Edit buttons */

.master-table-wrap button {
  min-height: 32px;

  padding: 0 12px;

  border: 1px solid #cbd8e5;
  border-radius: 7px;

  background: #ffffff;
  color: #1267d6;

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

.master-table-wrap button:hover {
  border-color: #1267d6;

  background: #eef5ff;
}


/* Empty / error states */

.master-table-wrap td[colspan] {
  padding: 30px !important;

  color: #63778b;
  font-size: 14px;

  text-align: center;
}


/* Product editing modal */

.master-edit-modal .modal-card {
  width: min(720px, 94vw);

  border: 1px solid #dce5ee;
  border-radius: 15px;

  box-shadow:
    0 28px 80px rgba(15, 35, 60, .30);
}


/* Mobile */

@media (max-width: 800px) {

  .master-products-modal {
    padding: 8px !important;
  }

  .master-products-window {
    width: 100% !important;
    height: 97vh !important;
  }

  .master-toolbar {
    grid-template-columns: 1fr !important;
  }

}


/* =========================================================
   MASTER CATALOGUE TABS + FILTERS
   ========================================================= */

.master-catalogue-tabs {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 18px 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
}

.catalogue-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fff;
  color: #344054;
  font-weight: 600;
  cursor: pointer;
}

.catalogue-tab:hover {
  background: #f8fafc;
}

.catalogue-tab.active {
  background: #eef4ff;
  border-color: #84adff;
  color: #175cd3;
}

.catalogue-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 25px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  font-size: 12px;
  font-weight: 700;
}

.catalogue-tab.active .catalogue-count {
  background: #dbeafe;
  color: #175cd3;
}

.master-toolbar {
  display: grid !important;
  grid-template-columns: minmax(260px, 1fr) minmax(190px, 260px) auto;
  gap: 10px;
  align-items: center;
}

.master-toolbar input,
.master-toolbar select {
  width: 100%;
  min-height: 40px;
  box-sizing: border-box;
}

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

  .master-catalogue-tabs {
    flex-wrap: wrap;
  }
}


/* =========================================================
   ADD SERVICE - MASTER PRODUCT COMMERCIAL INFO
   ========================================================= */

.product-info {
  margin: 14px 0 18px;
  padding: 16px;
  border: 1px solid #d9e2ec;
  border-radius: 12px;
  background: #f7f9fc;
}

.product-info.hidden {
  display: none;
}

.product-info-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.product-info-header strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  color: #102a43;
}

.product-info-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #627d98;
}

.product-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.product-info-grid > div {
  padding: 10px 12px;
  border-radius: 9px;
  background: #fff;
  border: 1px solid #e6edf5;
}

.product-info-grid span {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  color: #627d98;
}

.product-info-grid strong {
  font-size: 14px;
  color: #102a43;
}

.product-info-note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: #486581;
}

.pricing-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.pricing-pill.standard {
  background: #e3fcef;
  color: #087f5b;
}

.pricing-pill.override,
.pricing-pill.customer {
  background: #fff3bf;
  color: #8d5b00;
}

.pricing-pill.bespoke {
  background: #e7f0ff;
  color: #1557b0;
}

.pricing-pill.included {
  background: #eceff3;
  color: #52606d;
}

.pricing-pill.legacy {
  background: #f3e8ff;
  color: #6b21a8;
}

#saveNewService:disabled {
  opacity: .55;
  cursor: not-allowed;
}

@media (max-width: 720px) {
  .product-info-grid {
    grid-template-columns: 1fr;
  }
}
