* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f6f8;
  color: #18202a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef4f8, #f7f2e9);
}

.login-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid #dce2e8;
  border-radius: 8px;
  padding: 34px;
  box-shadow: 0 20px 50px rgba(30, 45, 62, 0.14);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #155e9f;
  color: #fff;
  font-weight: 800;
}

.login-card h1,
.topbar h1,
.panel h2,
.rate-section h3 {
  margin: 0;
}

.login-card h1 {
  margin-top: 18px;
  font-size: 25px;
}

.login-card p,
.topbar p,
.panel p,
.section-head p,
.database-panel p {
  color: #667587;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  color: #4c5a69;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd8e3;
  border-radius: 6px;
  background: #fff;
  color: #18202a;
  padding: 10px 12px;
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #155e9f;
  box-shadow: 0 0 0 3px rgba(21, 94, 159, 0.13);
}

.primary,
.secondary,
.danger-button,
.upload {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary {
  background: #155e9f;
  color: #fff;
}

.secondary,
.upload {
  background: #fff;
  color: #26313d;
  border-color: #ccd6e1;
}

.danger-button {
  background: #fff3f1;
  color: #b23824;
  border-color: #f0b6aa;
}

.small {
  padding: 7px 10px;
  font-size: 13px;
}

.full {
  width: 100%;
}

.error {
  color: #b23824;
  background: #fff3f1;
  border: 1px solid #f0b6aa;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 14px;
}

.success {
  color: #246128;
  background: #edf8ed;
  border: 1px solid #b9deb9;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 14px;
}

.login-help {
  margin-top: 14px;
  color: #7a8795;
  font-size: 13px;
  text-align: center;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
}

.sidebar {
  background: #101820;
  color: #d7e0e8;
  padding: 18px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-weight: 800;
}

.sidebar button {
  width: 100%;
  display: block;
  margin-bottom: 6px;
  padding: 11px 12px;
  text-align: left;
  color: #d7e0e8;
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.sidebar button.active,
.sidebar button:hover {
  background: #223242;
  color: #fff;
}

.workspace {
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h1 {
  font-size: 26px;
}

.topbar p {
  margin: 4px 0 0;
}

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

.stats div,
.panel,
.rate-section {
  background: #fff;
  border: 1px solid #dce2e8;
  border-radius: 8px;
}

.stats div {
  padding: 18px;
}

.stats strong {
  display: block;
  font-size: 30px;
  color: #155e9f;
}

.stats span {
  color: #667587;
  font-weight: 700;
}

.panel,
.rate-section {
  padding: 18px;
  margin-bottom: 18px;
}

.panel-head,
.section-head,
.detail-actions,
.database-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.search {
  max-width: 320px;
}

.lender-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.lender-card {
  border: 1px solid #dce2e8;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.lender-main {
  width: 100%;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  text-align: left;
  border: 0;
  background: #fff;
  padding: 16px;
}

.lender-main span,
.lender-badge {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  font-weight: 800;
}

.lender-main strong {
  align-self: end;
}

.lender-main small {
  grid-column: 2;
  color: #667587;
}

.card-actions {
  display: flex;
  border-top: 1px solid #e5ebf0;
}

.card-actions button {
  flex: 1;
  border: 0;
  background: #f8fafc;
  padding: 9px;
  color: #155e9f;
  font-weight: 700;
}

.lender-profile {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lender-profile p {
  margin: 6px 0 0;
}

.lender-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.lender-tabs button {
  border: 1px solid #ccd6e1;
  border-radius: 6px;
  background: #fff;
  color: #415063;
  padding: 10px 12px;
  font-weight: 800;
}

.lender-tabs button.active {
  border-color: #155e9f;
  background: #eaf4fc;
  color: #155e9f;
}

.info-grid,
.rate-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.info-card,
.rate-card {
  border: 1px solid #e0e7ef;
  border-radius: 7px;
  padding: 14px;
  background: #fbfcfe;
}

.rate-card.best {
  background: #edf8ed;
}

.rate-card.second {
  background: #fff8df;
}

.rate-card.third {
  background: #fff0dc;
}

.info-card h4 {
  margin: 0 0 6px;
  color: #18202a;
}

.info-card p {
  margin: 5px 0;
  color: #4c5a69;
}

.info-card small,
.rate-card small {
  display: block;
  margin-top: 6px;
  color: #7a8795;
}

.rate-card strong {
  color: #155e9f;
  display: block;
  font-size: 22px;
  margin: 4px 0;
}

.info-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid #e5ebf0;
  padding-top: 10px;
}

.notes-editor {
  min-height: 240px;
  line-height: 1.6;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid #e5ebf0;
  text-align: left;
  vertical-align: top;
}

th {
  color: #4c5a69;
  font-size: 12px;
  text-transform: uppercase;
  background: #f8fafc;
}

td small {
  display: block;
  margin-top: 3px;
  color: #7a8795;
}

.rate {
  color: #155e9f;
  font-weight: 800;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  color: #355827;
  background: #e7f4dd;
  font-size: 12px;
  font-weight: 800;
}

.status.inactive,
.status.expired,
.status.closed {
  background: #f1f3f5;
  color: #667587;
}

.status.special,
.status.expiring-soon,
.status.limited-places {
  background: #fff0d4;
  color: #8a5500;
}

.row-actions {
  white-space: nowrap;
}

.link-button {
  border: 0;
  background: transparent;
  color: #155e9f;
  font-weight: 800;
  padding: 4px 6px;
}

.link-button.danger {
  color: #b23824;
}

.empty {
  padding: 18px;
  background: #f8fafc;
  color: #7a8795;
  border: 1px dashed #cfd8e3;
  border-radius: 6px;
}

.quick-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.quick-list div {
  border: 1px solid #e5ebf0;
  border-radius: 6px;
  padding: 12px;
}

.quick-list span,
.quick-list small {
  display: block;
  color: #667587;
}

.quick-list strong {
  display: block;
  margin: 3px 0;
  color: #155e9f;
  font-size: 22px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(14, 23, 33, 0.58);
}

.modal {
  width: min(760px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #dce2e8;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: #fff;
  border-bottom: 1px solid #e5ebf0;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #ccd6e1;
  background: #fff;
}

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

.form-grid .field.textarea,
.section-note,
.modal-actions {
  grid-column: 1 / -1;
}

.section-note {
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 6px;
  background: #eef6fc;
  color: #155e9f;
  font-weight: 800;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.upload {
  position: relative;
}

.upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px;
  }

  .sidebar-brand {
    margin: 0 8px 0 0;
  }

  .sidebar button {
    width: auto;
    white-space: nowrap;
    margin: 0;
  }

  .workspace {
    padding: 16px;
  }

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

  .topbar,
  .panel-head,
  .section-head,
  .database-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    max-width: none;
  }
}
