:root {
  color-scheme: light;
  --canvas: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef2f5;
  --ink: #1c252c;
  --muted: #5c6973;
  --line: #d5dde3;
  --line-strong: #b9c5cd;
  --green: #16794d;
  --green-soft: #e4f3eb;
  --red: #b42318;
  --red-soft: #fce9e7;
  --blue: #175cd3;
  --blue-soft: #e8f0fe;
  --amber: #a15c07;
  --amber-soft: #fff2d8;
  --shadow: 0 10px 30px rgba(28, 37, 44, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-size: 15px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px max(20px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 6px;
  color: #ffffff;
  background: var(--ink);
  font-weight: 800;
  font-size: 14px;
}

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

.brand strong {
  font-size: 15px;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-nav a,
.link-button {
  min-height: 38px;
  padding: 9px 11px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}

.app-nav a:hover,
.link-button:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.app-nav form {
  margin: 0;
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 70px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.page-heading h1,
.section-heading h1 {
  margin: 2px 0 0;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.12;
}

.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.refresh-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--muted);
  font-size: 13px;
}

.refresh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.status-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 150px)) 1fr;
  align-items: center;
  gap: 20px;
  padding: 18px 0 26px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.status-summary > div:not(.scope-label) {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.summary-value {
  font-size: 27px;
  font-weight: 760;
}

.summary-label,
.scope-label {
  color: var(--muted);
  font-size: 13px;
}

.scope-label {
  justify-self: end;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

.service-section {
  margin-top: 26px;
  border-top: 1px solid var(--line);
}

.service-row {
  display: grid;
  grid-template-columns: minmax(280px, 1.5fr) minmax(150px, 0.55fr) auto;
  align-items: center;
  gap: 24px;
  min-height: 102px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.service-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.status-indicator {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--line-strong);
  box-shadow: 0 0 0 5px var(--surface-soft);
}

.status-active {
  background: var(--green);
  box-shadow: 0 0 0 5px var(--green-soft);
}

.status-inactive,
.status-failed {
  background: var(--red);
  box-shadow: 0 0 0 5px var(--red-soft);
}

.status-activating,
.status-deactivating,
.status-reloading {
  background: var(--amber);
  box-shadow: 0 0 0 5px var(--amber-soft);
}

.service-identity h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.service-identity p,
.service-runtime span {
  overflow-wrap: anywhere;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.service-runtime strong,
.service-runtime span {
  display: block;
}

.service-runtime strong {
  font-size: 14px;
}

.service-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, auto));
  gap: 7px;
}

.secondary-button,
.action-button,
.primary-button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.secondary-button,
.action-button,
.secondary-link {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--surface);
}

.secondary-button:hover,
.secondary-link:hover {
  border-color: var(--ink);
}

.action-start {
  border-color: #9ac8b2;
  color: var(--green);
  background: var(--green-soft);
}

.action-restart {
  border-color: #a9bfe9;
  color: var(--blue);
  background: var(--blue-soft);
}

.action-stop {
  border-color: #e4aea8;
  color: var(--red);
  background: var(--red-soft);
}

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

.primary-button {
  border: 1px solid var(--ink);
  color: #ffffff;
  background: var(--ink);
}

.primary-button:hover {
  background: #2d3941;
}

.login-layout {
  display: grid;
  min-height: calc(100vh - 180px);
  place-items: center;
}

.login-panel {
  width: min(440px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
}

.stacked-form {
  display: grid;
  gap: 9px;
  margin-top: 26px;
}

.stacked-form label {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 750;
}

.stacked-form input {
  width: 100%;
  height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--ink);
  background: #ffffff;
}

.stacked-form input:focus {
  outline: 3px solid var(--blue-soft);
  border-color: var(--blue);
}

.stacked-form .primary-button {
  margin-top: 12px;
}

.settings-band,
.audit-band {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.settings-form {
  width: min(560px, 100%);
  margin-top: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 16px;
}

.alert {
  margin-bottom: 20px;
  padding: 11px 13px;
  border: 1px solid;
  border-radius: 5px;
}

.alert-error {
  border-color: #e4aea8;
  color: #8f1d14;
  background: var(--red-soft);
}

.alert-success {
  border-color: #9ac8b2;
  color: #0c603b;
  background: var(--green-soft);
}

.logs-dialog {
  width: min(900px, calc(100% - 32px));
  max-height: min(720px, calc(100vh - 60px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.logs-dialog::backdrop {
  background: rgba(28, 37, 44, 0.56);
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-heading h2 {
  margin: 2px 0 0;
  font-size: 20px;
}

.close-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.logs-dialog pre {
  min-height: 360px;
  max-height: 560px;
  margin: 0;
  padding: 18px 20px;
  overflow: auto;
  color: #dce8df;
  background: #17201b;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 13px;
}

.result {
  display: inline-flex;
  padding: 3px 7px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: capitalize;
}

.result-success {
  color: var(--green);
  background: var(--green-soft);
}

.result-failed,
.result-denied,
.result-blocked {
  color: var(--red);
  background: var(--red-soft);
}

.empty-state {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  max-width: min(420px, calc(100% - 40px));
  padding: 12px 14px;
  border: 1px solid #9ac8b2;
  border-radius: 6px;
  color: #0c603b;
  background: var(--green-soft);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast-error {
  border-color: #e4aea8;
  color: #8f1d14;
  background: var(--red-soft);
}

.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .service-row {
    grid-template-columns: 1fr auto;
  }

  .service-runtime {
    text-align: right;
  }

  .service-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, 1fr);
    padding-left: 25px;
  }
}

@media (max-width: 680px) {
  .app-header {
    position: static;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
  }

  .brand {
    width: max-content;
  }

  .brand small {
    display: none;
  }

  .app-nav {
    justify-content: flex-start;
    width: 100%;
    overflow-x: auto;
  }

  .app-nav a,
  .link-button {
    min-height: 34px;
    padding: 7px 8px;
    font-size: 13px;
  }

  .page-shell {
    width: min(100% - 28px, 1180px);
    padding-top: 28px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .status-summary {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .status-summary > div:not(.scope-label) {
    display: grid;
    gap: 0;
  }

  .scope-label {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .service-row {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .service-runtime {
    padding-left: 25px;
    text-align: left;
  }

  .service-actions {
    grid-column: auto;
    grid-template-columns: repeat(2, 1fr);
    padding-left: 25px;
  }

  .login-panel {
    padding: 24px 20px;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
