:root {
  --ink: #17212b;
  --muted: #687684;
  --line: #e4e9ee;
  --surface: #ffffff;
  --page: #f4f7fa;
  --blue: #2457d6;
  --blue-dark: #1d46b1;
  --green: #15803d;
  --green-bg: #e8f7ed;
  --red: #b42318;
  --red-bg: #fff0ee;
  --shadow: 0 8px 28px rgba(20, 40, 65, .055);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  background: #101c2c;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.topbar-inner {
  max-width: 1440px;
  min-height: 66px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 34px;
}
.brand { color: #fff; font-size: 17px; font-weight: 750; letter-spacing: -.3px; white-space: nowrap; }
.brand span { color: #92b2ff; font-weight: 500; }
.topbar nav { display: flex; align-items: center; gap: 22px; flex: 1; }
.topbar nav a { color: #c8d3e0; font-size: 13px; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.user-menu { display: flex; align-items: center; gap: 14px; color: #c7d1dc; font-size: 12px; white-space: nowrap; }
.user-menu form { margin: 0; }
.link-button { padding: 0; color: #a9c0ff; border: 0; background: transparent; font: inherit; cursor: pointer; }
.container { max-width: 1440px; margin: 32px auto 70px; padding: 0 28px; }
.auth-container { max-width: 470px; margin-top: 8vh; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 29px; letter-spacing: -.8px; line-height: 1.2; margin-bottom: 8px; }
h2 { font-size: 18px; letter-spacing: -.25px; margin-bottom: 5px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.page-heading .muted { margin-bottom: 0; }
.eyebrow { font-size: 10px; font-weight: 750; letter-spacing: 1.15px; color: #78899a; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.card { background: var(--surface); border: 1px solid #e8edf2; border-radius: 13px; padding: 25px 27px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.card-heading p { margin-bottom: 0; }
.step-bubble { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; background: #edf3ff; color: var(--blue); font-size: 11px; font-weight: 800; }
.secure-chip { display: inline-flex; align-items: center; gap: 8px; border-radius: 30px; padding: 8px 12px; background: #edf8f1; color: #1a7440; font-size: 11px; font-weight: 650; white-space: nowrap; }
.dot, .status-dot { display: inline-block; height: 7px; width: 7px; background: #28a45e; border-radius: 50%; }
.muted-dot { background: #a1aab4; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 20px; }
label { display: flex; flex-direction: column; gap: 7px; color: #354454; font-size: 12px; font-weight: 650; min-width: 0; }
input, select {
  width: 100%; min-width: 0; height: 40px; border: 1px solid #d7dfe7; border-radius: 7px;
  background: #fff; color: #1e2935; padding: 8px 11px; font: inherit; font-size: 13px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: #85a6ef; box-shadow: 0 0 0 3px rgba(36,87,214,.09); }
input[type=file] { height: auto; min-height: 40px; padding: 7px; background: #fff; font-size: 12px; }
input[type=checkbox] { width: 15px; height: 15px; margin: 0; accent-color: var(--blue); }
.full-width { grid-column: 1 / -1; }
.key-panel { border: 1px solid #e1e8f0; background: #f8fafc; border-radius: 10px; padding: 18px; display: grid; grid-template-columns: .9fr 1.1fr; gap: 22px; }
.key-title { font-weight: 750; font-size: 13px; margin-bottom: 6px; }
.key-state { font-size: 12px; margin-bottom: 8px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.key-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.remember-check { flex-direction: row; align-items: center; gap: 8px; font-weight: 600; grid-column: 1 / -1; }
.key-inputs .tiny { grid-column: 1 / -1; margin: -7px 0 0; line-height: 1.45; }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 11px; }
button, .button-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 39px;
  border: 0; border-radius: 7px; padding: 9px 15px; cursor: pointer; font-size: 12px; font-weight: 700;
  transition: background .15s, transform .15s; text-decoration: none;
}
button:hover, .button-link:hover { transform: translateY(-1px); text-decoration: none; }
.primary { background: var(--blue); color: white; }
.primary:hover { background: var(--blue-dark); }
.secondary { background: #eaf0f6; color: #34485b; }
.secondary:hover { background: #dfe7ef; }
.success-button { background: var(--green); color: #fff; min-width: 190px; }
.success-button:hover { background: #116c33; }
.button-danger-outline { background: #fff; color: var(--red); border: 1px solid #f0c4c0; }
.button-danger-outline:hover { background: var(--red-bg); }
.button-small { min-height: 30px; padding: 6px 9px; font-size: 11px; background: #eaf0f6; color: #34485b; }
.full { width: 100%; }
.load-card { border-left: 3px solid #7c9bea; }
.load-form { display: flex; align-items: end; flex-wrap: wrap; gap: 14px; }
.file-inline { min-width: 235px; flex: 1; }
.saved-key-note { color: #276441; font-size: 12px; display: flex; gap: 8px; align-items: center; min-height: 39px; }
.override-key { width: 100%; color: #4d6174; font-size: 12px; }
.override-key summary { cursor: pointer; padding: 7px 0; }
.compact-grid { margin-top: 10px; }
.server-card { padding-bottom: 18px; }
.server-heading { align-items: center; }
.server-heading .primary { white-space: nowrap; }
.server-table-wrap { overflow-x: auto; }
.server-table-head, .server-row {
  display: grid; grid-template-columns: 1.02fr 1.3fr .62fr 1.12fr 1.8fr 35px;
  gap: 10px; align-items: end; min-width: 900px;
}
.server-table-head { color: #718090; font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .55px; padding: 0 10px 10px; }
.server-row { padding: 11px 10px; border-top: 1px solid #edf0f4; }
.server-row label { font-size: 11px; }
.server-row input, .server-row select { height: 37px; }
.icon-delete { min-height: 35px; width: 35px; padding: 0; border: 1px solid #f0d6d3; color: #bd392e; background: #fff8f7; font-size: 22px; font-weight: 400; }
.icon-delete:hover { background: #ffe9e6; }
.apply-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 23px; padding-top: 18px; border-top: 1px solid var(--line); }
.key-once-apply { margin-top: 20px; padding: 16px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; border: 1px dashed #d3dce6; border-radius: 9px; background: #fafbfd; align-items: end; }
.key-once-apply p { margin: 3px 0 0; }
.flash-stack { margin-bottom: 18px; }
.alert { padding: 12px 15px; border-radius: 8px; margin-bottom: 9px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.alert.success { background: var(--green-bg); color: #176538; border: 1px solid #c9ebd4; }
.alert.error { background: var(--red-bg); color: #9e2d24; border: 1px solid #f6d2ce; }
.alert.info { background: #edf4ff; color: #244f9f; border: 1px solid #d8e6ff; }
.auth-card { padding: 34px; margin-top: 5vh; }
.auth-card h1 { margin-bottom: 9px; }
.form-stack { display: flex; flex-direction: column; gap: 16px; margin-top: 22px; }
.check-label { display: flex; flex-direction: row; align-items: center; gap: 9px; }
.auth-card .check-label { font-size: 12px; }
.user-create-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; color: #718090; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
th, td { padding: 12px 10px; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
.pill { display: inline-flex; padding: 4px 8px; border-radius: 20px; font-size: 10px; font-weight: 700; }
.pill-green { background: #e8f7ed; color: #176538; }
.pill-red { background: #fff0ee; color: #a22c22; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.reset-form input { width: 145px; height: 31px; font-size: 11px; }
.narrow-card { max-width: 550px; }
.error-page { margin-top: 10vh; }
.button-link { background: var(--blue); color: #fff; margin-top: 10px; }

@media (max-width: 900px) {
  .topbar-inner { padding: 0 18px; gap: 18px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
  .topbar nav { order: 3; width: 100%; gap: 16px; }
  .user-menu { margin-left: auto; }
  .container { padding: 0 16px; margin-top: 22px; }
  .key-panel { grid-template-columns: 1fr; }
  .key-once-apply { grid-template-columns: 1fr 1fr; }
  .key-once-apply > div { grid-column: 1 / -1; }
}
@media (max-width: 650px) {
  .page-heading { align-items: flex-start; flex-direction: column; }
  h1 { font-size: 25px; }
  .card { padding: 19px 16px; }
  .form-grid, .key-inputs, .user-create-grid { grid-template-columns: 1fr; }
  .key-inputs .tiny, .remember-check { grid-column: auto; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions button { width: 100%; }
  .load-form { align-items: stretch; flex-direction: column; }
  .file-inline { min-width: 0; }
  .server-table-head { display: none; }
  .server-row { min-width: 0; grid-template-columns: 1fr 1fr; padding: 15px 0; gap: 10px; }
  .server-row .mobile-label:nth-child(2), .server-row .mobile-label:nth-child(5) { grid-column: 1 / -1; }
  .icon-delete { grid-column: 2; justify-self: end; }
  .apply-footer { flex-direction: column; align-items: stretch; }
  .apply-footer button { width: 100%; }
  .key-once-apply { grid-template-columns: 1fr; }
  .key-once-apply > div { grid-column: auto; }
  .secure-chip { white-space: normal; }
  .user-menu span { display: none; }
  .auth-card { padding: 25px 20px; }
  .reset-form { margin-top: 7px; }
}

/* Backend catalogue and per-user access management */
.refresh-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
  max-width: 760px;
  margin-top: 16px;
}
.catalog-meta {
  color: var(--muted, #6b7280);
  font-size: 12px;
  margin: 18px 0 10px;
}
.backend-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.backend-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid #dbe3ef;
  border-radius: 7px;
  background: #f6f8fc;
  color: #23334d;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.managed-users {
  display: grid;
  gap: 15px;
}
.managed-user {
  border: 1px solid #e3e8ef;
  border-radius: 10px;
  padding: 17px;
  background: #fff;
}
.managed-user-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.managed-user-head strong {
  margin-right: 8px;
  font-size: 15px;
}
.permission-form {
  border-top: 1px solid #e8edf3;
  margin-top: 15px;
  padding-top: 14px;
}
.permission-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}
.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px 14px;
  margin-bottom: 11px;
}
.permission-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.permission-item input {
  width: auto;
  min-height: 0;
  flex: 0 0 auto;
}
@media (max-width: 700px) {
  .managed-user-head { flex-direction: column; }
  .permission-grid { grid-template-columns: 1fr; }
}
