:root {
  --bg: #f5f7f6;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #65726d;
  --line: #dbe2df;
  --accent: #0f766e;
  --accent-strong: #0b5d56;
  --warning: #b45309;
  --danger: #b42318;
  --ok: #15803d;
  --shadow: 0 18px 45px rgba(20, 35, 30, 0.1);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
.primary-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  padding: 7px 11px;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--accent-strong);
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 7px 9px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.section-header,
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-form {
  display: grid;
  gap: 14px;
  min-width: min(620px, calc(100vw - 32px));
  padding: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.msp-page {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: #f5f7f6;
  color: #17211d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: 18px;
}

.login-panel {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  border: 1px solid #dbe2df;
  border-radius: 8px;
  background: #ffffff;
  padding: 20px;
  box-shadow: 0 18px 45px rgba(20, 35, 30, 0.1);
}

.login-panel h1,
.login-panel p {
  margin: 0;
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: #65726d;
  font-size: 13px;
  font-weight: 700;
}

.login-panel input {
  min-height: 38px;
  border: 1px solid #dbe2df;
  border-radius: 6px;
  padding: 7px 9px;
}

.login-error {
  min-height: 18px;
  color: #b42318;
  font-size: 13px;
}

.msp-sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
}

.msp-workspace {
  min-width: 0;
  min-height: 100vh;
}

.msp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.msp-topbar h2,
.msp-topbar p,
.msp-panel h3,
.msp-card p,
.metric-tile p {
  margin: 0;
}

.msp-actions,
.msp-nav {
  display: flex;
  gap: 8px;
}

.msp-actions {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.msp-nav {
  flex-direction: column;
  margin-top: 14px;
}

.msp-nav button {
  justify-content: flex-start;
  text-align: left;
}

.msp-nav button.is-active {
  border-color: var(--accent);
  background: #e7f5f2;
  color: var(--accent-strong);
  font-weight: 800;
}

.msp-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.metric-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 10px;
}

.metric-tile strong {
  display: block;
  font-size: 24px;
  line-height: 1;
  margin-bottom: 6px;
}

.metric-tile p {
  color: var(--muted);
  font-size: 12px;
}

.msp-section {
  display: none;
  padding: 18px;
}

.msp-section.is-active {
  display: block;
}

.msp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.msp-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.msp-list {
  display: grid;
  gap: 10px;
}

.msp-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 12px;
}

.msp-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.msp-card strong {
  font-size: 15px;
}

.msp-card p,
.device-row span,
.status-pill {
  color: var(--muted);
  font-size: 12px;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  background: white;
  font-weight: 800;
}

.status-pill.online {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--ok);
}

.status-pill.offline,
.status-pill.critical {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.status-pill.warning {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--warning);
}

.status-pill.info {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.device-table {
  display: grid;
  gap: 8px;
}

.device-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 82px 82px 82px 96px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 10px;
}

.device-row.is-head {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding-top: 0;
}

.device-main {
  display: grid;
  gap: 3px;
}

.token-output {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
  padding: 10px;
}

.token-output.has-token {
  display: block;
}

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

  .msp-page {
    grid-template-columns: 1fr;
  }

  .msp-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .device-row,
  .device-row.is-head {
    grid-template-columns: 1fr 1fr;
  }

  .device-row.is-head {
    display: none;
  }
}
