* { box-sizing: border-box; }
body { font-family: system-ui, 'Segoe UI', sans-serif; margin: 0; background: #f0f2f5; }
button { cursor: pointer; pointer-events: auto !important; }
.header { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1.25rem; background: #1a237e; color: #fff; }
.header h1 { margin: 0; font-size: 1.15rem; }
.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.header-actions a { color: rgba(255,255,255,0.9); text-decoration: none; }
.header-actions a:hover { text-decoration: underline; }
.header-actions button { padding: 0.35rem 0.75rem; background: rgba(255,255,255,0.2); border: none; color: #fff; border-radius: 6px; cursor: pointer; }
.header-actions button:hover { background: rgba(255,255,255,0.3); }
.screen { padding: 1rem; max-width: 1180px; margin: 0 auto; }
.screen.hidden { display: none !important; }
.card { background: #fff; border-radius: 8px; padding: 1.25rem; margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.card h2 { margin: 0 0 0.5rem 0; font-size: 1rem; color: #333; }
.card h3 { margin: 0 0 0.5rem 0; font-size: 0.95rem; color: #444; }
.hint, .meta { font-size: 0.85rem; color: #666; margin: 0.5rem 0; }
.error { color: #c62828; }
.hidden { display: none; }
.tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { padding: 0.5rem 1rem; background: #fff; border: 1px solid #ddd; border-radius: 6px; cursor: pointer; }
.tabs button.active { background: #1a237e; color: #fff; border-color: #1a237e; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.actions { margin-top: 0.5rem; }
.actions button { margin-right: 0.5rem; padding: 0.4rem 0.75rem; background: #3949ab; color: #fff; border: none; border-radius: 6px; cursor: pointer; }
.actions button.danger { background: #c62828; }
.form-section { font-size: 0.95rem; margin: 1.25rem 0 0.5rem 0; color: #333; border-bottom: 1px solid #eee; padding-bottom: 0.25rem; }
.form-section:first-of-type { margin-top: 0; }
.preset-row { display: flex; align-items: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.field-label { font-weight: 600; }
.field-desc { font-size: 0.75rem; color: #888; display: block; margin-bottom: 0.2rem; }
.test-result { margin-top: 0.5rem; padding: 0.5rem; border-radius: 4px; font-size: 0.9rem; min-height: 1.5rem; }
.test-result.ok { background: #e8f5e9; color: #2e7d32; }
.test-result.err { background: #ffebee; color: #c62828; }
.btn-test-broker { margin-right: 0.25rem; padding: 0.2rem 0.5rem; font-size: 0.8rem; background: #3949ab; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.btn-test-broker:hover { background: #303f9f; }
.btn-edit-broker { margin-right: 0.25rem; padding: 0.2rem 0.5rem; font-size: 0.8rem; background: #2e7d32; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.btn-edit-broker:hover { background: #1b5e20; }
.actions button.danger:hover { background: #b71c1c; }
.form-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; align-items: center; }
.form-row label { display: flex; flex-direction: column; gap: 0.25rem; }
.form-row input, .form-row select { padding: 0.4rem 0.6rem; }
.full-width { width: 100%; max-width: 400px; box-sizing: border-box; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid #eee; }
th { background: #f5f5f5; font-weight: 600; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.ok { background: #22c55e; }
.status-dot.err { background: #ef4444; }
.status-dot.warn { background: #eab308; }
.status-dot.checking { background: #eab308; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }
.btn-secondary { background: #757575; color: #fff; }
.btn-secondary:hover { background: #616161; }
.login-card { max-width: 400px; margin: 2rem auto; }
.login-card label { display: block; margin-bottom: 0.5rem; }
.login-card input { width: 100%; padding: 0.5rem; margin-top: 0.25rem; }
.login-card button { margin-top: 0.75rem; padding: 0.5rem 1rem; background: #1a237e; color: #fff; border: none; border-radius: 6px; cursor: pointer; }
pre { background: #f5f5f5; padding: 0.75rem; border-radius: 6px; overflow: auto; font-size: 0.85rem; white-space: pre-wrap; word-break: break-all; max-height: 300px; }
.broker-order-list { list-style: none; padding: 0; margin: 0.5rem 0; }
.broker-order-list li { padding: 0.4rem 0.6rem; margin-bottom: 0.25rem; background: #f5f5f5; border-radius: 4px; }
.broker-order-list li:hover { background: #eee; }
.broker-order-list li.backup-list-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; justify-content: space-between; }
.backup-list-item .backup-meta { flex: 1; min-width: 200px; font-size: 0.875rem; }
.backup-list-item .backup-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }
.backup-list-item .backup-actions button { padding: 0.25rem 0.5rem; font-size: 0.8rem; border: none; border-radius: 4px; cursor: pointer; }
.backup-list-item .backup-actions .btn-backup-dl { background: #3949ab; color: #fff; }
.backup-list-item .backup-actions .btn-backup-dl:hover { background: #303f9f; }
.backup-list-item .backup-actions .btn-backup-del { background: #c62828; color: #fff; }
.backup-list-item .backup-actions .btn-backup-del:hover { background: #b71c1c; }
.form-row-wrap { align-items: center; }
.form-row-wrap input[type=file] { max-width: 100%; }

.iot-json-editor {
  width: 100%;
  max-width: 100%;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.8rem;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  resize: vertical;
}
.iot-catalog-preview { margin: 0.75rem 0; font-size: 0.8rem; }
.iot-catalog-preview table { font-size: 0.8rem; margin-bottom: 0.75rem; }
.iot-catalog-preview h4 { margin: 0.5rem 0 0.25rem; font-size: 0.85rem; color: #444; }
.iot-templates-table { min-width: 640px; }
.iot-templates-table .btn-tiny {
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  margin-right: 0.25rem;
}

/* —— IoT designer tab (professional layout) —— */
.iot-designer-root { padding-bottom: 2rem; scroll-padding-top: 3rem; scroll-behavior: smooth; }
#iot-section-taxonomy,
#iot-section-library,
#iot-section-json,
#iot-section-studio,
#iot-section-user-tpl {
  scroll-margin-top: 3.5rem;
}
.iot-jump-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  padding: 0.5rem 0.75rem;
  margin: 0 0 0.75rem;
  background: #e8eaf6;
  border-radius: 8px;
  border: 1px solid #c5cae9;
  font-size: 0.85rem;
}
.iot-jump-label { color: #5c6bc0; font-weight: 600; margin-right: 0.25rem; }
.iot-jump-nav a {
  color: #1a237e;
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #9fa8da;
}
.iot-jump-nav a:hover { background: #f3e5f5; border-color: #7e57c2; }
.iot-panel--scroll .iot-device-accordion-root {
  max-height: min(55vh, 28rem);
  overflow-y: auto;
  padding-right: 0.25rem;
}
.iot-catalog-tabbed-root { margin-top: 0.5rem; }
.iot-catalog-tabnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.iot-catalog-tab {
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid #9fa8da;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  color: #311b92;
}
.iot-catalog-tab:hover { background: #ede7f6; }
.iot-catalog-tab.active {
  background: #5e35b1;
  color: #fff;
  border-color: #4527a0;
}
.iot-catalog-tab-panel { display: none; }
.iot-catalog-tab-panel.active { display: block; }
.iot-catalog-panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}
.iot-catalog-panel-toolbar h4 { margin: 0; font-size: 0.82rem; color: #4527a0; }
.iot-catalog-scroll-wrap {
  max-height: min(60vh, 560px);
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid #e1bee7;
  border-radius: 6px;
  background: #fafafa;
}
.iot-catalog-scroll-wrap.iot-collapsed { display: none; }
.iot-sample-new-card {
  border: 1px solid #c5cae9;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
  background: #f8f9ff;
}
.iot-sample-new-title { margin: 0 0 0.35rem; font-size: 0.9rem; color: #1a237e; }
.iot-sample-new-grid { margin-bottom: 0.35rem; }
.iot-btn-primary {
  padding: 0.45rem 1rem;
  background: #3949ab;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.iot-btn-primary:hover { background: #283593; }
.iot-sample-list-wrap { margin: 0.75rem 0; }
.iot-sample-list-title { margin: 0 0 0.35rem; font-size: 0.85rem; color: #4527a0; }
.iot-sample-list-scroll {
  max-height: 200px;
  overflow: auto;
  border: 1px solid #e1bee7;
  border-radius: 6px;
}
.iot-sample-templates-table { width: 100%; font-size: 0.78rem; border-collapse: collapse; }
.iot-sample-templates-table th { background: #ede7f6; text-align: left; padding: 0.35rem; position: sticky; top: 0; }
.iot-sample-templates-table td { padding: 0.3rem 0.35rem; border-bottom: 1px solid #eee; vertical-align: middle; }
.iot-sample-templates-table code { font-size: 0.72rem; }
.iot-hero {
  background: linear-gradient(135deg, #0d1642 0%, #1a237e 42%, #3949ab 100%);
  color: #fff;
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 12px 40px rgba(26, 35, 126, 0.25);
}
.iot-hero-inner { max-width: 52rem; }
.iot-hero-kicker {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  opacity: 0.85;
  margin: 0 0 0.35rem 0;
}
.iot-hero-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.iot-hero-lead {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
  opacity: 0.92;
}
.iot-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}
.iot-designer-root .iot-badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.28);
}

.iot-layout-split {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 900px) {
  .iot-layout-split { grid-template-columns: 1fr; }
}

.iot-panel {
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border: 1px solid #e8eaf6;
}
.iot-panel--accent {
  border-color: #c5cae9;
  background: linear-gradient(180deg, #fafbff 0%, #fff 100%);
}
.iot-panel--json .iot-json-editor { min-height: 220px; }
.iot-panel-title {
  margin: 0 0 0.35rem 0;
  font-size: 0.95rem;
  color: #1a237e;
  font-weight: 650;
}
.iot-panel-desc {
  margin: 0 0 0.75rem 0;
  font-size: 0.8rem;
  color: #666;
  line-height: 1.45;
}
.iot-summary-line {
  margin: 0 0 0.75rem 0;
  font-size: 0.82rem;
  color: #455a64;
}
.iot-json-actions { margin-top: 0.5rem; }

.iot-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.6rem;
}
.iot-cat-card {
  background: #f5f7ff;
  border: 1px solid #e8eaf6;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font-size: 0.8rem;
}
.iot-cat-card h4 {
  margin: 0 0 0.35rem 0;
  font-size: 0.82rem;
  color: #283593;
}
.iot-cat-card p {
  margin: 0;
  font-size: 0.75rem;
  color: #616161;
  line-height: 1.4;
}

.iot-device-accordion-root {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}
.iot-accordion-block {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  background: #fafafa;
}
.iot-accordion-head {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #37474f;
  border: none;
  background: #eceff1;
  cursor: pointer;
}
.iot-accordion-head:hover { background: #e3e7ea; }
.iot-accordion-body {
  padding: 0.45rem 0.65rem 0.65rem;
  background: #fff;
  border-top: 1px solid #eee;
}
.iot-device-chip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.78rem;
}
.iot-device-chip:last-child { border-bottom: none; }
.iot-device-chip code {
  font-size: 0.72rem;
  background: #e8eaf6;
  color: #1a237e;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
}
.iot-device-chip em {
  font-style: normal;
  font-size: 0.68rem;
  color: #6b7280;
  margin-left: auto;
}

.iot-user-templates-card {
  margin-top: 1rem;
  border: 1px solid #e8eaf6;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.iot-studio-card {
  margin-top: 1.25rem;
  border: 1px solid #c5cae9;
  background: linear-gradient(180deg, #fafbff 0%, #fff 30%);
  box-shadow: 0 6px 24px rgba(26, 35, 126, 0.08);
}
.iot-studio-heading { margin-top: 0; color: #1a237e; font-size: 1.05rem; }
.iot-studio-intro { max-width: 56rem; }
.iot-studio-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.35rem; }
.iot-studio-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.75rem 0 0.5rem;
}
.iot-studio-tab {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  border: 1px solid #c5cae9;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  color: #3949ab;
}
.iot-studio-tab:hover { background: #e8eaf6; }
.iot-studio-tab.active {
  background: #1a237e;
  color: #fff;
  border-color: #1a237e;
}
.iot-studio-pane.hidden { display: none !important; }
.iot-studio-pane { padding-top: 0.25rem; }

.iot-studio-global-templates {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid #9fa8da;
  border-radius: 10px;
  background: linear-gradient(180deg, #f3e5f5 0%, #fafafa 48%);
}
.iot-studio-global-templates-title {
  margin: 0 0 0.35rem 0;
  font-size: 1rem;
  color: #4a148c;
}
.iot-studio-global-templates-hint { margin: 0 0 0.5rem !important; }
.iot-studio-sample-global-scroll { max-height: min(38vh, 360px); }
.iot-sample-editor-section {
  margin-top: 1rem;
  padding: 1rem;
  border: 2px solid #7e57c2;
  border-radius: 10px;
  background: #faf8ff;
}
.iot-sample-editor-title {
  margin: 0 0 0.35rem 0;
  font-size: 1.05rem;
  color: #311b92;
}
.iot-sample-editor-hint { margin: 0 0 0.75rem !important; }
.iot-sample-templates-table tr.iot-sample-tpl-row--active {
  background: #e8eaf6 !important;
  outline: 1px solid #5e35b1;
}
.iot-sample-templates-table tr.iot-sample-tpl-row--active td {
  font-weight: 500;
}
.iot-studio-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
}
.iot-studio-form-grid--wide { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.iot-studio-fullrow { grid-column: 1 / -1; }
.iot-studio-fullrow textarea { width: 100%; max-width: 100%; box-sizing: border-box; font-family: ui-monospace, monospace; font-size: 0.8rem; }
.iot-studio-table { width: 100%; font-size: 0.8rem; }
.iot-studio-table th { background: #ede7f6; color: #4527a0; }
.iot-td-mono { font-size: 0.72rem; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; word-break: break-all; }
.iot-sample-canvas {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  border: 1px dashed #c5cae9;
  border-radius: 8px;
  min-height: 3rem;
  background: #fafbff;
}
.iot-sample-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid #e8eaf6;
  font-size: 0.82rem;
  cursor: grab;
}
.iot-sample-row:last-child { border-bottom: none; }
.iot-sample-drag { cursor: grab; color: #7e57c2; user-select: none; }
.iot-sample-title { flex: 1; min-width: 0; color: #333; }
.iot-sample-code { font-size: 0.72rem; background: #e8eaf6; padding: 0.15rem 0.35rem; border-radius: 4px; color: #1a237e; }
.iot-sample-head { margin-bottom: 0.5rem; }
code { font-family: monospace; font-size: 0.85em; background: #f0f0f0; padding: 0.1rem 0.3rem; border-radius: 4px; }
.footer { margin-top: 2rem; padding: 1rem; text-align: center; font-size: 0.85rem; color: #666; border-top: 1px solid #eee; }
.test-output { background: #1e1e1e; color: #d4d4d4; padding: 1rem; border-radius: 6px; font-size: 0.8rem; max-height: 400px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin-top: 0.5rem; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.hidden { display: none; }
.modal-card { background: #fff; border-radius: 8px; padding: 1.25rem; max-width: 560px; width: 90%; max-height: 90vh; overflow: auto; box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
.modal-card h2 { margin: 0 0 1rem 0; font-size: 1.1rem; }
.modal-card .form-row { margin-bottom: 0.75rem; }
.modal-card table { margin: 1rem 0; }
.modal-card #btnCloseUserTokensModal { margin-top: 1rem; }
.hub-presence-on { color: #15803d; font-weight: 600; }
.hub-presence-off { color: #9ca3af; }

/* IoT sample template designer (kéo thả lưới 8 cột, giống Chat) */
.iot-sample-designer-toolbar { align-items: flex-end; }
.iot-sample-designer-toolbar .device-setup-inline { font-size: 0.88rem; color: #37474f; }
.iot-sample-designer-toolbar .device-setup-inline select {
  margin-left: 0.35rem; padding: 0.4rem 0.5rem; border-radius: 6px; border: 1px solid #b0bec5;
  background: #fff; color: #263238; min-width: 12rem;
}
.iot-sample-designer-toolbar .device-setup-search {
  flex: 1; min-width: 160px; padding: 0.45rem 0.6rem; border-radius: 6px;
  border: 1px solid #b0bec5; background: #fff; color: #263238;
}
.iot-sample-designer-grid { margin-top: 0.5rem; }
.modal.device-modal-iot {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex;
  align-items: center; justify-content: center; z-index: 1100; padding: 1rem;
}
.modal.device-modal-iot.hidden { display: none !important; }
.modal.device-modal-iot .modal-content { background: #16213e; padding: 1.5rem; border-radius: 12px; min-width: 280px; max-width: 100%; color: #e2e8f0; }
.modal.device-modal-iot .modal-content h3 { margin: 0 0 1rem 0; color: #f1f5f9; }
.modal.device-modal-iot .device-setup-label { display: block; margin-bottom: 0.5rem; font-size: 0.9rem; }
.modal.device-modal-iot .modal-content input { width: 100%; padding: 0.5rem; border-radius: 6px; border: 1px solid #334155; background: #0f172a; color: #eee; font-size: 16px; }
.modal.device-modal-iot .modal-content .hint { color: #94a3b8; }
.modal.device-modal-iot .modal-content button { margin-right: 0.5rem; margin-top: 0.5rem; }

.device-template-toolbar,
.device-panel-setup-designer { max-width: 100%; }
.device-designer-toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin: 0.75rem 0; }
.device-designer-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 1rem; margin-top: 0.5rem; }
@media (max-width: 720px) {
  .device-designer-grid { grid-template-columns: 1fr; }
}
.device-designer-subtitle { margin: 0 0 0.35rem 0; font-size: 0.9rem; color: #546e7a; }
.device-palette-hint { margin: 0 0 0.5rem 0; font-size: 0.78rem; }
.device-setup-palette {
  display: flex; flex-wrap: wrap; gap: 0.45rem; align-content: flex-start; min-height: 120px;
  padding: 0.5rem; background: #0f172a; border: 1px dashed #475569; border-radius: 8px;
}
.device-palette-chip {
  cursor: grab; padding: 0.4rem 0.55rem; font-size: 0.8rem; border-radius: 6px;
  background: #1e3a5f; border: 1px solid #334155; color: #e2e8f0; max-width: 100%;
}
.device-palette-chip:active { cursor: grabbing; }
.device-palette-chip--static { background: #1e293b; border-color: #64748b; }
.device-setup-canvas {
  min-height: 180px; padding: 0.5rem; background: #0f172a; border: 2px dashed #3b82f6;
  border-radius: 8px; display: flex; flex-direction: column; gap: 0.5rem;
}
.device-setup-canvas.device-canvas-dragover { border-color: #93c5fd; background: #172554; }
.device-canvas-grid-row {
  border: 1px solid #334155; border-radius: 8px; background: #111c2e; padding: 0.35rem 0.4rem 0.45rem;
}
.device-canvas-grid-row.device-canvas-row--over { outline: 2px solid #3b82f6; outline-offset: 1px; }
.device-canvas-row-head {
  font-size: 0.72rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.25rem;
}
.device-canvas-grid-inner {
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0.35rem;
  align-items: stretch; min-height: 2.75rem; padding: 0.2rem 0; border-radius: 6px;
  transition: background 0.15s ease;
}
.device-canvas-grid-inner.device-canvas-inner--drag {
  background: rgba(59, 130, 246, 0.12); outline: 1px dashed #3b82f6;
}
.device-canvas-cell {
  position: relative; display: flex; flex-direction: column; gap: 0.2rem; min-width: 0;
  min-height: 3rem; padding: 0.5rem; background: #16213e; border: 1px solid #475569;
  border-radius: 6px; cursor: grab; font-size: 0.8rem; touch-action: none;
}
.device-canvas-cell:active { cursor: grabbing; }
.device-canvas-cell--over { outline: 2px solid #3b82f6; outline-offset: 1px; }
.device-canvas-cell-badge {
  font-size: 0.65rem; color: #38bdf8; font-family: ui-monospace, monospace; align-self: flex-start;
}
.device-canvas-row-type { font-size: 0.68rem; color: #64748b; text-transform: uppercase; flex-shrink: 0; }
.device-canvas-row-label {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e2e8f0;
}
.device-canvas-empty { color: #64748b; font-size: 0.85rem; padding: 1rem; text-align: center; }
.device-ctx-menu {
  position: fixed; z-index: 1200; min-width: 200px; padding: 0.35rem 0;
  background: #1e293b; border: 1px solid #475569; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.device-ctx-menu.hidden { display: none !important; }
.device-ctx-item {
  display: block; width: 100%; text-align: left; padding: 0.5rem 0.85rem;
  background: transparent; border: none; color: #e2e8f0; font-size: 0.88rem; cursor: pointer;
}
.device-ctx-item:hover { background: #334155; }
.device-ctx-submenu-label {
  padding: 0.35rem 0.85rem 0.2rem; font-size: 0.72rem; color: #94a3b8; text-transform: uppercase;
  letter-spacing: 0.03em; border-top: 1px solid #334155; margin-top: 0.25rem;
}
.device-ctx-width-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.25rem; padding: 0.35rem 0.5rem 0.5rem;
}
.device-ctx-chip {
  padding: 0.35rem 0; font-size: 0.8rem; border-radius: 6px; border: 1px solid #475569;
  background: #0f172a; color: #cbd5e1; cursor: pointer;
}
.device-ctx-chip:hover { background: #334155; border-color: #64748b; }
.device-widget-modal-layout { margin: 0.75rem 0; padding-top: 0.5rem; border-top: 1px solid #334155; }
.device-layout-hint { margin: 0 0 0.5rem 0; }
.device-layout-fields { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: flex-end; }
.device-layout-field { font-size: 0.85rem; color: #cbd5e1; }
.device-layout-field input {
  width: 4.5rem; margin-left: 0.25rem; padding: 0.35rem 0.4rem; border-radius: 6px;
  border: 1px solid #334155; background: #0f172a; color: #eee;
}
.device-widget-modal-content { max-width: 420px; }
.device-widget-modal-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.iot-catalog-tab-filter {
  flex: 1; min-width: 140px; max-width: 280px; padding: 0.35rem 0.5rem; border-radius: 6px;
  border: 1px solid #b0bec5; font-size: 0.85rem;
}
.iot-studio-act-subtabs {
  display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0;
  align-items: center;
}
.iot-studio-act-subtabs button {
  padding: 0.35rem 0.65rem; font-size: 0.82rem; border-radius: 6px;
  border: 1px solid #b0bec5; background: #fff; cursor: pointer;
}
.iot-studio-act-subtabs button.active {
  background: #4527a0; color: #fff; border-color: #4527a0;
}
.iot-studio-actions-search {
  width: 100%; max-width: 420px; padding: 0.4rem 0.55rem; border-radius: 6px;
  border: 1px solid #b0bec5; margin-bottom: 0.5rem; font-size: 0.88rem;
}
.iot-studio-table-scroll {
  max-height: min(55vh, 520px);
  overflow: auto;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}
.iot-user-tpl-designer-card {
  margin-top: 1rem;
  padding: 0.85rem;
  border: 1px dashed #7e57c2;
  border-radius: 10px;
  background: #faf8ff;
}
.iot-user-tpl-designer-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.iot-check-inline { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; white-space: nowrap; }

/* License POS tab */
.license-row-warn { background: #fff8e1; }
.license-row-denied { opacity: 0.92; border-left: 4px solid #c62828; }
.license-warn { color: #e65100; }
.license-registry-actions button { margin-right: 0.25rem; margin-bottom: 0.25rem; }
