:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #eef2f7;
  color: #172033;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 42%, #e8eef6 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: #1769e0;
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  filter: brightness(0.98);
}

button.secondary,
button.ghost,
button.danger {
  background: #eef3fa;
  color: #172033;
}

button.ghost {
  min-height: 34px;
  padding: 0 10px;
  background: transparent;
  color: #526071;
}

button.danger {
  color: #b42318;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #ccd6e3;
  border-radius: 8px;
  background: #fff;
  color: #172033;
  padding: 9px 11px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #1769e0;
  box-shadow: 0 0 0 3px rgb(23 105 224 / 12%);
  outline: 0;
}

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

label {
  display: grid;
  gap: 7px;
  color: #526071;
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  border: 1px solid #d9e1ec;
  border-radius: 12px;
  background: #fff;
  padding: 26px;
  box-shadow: 0 24px 80px rgb(23 32 51 / 10%);
}

.login-card p {
  color: #667085;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  border-right: 1px solid #d9e1ec;
  background: #ffffff;
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.brand span,
.sidebar-footer span,
.muted {
  color: #667085;
}

.brand strong,
.brand span {
  display: block;
}

.nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav-item {
  justify-content: start;
  background: transparent;
  color: #526071;
  text-align: left;
}

.nav-item.active {
  background: #e8f1ff;
  color: #0f57c3;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #edf1f6;
  padding-top: 14px;
  font-size: 13px;
}

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

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

.eyebrow {
  margin-bottom: 4px;
  color: #1769e0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.head-actions,
.tools,
.actions,
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

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

.metric {
  min-height: 108px;
  display: grid;
  align-content: space-between;
  border: 1px solid #d9e1ec;
  border-radius: 12px;
  background: #fff;
  padding: 16px;
}

.metric span {
  color: #667085;
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  font-size: 28px;
  line-height: 1;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(330px, 0.85fr);
  gap: 16px;
}

.history-layout {
  grid-template-columns: minmax(320px, 0.75fr) minmax(0, 1.25fr);
}

.panel {
  min-width: 0;
  border: 1px solid #d9e1ec;
  border-radius: 12px;
  background: #fff;
  padding: 16px;
  box-shadow: 0 10px 32px rgb(23 32 51 / 5%);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: #eef3fa;
  color: #526071;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.ok {
  background: #eaf7ef;
  color: #167044;
}

.badge.off {
  background: #fff1ea;
  color: #b54708;
}

.customer-form {
  display: grid;
  gap: 14px;
  border-bottom: 1px solid #edf1f6;
  padding-bottom: 14px;
  margin-bottom: 4px;
}

.import-box {
  border: 1px solid #d9e1ec;
  border-radius: 10px;
  background: #f8fafc;
  margin-bottom: 14px;
}

.import-box summary {
  cursor: pointer;
  padding: 12px;
  font-weight: 800;
}

.import-body {
  display: grid;
  gap: 10px;
  border-top: 1px solid #d9e1ec;
  padding: 12px;
}

.form-fields {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr);
  gap: 12px;
}

.form-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch-row {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #172033;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  width: 42px;
  height: 24px;
  position: relative;
  border-radius: 999px;
  background: #ccd6e3;
  transition: background 160ms ease;
}

.switch::after {
  content: "";
  width: 18px;
  height: 18px;
  position: absolute;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgb(23 32 51 / 18%);
  transition: transform 160ms ease;
}

.switch-row input:checked + .switch {
  background: #1769e0;
}

.switch-row input:checked + .switch::after {
  transform: translateX(18px);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 13px 8px;
  border-bottom: 1px solid #edf1f6;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #667085;
  font-size: 12px;
  text-transform: uppercase;
}

.search {
  width: min(260px, 100%);
}

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

.history-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.inline-pill {
  width: fit-content;
  margin-bottom: 10px;
}

.settings-grid label:nth-child(1),
.settings-grid label:nth-child(3),
.settings-grid label:nth-child(4),
.settings-grid label:nth-child(5) {
  grid-column: 1 / -1;
}

.results,
.history {
  display: grid;
  gap: 10px;
}

.result,
.history-item {
  border: 1px solid #d9e1ec;
  border-radius: 10px;
  background: #fff;
  padding: 12px;
}

.result {
  display: grid;
  gap: 6px;
}

.result.ok {
  border-left: 5px solid #1f9d61;
}

.result.fail {
  border-left: 5px solid #c83f3f;
}

.result-head,
.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.history-item {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  color: #172033;
  text-align: left;
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item.active {
  border-color: #1769e0;
  background: #f7fbff;
}

.status-count {
  color: #667085;
  font-size: 13px;
  white-space: nowrap;
}

.empty {
  border: 1px dashed #ccd6e3;
  border-radius: 10px;
  color: #667085;
  padding: 18px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(440px, calc(100vw - 36px));
  border-radius: 10px;
  background: #172033;
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 16px 40px rgb(23 32 51 / 18%);
  z-index: 10;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(15 23 42 / 48%);
  padding: 18px;
  z-index: 20;
}

.modal {
  width: min(420px, 100%);
  display: grid;
  justify-items: center;
  gap: 12px;
  border: 1px solid rgb(255 255 255 / 40%);
  border-radius: 14px;
  background: #fff;
  padding: 24px;
  text-align: center;
  box-shadow: 0 28px 80px rgb(15 23 42 / 28%);
}

.modal-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff4e5;
  color: #b54708;
  font-size: 28px;
  font-weight: 900;
}

.modal p {
  color: #667085;
  line-height: 1.5;
}

.modal-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

button.danger.solid {
  background: #d92d20;
  color: #fff;
}

@media (max-width: 1060px) {
  .app-shell,
  .split-grid,
  .history-layout,
  .stats-grid,
  .settings-grid,
  .history-filters {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    text-align: center;
  }

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

@media (max-width: 680px) {
  .content,
  .sidebar {
    padding: 14px;
  }

  .page-head,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .head-actions,
  .tools,
  .actions,
  .form-controls {
    width: 100%;
  }

  .head-actions button,
  .actions button,
  .tools input,
  .tools select {
    flex: 1;
  }

  .customer-form,
  .form-fields,
  .nav {
    grid-template-columns: 1fr;
  }

  .form-controls {
    align-items: stretch;
    flex-direction: column;
  }

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