:root {
  color-scheme: light;
  --bg: #2a1025;
  --surface: #fff8f8;
  --panel: #ffffff;
  --panel-2: #fffafa;
  --line: #f0dde0;
  --text: #291421;
  --muted: #8a7581;
  --soft: #fff0f2;
  --green: #20a66a;
  --blue: #5f65d8;
  --red: #e60023;
  --amber: #d98c18;
  --pink: #ff4f86;
  --shadow: 0 24px 70px rgba(55, 18, 42, 0.18);
}

html,
body {
  height: 100%;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(135deg, #f43b37 0 24%, transparent 24% 100%),
    linear-gradient(315deg, #e60023 0 20%, transparent 20% 100%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  height: 100vh;
  margin: 0 auto;
  padding: 22px 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
}

.topbar {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding-left: 4px;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #291421, #e60023);
  color: transparent;
  font-size: 0;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
}

.brand-mark::before {
  width: 11px;
  height: 11px;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.brand-mark::after {
  width: 5px;
  height: 5px;
  right: 5px;
  top: 5px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: -9px 9px 0 #ffffff;
}

.nav-pills {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border-radius: 8px;
  background: #fff0f2;
}

.nav-pill {
  border: 0;
  padding: 7px 11px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.nav-pill.active {
  background: var(--red);
  color: #ffffff;
}

.nav-pill:hover {
  background: #ffe2e7;
}

.nav-pill.active:hover {
  background: var(--red);
}

.app-version {
  justify-self: end;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.app-footer {
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: #fff0f2;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.12;
  letter-spacing: 0;
  color: #ffffff;
}

.summary {
  max-width: 720px;
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.55;
}

.status-panel,
.metrics article,
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.status-panel {
  min-width: 190px;
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 4px 10px;
  align-items: center;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 18px currentColor;
}

.dot.ok {
  background: var(--green);
}

.dot.fail {
  background: var(--red);
}

.status-panel small {
  grid-column: 2;
  color: var(--muted);
}

.metrics {
  display: grid;
  grid-template-columns: 0.7fr 0.8fr 1.7fr;
  gap: 12px;
  margin-bottom: 12px;
}

.metrics article {
  min-height: 92px;
  padding: 17px 18px;
  border-radius: 8px;
  display: grid;
  align-content: space-between;
  position: relative;
  overflow: hidden;
}

.metrics article::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 16px;
  width: 64px;
  height: 20px;
  opacity: 0.74;
  background:
    linear-gradient(135deg, transparent 0 16%, var(--pink) 17% 19%, transparent 20% 42%, var(--red) 43% 45%, transparent 46% 68%, var(--amber) 69% 71%, transparent 72%);
}

.metrics span,
.panel-head span,
.tool-meta,
.log-time {
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
  position: relative;
  z-index: 1;
}

.vendor-filter {
  display: block;
  align-items: center;
  align-self: start;
  margin-bottom: 8px;
  padding: 6px 8px;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.vendor-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-start;
}

.vendor-filter-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  min-height: 30px;
}

.vendor-filter-button.active {
  border-color: var(--red);
  background: var(--red);
  color: #ffffff;
}

.vendor-empty {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(720px, 1.8fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.view-panel {
  display: none;
  min-height: 0;
  overflow: hidden;
}

.view-panel.active {
  display: block;
}

#monitorView.active {
  display: grid;
  grid-template-rows: max-content minmax(0, 1fr);
  height: 100%;
}

#adminView.active {
  height: 100%;
}

.panel {
  min-height: 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fff8f8);
}

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

h2 {
  font-size: 17px;
}

button {
  border: 1px solid #f0cbd2;
  border-radius: 8px;
  background: #fff5f6;
  color: var(--text);
  font-weight: 800;
  padding: 9px 12px;
  cursor: pointer;
}

button:hover {
  background: #ffebef;
}

.dark-action {
  border-color: var(--red);
  background: var(--red);
  color: #ffffff;
}

.dark-action:hover {
  background: #c9001e;
}

.danger-button {
  border-color: #f0c9ce;
  background: #fff4f5;
  color: #9f2636;
}

.danger-button:hover {
  background: #ffe9ec;
}

.tool-list,
.log-list {
  display: grid;
  gap: 10px;
  padding: 14px;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.log-list {
  display: block;
  padding: 0;
  background: #fff8f9;
  overflow-x: auto;
}

.tool {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
  box-shadow: 0 10px 24px rgba(55, 18, 42, 0.06);
}

.tool h3 {
  margin: 0 0 7px;
  font-size: 16px;
}

.tool p {
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.tool-empty {
  border-style: dashed;
  background: #fff7f8;
}

.tool-code {
  margin-top: 12px;
  color: var(--red);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.log {
  display: grid;
  grid-template-columns: 176px 46px minmax(150px, 190px) minmax(360px, 1fr);
  min-width: 860px;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 10px;
  border-bottom: 1px solid #e1e7dc;
  font-size: 12px;
}

.log:hover {
  background: #fff0f2;
}

.log-empty {
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 900;
  background: #fff0f2;
  color: var(--blue);
}

.badge.ERROR {
  background: #fff0f2;
  color: var(--red);
}

.badge.SUCCESS {
  background: #e8f8ef;
  color: var(--green);
}

.log-message {
  font-weight: 750;
  font-size: 13px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-summary {
  color: var(--text);
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log .tool-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-detail-wrap {
  justify-self: end;
}

.log-detail-wrap summary {
  width: fit-content;
  color: var(--red);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  list-style: none;
  white-space: nowrap;
}

.log-detail-wrap summary::-webkit-details-marker {
  display: none;
}

.log-detail-wrap summary::after {
  content: " +";
}

.log-detail-wrap[open] summary::after {
  content: " -";
}

.log-detail {
  position: relative;
  right: 0;
  z-index: 1;
  min-width: min(420px, 70vw);
  margin-top: 8px;
  border: 1px solid #dfe5dc;
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-grid,
.vendor-admin-grid,
.token-admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.76fr) minmax(640px, 1.4fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.token-admin-grid {
  grid-template-columns: minmax(320px, 0.76fr) minmax(640px, 1.4fr);
}

.vendor-admin-grid .panel-head h2,
.token-admin-grid .panel-head h2,
.admin-grid .panel-head h2 {
  font-size: 20px;
}

.vendor-admin-grid .panel-head span,
.vendor-admin-grid .panel-actions span,
.token-admin-grid .panel-head span,
.token-admin-grid .panel-actions span,
.admin-grid .panel-head span,
.admin-grid .panel-actions span {
  font-size: 15px;
}

.vendor-list-panel,
.vendor-detail-panel,
.token-panel {
  min-height: 0;
  height: 100%;
}

.vendor-list-panel,
.vendor-detail-panel,
.token-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.vendor-list {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px;
  overflow: auto;
}

.vendor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  text-align: left;
}

.vendor-row.active {
  border-color: var(--red);
  background: #fff0f2;
}

.vendor-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.vendor-detail-body {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  overflow: auto;
}

.token-detail-body {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  overflow: auto;
}

.vendor-settings {
  display: grid;
  gap: 12px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.vendor-settings.minimal {
  gap: 0;
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.token-panel {
  max-height: none;
}

.sub-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fffafa;
}

.sub-tab {
  padding: 8px 12px;
  border-radius: 8px;
  background: #fff5f6;
}

.sub-tab.active {
  border-color: var(--red);
  background: var(--red);
  color: #ffffff;
}

.admin-section {
  display: none;
}

.admin-section.active {
  display: grid;
}

.form-body {
  align-self: start;
  display: grid;
  gap: 11px;
  padding: 16px;
}

.vendor-modal {
  width: min(480px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.vendor-modal::backdrop {
  background: rgba(42, 16, 37, 0.46);
}

.modal-card {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.form-body label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 16px;
  font-weight: 850;
}

.required-label::after {
  content: "*";
  margin-left: 4px;
  color: var(--red);
}

.form-body input[type="text"],
.form-body input[type="password"],
.form-body input[type="date"],
.form-body textarea {
  width: 100%;
  border: 1px solid #f0cbd2;
  border-radius: 8px;
  background: #fffafa;
  color: var(--text);
  padding: 12px 13px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
}

.form-body textarea {
  min-height: 78px;
  resize: vertical;
}

.api-tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8f8;
}

.api-tool-grid.empty {
  display: block;
  border-style: dashed;
  background: #fffafa;
}

.api-tool-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  font-weight: 800;
}

.api-register-card {
  position: relative;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}

.api-register-card h3 {
  margin: 0;
  padding-right: 78px;
  font-size: 16px;
}

.api-register-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.api-register-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  z-index: 1;
}

.token-list {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
  max-height: none;
  min-height: 0;
  overflow: auto;
}

.token-line-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.token-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}

.token-card.disabled {
  opacity: 0.66;
}

.token-card h3 {
  margin: 0 0 4px;
  font-size: 19px;
}

.token-card p {
  color: var(--muted);
  font-size: 15px;
}

.connector-settings {
  display: grid;
  gap: 8px;
  border: 1px solid #d8e4f2;
  border-radius: 8px;
  background: #f7fbff;
  padding: 12px;
}

.connector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.connector-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
}

.connector-row {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid #e3edf7;
  border-radius: 8px;
  background: #ffffff;
  padding: 9px;
}

.connector-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.connector-row code {
  color: #1e4f78;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.token-full {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid #ffc9d2;
  border-radius: 8px;
  background: #fff2f4;
  padding: 10px;
}

.token-full span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.token-full code {
  color: var(--red);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.token-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.token-card dl div {
  border: 1px solid #f0dde0;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px;
}

.token-card dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.token-card dd {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.token-expiry-settings {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.token-expiry-settings button {
  min-height: 42px;
}

.vendor-status-label {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: fit-content;
  min-width: 104px;
  border: 1px solid #0f6b33;
  border-radius: 8px;
  background: #15803d;
  color: #ffffff;
  padding: 8px 12px;
  font-size: 16px;
  font-weight: 900;
}

.vendor-status-label:empty {
  display: none;
}

.vendor-status-label.disabled {
  border-color: #8f1025;
  background: #b1122b;
  color: #ffffff;
}

.token-edit-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.field-help {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.token-note-edit {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.token-note-edit textarea {
  width: 100%;
  border: 1px solid #f0cbd2;
  border-radius: 8px;
  background: #fffafa;
  color: var(--text);
  padding: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  resize: vertical;
}

.api-tool-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 8px;
}

.api-tool-grid.compact label {
  font-size: 13px;
}

.token-date-edit {
  width: 100%;
  border: 1px solid #f0cbd2;
  border-radius: 8px;
  background: #fffafa;
  color: var(--text);
  padding: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}

.token-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    min-height: 100vh;
    display: block;
    padding: 24px 0;
  }

  .view-panel,
  #adminView.active {
    overflow: visible;
    height: auto;
  }

  .hero,
  .workspace,
  .metrics,
  .vendor-filter,
  .admin-grid,
  .vendor-admin-grid,
  .token-admin-grid {
    grid-template-columns: 1fr;
  }

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

  .nav-pills {
    justify-self: start;
    max-width: 100%;
    overflow-x: auto;
  }

  .app-version {
    justify-self: start;
  }

  .hero {
    display: grid;
  }

.workspace {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .admin-grid {
    height: auto;
    overflow: visible;
  }

  .panel {
    min-height: 420px;
  }

  .status-panel {
    width: 100%;
  }

  .vendor-filter-list {
    justify-content: flex-start;
  }

  .api-tool-grid,
  .token-card dl,
  .token-expiry-settings,
  .token-line-grid,
  .token-full,
  .connector-row,
  .api-tool-grid.compact {
    grid-template-columns: 1fr;
  }

  .shell {
    width: min(100% - 22px, 1180px);
    padding: 24px 0;
  }
}

.monitor-workspace {
  grid-template-columns: minmax(0, 1fr);
}
