* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Global header ---- */
.global-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1rem;
  background: #0d0d1a;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}

.global-header__title {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #a0c4ff;
}

.global-header__actions {
  display: flex;
  gap: 0.5rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ---- Right panel ---- */
.right-panel {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Two-column main layout (config + device status) ---- */
.main-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

.config-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.device-panel {
  position: sticky;
  top: 20px;
  align-self: start;
  max-width: 360px;
}

@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

.btn-primary {
  padding: 0.35rem 0.85rem;
  border: 1px solid #2a8bc0;
  border-radius: 4px;
  background: #1a6ba0;
  color: #fff;
  cursor: pointer;
  font-size: 0.82rem;
}

.btn-primary:hover:not(:disabled) {
  background: #2a8bc0;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ---- Left panel ---- */
.left-panel {
  width: 220px;
  min-width: 180px;
  background: #12122a;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
}

.panel-title {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #a0c4ff;
  border-bottom: 1px solid #333;
}

.device-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.device-list li {
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.device-list li:hover {
  background: #1e1e3f;
}

.device-list li.selected {
  background: #1e2a4a;
  border-left-color: #4a9eff;
  color: #a0c4ff;
}

.panel-actions {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid #333;
}

/* ---- Runtime controls toolbar (sticky) ---- */
.runtime-controls {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0f1220;
  padding: 10px 16px;
  border-bottom: 1px solid #2a2f45;
  flex-shrink: 0;
}

.runtime-controls__buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-group-sep {
  width: 1px;
  height: 1.5rem;
  background: #444;
  margin: 0 0.25rem;
}

/* ---- Workspace content area ---- */
.workspace-content {
  padding: 0 1rem 1rem;
  display: flex;
  flex-direction: column;
}

.workspace-section {
  padding-top: 0;
}

/* ---- Section title + divider (Cisco style) ---- */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: #8aa0ff;
  margin-top: 18px;
  margin-bottom: 6px;
  display: block;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  margin-bottom: 6px;
}

.section-title-row .section-title {
  margin-top: 0;
  margin-bottom: 0;
}

.section-divider {
  border: none;
  border-bottom: 1px solid #2a2f45;
  margin-bottom: 14px;
}

.section-actions {
  display: flex;
  gap: 0.35rem;
}

.section-body {
  padding: 0 0 0.75rem;
}

/* ---- Field table ---- */
.field-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
}

.field-table th {
  text-align: left;
  padding: 0.3rem 0.5rem 0.3rem 0;
  color: #888;
  font-weight: 400;
  white-space: nowrap;
  width: 140px;
}

.field-table td {
  padding: 0.3rem 0;
  color: #e0e0e0;
}

/* ---- Field inputs (edit mode) ---- */
.field-input {
  background: #1a1a3a;
  border: 1px solid #4a4a7a;
  border-radius: 3px;
  color: #e0e0e0;
  padding: 0.2rem 0.4rem;
  font-size: 0.875rem;
  width: 100%;
  max-width: 260px;
}

.field-input:focus {
  outline: none;
  border-color: #4a9eff;
}

select.field-input {
  cursor: pointer;
}

/* ---- Reads list ---- */
.reads-container {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #3d3d6e #0d0d1a;
}

.reads-container::-webkit-scrollbar {
  width: 6px;
}

.reads-container::-webkit-scrollbar-track {
  background: #0d0d1a;
}

.reads-container::-webkit-scrollbar-thumb {
  background-color: #3d3d6e;
  border-radius: 3px;
}

.reads-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* ---- Read row (view mode) ---- */
.read-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  font-family: 'Courier New', monospace;
  color: #c8e6c9;
  background: #0d0d1a;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
}

.read-row.read-row-duplicate {
  border-color: #ff6b6b;
  background: #1a0a0a;
}

.read-row-text {
  flex: 1;
}

.read-actions {
  display: flex;
  gap: 0.3rem;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

/* ---- Read editor (inline) ---- */
.read-editor {
  background: #0d0d1a;
  border: 1px solid #4a4a7a;
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
}

.read-editor-fields {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 0.3rem 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-family: system-ui, sans-serif;
}

.read-editor-fields label {
  color: #888;
}

.read-editor-actions {
  display: flex;
  gap: 0.35rem;
}

/* ---- Small buttons (section controls) ---- */
.btn-sm {
  padding: 0.2rem 0.55rem;
  border: 1px solid #444;
  border-radius: 3px;
  background: #2d2d4e;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 0.78rem;
}

.btn-sm:hover {
  background: #3d3d6e;
}

.btn-sm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm.btn-save {
  border-color: #2a8bc0;
  background: #1a4a6a;
}

.btn-sm.btn-save:hover {
  background: #2a6a9a;
}

.btn-sm.btn-danger {
  border-color: #8b2a2a;
  background: #5a1a1a;
  color: #ffaaaa;
}

.btn-sm.btn-danger:hover {
  background: #7a2a2a;
}

/* ---- Buttons ---- */
.btn-action {
  padding: 0.35rem 0.75rem;
  border: 1px solid #444;
  border-radius: 4px;
  background: #2d2d4e;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 0.82rem;
}

.btn-action:hover:not(:disabled) {
  background: #3d3d6e;
}

.btn-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---- Device status dot ---- */
.device-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #888;
  flex-shrink: 0;
}

.device-online  { background: #22c55e; }
.device-error   { background: #ef4444; }
.device-offline { background: #888; }
.device-warning { background: #f59e0b; }

@keyframes pulse {
  0%   { opacity: 0.4; }
  50%  { opacity: 1; }
  100% { opacity: 0.4; }
}

.device-blink {
  animation: pulse 0.25s ease-in-out;
}

/* ---- Device Status panel health badge ---- */
.ds-health-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.ds-health-ok       { background: #14532d; color: #86efac; border: 1px solid #22c55e; }
.ds-health-error    { background: #450a0a; color: #fca5a5; border: 1px solid #ef4444; }
.ds-health-stale    { background: #451a03; color: #fcd34d; border: 1px solid #f59e0b; }
.ds-health-disabled { background: #1c1c2e; color: #94a3b8; border: 1px solid #475569; }
.ds-health-unknown  { background: #1c1c2e; color: #94a3b8; border: 1px solid #475569; }

/* ---- Device Summary runtime badge ---- */
.ds-runtime-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: capitalize;
}

.ds-runtime-online  { background: #14532d; color: #86efac; border: 1px solid #22c55e; }
.ds-runtime-error   { background: #450a0a; color: #fca5a5; border: 1px solid #ef4444; }
.ds-runtime-offline { background: #1c1c2e; color: #94a3b8; border: 1px solid #475569; }
.ds-runtime-warning { background: #451a03; color: #fcd34d; border: 1px solid #f59e0b; }

/* ---- Diagnostics latency colour ---- */
.ds-latency-ok      { color: #86efac; }
.ds-latency-warn    { color: #fcd34d; }
.ds-latency-error   { color: #fca5a5; }
.ds-latency-unknown { color: #94a3b8; }

/* ---- Poll Performance bar ---- */
.ds-poll-perf {
  margin-top: 0.65rem;
}

.ds-poll-perf-label {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-bottom: 0.3rem;
}

.ds-poll-perf-bar-wrap {
  width: 100%;
  background: #2d2d4e;
  border-radius: 3px;
  height: 8px;
  overflow: hidden;
  border: 1px solid #3a3a5e;
}

.ds-poll-perf-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.ds-poll-perf-bar.ds-latency-ok    { background: #22c55e; }
.ds-poll-perf-bar.ds-latency-warn  { background: #f59e0b; }
.ds-poll-perf-bar.ds-latency-error { background: #ef4444; }
.ds-poll-perf-bar.ds-latency-unknown { background: #475569; }

/* ---- Sparkline SVG ---- */
.ds-sparkline {
  display: block;
  width: 100%;
  height: 40px;
  background: #16162a;
  border-radius: 4px;
  border: 1px solid #2d2d4e;
}

.ds-sparkline-label {
  font-size: 0.72rem;
  margin-top: 0.25rem;
  text-align: right;
}

/* ---- Slot hint (used slots indicator in target edit form) ---- */
.slot-hint {
  font-size: 0.75rem;
  color: #888;
  margin-left: 0.4rem;
}

/* ---- Field validation error ---- */
.field-error {
  display: block;
  color: #ff6b6b;
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: #2d2d4e;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
  color: #e0e0e0;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  transition: opacity 0.3s;
}

.toast.hidden {
  display: none;
}

/* ---- Header logo icon ---- */
.header-logo {
  width: 22px;
  height: 22px;
  margin-right: 8px;
  vertical-align: middle;
}

/* ---- Login logo ---- */
.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

/* ---- Login page ---- */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.login-card {
  background: #12122a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 2rem 2.5rem;
  width: 320px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.login-card__title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #a0c4ff;
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-field {
  margin-bottom: 1rem;
}

.login-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 0.35rem;
}

.login-field .field-input {
  max-width: 100%;
}

.login-btn {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.88rem;
}

.login-error {
  display: none;
  color: #ff6b6b;
  font-size: 0.82rem;
  margin-top: 0.75rem;
  text-align: center;
}

/* ---- User menu dropdown ---- */
.user-menu {
  position: relative;
}

.user-menu__trigger {
  padding: 0.35rem 0.75rem;
  border: 1px solid #444;
  border-radius: 4px;
  background: #2d2d4e;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 0.82rem;
}

.user-menu__trigger:hover {
  background: #3d3d6e;
}

.user-menu__dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #12122a;
  border: 1px solid #444;
  border-radius: 4px;
  min-width: 120px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.user-menu__dropdown.open {
  display: block;
}

.user-menu__item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  text-align: left;
  background: none;
  border: none;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 0.82rem;
}

.user-menu__item:hover {
  background: #1e1e3f;
}

.change-password-notice {
  color: #f59e0b;
  font-size: 0.82rem;
  margin-bottom: 1.25rem;
  text-align: center;
  line-height: 1.4;
}

/* ---- Help page ---- */
.help-page {
  height: 100vh;
  overflow: hidden;
}

.help-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 42px);
  overflow: hidden;
}

/* Left navigation */
.help-nav {
  width: 220px;
  min-width: 180px;
  background: #12122a;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.help-nav__title {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #a0c4ff;
  border-bottom: 1px solid #333;
}

.help-nav__list {
  list-style: none;
  padding: 0.35rem 0;
}

.help-nav__link {
  display: block;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: #c0c0d0;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.help-nav__link:hover {
  background: #1e1e3f;
  color: #e0e0ff;
}

.help-nav__link--active {
  background: #1e2a4a;
  border-left-color: #4a9eff;
  color: #a0c4ff;
}

/* Main content area */
.help-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem 3rem;
  scrollbar-width: thin;
  scrollbar-color: #3d3d6e #0d0d1a;
}

.help-content::-webkit-scrollbar {
  width: 6px;
}

.help-content::-webkit-scrollbar-track {
  background: #0d0d1a;
}

.help-content::-webkit-scrollbar-thumb {
  background-color: #3d3d6e;
  border-radius: 3px;
}

/* Page header */
.help-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #2a2f45;
}

.help-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #a0c4ff;
  margin-bottom: 0.4rem;
}

.help-subtitle {
  font-size: 0.9rem;
  color: #888;
}

/* Sections */
.help-section {
  margin-bottom: 2.5rem;
  scroll-margin-top: 1rem;
}

.help-section__heading {
  font-size: 1rem;
  font-weight: 600;
  color: #8aa0ff;
  margin-bottom: 0.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.help-section__subheading {
  font-size: 0.9rem;
  font-weight: 600;
  color: #a0c4ff;
  margin-top: 1rem;
  margin-bottom: 0.4rem;
}

.help-section__body {
  font-size: 0.9rem;
  color: #c8c8d8;
  line-height: 1.65;
  margin-bottom: 0.75rem;
}

/* Help table */
.help-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.help-table th {
  text-align: left;
  padding: 0.45rem 0.75rem;
  background: #0d0d1a;
  color: #8aa0ff;
  font-weight: 600;
  border-bottom: 1px solid #2a2f45;
}

.help-table td {
  padding: 0.5rem 0.75rem;
  color: #c8c8d8;
  border-bottom: 1px solid #1e2035;
  vertical-align: top;
  line-height: 1.55;
}

.help-table tr:hover td {
  background: #1a1a30;
}

/* Field name badge */
.help-field {
  display: inline-block;
  background: #1e2a4a;
  border: 1px solid #2a3a6a;
  border-radius: 3px;
  padding: 0.1rem 0.45rem;
  font-size: 0.82rem;
  color: #a0c4ff;
  white-space: nowrap;
}

/* Inline code */
.help-code {
  background: #0d0d1a;
  border: 1px solid #2a2a4a;
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  color: #c8e6c9;
}

/* Lists inside help */
.help-list {
  padding-left: 1.2rem;
  margin: 0.35rem 0;
  font-size: 0.875rem;
  color: #c8c8d8;
  line-height: 1.7;
}

.help-list--compact {
  margin: 0.2rem 0 0;
}

/* Definition list for troubleshooting */
.help-dl {
  margin-top: 0.25rem;
}

.help-dl__term {
  font-size: 0.9rem;
  font-weight: 600;
  color: #a0c4ff;
  margin-top: 1rem;
}

.help-dl__desc {
  font-size: 0.875rem;
  color: #c8c8d8;
  margin-left: 1rem;
  line-height: 1.55;
}

/* Credits / copyright */
.help-credits {
  margin-top: 0.75rem;
}

.help-copyright {
  color: #666;
  font-size: 0.85rem;
}

/* Back button */
.help-back-btn {
  text-decoration: none;
  display: inline-block;
}

@media (max-width: 700px) {
  .help-nav {
    display: none;
  }

  .help-content {
    padding: 1rem 1rem 3rem;
  }
}
