:root {
  --indigo-50: #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;
  --slate-25: #fcfcfd;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --green-50: #ecfdf5;
  --green-600: #059669;
  --amber-50: #fffbeb;
  --amber-600: #d97706;
  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.05);
  --shadow-md: 0 10px 24px rgb(15 23 42 / 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--slate-50);
  color: var(--slate-900);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  letter-spacing: -0.035em;
  line-height: 1.15;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.05rem;
  letter-spacing: -0.015em;
}

h3 {
  margin-bottom: 5px;
  font-size: 0.95rem;
}

p {
  color: var(--slate-500);
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 24px 18px;
  border-right: 1px solid var(--slate-200);
  background: #fff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--indigo-500), var(--indigo-700));
  box-shadow: 0 7px 16px rgb(79 70 229 / 0.22);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.96rem;
  letter-spacing: -0.01em;
}

.brand small {
  margin-top: -2px;
  color: var(--slate-500);
  font-size: 0.72rem;
}

.nav-list {
  display: grid;
  gap: 5px;
  margin-top: 38px;
}

.nav-list a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--slate-600);
  font-size: 0.9rem;
  font-weight: 600;
  transition:
    background 120ms ease,
    color 120ms ease;
}

.nav-list a span {
  width: 18px;
  color: var(--slate-500);
  font-size: 1.05rem;
  text-align: center;
}

.nav-list a:hover {
  background: var(--slate-50);
  color: var(--slate-900);
}

.nav-list a.active {
  background: var(--indigo-50);
  color: var(--indigo-700);
}

.nav-list a.active span {
  color: var(--indigo-600);
}

.sidebar-footer {
  display: grid;
  gap: 15px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--slate-200);
}

.admin-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.admin-identity strong,
.admin-identity small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-identity strong {
  font-size: 0.84rem;
}

.admin-identity small {
  color: var(--slate-500);
  font-size: 0.72rem;
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--indigo-100);
  color: var(--indigo-700);
  font-size: 0.8rem;
  font-weight: 800;
}

.main-content {
  min-width: 0;
  padding: 42px clamp(24px, 5vw, 64px) 64px;
}

.mobile-header {
  display: none;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto 28px;
  max-width: 1180px;
}

.page-header p {
  margin-bottom: 0;
  font-size: 0.94rem;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--indigo-600);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.card,
.service-card,
.metric-card {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.card {
  max-width: 1180px;
  margin: 0 auto 22px;
  padding: 24px;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.card-heading p {
  margin-bottom: 0;
  font-size: 0.88rem;
}

.metric-grid {
  display: grid;
  max-width: 1180px;
  margin: 0 auto 22px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  min-width: 0;
  padding: 20px;
}

.metric-card span {
  display: block;
  margin-bottom: 9px;
  color: var(--slate-500);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  overflow: hidden;
  font-size: 1.05rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boundary-grid {
  display: grid;
  margin-top: 24px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.boundary-grid > div {
  padding: 18px;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  background: var(--slate-25);
}

.boundary-grid p {
  margin-bottom: 0;
  font-size: 0.82rem;
}

.boundary-icon {
  display: grid;
  width: 30px;
  height: 30px;
  margin-bottom: 14px;
  place-items: center;
  border-radius: 9px;
  font-size: 0.8rem;
  font-weight: 800;
}

.boundary-safe {
  background: var(--green-50);
  color: var(--green-600);
}

.boundary-locked {
  background: var(--indigo-50);
  color: var(--indigo-600);
}

.status-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-success {
  background: var(--green-50);
  color: var(--green-600);
}

.status-warning {
  background: var(--amber-50);
  color: var(--amber-600);
}

.status-danger {
  background: var(--red-50);
  color: var(--red-600);
}

.service-grid {
  display: grid;
  max-width: 1180px;
  margin: 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.service-card {
  padding: 21px;
}

.service-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.service-topline h2 {
  overflow-wrap: anywhere;
}

.service-topline p {
  margin-bottom: 0;
  font-size: 0.83rem;
}

.service-meta {
  margin: 20px 0;
  padding: 13px 0;
  border-top: 1px solid var(--slate-200);
  border-bottom: 1px solid var(--slate-200);
}

.service-meta div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.service-meta dt {
  color: var(--slate-500);
  font-size: 0.75rem;
}

.service-meta dd {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 700;
}

.service-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 0.8rem;
  font-weight: 750;
  line-height: 1.2;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgb(99 102 241 / 0.25);
  outline-offset: 2px;
}

.button-primary {
  border-color: var(--indigo-600);
  background: var(--indigo-600);
  box-shadow: 0 5px 12px rgb(79 70 229 / 0.2);
  color: #fff;
}

.button-primary:hover {
  background: var(--indigo-700);
}

.button-secondary {
  border-color: var(--slate-300);
  background: #fff;
  color: var(--slate-700);
}

.button-secondary:hover,
.button-quiet:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
}

.button-disabled,
.button-disabled:hover {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

.button-danger {
  border-color: var(--red-100);
  background: var(--red-50);
  color: var(--red-700);
}

.button-danger:hover {
  border-color: var(--red-600);
  background: var(--red-600);
  color: #fff;
}

.button-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--slate-600);
}

.button-full {
  width: 100%;
}

.alert {
  max-width: 1180px;
  margin: 0 auto 20px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
}

.alert-error {
  border-color: var(--red-100);
  background: var(--red-50);
  color: var(--red-700);
}

.alert-success {
  border-color: #a7f3d0;
  background: var(--green-50);
  color: #047857;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  padding: 32px 20px;
  place-items: center;
  background:
    radial-gradient(circle at 15% 15%, rgb(224 231 255 / 0.8), transparent 28rem),
    radial-gradient(circle at 85% 85%, rgb(241 245 249 / 0.9), transparent 25rem),
    var(--slate-50);
}

.auth-panel {
  width: min(100%, 470px);
  padding: 30px;
  border: 1px solid var(--slate-200);
  border-radius: 18px;
  background: rgb(255 255 255 / 0.96);
  box-shadow: var(--shadow-md);
}

.auth-brand {
  margin-bottom: 38px;
}

.auth-heading {
  margin-bottom: 24px;
}

.auth-heading p {
  margin-bottom: 0;
  font-size: 0.88rem;
}

.auth-panel .alert {
  margin-bottom: 18px;
}

.form-stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--slate-700);
  font-size: 0.76rem;
  font-weight: 750;
}

label small,
.field-caption + code + small {
  color: var(--slate-500);
  font-size: 0.7rem;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--slate-300);
  border-radius: 9px;
  background: #fff;
  box-shadow: inset 0 1px 1px rgb(15 23 42 / 0.025);
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: 82px;
  padding: 10px 11px;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--slate-500);
}

.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.security-note {
  margin: 26px 0 0;
  color: var(--slate-500);
  font-size: 0.67rem;
  text-align: center;
}

.qr-card {
  display: grid;
  gap: 18px;
  margin-bottom: 22px;
  place-items: center;
  text-align: center;
}

.qr-card img {
  width: 220px;
  height: 220px;
  padding: 9px;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  background: #fff;
}

.qr-card code {
  display: block;
  margin: 7px 0 4px;
  color: var(--slate-900);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.field-caption {
  color: var(--slate-500);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.filter-row {
  display: flex;
  align-items: end;
  gap: 12px;
}

.filter-row label {
  min-width: 180px;
}

.filter-row label:nth-child(2) {
  min-width: 110px;
}

.log-panel {
  max-width: 1180px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #273449;
  border-radius: var(--radius);
  background: #0b1120;
  box-shadow: var(--shadow-md);
  color: #dbeafe;
}

.log-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 11px 15px;
  border-bottom: 1px solid #263248;
  background: #111827;
}

.log-toolbar span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.log-toolbar .status-dot {
  color: #34d399;
}

.log-toolbar small {
  color: #94a3b8;
  font-size: 0.68rem;
}

.log-panel pre {
  min-height: 430px;
  max-height: 65vh;
  margin: 0;
  overflow: auto;
  padding: 18px;
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.73rem;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
}

.audit-card {
  padding: 0;
  overflow: hidden;
}

.audit-row {
  display: grid;
  align-items: center;
  grid-template-columns: 1.25fr 1fr 1fr 1.7fr;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--slate-200);
  font-size: 0.76rem;
}

.audit-row:last-child {
  border-bottom: 0;
}

.audit-header {
  background: var(--slate-50);
  color: var(--slate-500);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.audit-row > div {
  min-width: 0;
}

.audit-row strong,
.audit-row small,
.audit-row code {
  display: block;
}

.audit-row .status-chip {
  display: inline-flex;
  margin-top: 5px;
}

.audit-row small,
.audit-row time {
  color: var(--slate-500);
  font-size: 0.7rem;
}

.audit-row code {
  margin-top: 4px;
  overflow: hidden;
  color: var(--slate-600);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  padding: 48px 20px;
  color: var(--slate-500);
  font-size: 0.82rem;
  text-align: center;
}

.restart-dialog {
  width: min(calc(100% - 32px), 500px);
  padding: 26px;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 24px 70px rgb(15 23 42 / 0.28);
}

.restart-dialog::backdrop {
  background: rgb(15 23 42 / 0.62);
  backdrop-filter: blur(3px);
}

.restart-dialog h2 {
  font-size: 1.25rem;
}

.restart-dialog > form > p {
  margin-bottom: 20px;
  font-size: 0.83rem;
}

.dialog-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 15px;
  place-items: center;
  border-radius: 12px;
  background: var(--red-50);
  color: var(--red-700);
  font-size: 1.25rem;
  font-weight: 800;
}

.reauth-box {
  display: grid;
  gap: 13px;
  margin-top: 17px;
  padding: 15px;
  border: 1px solid var(--slate-200);
  border-radius: 11px;
  background: var(--slate-50);
}

.reauth-box > strong {
  font-size: 0.8rem;
}

.reauth-box > p {
  margin: -10px 0 0;
  font-size: 0.7rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
}

@media (max-width: 900px) {
  .metric-grid,
  .boundary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .service-grid {
    grid-template-columns: 1fr;
  }

  .audit-header {
    display: none;
  }

  .audit-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--slate-200);
  }

  .sidebar > .brand {
    margin-bottom: 15px;
  }

  .nav-list {
    display: flex;
    margin-top: 0;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .nav-list a {
    flex: 0 0 auto;
  }

  .sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 12px;
  }

  .sidebar-footer form {
    width: auto;
  }

  .main-content {
    padding: 28px 16px 48px;
  }

  .page-header {
    display: grid;
  }

  .metric-grid,
  .boundary-grid {
    grid-template-columns: 1fr;
  }

  .filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .filter-row label {
    min-width: 0;
  }

  .filter-row .button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .auth-page {
    padding: 0;
    place-items: stretch;
  }

  .auth-panel {
    min-height: 100vh;
    padding: 25px 20px;
    border: 0;
    border-radius: 0;
  }

  .service-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .audit-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .log-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

