/* BSC Connect control center: layout and hierarchy shared by all portal views. */
:root {
  --rail-bg: #f3f8f6;
  --rail-text: #526568;
  --rail-active: #192b2d;
  --rail-hover: #edf4f2;
  --sidebar-w: 216px;
}
:root[data-theme="dark"] {
  --rail-bg: #1c2324;
  --rail-text: #b0c1bf;
  --rail-active: #edf4f2;
  --rail-hover: #253a34;
}

/* Navigation follows the selected theme and uses the same surfaces as content. */
.sidebar { flex: 0 0 var(--sidebar-w); width: var(--sidebar-w); min-width: 0; max-width: var(--sidebar-w); background: var(--rail-bg); border-right: 0; color: var(--rail-active); }
.side-brand { flex-basis: 64px; min-height: 64px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.side-brand .brand-text strong { color: var(--rail-active); font-size: 19px; font-weight: 600; letter-spacing: -.035em; }
.side-brand .brand-dot { color: var(--accent); }
.side-brand .brand-text small { color: var(--rail-text); }
.side-nav { padding: 12px 10px; gap: 2px; }
.side-nav .nav-item svg { display: block; width: 17px; height: 17px; opacity: .72; }
.side-section { color: var(--rail-active); opacity: 1; padding: 22px 9px 6px; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.side-section:first-child { padding-top: 8px; }
.nav-item { min-height: 39px; gap: 10px; color: var(--rail-text); padding: 8px 11px; border-radius: 0; font-weight: 500; }
.nav-item:hover { background: var(--rail-hover); color: var(--rail-active); }
.nav-item.active {
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-item.active svg { opacity: 1; }
.nav-item.active .badge-count { background: transparent; color: var(--accent); }
.badge-count { background: transparent; color: var(--text-dim); border-radius: 0; padding-inline: 2px; }
.side-foot { border-top: 1px solid var(--border); }
.user-chip { background: transparent; }
.user-chip .u-name { color: var(--rail-active); }
.user-chip .u-mail { color: var(--rail-text); }
.user-chip .logout-btn { color: var(--rail-text); }
.user-chip .logout-btn:hover { background: var(--surface-3); color: var(--err); }

.content-topbar { min-height: 64px; flex-basis: 64px; padding-inline: 18px; border-color: var(--border); background: var(--rail-bg); }
.content-main { height: calc(100vh - 64px); }
.page-title { font-size: 21px; font-weight: 600; }
.app-page { width: 100%; max-width: none; margin: 0; padding: 16px 18px 24px; gap: 16px; }
#view-dashboard { overflow-y: auto; }

/* The five readings form one instrument strip, with a single heading. */
.status-overview {
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.status-overview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 0;
}
.status-overview-head h2 { font-size: 14px; font-weight: 600; letter-spacing: .015em; }
.status-overview-total { color: var(--text-dim); font-size: 13px; }
#view-dashboard .stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; padding: 6px 0 10px; }
#view-dashboard .stat-card {
  min-height: 60px;
  padding: 6px 14px;
  gap: 9px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}
#view-dashboard .stat-card:last-child { border-right: 0; }
#view-dashboard .stat-ico { width: 22px; height: 22px; background: transparent; }
#view-dashboard .stat-ico svg { width: 19px; height: 19px; }
#view-dashboard .stat-meta .v { font-size: 26px; }
#view-dashboard .stat-meta .l { margin-top: 5px; font-size: 12px; }

/* The list heading, filters, and rows form one workspace. */
#view-dashboard .device-workspace {
  flex: 0 0 auto;
  display: flex;
  min-height: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: none;
  overflow: visible;
}
#view-dashboard .device-workspace .panel-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 9px;
  min-height: 0;
  padding: 12px 14px;
  border: 0;
}
.dashboard-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; min-height: 44px; }
#view-dashboard .dashboard-heading h2 { font-size: 22px; font-weight: 600; letter-spacing: -.025em; }
#view-dashboard .dashboard-heading .head-actions { margin-left: auto; flex: 0 0 auto; }
.dashboard-heading .head-actions .btn { display: inline-flex; align-items: center; gap: 7px; }
.dashboard-filters { flex: 1 1 370px; width: auto; max-width: none; gap: 6px; }
.dashboard-filters .search { flex: 1 1 220px; min-width: 160px; max-width: none; background: var(--surface); }
.tag-filter-btn, .filter-btn { background: var(--surface); }
#view-dashboard .device-workspace .panel-body { flex: 0 0 auto; padding: 0; border-top: 1px solid var(--border); }
#view-dashboard .table-scroll { flex: 0 0 auto; background: var(--surface); border: 0; border-radius: 0 0 10px 10px; overflow: visible; }
#view-dashboard .table-scroll .bsc-table { min-width: 880px; width: 100%; }
#view-dashboard .bsc-table thead th {
  position: sticky;
  top: 0;
  padding-top: 15px;
  padding-bottom: 15px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
}
#view-dashboard .device-row { position: relative; }
#view-dashboard .device-row.menu-open { z-index: 30; }
#view-dashboard .device-row td { height: 68px; padding-top: 9px; padding-bottom: 9px; }
#view-dashboard .device-row .dev-main { box-shadow: none; }
#view-dashboard .bsc-table .dev-name { font-size: 15px; }
#view-dashboard .bsc-table .dev-id { margin-top: 5px; color: var(--text-dim); }
.dev-details { display: none; }
#view-dashboard .bsc-table .pill { min-width: 88px; justify-content: center; }
#view-dashboard .bsc-table td.actions .actions-wrap { gap: 12px; }
#view-dashboard .bsc-table td.actions .row-history-action,
#view-dashboard .bsc-table td.actions .row-diagnosis-action,
#view-dashboard .bsc-table td.actions .row-more-toggle { width: 32px; height: 32px; }
#view-dashboard .actions-wrap .row-history-action,
#view-dashboard .actions-wrap .row-diagnosis-action { border: 1px solid var(--border); background: var(--surface); }
#view-dashboard .actions-wrap .row-history-action:hover,
#view-dashboard .actions-wrap .row-diagnosis-action:hover { background: var(--surface-2); border-color: var(--border-2); }
#view-dashboard .actions-wrap .row-action-primary {
  width: 32px;
  height: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
}
#view-dashboard .actions-wrap .row-action-primary:hover { color: var(--accent-2); background: var(--accent-soft); border-color: var(--border-2); }
#view-dashboard .actions-wrap .row-action-primary svg { flex: 0 0 auto; width: 16px; height: 16px; }
.row-more { position: relative; display: inline-flex; }
#view-dashboard .actions-wrap .row-more-toggle {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
}
#view-dashboard .actions-wrap .row-more-toggle:hover,
#view-dashboard .row-more.open .row-more-toggle { border-color: var(--border-2); background: var(--surface-2); color: var(--text); }
.row-menu {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  z-index: 40;
  display: none;
  min-width: 215px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.row-more.open .row-menu { display: block; }
.row-menu.drop-up { top: auto; bottom: calc(100% + 5px); }
#view-dashboard .row-menu .menu-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: auto;
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: 500 13px var(--sans);
  text-align: left;
  cursor: pointer;
}
#view-dashboard .row-menu .menu-action:hover { background: var(--surface-2); }
#view-dashboard .row-menu .menu-action.danger { color: var(--err); }
#view-dashboard .row-menu .menu-action svg { flex: 0 0 auto; width: 16px; height: 16px; }
#view-dashboard .row-menu .menu-action .icon-badge { position: static; order: 3; margin-left: auto; }

/* Secondary views use section rules rather than stacks of cards. */
.app-page:not(#view-dashboard) .panel {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border-2);
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}
.app-page:not(#view-dashboard) .panel:first-child { border-top: 0; }
.app-page:not(#view-dashboard) .panel.panel-danger { border-top: 2px solid var(--err); }
.app-page:not(#view-dashboard) .panel-head { padding: 18px 0 12px; border: 0; }
.app-page:not(#view-dashboard) .panel-head h2 { font-size: 20px; }
.app-page:not(#view-dashboard) .panel-body { padding: 8px 0 20px; }
#view-account .panel-head,
#view-settings .panel-head { display: none; }
.app-page:not(#view-dashboard) .form-grid { gap: 12px 16px; }
#view-settings .panel-body { max-width: 760px; }
#view-settings .settings-section { padding-bottom: 16px; }
#view-settings .settings-section + .settings-section { padding-top: 16px; }
#view-settings .settings-section h3 { margin-bottom: 8px; font-size: 16px; }
#view-settings .switch-row { max-width: none; padding: 10px 0; }
#view-settings #password-form .form-grid { display: flex; flex-direction: column; max-width: 420px; gap: 10px; }
#view-settings #password-form .field { gap: 4px; }
#view-settings #password-form .field label { margin: 0; }
#view-settings #password-form .form-actions { margin-top: 14px; }
.app-page:not(#view-dashboard) .table-scroll { background: var(--surface); border-top: 1px solid var(--border-2); border-bottom: 1px solid var(--border); border-radius: 0; }
.app-page:not(#view-dashboard) .bsc-table thead th { background: var(--surface-2); text-transform: none; letter-spacing: 0; }
.app-page:not(#view-dashboard) .bsc-table td { height: 56px; }
.dev-stats { margin-bottom: 18px; }
.status-alarm { background: #f0e8f7; color: #6e3f91; animation: none; }
:root[data-theme="dark"] .status-alarm { background: #3b2d46; color: #d8b8ec; }
.modal-card { border-radius: 10px; box-shadow: var(--shadow); }

/* All sign-in forms share one restrained layout. */
.screen .card { max-width: 500px; border-radius: 10px; box-shadow: var(--shadow); }
#view-auth .auth-brand {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 0 12px;
  margin-bottom: 28px;
  text-align: left;
}
#view-auth .auth-brand .brand-logo { grid-row: 1 / 3; width: 52px; height: 52px; }
#view-auth .auth-brand .brand-name { margin: 0; font-size: 23px; }
#view-auth .auth-brand .brand-tagline { max-width: none; font-size: 12.5px; }

/* The relay controls read as one instrument bar above the unchanged device UI. */
.console-bar,
.topbar { border-bottom: 1px solid var(--border-2); }
.topbar .console-brand { min-width: 180px; }
.topbar .console-brand .brand-text strong { font-size: 18px; font-weight: 600; letter-spacing: -.035em; }
.topbar .console-brand .brand-text small { color: var(--text-dim); font-size: 11px; }
.topbar .console-brand .brand-dot { color: var(--accent); }
.console-bar { padding-inline: 24px; }
.console-bar #status,
.topbar #status { font-weight: 600; }
.seg { background: var(--surface-2); border: 0; border-radius: 6px; }
.seg-btn { min-height: 32px; }
.view-console .panel-logs .panel-body,
.panel-logs .panel-body { padding: 20px 24px; }
.panel-logs .toolbar { gap: 12px; }
.panel-logs .viewer { border: 0; border-top: 1px solid var(--border); border-radius: 0; }
.panel-logs .files { border-top: 1px solid var(--border); }

@media (max-width: 1180px) {
  #view-dashboard .stat-card { gap: 7px; padding-inline: 13px; }
  #view-dashboard .stat-meta .v { font-size: 25px; }
  #view-dashboard .stat-meta .l { font-size: 11.5px; }
  .app-page { padding: 12px; gap: 14px; }
  #view-dashboard { overflow-y: auto; }
  #view-dashboard .device-workspace { flex: 0 0 auto; }
  .dashboard-heading { flex-wrap: wrap; }
  #view-dashboard .dashboard-heading .head-actions { margin-left: auto; }
  .dashboard-filters { flex-wrap: wrap; }
  .dashboard-filters .search { flex: 1 1 220px; max-width: none; }
  #view-dashboard .device-workspace .panel-body { overflow: visible; }
  #view-dashboard .table-scroll { overflow: visible; max-height: none; background: var(--surface); }
  #view-dashboard .bsc-table,
  #view-dashboard .bsc-table tbody { display: block; width: 100%; }
  #view-dashboard .table-scroll .bsc-table { min-width: 0; border-collapse: separate; border-spacing: 0; }
  #view-dashboard .bsc-table thead { display: none; }
  #view-dashboard .device-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    margin-bottom: 0;
    background: var(--surface);
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    overflow: visible;
  }
  #view-dashboard .device-row:last-child { border-bottom: 0; }
  #view-dashboard .device-row td { display: block; height: auto; padding: 10px 14px; border: 0; }
  #view-dashboard .device-row .dev-main { grid-column: 1; grid-row: 1; width: auto; min-width: 0; max-width: none; box-shadow: none; padding-bottom: 4px; }
  #view-dashboard .device-row td:nth-child(2) { grid-column: 2; grid-row: 1; justify-self: end; }
  #view-dashboard .device-row .dev-fw,
  #view-dashboard .device-row .dev-updated { display: none; }
  #view-dashboard .device-row .tag-cell { grid-column: 1; grid-row: 2; padding-top: 2px; padding-bottom: 10px; }
  #view-dashboard .device-row .actions { grid-column: 1 / -1; grid-row: 3; border-top: 1px solid var(--border); padding-block: 7px; }
  #view-dashboard .device-row .actions-wrap { flex-wrap: wrap; }
  #view-dashboard .dev-main-wrap { width: auto; }
  #view-dashboard .dev-details { display: flex; flex-wrap: wrap; gap: 0 14px; margin-top: 7px; color: var(--text-dim); font-size: 12px; }
  #view-dashboard .device-row .dev-id { max-width: 100%; }
  #view-dashboard .device-row .pill { min-width: 0; }
}
@media (max-width: 860px) {
  #view-dashboard .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #view-dashboard .stat-card:nth-child(3) { border-right: 0; }
  #view-dashboard .stat-card:nth-child(n+4) { border-top: 1px solid var(--border); }
}
@media (max-width: 560px) {
  .app-page { padding: 10px; gap: 12px; }
  .status-overview-head { padding-inline: 15px; }
  #view-dashboard .stat-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); padding-block: 6px 8px; }
  #view-dashboard .stat-card { flex-direction: column; align-items: center; min-height: 64px; padding: 5px 2px; gap: 0; border-right: 1px solid var(--border); border-top: 0; }
  #view-dashboard .stat-card:nth-child(3) { border-right: 1px solid var(--border); }
  #view-dashboard .stat-card:last-child { border-right: 0; }
  #view-dashboard .stat-card:nth-child(n+4) { border-top: 0; }
  #view-dashboard .stat-ico { display: none; }
  #view-dashboard .stat-meta { align-items: center; text-align: center; }
  #view-dashboard .stat-meta .v { font-size: 21px; }
  #view-dashboard .stat-meta .l { font-size: 10px; line-height: 1.15; white-space: normal; }
  .dashboard-heading { align-items: flex-start; gap: 8px; }
  #view-dashboard .dashboard-heading .head-actions { width: 100%; justify-content: space-between; }
  .dashboard-filters .search { flex-basis: 100%; }
  #view-dashboard .device-row { grid-template-columns: minmax(0, 1fr); }
  #view-dashboard .device-row .dev-main,
  #view-dashboard .device-row td:nth-child(2) { grid-column: 1; }
  #view-dashboard .device-row td:nth-child(2) { grid-row: 2; justify-self: start; padding-top: 0; }
  #view-dashboard .device-row .tag-cell { grid-row: 3; }
  #view-dashboard .device-row .actions { grid-row: 4; }
  #view-dashboard .row-menu { left: 0; right: auto; }
  .console-bar { padding-inline: 12px; }
}
