:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202c;
  --muted: #667085;
  --line: #dce3eb;
  --nav: #121a26;
  --blue: #2563eb;
  --green: #0f9f6e;
  --red: #c93d3d;
  --amber: #b7791f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  padding: 22px;
  background: var(--nav);
  color: #fff;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f4b740;
  color: #111827;
  font-weight: 900;
}

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

.brand small {
  color: #cbd5e1;
}

nav {
  display: grid;
  align-content: start;
  gap: 7px;
  overflow-y: auto;
}

nav button,
.secondary-action {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dbe4ef;
  text-align: right;
}

nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

nav button span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

nav button.active,
nav button:hover,
.secondary-action:hover {
  background: rgba(255, 255, 255, 0.09);
}

.secondary-action {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

main {
  min-width: 0;
  padding: 26px;
  display: grid;
  gap: 18px;
}

.topbar,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  align-items: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 32px;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
}

#pageSubtitle,
.panel-head span,
small {
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 8px;
}

.top-actions button,
.primary,
.secondary,
.icon-button,
.row-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

#addRecordBtn,
.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.metrics article,
.panel,
.module-card,
.activity-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metrics article {
  padding: 14px;
}

.metrics span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  font-size: 24px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.module-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.integration-card {
  margin-bottom: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.integration-card strong,
.integration-card small {
  display: block;
}

.integration-card button {
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  padding: 9px 11px;
  white-space: nowrap;
}

.module-card {
  min-height: 144px;
  padding: 14px;
  display: grid;
  gap: 8px;
  text-align: right;
}

.module-card:hover {
  border-color: var(--blue);
}

.module-color {
  width: 34px;
  height: 6px;
  border-radius: 999px;
}

.module-card small {
  line-height: 1.5;
}

.module-card b {
  align-self: end;
}

.activity {
  display: grid;
  gap: 10px;
}

.activity-item {
  padding: 12px;
  display: grid;
  gap: 6px;
}

.activity-item span {
  color: var(--muted);
  font-size: 13px;
}

.table-tools {
  margin-bottom: 12px;
}

.table-tools input,
label input,
label select,
label textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 11px;
}

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

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

.pill.good {
  background: #e8f8f1;
  color: var(--green);
}

.pill.danger {
  background: #fdecec;
  color: var(--red);
}

.row-actions {
  display: flex;
  gap: 6px;
}

.empty-state {
  padding: 40px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.error {
  color: var(--red);
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: 10px;
  padding: 0;
}

dialog:has(.wide-dialog) {
  width: min(1040px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

.dialog-card {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.wide-dialog {
  min-width: 0;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 22px;
}

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

.span-2 {
  grid-column: span 2;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: end;
  min-height: 42px;
}

.checkbox-line input {
  width: auto;
}

.integration-status {
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.integration-status strong,
.integration-status span {
  display: block;
}

.integration-status span,
.integration-status p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.mapping-table {
  min-width: 900px;
}

.mapping-table input,
.mapping-table select {
  width: 100%;
  min-width: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.mapping-table input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

label textarea,
label input,
label select {
  color: var(--ink);
  font-weight: 400;
}

.dialog-actions {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
}

@media (max-width: 1180px) {
  body {
    grid-template-columns: 1fr;
  }

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

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

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

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  main {
    padding: 16px;
  }

  .topbar,
  .panel-head,
  .integration-card,
  .integration-status {
    flex-direction: column;
  }

  .top-actions,
  .dialog-actions {
    width: 100%;
  }

  .top-actions button,
  .dialog-actions button {
    flex: 1;
  }

  nav,
  .metrics,
  .module-cards,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}
