:root {
  --ibm-blue-60: #0f62fe;
  --ibm-blue-70: #0043ce;
  --ibm-blue-50: #4589ff;
  --ibm-gray-10: #f4f4f4;
  --ibm-gray-20: #e0e0e0;
  --ibm-gray-30: #c6c6c6;
  --ibm-gray-40: #a8a8a8;
  --ibm-gray-50: #8d8d8d;
  --ibm-gray-60: #6f6f6f;
  --ibm-gray-70: #525252;
  --ibm-gray-80: #393939;
  --ibm-gray-90: #262626;
  --ibm-gray-100: #161616;
  --ibm-red-60: #da1e28;
  --ibm-green-50: #24a148;
  --ibm-cyan-40: #33b1ff;
  --header-h: 48px;
  --rail-w: 256px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  background: var(--ibm-gray-100);
  color: var(--ibm-gray-10);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; }

/* IBM 8-bar mark */
.ibm-bars {
  display: flex;
  gap: 2px;
  height: 16px;
  align-items: stretch;
}
.ibm-bars span {
  width: 3px;
  background: var(--ibm-gray-10);
  display: block;
}
.ibm-bars span:nth-child(1),
.ibm-bars span:nth-child(8) { background: var(--ibm-blue-50); }

.product {
  display: flex;
  align-items: center;
  gap: 12px;
}
.product-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.16px;
}
.product-name small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--ibm-gray-40);
  letter-spacing: 0.32px;
  text-transform: uppercase;
}

/* Login */
.login-shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
}
.login-brand {
  background: var(--ibm-gray-100);
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--ibm-gray-90);
}
.login-brand h1 {
  font-size: 42px;
  font-weight: 300;
  margin: 48px 0 12px;
  letter-spacing: -0.5px;
  line-height: 1.15;
}
.login-brand p { color: var(--ibm-gray-40); max-width: 28ch; }
.login-meta { color: var(--ibm-gray-60); font-size: 12px; }
.login-panel {
  background: var(--ibm-gray-90);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.login-card { width: 100%; max-width: 400px; }
.login-card h2 {
  font-size: 28px;
  font-weight: 400;
  margin: 0 0 32px;
}

.field { margin-bottom: 24px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--ibm-gray-30);
  margin-bottom: 8px;
}
.field input, .field textarea {
  width: 100%;
  height: 40px;
  background: var(--ibm-gray-10);
  color: var(--ibm-gray-100);
  border: none;
  border-bottom: 1px solid var(--ibm-gray-50);
  padding: 0 16px;
  font: inherit;
  outline: none;
}
.field textarea {
  height: 120px;
  padding: 12px 16px;
  resize: vertical;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 12px;
}
.field input:focus, .field textarea:focus {
  border-bottom: 2px solid var(--ibm-blue-60);
  box-shadow: 0 2px 0 0 var(--ibm-blue-60);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 16px;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 400;
  text-decoration: none;
  color: #fff;
  background: var(--ibm-blue-60);
  min-width: 160px;
}
.btn:hover { background: var(--ibm-blue-70); }
.btn.full { width: 100%; }
.btn.ghost {
  background: transparent;
  color: var(--ibm-gray-10);
  border: 1px solid var(--ibm-gray-50);
  min-width: 0;
  height: 40px;
}
.btn.ghost:hover { background: var(--ibm-gray-80); }
.btn.danger { background: var(--ibm-red-60); }
.btn.danger:hover { background: #a2191f; }
.btn.sm { height: 32px; min-width: 0; padding: 0 12px; font-size: 12px; }

.alert {
  padding: 12px 16px;
  margin-bottom: 16px;
  border-left: 3px solid var(--ibm-red-60);
  background: #2d0709;
  color: var(--ibm-gray-10);
  font-size: 13px;
}
.alert.success {
  border-left-color: var(--ibm-green-50);
  background: #071d0e;
}

/* App chrome */
.app { min-height: 100%; }
.header {
  height: var(--header-h);
  background: var(--ibm-gray-100);
  border-bottom: 1px solid var(--ibm-gray-90);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--ibm-gray-30);
  font-size: 13px;
}
.layout {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: calc(100vh - var(--header-h));
}
.rail {
  background: var(--ibm-gray-90);
  padding: 16px 0;
  border-right: 1px solid var(--ibm-gray-80);
}
.rail a {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  color: var(--ibm-gray-10);
  text-decoration: none;
  border-left: 4px solid transparent;
}
.rail a.active {
  background: var(--ibm-gray-80);
  border-left-color: var(--ibm-blue-60);
  font-weight: 600;
}
.rail .hint {
  padding: 24px 16px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.32px;
  color: var(--ibm-gray-50);
}

.main { padding: 32px; }
.page-title {
  font-size: 28px;
  font-weight: 400;
  margin: 0 0 8px;
}
.page-sub { color: var(--ibm-gray-40); margin: 0 0 24px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--ibm-gray-80);
  border: 1px solid var(--ibm-gray-80);
  margin-bottom: 32px;
}
.tile {
  background: var(--ibm-gray-90);
  padding: 16px 20px 20px;
  min-height: 96px;
}
.tile .k {
  font-size: 12px;
  color: var(--ibm-gray-40);
  margin-bottom: 8px;
}
.tile .v {
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.3px;
}
.tile .v.ok { color: var(--ibm-green-50); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.section-head h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--ibm-gray-90);
}
table.data th, table.data td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ibm-gray-80);
  vertical-align: middle;
  font-size: 13px;
}
table.data th {
  background: var(--ibm-gray-80);
  font-weight: 600;
  font-size: 12px;
  color: var(--ibm-gray-30);
}
table.data tr:hover td { background: #2c2c2c; }
.pk { font-size: 12px; color: var(--ibm-gray-30); max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  background: var(--ibm-gray-70);
  color: var(--ibm-gray-10);
}
.tag.on { background: #071d0e; color: var(--ibm-green-50); }
.tag.off { background: #2d0709; color: #ff8389; }

.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1px;
  background: var(--ibm-gray-80);
  border: 1px solid var(--ibm-gray-80);
}
.export-card {
  background: var(--ibm-gray-90);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.export-card h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
}
.export-card p {
  margin: 0;
  color: var(--ibm-gray-40);
  font-size: 13px;
  min-height: 64px;
}
.export-card details {
  margin-top: 8px;
}
.export-card summary {
  cursor: pointer;
  color: var(--ibm-blue-50);
  font-size: 13px;
}
.export-card.featured {
  outline: 2px solid var(--ibm-blue-60);
  outline-offset: -2px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.device-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 12px;
  background: var(--ibm-gray-80);
  cursor: pointer;
  font-size: 13px;
}
.device-card:has(input:checked) {
  outline: 2px solid var(--ibm-blue-60);
  background: #1c2b4a;
}
.device-card input { accent-color: var(--ibm-blue-60); }
.choice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
  font-size: 14px;
}
.hint-text {
  margin: 8px 0 0;
  color: var(--ibm-gray-40);
  font-size: 12px;
}

.panel {
  background: var(--ibm-gray-90);
  padding: 24px;
  margin-top: 32px;
  border-top: 4px solid var(--ibm-blue-60);
}
.panel h3 { margin: 0 0 16px; font-weight: 400; font-size: 20px; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}

.conf-box {
  background: var(--ibm-gray-100);
  border: 1px solid var(--ibm-gray-80);
  padding: 16px;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-x: auto;
  color: var(--ibm-cyan-40);
}
.qr { background: #fff; padding: 12px; display: inline-block; }
.qr img { display: block; width: 220px; height: 220px; }

.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input {
  height: 32px;
  background: var(--ibm-gray-10);
  color: var(--ibm-gray-100);
  border: none;
  padding: 0 8px;
  width: 140px;
  font: inherit;
}

@media (max-width: 980px) {
  .login-shell, .layout, .tiles, .grid-2 { grid-template-columns: 1fr; }
  .rail { display: none; }
  .main { padding: 20px 16px; }
}
