:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-alt: #f7f6f2;

  --text: #202621;
  --muted: #737a74;
  --faint: #9ba09c;

  --line: #e7e7e2;
  --line-strong: #dcded9;

  --green: #476556;
  --green-soft: #edf1ee;

  --warm: #8b735d;
  --warm-soft: #f5f1ec;

  --blue: #5c7178;
  --blue-soft: #eef2f3;

  --danger: #9a4e47;
  --danger-soft: #f8eeec;

  --warning: #8a6a45;
  --warning-soft: #f7f2e9;

  --radius: 12px;
  --radius-small: 8px;

  --shadow:
    0 1px 2px rgba(26, 34, 28, 0.035),
    0 6px 22px rgba(26, 34, 28, 0.035);
}


* {
  box-sizing: border-box;
}


html,
body {
  margin: 0;
  min-height: 100%;
}


body {
  background: var(--bg);
  color: var(--text);

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Helvetica,
    Arial,
    sans-serif;

  font-size: 14px;
  line-height: 1.45;

  -webkit-font-smoothing: antialiased;
}


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


button {
  color: inherit;
}


.hidden {
  display: none !important;
}


.full {
  width: 100%;
}


.mobile-only {
  display: none;
}


/* Login ------------------------------------------------------------------ */

.login-screen {
  min-height: 100vh;

  display: grid;
  place-items: center;

  padding: 24px;
}


.login-panel {
  width: min(360px, 100%);

  border: 1px solid var(--line);
  border-radius: var(--radius);

  background: var(--surface);

  padding: 30px;

  box-shadow: var(--shadow);
}


.brand {
  color: var(--text);

  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}


.login-panel h1 {
  margin: 32px 0 4px;

  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.6px;
}


.login-panel p {
  margin: 0 0 28px;

  color: var(--muted);
}


.login-panel label {
  display: block;

  margin-bottom: 7px;

  color: var(--muted);

  font-size: 12px;
  font-weight: 600;
}


.login-panel input {
  width: 100%;

  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);

  outline: none;

  background: var(--surface);

  padding: 11px 12px;

  color: var(--text);

  transition:
    border-color 130ms ease,
    box-shadow 130ms ease;
}


.login-panel input:focus {
  border-color: #9cac9f;

  box-shadow:
    0 0 0 3px rgba(71, 101, 86, 0.07);
}


.login-panel .button {
  margin-top: 12px;
}


/* Buttons ---------------------------------------------------------------- */

.button,
.plain-button {
  appearance: none;

  border: 0;

  cursor: pointer;
}


.button {
  border-radius: var(--radius-small);

  padding: 9px 13px;

  font-size: 12px;
  font-weight: 600;

  transition:
    background 130ms ease,
    border-color 130ms ease,
    transform 130ms ease;
}


.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}


.button.primary {
  background: #344e40;
  color: #fff;
}


.button.primary:hover {
  background: #2c4337;
}


.button.subtle {
  border: 1px solid var(--line);

  background: var(--surface);
}


.button.subtle:hover {
  background: var(--surface-alt);
}


.button.warning {
  border: 1px solid #eadfd2;

  background: var(--warning-soft);
  color: #74583b;
}


.button.danger {
  border: 1px solid #ecd9d5;

  background: var(--danger-soft);
  color: var(--danger);
}


.button.compact {
  padding: 7px 10px;
}


.plain-button {
  background: transparent;
  padding: 6px;

  color: var(--muted);
}


/* App -------------------------------------------------------------------- */

.app {
  display: grid;

  grid-template-columns:
    212px minmax(0, 1fr);

  min-height: 100vh;
}


.sidebar {
  position: sticky;
  top: 0;

  display: flex;
  flex-direction: column;

  height: 100vh;

  border-right: 1px solid var(--line);

  background: #fcfbf8;

  padding: 22px 14px;
}


.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 0 9px 22px;
}


.navigation {
  display: flex;
  flex-direction: column;
  gap: 1px;

  overflow-y: auto;
}


.nav-button {
  width: 100%;

  border: 0;
  border-radius: 8px;

  background: transparent;

  padding: 8px 10px;

  cursor: pointer;

  color: #626963;

  text-align: left;

  font-size: 13px;
  font-weight: 450;

  transition:
    background 110ms ease,
    color 110ms ease;
}


.nav-button:hover {
  background: #f2f2ee;
  color: var(--text);
}


.nav-button.active {
  background: var(--green-soft);
  color: #334b3e;

  font-weight: 600;
}


.sidebar-footer {
  margin-top: auto;

  padding-top: 16px;
}


.side-mode {
  margin-bottom: 9px;

  border: 1px solid var(--line);
  border-radius: var(--radius-small);

  background: var(--surface);

  padding: 9px 10px;

  color: var(--muted);

  font-size: 11px;
}


.main {
  min-width: 0;
}


.topbar {
  position: sticky;
  z-index: 20;
  top: 0;

  min-height: 70px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;

  border-bottom: 1px solid var(--line);

  background: rgba(250, 249, 246, 0.93);

  padding:
    10px
    clamp(20px, 3vw, 34px);

  backdrop-filter: blur(12px);
}


.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}


.page-context {
  color: var(--faint);

  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}


.page-title {
  margin: 1px 0 0;

  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.45px;
}


.system-state {
  border: 1px solid var(--line);
  border-radius: 999px;

  background: var(--surface);

  padding: 6px 10px;

  color: #55605a;

  font-size: 11px;
  font-weight: 550;
}


.complexity-switch {
  display: flex;

  border: 1px solid var(--line);
  border-radius: 9px;

  background: var(--surface);

  padding: 2px;
}


.complexity-button {
  border: 0;
  border-radius: 6px;

  background: transparent;

  padding: 6px 10px;

  cursor: pointer;

  color: var(--muted);

  font-size: 11px;
  font-weight: 600;
}


.complexity-button.active {
  background: var(--green-soft);
  color: #334b3e;
}


.page-content {
  width: min(1280px, 100%);

  margin: 0 auto;

  padding:
    30px
    clamp(20px, 3vw, 36px)
    64px;
}


.loading {
  padding: 70px 0;

  color: var(--muted);

  text-align: center;
}


/* Structure -------------------------------------------------------------- */

.page-heading {
  margin-bottom: 24px;
}


.page-heading h2 {
  margin: 0;

  font-size: 27px;
  font-weight: 570;
  letter-spacing: -0.85px;
}


.page-heading p {
  max-width: 700px;

  margin: 7px 0 0;

  color: var(--muted);

  font-size: 14px;
}


.grid {
  display: grid;

  grid-template-columns:
    repeat(
      auto-fit,
      minmax(230px, 1fr)
    );

  gap: 12px;
}


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


.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);

  background: var(--surface);

  padding: 18px;

  box-shadow: var(--shadow);
}


.panel + .panel,
.panel + .section,
.section + .panel,
.section + .section {
  margin-top: 12px;
}


.panel.soft-green {
  background:
    linear-gradient(
      0deg,
      rgba(237, 241, 238, 0.42),
      rgba(255, 255, 255, 0.97)
    );
}


.panel.soft-warm {
  background:
    linear-gradient(
      0deg,
      rgba(245, 241, 236, 0.48),
      rgba(255, 255, 255, 0.97)
    );
}


.panel.soft-blue {
  background:
    linear-gradient(
      0deg,
      rgba(238, 242, 243, 0.42),
      rgba(255, 255, 255, 0.97)
    );
}


.panel-title {
  margin-bottom: 10px;

  color: var(--muted);

  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.25px;
  text-transform: uppercase;
}


.metric {
  font-size: 25px;
  font-weight: 560;
  letter-spacing: -0.75px;
}


.metric.small {
  font-size: 18px;
}


.supporting {
  margin-top: 5px;

  color: var(--muted);

  font-size: 12px;
  line-height: 1.5;
}


.section {
  margin-top: 18px;
}


.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  margin-bottom: 9px;
}


.section-header h3 {
  margin: 0;

  font-size: 15px;
  font-weight: 600;
}


.section-header p {
  margin: 3px 0 0;

  color: var(--muted);

  font-size: 12px;
}


.status-row {
  display: flex;
  align-items: center;
  gap: 7px;
}


.dot {
  width: 7px;
  height: 7px;

  border-radius: 50%;

  background: #76927f;
}


.dot.warning {
  background: #a78760;
}


.dot.danger {
  background: #b6685e;
}


.tag {
  display: inline-flex;
  align-items: center;

  border: 1px solid var(--line);
  border-radius: 999px;

  background: var(--surface-alt);

  padding: 4px 7px;

  color: var(--muted);

  font-size: 10px;
  font-weight: 600;
}


.tag.green {
  border-color: #dce5df;
  background: var(--green-soft);
  color: #3f5e4e;
}


.tag.warning {
  border-color: #ebe0d3;
  background: var(--warning-soft);
  color: #72583e;
}


.tag.danger {
  border-color: #ead9d6;
  background: var(--danger-soft);
  color: #8d4b44;
}


.message {
  border-radius: var(--radius-small);

  padding: 9px 11px;

  font-size: 12px;
}


.message.error {
  background: var(--danger-soft);
  color: var(--danger);
}


.message.warning {
  background: var(--warning-soft);
  color: #72583e;
}


.message.success {
  background: var(--green-soft);
  color: #3e5b4b;
}


.notice {
  border-left: 2px solid #cad6cd;

  padding:
    4px
    0
    4px
    12px;

  color: var(--muted);

  font-size: 12px;
}


.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);

  padding: 34px 20px;

  color: var(--muted);

  text-align: center;
}


.empty strong {
  display: block;

  margin-bottom: 5px;

  color: var(--text);

  font-weight: 600;
}


/* Tables ----------------------------------------------------------------- */

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


table {
  width: 100%;

  border-collapse: collapse;

  font-size: 12px;
}


th {
  border-bottom: 1px solid var(--line);

  padding: 9px 8px;

  color: var(--faint);

  text-align: left;

  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}


td {
  border-bottom: 1px solid #efefeb;

  padding: 10px 8px;

  vertical-align: top;
}


tbody tr:last-child td {
  border-bottom: 0;
}


.mono {
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;

  font-size: 11px;
}


/* Credentials ------------------------------------------------------------ */

.credential-grid {
  display: grid;

  grid-template-columns:
    repeat(
      auto-fit,
      minmax(265px, 1fr)
    );

  gap: 10px;
}


.credential {
  border: 1px solid var(--line);
  border-radius: var(--radius);

  background: var(--surface);

  padding: 15px;
}


.credential-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;

  margin-bottom: 12px;
}


.credential h4 {
  margin: 0;

  font-size: 14px;
  font-weight: 600;
}


.credential-subtitle {
  margin-top: 3px;

  color: var(--muted);
  font-size: 11px;
}


.credential-value {
  margin-top: 6px;

  border-radius: 7px;

  background: #f8f7f4;

  padding: 7px 8px;
}


.credential-value label {
  display: block;

  margin-bottom: 2px;

  color: var(--faint);

  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
}


.credential-actions,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;

  margin-top: 11px;
}


/* Forms ------------------------------------------------------------------ */

.field {
  margin-bottom: 12px;
}


.field label {
  display: block;

  margin-bottom: 5px;

  color: var(--muted);

  font-size: 11px;
  font-weight: 600;
}


.field input,
.field select,
.field textarea,
.inline-select {
  width: 100%;

  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);

  outline: none;

  background: var(--surface);

  padding: 9px 10px;

  color: var(--text);
}


.field textarea {
  min-height: 100px;

  resize: vertical;
}


.field input:focus,
.field select:focus,
.field textarea:focus,
.inline-select:focus {
  border-color: #a5b3aa;

  box-shadow:
    0 0 0 3px rgba(71, 101, 86, 0.055);
}


.inline-control {
  display: grid;

  grid-template-columns:
    minmax(180px, 320px)
    auto;

  gap: 8px;

  align-items: end;
}


/* Developer Mode --------------------------------------------------------- */

.developer-banner {
  margin-bottom: 16px;

  border: 1px solid #e6e7e3;
  border-radius: var(--radius-small);

  background: #f5f5f2;

  padding: 10px 12px;

  color: var(--muted);

  font-size: 11px;
}


.control-grid {
  display: grid;

  grid-template-columns:
    repeat(
      auto-fit,
      minmax(270px, 1fr)
    );

  gap: 12px;
}


.control-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);

  background: var(--surface);

  padding: 16px;
}


.control-block h4 {
  margin: 0 0 4px;

  font-size: 14px;
  font-weight: 600;
}


.control-block p {
  margin: 0 0 13px;

  color: var(--muted);

  font-size: 11px;
}


details {
  border: 1px solid var(--line);
  border-radius: var(--radius-small);

  background: var(--surface);

  padding: 10px 12px;
}


details + details {
  margin-top: 8px;
}


summary {
  cursor: pointer;

  color: #59615b;

  font-size: 12px;
  font-weight: 600;
}


pre {
  overflow: auto;

  max-height: 420px;

  margin:
    10px
    0
    0;

  border-radius: 7px;

  background: #f6f6f3;

  padding: 12px;

  color: #454b46;

  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;

  font-size: 10px;
  line-height: 1.5;

  white-space: pre-wrap;
  word-break: break-word;
}


/* Modal ------------------------------------------------------------------ */

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;

  display: grid;
  place-items: center;

  background: rgba(24, 29, 25, 0.2);

  padding: 20px;

  backdrop-filter: blur(3px);
}


.modal {
  width: min(520px, 100%);

  max-height: 88vh;
  overflow-y: auto;

  border: 1px solid var(--line);
  border-radius: var(--radius);

  background: var(--surface);

  padding: 22px;

  box-shadow:
    0 20px 60px rgba(20, 27, 22, 0.16);
}


.modal h2 {
  margin: 0;

  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.4px;
}


.modal-copy {
  margin: 5px 0 18px;

  color: var(--muted);

  font-size: 12px;
}


.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;

  margin-top: 16px;
}


/* Toast ------------------------------------------------------------------ */

.toast {
  position: fixed;
  z-index: 200;

  right: 20px;
  bottom: 20px;

  max-width:
    min(
      420px,
      calc(100vw - 40px)
    );

  border: 1px solid #314a3d;
  border-radius: var(--radius-small);

  background: #344e40;

  padding: 10px 13px;

  color: #fff;

  font-size: 12px;

  box-shadow:
    0 8px 32px rgba(20, 32, 25, 0.14);
}


/* Compact developer density --------------------------------------------- */

body.compact-ui .page-content {
  padding-top: 20px;
}


body.compact-ui .panel,
body.compact-ui .control-block {
  padding: 13px;
}


body.compact-ui td {
  padding-top: 7px;
  padding-bottom: 7px;
}


/* Responsive ------------------------------------------------------------- */

@media (max-width: 900px) {

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


  .sidebar {
    position: fixed;
    z-index: 60;
    inset:
      0
      auto
      0
      0;

    width: min(270px, 88vw);

    transform: translateX(-105%);

    box-shadow:
      12px 0 35px rgba(28, 34, 29, 0.09);

    transition:
      transform 160ms ease;
  }


  .sidebar.open {
    transform: translateX(0);
  }


  .mobile-only {
    display: inline-flex;
  }


  .system-state {
    display: none;
  }

}


@media (max-width: 650px) {

  .topbar {
    min-height: 62px;

    padding: 9px 12px;
  }


  .topbar-right {
    gap: 6px;
  }


  .page-title {
    font-size: 16px;
  }


  .page-content {
    padding:
      22px
      12px
      48px;
  }


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


  .complexity-button {
    padding:
      5px
      7px;

    font-size: 10px;
  }


  #refresh-button {
    display: none;
  }


  .inline-control {
    grid-template-columns: 1fr;
  }

}
