/* Premium application shell. Loaded last so one visual contract wins. */

body {
  display: block;
  overflow: auto;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
}

/* ---------- App header ---------- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 160;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: #fff;
  border-bottom: 1px solid var(--sidebar-border);
  box-shadow: var(--shadow-sm);
}
.sidebar-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text-primary);
  cursor: pointer;
  flex: none;
}
.sidebar-toggle:hover { background: var(--bg-hover); border-color: var(--accent); }
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
}
.header-spacer { flex: 1; }
.app-header .connection-status,
.app-header .version-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.app-header .sidebar-user {
  margin: 0;
  padding: 4px 8px 4px 4px;
  max-width: 220px;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  box-shadow: none;
  z-index: 150;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  transition: width 0.18s ease, transform 0.2s ease;
}

.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.tdn-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tdn-brand-mark {
  display: block;
  flex: none;
  width: auto;
  max-width: 148px;
  height: 26px;
  object-fit: contain;
  object-position: left center;
  border-radius: 0;
  background: transparent;
}

.tdn-brand-name {
  display: block !important;
  color: var(--text-muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.workspace-switcher { margin-top: 14px; }
.workspace-switcher-button {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.workspace-switcher-button:hover { border-color: var(--accent); background: var(--accent-dim); }
.workspace-switcher-static { font-size: 13px; font-weight: 600; }
.workspace-switcher-static::before {
  content: "Workspace";
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.workspace-switcher-menu {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  padding: 6px;
}
.workspace-switcher-item {
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  margin-bottom: 2px;
}
.workspace-switcher-item:hover,
.workspace-switcher-item.highlighted { background: var(--bg-hover); }
.workspace-switcher-item.current { background: var(--accent-dim); color: var(--accent-hover); }
.workspace-switcher-search { background: #fff; border-bottom: 1px solid var(--border); }

.nav-links {
  padding: 12px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}

.nav-section-label {
  padding: 10px 12px 6px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nav-link {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 9px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 0;
  gap: 11px;
}

.nav-link svg { color: #7d8c96; flex-shrink: 0; }
.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}
.nav-link:hover svg { color: var(--text-primary); }
.nav-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  font-weight: 600;
  box-shadow: none;
}
.nav-link.active svg { color: var(--sidebar-text-active); }

.sidebar-footer { display: none; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
}

.sidebar-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar-user-initial {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user-meta { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}
.sidebar-user-role {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.connection-status {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 4px;
}

/* ---------- Main canvas ---------- */
.content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  background: var(--bg-primary);
  padding: 24px clamp(18px, 3vw, 40px) 56px;
  min-height: calc(100vh - var(--header-height));
  transition: margin-left 0.18s ease;
}

body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }
body.sidebar-collapsed .nav-section-label,
body.sidebar-collapsed .nav-link span { display: none; }
body.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 10px 8px;
  gap: 0;
}
body.sidebar-collapsed .content { margin-left: var(--sidebar-collapsed); }

body.auth-screen .app-header,
body.auth-screen .sidebar,
body.auth-screen .sidebar-backdrop { display: none !important; }
body.auth-screen .content {
  margin: 0 !important;
  padding: 0 !important;
  min-height: 100vh;
}

.page-header {
  align-items: flex-start;
  margin-bottom: 22px;
  gap: 16px;
}

.page-header h1 {
  color: var(--text-primary);
  font-size: clamp(22px, 2.1vw, 28px);
  font-weight: 650;
  letter-spacing: -0.032em;
  line-height: 1.15;
}

.page-header .subtitle {
  color: var(--text-secondary);
  font-size: 13.5px;
  margin-top: 6px;
  max-width: 52rem;
}

.help-tip {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-light);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  vertical-align: 2px;
  margin-left: 4px;
}

/* ---------- Controls ---------- */
.btn {
  height: var(--control-height);
  min-height: var(--control-height);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  gap: 7px;
  padding: 0 14px;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 1px 2px rgba(14, 158, 163, 0.28);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-secondary,
.btn:not(.btn-primary):not(.btn-danger):not(.btn-icon) {
  background: #fff;
  border-color: var(--border-light);
  color: var(--text-primary);
}
.btn-secondary:hover,
.btn:not(.btn-primary):not(.btn-danger):not(.btn-icon):hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #a82e2e;
  border-color: #a82e2e;
  color: #fff;
}

.btn-sm { min-height: 32px; height: 32px; border-radius: 8px; font-size: 12px; }
.btn-icon {
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 8px;
  color: var(--text-muted);
}
.btn-icon:hover { background: var(--bg-subtle); color: var(--text-primary); }

.btn:focus-visible,
.btn-icon:focus-visible,
.nav-link:focus-visible,
.input:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible {
  box-shadow: var(--focus-ring);
  outline: 0;
}

.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
input[type="time"],
select,
textarea {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 9px;
  min-height: var(--control-height);
  padding: 0 12px;
  color: var(--text-primary);
}
.input:hover, input:hover, select:hover, textarea:hover { border-color: #adc0c6; }
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  outline: 0;
}

.pairing-input {
  font-family: var(--font-mono);
  font-size: 28px;
  letter-spacing: 0.28em;
  border-radius: 12px;
  background: var(--bg-subtle);
  min-height: 56px;
}

/* ---------- Cards, metrics, tables ---------- */
.info-card,
.card,
.settings-section,
.activity-table-wrap,
.content-item,
.device-card,
.widget-type-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.info-card { padding: 16px 18px; }
.info-card:hover,
.card:hover { border-color: #c9d6db; }
.info-card-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.info-card-value {
  color: var(--text-primary);
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.03em;
  margin-top: 6px;
}

.dash-stats-row {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px !important;
  margin-bottom: 18px !important;
}

.display-toolbar,
.content-library-toolbar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 8px;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
}
.display-search { flex: 1 1 240px; min-width: 0; max-width: 440px; }
.display-search .input { width: 100% !important; }
.display-toolbar select.input { width: 190px; flex: 0 0 auto; }

.device-grid { grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 16px; }
.device-card { overflow: hidden; }
.device-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.device-card.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.device-card-preview { background: #e8eef1; }
.device-card-body { padding: 14px 16px 16px; }
.device-card-name,
.content-item-name {
  color: var(--text-primary);
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.015em;
}
.device-card-content-action { color: var(--accent-hover); font-weight: 650; }
.device-card-content-value.is-empty { color: var(--warning); }

.device-status-badge,
.status-badge,
.badge,
.id-badge {
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 650;
  font-size: 11px;
}
.device-status-badge.healthy,
.device-status-badge.online,
.status-badge.success { background: var(--success-dim); border-color: #b9e4cb; color: #157347; }
.device-status-badge.degraded,
.device-status-badge.provisioning,
.status-badge.warning { background: var(--warning-dim); border-color: #f1d38b; color: #8a5a00; }
.device-status-badge.offline,
.status-badge.error { background: var(--danger-dim); border-color: #f4c7c3; color: #b42318; }

.group-section > div:first-child,
.ungrouped-section > div:first-child,
.wall-section > div:first-child {
  background: #fff !important;
  border: 1px solid var(--border) !important;
  border-left: 3px solid var(--accent) !important;
  border-radius: 10px;
  margin-bottom: 12px !important;
  padding: 10px 12px !important;
}

.selection-toolbar {
  background: var(--accent-dim) !important;
  border: 1px solid #b7e0e1;
  border-radius: 10px;
}

table { border-collapse: separate; border-spacing: 0; width: 100%; }
th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
th, td { border-bottom: 1px solid var(--border); padding: 13px 15px; text-align: left; }
tbody tr:hover td { background: #f7fbfb; }

.activity-table-wrap { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.activity-table th { background: var(--bg-subtle); color: var(--text-muted); }
.activity-table td { color: var(--text-primary); }
.activity-table tbody tr:hover { background: #f7fbfb; }

/* ---------- Content library ---------- */
.content-add-toolbar { align-items: stretch; gap: 14px; }
.content-upload-panel,
.content-source-panel {
  border-radius: var(--radius-lg);
  border-color: var(--border);
  background: #fff;
}
.upload-area {
  border: 1.5px dashed #c5d3d7;
  background: #fbfcfd;
  margin-bottom: 0;
}
.upload-area:hover,
.upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.content-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.content-item:hover { box-shadow: var(--shadow); }

/* ---------- Widgets ---------- */
.widget-type-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

/* ---------- Dialogs ---------- */
.modal-overlay {
  background: rgba(12, 22, 30, 0.48);
  backdrop-filter: blur(6px);
}
.modal {
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { color: var(--text-primary); font-size: 17px; letter-spacing: -0.02em; }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: #f8fafb;
  border-radius: 0 0 16px 16px;
}
.form-group { margin-bottom: 16px; }
.form-group label,
.modal label {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}
.settings-section { margin-bottom: 16px; padding: 22px; }
.settings-section h3 { color: var(--text-primary); margin: 0 0 8px; font-size: 16px; }

.add-device-meta {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 16px;
}
.add-device-meta-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.add-device-meta code {
  display: block;
  font-size: 13px;
  margin: 3px 0;
  color: var(--accent-hover);
  word-break: break-all;
}
.add-device-meta-hint { font-size: 11px; color: var(--text-muted); }
.add-device-section {
  border-top: 1px solid var(--border);
  margin-top: 18px;
  padding-top: 16px;
}
.add-device-section p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 600;
}
.player-download-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ---------- Empty + toast ---------- */
.empty-state {
  background: #fff;
  border: 1px dashed var(--border-light);
  border-radius: 16px;
  padding: 64px 28px;
}
.empty-state svg { opacity: 0.35; color: var(--accent); }
.empty-state h3 { color: var(--text-primary); font-size: 18px; letter-spacing: -0.02em; }
.empty-state p { color: var(--text-secondary); }

.toast {
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  min-width: 300px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

.getting-started-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

/* ---------- Schedule ---------- */
.schedule-controls {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}
.schedule-calendar-shell { background: #fff; box-shadow: var(--shadow-sm); border-radius: 12px; overflow: hidden; }
.schedule-day-header.is-today {
  background: var(--accent-dim);
  color: var(--accent-hover);
  box-shadow: inset 0 -2px var(--accent);
}

/* ---------- Login ---------- */
body.auth-screen { background: #081018; }
body.auth-screen .content {
  margin-left: 0;
  padding: 0;
  height: 100vh;
  overflow: auto;
  background: #081018;
  display: flex;
}

.login-shell {
  min-height: 100%;
  width: 100%;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(400px, 540px);
  background: #081018;
}

.login-showcase {
  position: relative;
  display: flex;
  align-items: center;
  padding: 56px 64px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 55% at 18% 18%, rgba(14, 158, 163, 0.38), transparent 58%),
    radial-gradient(ellipse 45% 40% at 88% 82%, rgba(18, 80, 110, 0.4), transparent 52%),
    linear-gradient(180deg, #0d1a24 0%, #081018 100%);
}

.login-showcase::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.028) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,0.028) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: 0.7;
  pointer-events: none;
}

.login-showcase-inner { position: relative; max-width: min(480px, 100%); color: #e8eef2; }
.login-kicker {
  color: #7ad4d6;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.login-showcase h1 {
  font-size: clamp(26px, 4vw, 46px);
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1.12;
  color: #f4f8fa;
  margin-bottom: 16px;
  overflow-wrap: break-word;
}
.login-showcase p {
  color: #9aadb8;
  font-size: 16px;
  line-height: 1.55;
  max-width: min(28rem, 100%);
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  background: #f4f6f8;
  border-left: 1px solid rgba(255,255,255,0.04);
  min-height: 100%;
}

.login-card { width: 100%; max-width: 400px; }
.login-form-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 28px 24px;
}
.login-card-brand { margin: 0 auto 22px; text-align: center; }
.login-card-tdn-logo,
.login-logo {
  display: block;
  height: 36px;
  max-width: 220px;
  margin: 0 auto 14px;
  object-fit: contain;
}
.login-card-divider {
  display: block;
  font-family: var(--font);
  font-size: 22px;
  font-style: normal;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  gap: 0;
  white-space: normal;
}
.login-card-divider::before,
.login-card-divider::after { display: none; }
.login-card-subtitle { color: var(--text-secondary); font-size: 13.5px; margin: 8px 0 0; }
.login-form-card .form-group { margin-bottom: 16px; }
.login-form-card .form-group label { color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.login-form-card .input { margin-top: 6px; width: 100%; }
.login-submit { min-height: 42px; width: 100%; }
.login-powered { margin-top: 18px; color: var(--text-muted); font-size: 11px; }
.login-powered img { height: 18px; max-width: 140px; }

/* ---------- Designer studio ---------- */
.id-starter { max-width: 1280px; margin: 0 auto; }
.id-starter-header {
  border: 0;
  border-left: 4px solid var(--accent);
  border-radius: 0 12px 12px 0;
  background: #fff;
  box-shadow: var(--shadow-sm);
  padding: 24px 28px;
}
.id-starter-header h1 { color: var(--text-primary); font-size: 28px; letter-spacing: -0.03em; }
.id-starter-header p { max-width: 700px; color: var(--text-secondary); }
.id-starter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.id-starter-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.id-starter-card:hover,
.id-starter-card:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.id-starter-cta {
  display: block;
  margin: 8px 16px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.id-builder {
  grid-template-columns: 260px minmax(0, 1fr) 330px;
  grid-template-rows: 1fr;
  height: calc(100vh - 216px);
  min-height: 670px;
  gap: 16px;
}
.id-canvas-col { grid-column: 2; grid-row: 1; min-height: 0; }
.id-rail-left { grid-column: 1; grid-row: 1; }
.id-rail-right { grid-column: 3; grid-row: 1; }
.id-rail { border-color: var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); }
.id-canvas-col { display: flex; flex-direction: column; min-height: 0; }
.id-canvas-toolbar {
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
}
.studio-canvas-tools { display: flex; align-items: center; gap: 6px; }
.studio-tool {
  min-width: 32px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}
.studio-tool:hover, .studio-tool.is-on { border-color: var(--accent); color: var(--accent-hover); background: var(--accent-dim); }
.studio-zoom-label { min-width: 42px; text-align: center; font-size: 11px; color: var(--text-muted); font-weight: 650; }
.id-canvas-stage {
  min-height: 420px;
  flex: 1;
  padding: clamp(18px, 3vw, 36px);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 0;
  background: #e8eef1;
  position: relative;
}
.id-canvas-stage.is-grid::before {
  content: "";
  position: absolute;
  inset: 18px;
  pointer-events: none;
  border-radius: 8px;
  background-image:
    linear-gradient(rgba(14, 158, 163, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14, 158, 163, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  z-index: 0;
}
.id-canvas-stage .id-screen-bezel { position: relative; z-index: 1; transform-origin: center center; transition: transform 0.16s ease; }
.id-tab.is-active { border-bottom-color: var(--accent); color: var(--accent-hover); }
.id-orient-btn.is-active { background: var(--accent-dim); color: var(--accent-hover); }
.id-blocks .gjs-block { border-color: var(--border); border-radius: 8px; background: #fff; }
.id-blocks .gjs-block:hover { border-color: var(--accent); color: var(--accent-hover); background: var(--accent-dim); }
.id-screen .gjs-highlighter,
.id-screen .gjs-selected { outline: 1.5px solid var(--accent) !important; outline-offset: 0; }
.id-screen .gjs-toolbar {
  background: #0c141c !important;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(12, 20, 28, 0.28);
}
.id-screen .gjs-toolbar-item { color: #fff !important; }
.id-screen .gjs-badge {
  background: var(--accent) !important;
  color: #fff !important;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.id-screen .gjs-resizer-h {
  width: 9px !important;
  height: 9px !important;
  border: 2px solid var(--accent) !important;
  background: #fff !important;
  border-radius: 2px !important;
  box-shadow: 0 1px 2px rgba(16, 24, 32, 0.18);
}
.id-screen .gjs-dashed { outline-color: rgba(14, 158, 163, 0.45) !important; }

.studio-timeline {
  border: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  background: #fff;
  padding: 10px 14px 12px;
  flex: 0 0 auto;
}
.studio-timeline-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.studio-play {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
}
.studio-play:hover { background: var(--accent-hover); }
.studio-timeline-title { font-size: 12px; font-weight: 650; color: var(--text-primary); flex: 1; }
.studio-duration {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 650;
}
.studio-duration .input { width: 64px; min-height: 30px; height: 30px; }
.studio-timeline-ruler {
  position: relative;
  height: 16px;
  margin: 0 72px 6px;
  border-bottom: 1px solid var(--border);
}
.studio-timeline-ruler span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.studio-tracks { display: grid; gap: 6px; }
.studio-track {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 650;
}
.studio-track i {
  display: block;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #7ad4d6);
  min-width: 8px;
}
.studio-track[data-track="bg"] i { background: #c5d0d6; }
.studio-track[data-track="ticker"] i { background: #f0c36b; }

.playlist-draft-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border: 1px solid #f1d38b;
  border-radius: 12px;
  background: var(--warning-dim);
}
.playlist-draft-copy { display: flex; align-items: flex-start; gap: 10px; color: var(--warning); }
.playlist-draft-copy strong { display: block; color: var(--text-primary); font-size: 14px; }
.playlist-draft-copy span { display: block; font-size: 12px; color: var(--text-secondary); }
.playlist-draft-actions { display: flex; gap: 8px; flex-shrink: 0; }

.flow-canvas {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px 22px 28px;
  box-shadow: var(--shadow-sm);
}
.flow-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px 36px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 650;
}
.flow-meta-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--border-light); }
.flow-meta-hint { margin-left: auto; font-weight: 500; }
.flow-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  border: 1.5px dashed var(--border-light);
  border-radius: 12px;
}
.flow-empty p + p { font-size: 13px; margin-top: 6px; }
.flow-step {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 10px;
  cursor: grab;
}
.flow-step:last-child { margin-bottom: 0; }
.flow-step:first-of-type .flow-connector { display: none; }
.flow-connector {
  position: absolute;
  left: 13px;
  top: -12px;
  width: 2px;
  height: 12px;
  background: var(--border-light);
}
.flow-node {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin-top: 14px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent-hover);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 750;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--accent);
  z-index: 1;
}
.flow-card {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.flow-step:hover .flow-card { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.flow-thumb {
  width: 112px;
  height: 63px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-subtle);
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.flow-thumb img { width: 100%; height: 100%; object-fit: cover; }
.flow-thumb-icon { color: var(--text-muted); opacity: 0.7; }
.flow-thumb .flow-widget-preview {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  display: block;
  background: #111820;
}
.flow-thumb .flow-widget-preview-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  transform: translate(-50%, -50%) scale(.0583333333);
  transform-origin: center;
  border: 0;
  display: block;
  background: #111820;
}
.flow-thumb .flow-widget-preview[data-orientation="portrait"] .flow-widget-preview-frame {
  width: 1080px;
  height: 1920px;
  transform: translate(-50%, -50%) scale(.0208333333);
}
.flow-thumb .flow-widget-preview[data-orientation="square"] .flow-widget-preview-frame {
  width: 1080px;
  height: 1080px;
  transform: translate(-50%, -50%) scale(.037037037);
}
.flow-copy { flex: 1; min-width: 0; }
.flow-name {
  font-size: 14px;
  font-weight: 650;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flow-sub { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.flow-sched {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent-hover);
  font-size: 11px;
  font-weight: 650;
}
.flow-duration {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.flow-duration .input { width: 64px; min-height: 32px; height: 32px; text-align: center; }
.flow-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.flow-actions .btn-icon { color: var(--text-muted); }
.flow-actions .btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.flow-step.flow-drop-above::before {
  content: "";
  position: absolute;
  left: 7px;
  top: -7px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-dim);
  z-index: 2;
}

@media (max-width: 820px) {
  .flow-card { flex-wrap: wrap; }
  .flow-actions { width: 100%; justify-content: flex-end; }
  .flow-meta { margin-left: 0; flex-wrap: wrap; }
}

.industrial-starter-card:hover,
.industrial-starter-card:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.industrial-designer-tab.active { border-bottom-color: var(--accent); color: var(--accent); }

/* ---------- Canva-style designer ---------- */
body.designer-immersive .app-header,
body.designer-immersive .sidebar,
body.designer-immersive .sidebar-toggle,
body.designer-immersive .sidebar-backdrop { display: none !important; }
body.designer-immersive .content {
  margin: 0 !important;
  padding: 0 !important;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: #e9edf0;
}
.canva-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #e9edf0;
  color: var(--text-primary);
}
.canva-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 12px 0 8px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 5;
}
.canva-title {
  width: min(280px, 28vw);
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 650;
  background: transparent;
}
.canva-title:hover, .canva-title:focus { border-color: var(--border); background: #fff; outline: none; }
.canva-top-center { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.canva-top-actions { display: flex; align-items: center; gap: 8px; margin-left: 12px; }
.canva-meta { font-size: 11px; color: var(--text-muted); font-weight: 650; }
.canva-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
}
.canva-icon-btn:hover { background: var(--bg-subtle); color: var(--text-primary); }
.canva-resize { background: var(--bg-subtle); border-radius: 8px; padding: 2px; }
.canva-resize .id-orient-btn {
  min-height: 28px;
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  border: 0;
  background: transparent;
}
.canva-resize .id-orient-btn.is-active { background: #fff; box-shadow: var(--shadow-sm); color: var(--text-primary); }
.canva-body {
  display: grid;
  grid-template-columns: 72px 280px minmax(0, 1fr) 300px;
  flex: 1;
  min-height: 0;
}
.canva-body > * { grid-column: auto !important; grid-row: auto !important; }
.canva-icons {
  background: #0f1a22;
  color: #c5d0da;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 8px 6px;
  gap: 4px;
}
.canva-rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px 8px;
  border-radius: 10px;
  color: #9aa8b4;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.canva-rail-btn svg { color: currentColor; }
.canva-rail-btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
.canva-rail-btn.is-on { background: rgba(14, 158, 163, 0.18); color: #7ad4d6; }
.canva-panel {
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 14px 24px;
}
.canva-panel h3 { font-size: 16px; letter-spacing: -0.02em; margin: 0 0 6px; }
.canva-panel-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.canva-artboard {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #dfe5ea;
  overflow: hidden;
}
.canva-artboard .id-canvas-stage {
  flex: 1;
  border: 0;
  background: #cfd6dc;
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 28px !important;
  overflow: hidden;
}
.canva-artboard .id-screen-bezel {
  width: min(920px, calc(100% - 8px)) !important;
  max-width: 100%;
  flex: 0 0 auto;
  padding: 12px;
  background: #111820;
  border-radius: 12px;
}
.canva-artboard .id-screen {
  width: 100% !important;
  height: auto !important;
  min-height: 260px;
  aspect-ratio: var(--screen-ratio, 16 / 9) !important;
  max-height: none !important;
  position: relative;
  background: #fff;
}
.canva-artboard .id-canvas-stage[data-orientation="portrait"] .id-screen-bezel {
  width: min(380px, calc(100% - 8px)) !important;
}
.canva-artboard .id-canvas-stage[data-orientation="square"] .id-screen-bezel {
  width: min(560px, calc(100% - 8px)) !important;
}
.canva-artboard #industrialGrapesCanvas,
.canva-artboard .gjs-editor,
.canva-artboard .gjs-cv-canvas,
.canva-artboard .gjs-cv-canvas__frames,
.canva-artboard .gjs-frame-wrapper,
.canva-artboard .gjs-frame {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
}
.canva-artboard .studio-timeline {
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: #fff;
}
.canva-props {
  background: #fff;
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.canva-props .id-section { border: 0; }
.id-friendly-inspector[hidden],
.id-inspector-empty[hidden],
.id-inspector-position[hidden],
#idInspectorTextWrap[hidden] { display: none !important; }
.id-inspector-empty {
  padding: 18px 4px;
  color: var(--text-muted);
}
.id-inspector-empty strong { display: block; color: var(--text-primary); margin-bottom: 6px; }
#industrialGrapesBlocks,
#industrialGrapesBlocks .gjs-blocks-cs,
#industrialGrapesBlocks .gjs-one-bg,
#industrialGrapesBlocks .gjs-two-color {
  background: transparent !important;
  background-color: transparent !important;
  color: var(--text-primary) !important;
}
.cv-blocks .gjs-block-category .gjs-title { display: none !important; }
.cv-blocks .gjs-blocks-c {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 !important;
}
.cv-blocks .gjs-block-category { background: transparent !important; }
.cv-blocks .gjs-block {
  width: 100% !important;
  min-height: 96px !important;
  height: auto !important;
  margin: 0 !important;
  padding: 8px !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  background: #fff !important;
  box-shadow: none !important;
  flex-direction: column !important;
  overflow: hidden !important;
  color: var(--text-primary) !important;
}
.cv-blocks .gjs-block:hover { border-color: var(--accent) !important; background: var(--accent-dim) !important; }
.cv-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.cv-tile-art {
  display: grid;
  place-items: center;
  width: 100%;
  height: 52px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.04em;
}
.cv-tile b { font-size: 11px; font-weight: 650; color: var(--text-secondary); }
.cv-art-heading { font-family: Georgia, serif; font-size: 28px; }
.cv-art-kpi, .cv-art-chart { color: var(--accent-hover); }
.canva-mini-templates { display: grid; gap: 8px; }
.canva-mini-tpl {
  text-align: left;
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7f9fa;
  font-weight: 650;
  font-size: 13px;
}
.canva-mini-tpl:hover { border-color: var(--accent); background: var(--accent-dim); }
.canva-overlay {
  position: absolute;
  inset: 56px 0 0;
  background: #e9edf0;
  z-index: 6;
  overflow: auto;
  padding: 28px 40px;
}
.canva-shell { position: relative; }

@media (max-width: 1100px) {
  .canva-body { grid-template-columns: 64px 220px minmax(0, 1fr); }
  .canva-props { display: none; }
}
@media (max-width: 760px) {
  .canva-body { grid-template-columns: 1fr; }
  .canva-icons { flex-direction: row; overflow-x: auto; }
  .canva-panel { display: none; }
  .canva-top-center { display: none; }
}

/* ---------- Auth / mobile ---------- */
@media (max-width: 960px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-showcase { min-height: 0; padding: 32px 22px 24px; align-items: flex-start; }
  .login-showcase h1 { font-size: 24px; }
  .login-showcase p { font-size: 13.5px; max-width: 100%; }
  .login-panel { padding: 20px 16px 40px; border-left: 0; }
}

@media (max-width: 1100px) {
  .dash-stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .id-builder { grid-template-columns: 220px minmax(0, 1fr) 280px; }
  .id-starter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .id-builder { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .id-canvas-col { order: 1; min-height: 520px; }
  .id-rail-left { order: 2; }
  .id-rail-right { order: 3; }
  .content { margin-left: 0; padding: 24px 18px 40px; }
}

@media (max-width: 768px) {
  .content { margin-left: 0; padding: 16px; padding-top: 68px; }
  .mobile-menu-btn {
    background: #fff;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
  }
}

@media (max-width: 560px) {
  .page-header { gap: 16px; flex-direction: column; }
  .dashboard-header-actions { flex-direction: column; width: 100%; }
  .dashboard-header-actions .btn { width: 100%; flex: none; }
  .dash-stats-row { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .info-card { padding: 14px; }
  .info-card-value { font-size: 22px; }
  .id-starter-grid { grid-template-columns: 1fr; }
  .player-download-grid { grid-template-columns: 1fr; }
  .display-toolbar,
  .content:has(#groupedDevices) .display-toolbar { flex-direction: column; align-items: stretch; }
  .display-search,
  .content:has(#groupedDevices) .display-search { max-width: none; flex: 0 0 auto; width: 100%; }
  .display-toolbar select.input,
  .display-toolbar .input,
  .content:has(#groupedDevices) .display-toolbar select.input { width: 100% !important; }
}

html:not(.internal-tools) .internal-only,
html:not(.internal-tools) [data-internal-nav] { display: none !important; }
.internal-tools [data-internal-nav] { display: list-item !important; }
.internal-tools .nav-section[data-internal-nav] { display: flex !important; }

/* ---------- Plant CMS ---------- */
body.plant-cms .workspace-switcher,
body.plant-cms #billingNavItem { display: none !important; }

.cms-count { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.cms-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); margin-left: auto; }
.cms-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.cms-library .page-header { margin-bottom: 16px; }
.cms-header-actions { display: flex; gap: 8px; }
.cms-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  margin-bottom: 12px;
  padding: 12px 16px;
  border: 1.5px dashed #c9d5d8;
  border-radius: 12px;
  background: #f8fbfb;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}
.cms-drop svg { color: var(--accent); flex: none; }
.cms-drop:hover,
.cms-drop.dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text-primary);
}
.cms-drop .upload-progress { width: min(420px, 100%); margin: 0; }
.cms-drop .upload-progress p { margin: 6px 0 0; font-size: 12px; color: var(--text-muted); }
.cms-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-bottom: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.cms-toolbar .input { width: auto; min-width: 132px; }
.cms-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 240px;
  min-width: 180px;
  max-width: 420px;
  height: var(--control-height);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-muted);
}
.cms-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
}
.cms-subtle-link {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 2px 12px;
  cursor: pointer;
}
.cms-subtle-link:hover { text-decoration: underline; }
.cms-sources {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.cms-source {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.cms-source strong { font-size: 13px; }
.cms-source-hint { margin: 0; font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.cms-library .content-breadcrumb {
  background: transparent;
  border: 0;
  padding: 0 2px 12px;
  gap: 4px;
}
.cms-crumb {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}
.cms-crumb:hover { background: var(--accent-dim); color: var(--accent); }
.cms-crumb-sep { color: var(--text-muted); font-size: 12px; }
.cms-crumb-actions { margin-left: auto; display: flex; gap: 6px; }
.cms-batch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--accent-dim);
  border: 1px solid #b7e0e1;
  border-radius: 12px;
}
.cms-batch[hidden] {
  display: none !important;
}
.cms-batch-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.cms-library .folder-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  color: inherit;
}
.cms-library .folder-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.media-folder-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: #fff4dc;
  color: #c99214;
  flex: none;
}
.folder-card.is-people .media-folder-icon { background: var(--accent-dim); color: var(--accent); }
.media-folder-name {
  display: block;
  font-size: 14px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-folder-count {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-muted);
}
.cms-library .content-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.cms-library .media-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.cms-library .media-card:hover {
  border-color: #c5d4d8;
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.cms-library .media-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.cms-library .media-card.is-expired { opacity: 0.62; }
.media-check {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(16, 24, 32, 0.55);
  cursor: pointer;
}
.media-check input { margin: 0; width: 14px; height: 14px; accent-color: var(--accent); }
.cms-library .media-thumb {
  aspect-ratio: 16 / 10;
  background:
    linear-gradient(180deg, rgba(16,24,32,0.04), rgba(16,24,32,0.08)),
    #e8eef0;
  position: relative;
}
.cms-library .media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(16, 24, 32, 0.72);
}
.media-play::after {
  content: "";
  position: absolute;
  top: 14px;
  left: 17px;
  border-style: solid;
  border-width: 8px 0 8px 14px;
  border-color: transparent transparent transparent #fff;
}
.media-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.media-fallback[data-kind="video"]::after {
  content: "";
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 10px 0 10px 16px;
  border-color: transparent transparent transparent var(--text-muted);
}
.cms-library .media-card .media-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(16, 24, 32, 0.72);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.cms-library .media-card .content-item-body { padding: 12px 14px 4px; }
.cms-library .media-card .content-item-name {
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.3;
}
.cms-library .media-card .content-item-size { font-size: 12px; }
.cms-library .media-card .content-item-actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px 12px;
  justify-content: flex-end;
}
.cms-library .media-card .content-item-actions .btn {
  flex: 0 0 auto;
  min-width: 0;
  padding: 5px 10px;
}
.cms-library .cms-table .content-item,
.cms-library .media-table .content-item {
  display: table-row;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}
.cms-library .media-table .content-item-preview {
  aspect-ratio: auto;
  background: transparent;
  height: auto;
  overflow: visible;
  display: flex;
  align-items: center;
}
.media-table .media-col-check { width: 36px; }
.media-col-file {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}
.media-col-file .content-item-name { display: block; font-size: 13.5px; }
.media-mini {
  display: block;
  width: 44px;
  height: 32px;
  border-radius: 6px;
  overflow: hidden;
  background: #e8eef0;
  flex: none;
  position: relative;
}
.media-mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-table .media-badge {
  position: static;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}
.media-table .content-item-actions { display: flex; gap: 6px; justify-content: flex-end; }
.media-table .content-item-actions .btn { flex: none; }
.media-expired { display: block; color: var(--danger); font-weight: 650; }
.cms-library .media-table tr.is-selected td { background: var(--accent-dim); }

@media (max-width: 900px) {
  .cms-sources { grid-template-columns: 1fr; }
  .cms-toolbar .input, .cms-search { max-width: none; width: 100%; flex: 1 1 100%; }
  .app-header .version-status,
  .app-header .connection-status span:last-child { display: none; }
  .app-header .sidebar-user-meta { display: none; }
  .sidebar {
    transform: translateX(-100%);
    width: min(80vw, var(--sidebar-width)) !important;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  body.sidebar-collapsed .sidebar { width: min(80vw, var(--sidebar-width)) !important; }
  body.sidebar-collapsed .nav-section-label,
  body.sidebar-collapsed .nav-link span { display: block; }
  body.sidebar-collapsed .nav-link { justify-content: flex-start; padding: 8px 12px; gap: 11px; }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: var(--header-height) 0 0 0;
    background: rgba(8, 16, 24, 0.45);
    z-index: 140;
  }
  .sidebar-backdrop.open { display: block; }
  .content,
  body.sidebar-collapsed .content { margin-left: 0; padding: 16px; }
  .tdn-brand-name { max-width: 110px; }
}

/* ---------- Standard data grid ---------- */
.data-grid-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
  box-shadow: var(--shadow-sm);
}
.data-grid {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
}
.data-grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #f6f8fa;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  white-space: nowrap;
}
.data-grid th[data-sort] { cursor: pointer; user-select: none; }
.data-grid th[data-sort]:hover { color: var(--text-primary); }
.widget-bulkbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-dim);
}
.widget-bulk-summary { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.widget-bulk-summary strong { color: var(--accent-hover); font-size: 13px; }
.widget-bulk-summary span { color: var(--text-secondary); font-size: 12px; }
.widget-bulk-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.widget-select-cell { width: 38px; text-align: center !important; padding-left: 8px !important; padding-right: 8px !important; }
.widget-select-cell input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.data-grid th.is-sorted { color: var(--accent); }
.data-grid th.is-sorted::after {
  content: " ↑";
  font-size: 11px;
}
.data-grid th.is-sorted[data-dir="desc"]::after { content: " ↓"; }
.data-grid td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-grid tbody tr { cursor: pointer; }
.data-grid tbody tr:hover td { background: #f4f8f8; }
.data-grid .preview-thumb {
  display: block;
  width: 112px;
  height: 63px;
  border-radius: 8px;
  overflow: hidden;
  background: #111820;
  border: 1px solid var(--border);
  position: relative;
  flex: none;
}
.data-grid .preview-thumb[data-orientation="portrait"] {
  width: 40px;
  height: 72px;
}
.data-grid .preview-thumb[data-orientation="square"] {
  width: 63px;
  height: 63px;
}
.data-grid .preview-folder { background: #fff4dc; }
.data-grid .preview-folder.is-people { background: var(--accent-dim); }
.data-grid .content-item-actions { white-space: nowrap; }
/* Rows in the data grid are table rows, not media cards. The shared
   .content-item-preview aspect-ratio rule otherwise makes each row as tall as
   a large thumbnail and leaves a huge blank panel beside the file name. */
.data-grid .content-item-preview {
  display: table-cell;
  aspect-ratio: auto;
  height: auto;
  min-height: 0;
  overflow: visible;
  background: transparent;
  justify-content: initial;
}
.data-grid .preview-thumb img,
.data-grid .preview-thumb video,
.data-grid .preview-thumb iframe {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border: 0;
  background: #111;
}

/* Render widget HTML at display resolution, then scale the complete canvas into
   the table thumbnail. A 112px iframe viewport makes clamp() typography hit its
   minimum size and clips titles such as "Happy Birthday, Priya!". */
.data-grid .preview-thumb iframe {
  width: 1920px;
  height: 1080px;
  transform: scale(.0583333333);
  transform-origin: top left;
  object-fit: initial;
}
.data-grid .preview-thumb[data-orientation="portrait"] iframe {
  width: 1080px;
  height: 1920px;
  transform: scale(.037037037);
}
.data-grid .preview-thumb[data-orientation="square"] iframe {
  width: 1080px;
  height: 1080px;
  transform: scale(.0583333333);
}
.data-grid .preview-empty {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #8b99a3;
  font-size: 11px;
}
.data-grid .file-cell {
  min-width: 240px;
}
.data-grid td.file-cell {
  display: table-cell;
  min-width: 0;
  white-space: nowrap;
}
.data-grid td.file-cell > .preview-thumb {
  display: inline-block;
  vertical-align: middle;
}
.data-grid td.file-cell > span:not(.preview-thumb) {
  display: inline-block;
  max-width: calc(100% - 132px);
  margin-left: 12px;
  overflow: hidden;
  vertical-align: middle;
  white-space: normal;
}
.data-grid .file-cell strong { display: block; font-size: 13.5px; }
.data-grid .file-cell small { color: var(--text-muted); }
.cms-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.cms-table-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
}
.cms-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
.cms-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #f7f8fa;
  white-space: nowrap;
}
.cms-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cms-table tbody tr:hover { background: #f4f7f8; }
.cms-table a { color: var(--text-primary); font-weight: 600; text-decoration: none; }
.cms-table a:hover { color: var(--accent); }
.content-grid.is-table { display: block; }
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.view-toggle-btn {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}
.view-toggle-btn.is-on { background: var(--accent-dim, #e6f4f4); color: var(--accent); }

/* ---------- SCADA / FUXA ---------- */
body.scada-view,
html:has(body.scada-view) {
  overflow: hidden;
  height: 100%;
}
.scada-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  gap: 0;
}
.scada-shell h1 {
  flex: none;
  margin: 0;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.scada-frame {
  display: block;
  flex: none;
  min-height: 0;
  width: 125%;
  height: 125%;
  border: 0;
  border-radius: 0;
  background: #111;
  transform: scale(.8);
  transform-origin: top left;
}

/* ---------- Penpot-style designer ---------- */
.pp-start { max-width: 1080px; margin: 0 auto; padding: 28px 8px 64px; }
.pp-start-head h1 { font-size: 28px; letter-spacing: -0.03em; margin: 4px 0 8px; }
.pp-start-head p { color: var(--text-secondary); max-width: 640px; }
.pp-kicker { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin: 0; }
.pp-start-section { margin-top: 28px; }
.pp-start-section h2 { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 12px; }
.pp-board-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.pp-board-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.pp-board-card strong { font-size: 15px; }
.pp-board-card span, .pp-board-card em { font-size: 12px; color: var(--text-muted); font-style: normal; }
.pp-board-card.is-on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim, #d7f1f2); }
.pp-board-thumb {
  width: 100%;
  height: 88px;
  border-radius: 8px;
  background: #e8e9eb;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}
.pp-board-thumb i {
  display: block;
  background: #fff;
  border: 1px solid #c9ced4;
  box-shadow: 0 6px 16px rgba(16, 24, 32, 0.08);
}
.pp-board-thumb[data-orientation="landscape"] i { width: 72%; aspect-ratio: 16 / 9; }
.pp-board-thumb[data-orientation="portrait"] i { height: 78%; aspect-ratio: 9 / 16; }
.pp-board-thumb[data-orientation="square"] i { width: 52%; aspect-ratio: 1 / 1; }
.pp-layout-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.pp-layout-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}
.pp-layout-card:hover { border-color: var(--accent); }
.pp-layout-art {
  display: block;
  height: 92px;
  border-radius: 8px;
  background: #eef1f3;
  margin-bottom: 10px;
}
.pp-layout-card strong { display: block; font-size: 14px; }
.pp-layout-card span { display: block; font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.pp-shell .canva-artboard { background: #e8e9eb; }
.pp-shell .canva-artboard .id-canvas-stage {
  background: #e8e9eb !important;
  padding: 36px !important;
}
.pp-board { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.pp-board-caption {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7280;
  display: flex;
  gap: 8px;
}
.pp-shell .canva-artboard .id-screen-bezel {
  width: auto !important;
  max-width: none !important;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: 0 18px 40px rgba(16, 24, 32, 0.14);
}
.pp-shell .canva-artboard .id-screen {
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  background: #fff;
  border: 1px solid #c9ced4;
}
.pp-shell .studio-timeline { display: none; }

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