/* Layout */
body {
  display: flex;
  overflow: hidden;
}

/* ⚠️ VARSAYILAN: GİZLİ. Ray statik HTML'de duruyor ve eskiden görünür başlıyordu;
   giriş ekranına giden herkes, JavaScript yüklenene kadar panelin tüm menüsünü
   görüyordu. Gizleme kodu doğruydu — yanlış olan, gizlemeye ihtiyaç duyulmasıydı.
   Artık oturum KANITLANINCA gösteriliyor: rail-boot.js kararı ilk boyamadan önce
   veriyor, app.js her yönlendirmede günceller. */
body.rail-ready .sidebar { display: flex; }

.sidebar {
  display: none;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  /* display BURADA DEGIL: gorunur haldeki degeri body.rail-ready kurali veriyor.
     Ayni kuralda birakmak, ustteki display:none'i yenerdi — ayni bildirimin
     ikinci kez yazilmasi ozgullugu degil SIRAYI kullanir. */
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
}

/* Workspace switcher (Phase 3 MVP). Sits in sidebar-header below the logo.
   Three render modes via JS: dropdown (>1 ws), static text (1 ws),
   muted empty state (0 ws). */
.workspace-switcher { position: relative; margin-top: 12px; }
.workspace-switcher-button {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 8px 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: 13px; cursor: pointer; transition: all var(--transition);
}
.workspace-switcher-button:hover { border-color: var(--accent); }
.workspace-switcher-static {
  display: block; padding: 4px 2px;
  color: var(--text-primary); font-size: 13px; font-weight: 500;
}
.workspace-switcher-static::before {
  content: 'Workspace';
  display: block;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 2px;
}
.workspace-switcher-empty {
  display: block; padding: 8px 10px;
  color: var(--text-muted); font-size: 12px; font-style: italic;
}
/* #19: single-workspace view - name + always-visible manage icons (no dropdown). */
.workspace-switcher-single { display: flex; align-items: center; gap: 4px; }
.workspace-switcher-single .workspace-switcher-static { flex: 1; min-width: 0; }
.workspace-switcher-single .workspace-switcher-members,
.workspace-switcher-single .workspace-switcher-pencil { visibility: visible; align-self: end; }
.workspace-switcher-button .chev {
  flex-shrink: 0; margin-left: 8px; color: var(--text-muted);
  transition: transform var(--transition);
}
.workspace-switcher.open .chev { transform: rotate(180deg); }
.workspace-switcher-menu {
  display: none;
  /* Width: detach from the narrow sidebar-header (188px content width). The
     sidebar is z-indexed and the dropdown is free to extend beyond the
     sidebar into the main content area. min/max bounds keep it readable
     for normal-length names without sprawling on extreme cases. */
  position: absolute; top: calc(100% + 4px); left: 0;
  min-width: 280px; max-width: 360px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  max-height: 360px; padding: 4px 0; overflow-y: auto; z-index: 100;
}
.workspace-switcher.open .workspace-switcher-menu { display: block; }
/* #16: sticky type-to-filter search header inside the (scrolling) menu. */
.workspace-switcher-search {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-card); padding: 8px;
  border-bottom: 1px solid var(--border);
}
.workspace-switcher-search input {
  width: 100%; box-sizing: border-box; padding: 6px 8px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); font-size: 13px;
}
.workspace-switcher-search input:focus { outline: none; border-color: var(--accent); }
.workspace-switcher-noresults {
  padding: 12px; color: var(--text-muted); font-size: 13px; text-align: center;
}
.workspace-switcher-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary); font-size: 13px;
}
.workspace-switcher-item:last-child { border-bottom: none; }
.workspace-switcher-item:hover { background: var(--bg-input); }
/* keyboard-cursor highlight (arrow keys) - same surface as hover */
.workspace-switcher-item.highlighted { background: var(--bg-input); }
.workspace-switcher-item.current { font-weight: 600; }
.workspace-switcher-item .check {
  flex-shrink: 0; color: var(--accent); width: 14px;
}
.workspace-switcher-item .ws-meta { flex: 1; min-width: 0; }
.workspace-switcher-item .ws-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.workspace-switcher-item .ws-org {
  font-size: 11px; color: var(--text-muted); margin-top: 1px;
  /* nowrap + ellipsis: long "Org Name . N devices" lines truncate cleanly
     instead of wrapping onto a second line that doubles row height. */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.workspace-switcher-pencil {
  flex-shrink: 0; visibility: hidden;
  background: none; border: none; padding: 4px;
  color: var(--text-muted); cursor: pointer;
  border-radius: 4px; transition: all var(--transition);
}
.workspace-switcher-item:hover .workspace-switcher-pencil { visibility: visible; }
.workspace-switcher-pencil:hover { color: var(--accent); background: var(--bg-input); }
/* "New workspace" — a full-width action UNDER the selector, in both the single and dropdown views.
   ⚠️ ALWAYS VISIBLE, unlike the rename/members icons beside it, which reveal on hover. Those
   decorate a row you can already see; this is the only route to a capability that is otherwise
   invisible, and hiding it is how 313 organizations ended up with one workspace each.
   ⚠️ AND IT IS NOT IN THE DROPDOWN. Inside the menu it read as a workspace you could switch to,
   and in the single-workspace case — the common one — there is no menu to open at all. */
.workspace-switcher-create {
  display: flex; align-items: center; gap: 6px;
  width: 100%; margin-top: 6px; padding: 5px 2px;
  background: none; border: none;
  /* ⚠️ --sidebar-fg, --text-muted DEGIL. Bu denetim KOYU rayin uzerinde duruyor;
     --text-muted acik icerik alani icin secilmis bir tondur ve burada 2.36:1
     veriyordu — dosyanin basindaki "the --sidebar-* set is the DARK rail"
     uyarisinin tam tersi. Koyu temada tesadufen okunur haldeydi. */
  color: var(--sidebar-fg); font-size: 12px; text-align: left;
  cursor: pointer; border-radius: 4px; transition: all var(--transition);
}
.workspace-switcher-create:hover { color: var(--accent); }
.workspace-switcher-create svg { flex-shrink: 0; }
/* ⚠️ THE MENU ANCHORS TO THE CONTAINER, SO THIS CONTROL MUST NOT ADD TO ITS HEIGHT.
   .workspace-switcher-menu is absolutely positioned at top: calc(100% + 4px) against
   .workspace-switcher. Adding an in-flow row after the menu grew that container by ~30px, so the
   dropdown opened BELOW the "New workspace" line instead of directly under its own button — the
   action wedged between the selector and the list it opens. Taking the control out of flow keeps
   the anchor where the menu expects it, and the container reserves the space instead. */
.workspace-switcher { padding-bottom: 28px; }
.workspace-switcher-create { position: absolute; left: 0; bottom: 0; margin-top: 0; }
/* Members icon - same shape as the pencil; navigates to #/workspace/:id/members. */
.workspace-switcher-members {
  flex-shrink: 0; visibility: hidden;
  background: none; border: none; padding: 4px;
  color: var(--text-muted); cursor: pointer;
  border-radius: 4px; transition: all var(--transition);
}
.workspace-switcher-item:hover .workspace-switcher-members { visibility: visible; }
.workspace-switcher-members:hover { color: var(--accent); background: var(--bg-input); }

/* Workspace members page (Phase 2 user-mgmt, slice 2A read-only). Three
   sections render via JS: direct members, via_org access, pending invites.
   Row layout mirrors the sidebar user card's avatar pattern for visual
   continuity. via_org rows are opacity-reduced and invite rows use the
   input-bg shade so the three states are distinguishable at a glance. */
.members-list { display: flex; flex-direction: column; gap: 4px; }
.member-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-card);
}
.member-row--via-org { opacity: 0.75; }
.member-row--invited { background: var(--bg-input); }
.member-avatar {
  flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.member-avatar--muted { background: var(--text-muted); }
.member-meta { flex: 1; min-width: 0; }
.member-name {
  font-size: 13px; font-weight: 500; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.member-email {
  font-size: 11px; color: var(--text-muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.member-role {
  flex-shrink: 0; font-size: 12px; color: var(--text-secondary);
  padding: 4px 8px; background: var(--bg-input);
  border-radius: 4px; min-width: 60px; text-align: center;
}
.member-detail {
  flex-shrink: 0; font-size: 11px; color: var(--text-muted);
  min-width: 110px; text-align: right;
}
.member-via-org { font-style: italic; }
.member-badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 6px; background: var(--bg-input); color: var(--text-muted);
  border-radius: 3px; font-weight: 600;
}

/* Slice 2B - mutation affordances. .member-actions is the cell that holds
   per-row admin buttons (remove on direct-member rows, cancel on invited
   rows). via_org rows omit the cell entirely. The role select replaces the
   .member-role div for admins on direct-member rows. */
.member-role-select {
  flex-shrink: 0; font-size: 12px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 8px; min-width: 90px; cursor: pointer;
}
.member-role-select:hover { border-color: var(--accent); }
.member-actions {
  flex-shrink: 0; display: flex; align-items: center; gap: 4px;
  margin-left: 4px;
}
.member-action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 6px;
  color: var(--text-muted); cursor: pointer;
  border-radius: 4px; transition: all var(--transition);
}
.member-action-btn:hover { background: var(--bg-input); }
.member-action-btn--danger:hover { color: var(--danger); }

.nav-links {
  flex: 1;
  padding: 12px 8px;
  /* Scroll the nav when it's taller than the viewport (short screens, e.g.
     1366x768) so items below the fold (Settings) stay reachable. min-height:0
     is required for a flex child to shrink and scroll instead of overflowing. */
  overflow-y: auto;
  min-height: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: all var(--transition);
  margin-bottom: 2px;
}

.nav-link:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--accent);
  color: white;
}

/* ---- Sidebar groups (components/nav-groups.js) ---- */
.nav-group { list-style: none; margin-top: 10px; }
.nav-group[hidden] { display: none; }
.nav-group-items { list-style: none; margin: 2px 0 0; padding: 0; }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-group-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 12px; border: 0; border-radius: var(--radius);
  /* --text-secondary, not --text-muted: #64748b on the sidebar is ~3.1:1 and fails WCAG AA for
     text this small; #94a3b8 is ~5.7:1. */
  background: transparent; color: var(--text-secondary);
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  cursor: pointer; text-align: left;
}
.nav-group-toggle:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-group-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav-group-label { flex: 1; }
.nav-group-chevron { flex: none; transition: transform var(--transition); }
.nav-group.collapsed .nav-group-chevron { transform: rotate(-90deg); }
/* Collapsed, but the page you are on is inside: keep that visible on the header. */
.nav-group.collapsed.has-active .nav-group-toggle { color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.nav-group-badge {
  flex: none; min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 10px; line-height: 18px; text-align: center;
  letter-spacing: 0;
}
.nav-group-badge[hidden] { display: none; }
/* "New" on a nav link, until that page has been opened once (nav-groups.js). */
.nav-new-pill {
  margin-left: auto; padding: 1px 7px; border-radius: 9px;
  background: rgba(59,130,246,.18); color: #93c5fd; border: 1px solid rgba(59,130,246,.45);
  font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
.nav-link.active .nav-new-pill { background: rgba(255,255,255,.2); color: #fff; border-color: transparent; }
.nav-new-pill[hidden] { display: none; }
/* A tool being retired: still reachable, visibly not the way forward. */
.nav-legacy .nav-link:not(.active) { opacity: .6; }
/* Help lives with the utilities in the footer, not among the jobs. */
.nav-link-utility { padding: 6px 10px; margin-bottom: 10px; font-size: 13px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.version-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.version-badge {
  background: var(--warning);
  color: #000;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  line-height: 1.4;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--danger); }
.status-dot.provisioning { background: var(--warning); animation: pulse 2s infinite; }
/* v4 liveness (server-derived): healthy=green, degraded=amber+pulse (reconnecting), offline=red (above) */
.status-dot.healthy { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.degraded { background: var(--warning); box-shadow: 0 0 6px var(--warning); animation: pulse 2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Wraps the (optional) banners strip and main content so they stack
   vertically as a single flex column, independent from the fixed sidebar.
   Without this wrapper, #banners and .content would be direct siblings in
   the (row-direction) body flexbox, turning the banner into a narrow flex
   item next to the content instead of a full-width strip above it, and
   shifting the whole dashboard layout out of alignment with the sidebar. */
/* ⚠️ YAN RAY GIZLENDIGINDE BU BOSLUK DA KALKMALI.
   Giris, sifre sifirlama ve ilk kurulum ekranlarinda rail display:none oluyor ama
   ONUN GENISLIGI burada ayrilmis durumda. Kod bunu temizlemeye calisiyordu —
   `app.style.marginLeft = '0'` — ancak bosluk #app'te degil BU ogede; yani o satir
   hicbir sey yapmiyordu ve giris karti 200px saga kaymis halde duruyordu.
   Sinif govdeye biniyor, cunku bosluga sahip olan oge ile onu kaldirmasi gereken
   kod arasindaki bagi tek bir yerde tutuyor. */
/* Boşluk da aynı sınıfa bağlı: ray yoksa içerik alanı onun genişliğini
   ayırmaz. Eskiden bunu temizlemeye çalışan satır YANLIŞ ÖĞEYİ hedefliyordu
   (#app'i, oysa boşluk burada) ve giriş kartı 200px sağa kaymış duruyordu. */
body.rail-ready .main-wrapper { margin-left: var(--sidebar-width); }

.main-wrapper {
  margin-left: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
}

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 32px;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 600;
}

.page-header .subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 2px;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 13px;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--accent);
  /* white DEGIL: gerekcesi variables.css'te --accent-contrast'in yaninda. */
  color: var(--accent-contrast);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-danger {
  background: var(--danger-dim);
  color: #fca5a5;
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.selection-group-menu {
  position: relative;
}

.selection-bar-divider {
  width: 1px;
  height: 22px;
  margin: 0 2px;
  background: var(--border);
}

.selection-group-menu summary {
  list-style: none;
  cursor: pointer;
}

.selection-group-menu summary::-webkit-details-marker {
  display: none;
}

.selection-group-menu-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 200px;
  padding: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

.selection-group-menu[open] .selection-group-menu-panel {
  display: grid;
}

.selection-group-menu-panel button {
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.selection-group-menu-panel button:hover {
  background: var(--bg-card-hover);
}

.selection-group-menu-divider {
  height: 1px;
  margin: 4px 2px;
  background: var(--border);
}

.selection-group-menu-panel .selection-group-menu-create {
  color: var(--accent);
}

.btn-icon {
  padding: 6px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Device Grid */
/* Operasyon Konsolu: one screen per ROW rather than a card grid — an
   operator scans a fleet down a column, not across a mosaic. The card
   markup is unchanged; only the axis is. */
.device-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
}

.device-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

/* #238: a rotated display shown as its viewer sees it. The stage is the panel's face; the frame is
   its framebuffer, turned back by the mount (js/lib/device-frame.js sizes and rotates it from the
   players' shared rule). The frame is centred on its offset parent, so a stage without
   `position: relative` would centre it on the page — hence both halves live here together. */
.display-stage {
  position: relative;
  overflow: hidden;
}

.display-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.device-card-preview {
  aspect-ratio: 16/9;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.device-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.device-card-preview .no-preview {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 8px;
}

.device-card-preview .no-preview svg {
  opacity: 0.3;
}

.device-card-status {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
/* Device cards render the reused liveness pill (.device-status-badge from device-detail), which brings
   its own bg/padding/shape — so neutralize the dark wrapper for those. Wall cards keep the dark pill
   above for their "NxN wall" label (they share .device-card-status but have no .is-liveness). */
.device-card-status.is-liveness {
  background: none;
  backdrop-filter: none;
  padding: 0;
  border-radius: 0;
}
/* Lift the list pill off the screenshot so it stays legible over any image. */
.device-card-status.is-liveness .device-status-badge {
  box-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.device-card-select {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 5;
  background: rgba(0,0,0,0.6);
  border-radius: 4px;
  padding: 3px 5px;
  display: flex;
  align-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
/* The drag handle: the visible half of "you can reorder these" (#106). Shown on hover, like the
   select box opposite it. */
.device-card { position: relative; }
.device-card-drag {
  position: absolute;
  top: 8px;
  left: 40px;   /* beside the select box; the right corner is the status badge's */
  z-index: 5;
  background: rgba(0,0,0,0.6);
  color: #e5e7eb;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 15px;
  line-height: 1.4;
  cursor: grab;
  opacity: 0;
  transition: opacity var(--transition);
  user-select: none;
}
.device-card:hover .device-card-drag { opacity: 1; }
.device-card.dragging { opacity: 0.45; }
.device-card:hover .device-card-select,
.device-card.selected .device-card-select { opacity: 1; }
.device-card-select input { cursor: pointer; margin: 0; }
.device-card.selected { outline: 2px solid var(--primary, #3B82F6); outline-offset: -2px; }

/* Wall editor — free-form pan/zoom canvas */
.wall-viewport {
  position: relative;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  background:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px) 0 0 / 40px 40px,
    var(--bg-primary);
}
.wall-viewport.panning { cursor: grabbing; }
/* Inner canvas: a 0×0 anchor whose CSS transform supplies pan + zoom.
   All rect children are absolutely positioned in canvas-data coordinates
   and inherit the parent transform. transform-origin is the canvas's
   top-left so pan offsets map cleanly to data → screen pixels. */
.wall-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  /* Disable transition so panning doesn't lag behind the cursor */
}
.wall-zoom-readout {
  position: absolute;
  bottom: 8px;
  right: 12px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.wall-screen {
  position: absolute;
  background: rgba(59,130,246,0.08);
  border: 2px solid var(--primary, #3B82F6);
  border-radius: 4px;
  box-sizing: border-box;
  cursor: move;
  user-select: none;
  touch-action: none;
  overflow: hidden;
}
.wall-screen-overlap {
  position: absolute;
  background: rgba(96,165,250,0.35);
  pointer-events: none;
  display: none;
  z-index: 1;
}
.wall-screen-label {
  position: absolute;
  top: 4px;
  left: 6px;
  right: 24px;
  pointer-events: none;
  z-index: 2;
}
.wall-screen-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #fff);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wall-screen-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-muted);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.wall-screen-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.wall-screen-remove:hover { background: var(--danger, #ef4444); }

.wall-player {
  position: absolute;
  background: rgba(96,165,250,0.18);
  border: 2px dashed #60a5fa;
  border-radius: 4px;
  box-sizing: border-box;
  cursor: move;
  user-select: none;
  touch-action: none;
  z-index: 5;
  box-shadow: 0 0 0 9999px transparent; /* keeps stacking explicit */
}
.wall-player-label {
  position: absolute;
  top: 4px;
  left: 6px;
  pointer-events: none;
  color: #dbeafe;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  font-size: 11px;
  letter-spacing: 1px;
}

/* Selected rect highlight (works for both screens and the player) */
.wall-screen.selected,
.wall-player.selected {
  outline: 3px solid #facc15;
  outline-offset: 1px;
  z-index: 6;
}

/* Fine-position panel inputs */
.wall-pos-grid {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 6px 8px;
  align-items: center;
  font-size: 12px;
}
.wall-pos-grid label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.wall-pos-grid input {
  width: 100%;
  padding: 4px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary, #fff);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.wall-pos-grid input:focus { outline: 1px solid var(--primary); outline-offset: 0; border-color: var(--primary); }

/* Eight resize handles, used by both screens and the player */
.wall-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 1px solid #1d4ed8;
  border-radius: 2px;
  z-index: 4;
}
.wall-player .wall-handle { border-color: #60a5fa; }
.wall-handle-nw { top: -5px; left: -5px; cursor: nw-resize; }
.wall-handle-n  { top: -5px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.wall-handle-ne { top: -5px; right: -5px; cursor: ne-resize; }
.wall-handle-e  { top: 50%; right: -5px; transform: translateY(-50%); cursor: e-resize; }
.wall-handle-se { bottom: -5px; right: -5px; cursor: se-resize; }
.wall-handle-s  { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.wall-handle-sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.wall-handle-w  { top: 50%; left: -5px; transform: translateY(-50%); cursor: w-resize; }

/* Wall editor — legacy cells (kept for migration; new editor uses wall-canvas) */
.wall-cell {
  position: relative;
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-secondary);
  user-select: none;
}
.wall-cell.occupied {
  background: rgba(59,130,246,0.15);
  border: 2px solid var(--primary, #3B82F6);
  cursor: grab;
}
.wall-cell.occupied:active { cursor: grabbing; }
.wall-cell.drag-over {
  border-color: var(--success, #10b981);
  box-shadow: 0 0 0 2px rgba(16,185,129,0.25) inset;
}
.wall-cell-name { font-weight: 500; padding: 0 6px; text-align: center; }
.wall-cell-pos {
  position: absolute;
  bottom: 4px;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
.wall-cell-remove {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.6);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 20px; height: 20px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.wall-cell-remove:hover { background: var(--danger, #ef4444); }

.wall-card .wall-card-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(59,130,246,0.1));
}
.wall-card-grid {
  display: grid;
  gap: 4px;
  width: 65%;
  aspect-ratio: 16/9;
  padding: 8px;
}
.wall-card-cell {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(139,92,246,0.3);
  border-radius: 2px;
}
.wall-card-cell.filled {
  background: rgba(139,92,246,0.5);
  border-color: rgba(139,92,246,0.9);
}

.device-card-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 10px 8px;
  background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0));
  color: #fff;
  font-size: 11px;
  pointer-events: none;
}
.device-card-progress-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.device-card-progress-label .dcp-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.device-card-progress-label .dcp-time {
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}
.device-card-progress-track {
  height: 3px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  overflow: hidden;
}
.device-card-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary, #3B82F6);
  transition: width 0.9s linear;
}
.device-card-progress-fill.indeterminate {
  background: linear-gradient(90deg, transparent, var(--primary, #3B82F6), transparent);
  background-size: 50% 100%;
  animation: dcp-indeterminate 1.4s linear infinite;
}
@keyframes dcp-indeterminate {
  0% { background-position: -50% 0; }
  100% { background-position: 150% 0; }
}

.device-card-body {
  padding: 14px 16px;
}

.device-card-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 6px;
}

.device-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 12px;
}

.device-card-meta .meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* #467: the player version on a card; amber when an Android player is behind the served APK. */
.device-card-meta { flex-wrap: wrap; row-gap: 4px; }
.device-card-meta .meta-version { font-variant-numeric: tabular-nums; }
.device-card-meta .meta-version.is-behind { color: var(--warning, #f59e0b); font-weight: 600; }
/* #467: card details chosen per browser — hidden by a class on the grid, no re-render. */
.hide-card-version [data-card-field="version"],
.hide-card-battery [data-card-field="battery"],
.hide-card-wifi [data-card-field="wifi"],
.hide-card-storage [data-card-field="storage"] { display: none !important; }
.card-fields-menu { position: relative; }
.card-fields-menu > summary { list-style: none; cursor: pointer; }
.card-fields-menu > summary::-webkit-details-marker { display: none; }
.card-fields-pop {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 170px;
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px;
  background: var(--bg-card, #1e293b); border: 1px solid var(--border, #334155); border-radius: 10px;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .5); font-size: 13px;
}
.card-fields-pop label { display: flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap; }

/* Device Detail */
.device-detail {
  max-width: 1200px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-size: 13px;
  transition: color var(--transition);
}

.back-link:hover { color: var(--text-primary); }

.device-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.device-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.device-header-left h1 {
  font-size: 22px;
}

.device-status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.device-status-badge.online { background: var(--success-dim); color: var(--success); }
.device-status-badge.offline { background: var(--danger-dim); color: #fca5a5; }
.device-status-badge.provisioning { background: var(--warning-dim); color: var(--warning); }
/* v4 liveness (server-derived): healthy=green, degraded=amber (reconnecting), offline reuses .offline above */
.device-status-badge.healthy { background: var(--success-dim); color: var(--success); }
.device-status-badge.degraded { background: var(--warning-dim); color: var(--warning); }

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  cursor: pointer;
}

.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Screenshot Preview */
.screenshot-container {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16/9;
  position: relative;
  margin-bottom: 20px;
}

.screenshot-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.screenshot-container .no-screenshot {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 8px;
}

/* Live video overlay: sits on top of the screenshot in the Now Playing stage. Hidden until the
   WebRTC viewer actually connects; on any failure it hides again and the screenshot underneath
   shows through, so the tile never goes blank. */
.screenshot-container .live-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  z-index: 1;
}
.screenshot-container .live-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.screenshot-container .live-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff4747;
  box-shadow: 0 0 0 0 rgba(255,71,71,0.7);
  animation: live-pulse 1.8s infinite;
}
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,71,71,0.6); }
  70%  { box-shadow: 0 0 0 6px rgba(255,71,71,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,71,71,0); }
}
@media (prefers-reduced-motion: reduce) {
  .screenshot-container .live-badge::before { animation: none; }
}

/* Remote Control */
.remote-container {
  display: flex;
  gap: 20px;
}

.remote-screen {
  flex: 1;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  cursor: crosshair;
}

.remote-screen canvas {
  width: 100%;
  display: block;
}

.remote-controls {
  width: 120px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.remote-controls .btn {
  width: 100%;
  justify-content: center;
}

/* Playlist */
.playlist-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
}

.playlist-item:hover {
  border-color: var(--border-light);
}

.playlist-item-thumb {
  width: 80px;
  height: 45px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg-primary);
  flex-shrink: 0;
}

.playlist-item-info {
  flex: 1;
  min-width: 0;
}

.playlist-item-name {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

.playlist-item-actions {
  display: flex;
  gap: 4px;
}

/* Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.info-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.info-card-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.info-card-value {
  font-size: 20px;
  font-weight: 600;
}

.info-card-value.small {
  font-size: 14px;
}

/* Progress bar */
.progress-bar {
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--transition);
}

.progress-bar-fill.success { background: var(--success); }
.progress-bar-fill.warning { background: var(--warning); }
.progress-bar-fill.danger { background: var(--danger); }

/* Content Library */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.content-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
}

.content-item:hover {
  border-color: var(--border-light);
}

.content-item-preview {
  aspect-ratio: 16/9;
  background: var(--bg-primary);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.content-item-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.content-item-preview .video-icon {
  color: var(--text-muted);
}

.content-item-body {
  padding: 10px 12px;
}

.content-item-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.content-item-size {
  font-size: 11px;
  color: var(--text-muted);
}

.content-item-actions {
  display: flex;
  justify-content: flex-end;
  /* ⚠️ WRAP, NEVER OVERFLOW. A right-aligned (flex-end) row that is wider than its card spills out
     of the LEFT edge, and .content-item clips with overflow:hidden — so the FIRST button vanished.
     Adding Duplicate made the widget row Edit · Duplicate · History · Delete (~280px) in cards that
     auto-fill down to 200px, and Edit disappeared from every widget on a wide screen. */
  flex-wrap: wrap;
  padding: 0 12px 10px;
  gap: 4px;
}

/* Upload Area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 24px;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}

.upload-area svg {
  margin: 0 auto 12px;
  color: var(--text-muted);
}

.upload-area p {
  color: var(--text-secondary);
  font-size: 14px;
}

.upload-area .upload-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 440px;
  max-width: 90vw;
  box-shadow: var(--shadow);
  /* Cap to the viewport and lay out as a column so a tall form (e.g. the directory-board
     widget with many entries) scrolls inside .modal-body while the header/footer stay
     pinned — otherwise the modal grows past the screen and Save becomes unreachable. */
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
  /* Scroll region between the pinned header and footer. min-height:0 lets the flex item
     shrink below its content so overflow-y actually engages inside the column. */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.modal-description {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  transition: border-color var(--transition);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.pairing-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 8px;
  font-family: 'Courier New', monospace;
}

.pairing-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 280px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  margin: 0 auto 16px;
  opacity: 0.3;
}

.empty-state h3 {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  max-width: 360px;
  margin: 0 auto;
}

/* Settings */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.settings-section h3 {
  font-size: 16px;
  margin-bottom: 16px;
}

/* Assign Modal */
.assign-content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.assign-content-item {
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
}

.assign-content-item:hover {
  border-color: var(--accent);
}

.assign-content-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.assign-content-item img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.assign-content-item-name {
  padding: 6px 8px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* Upload progress */
.upload-progress {
  margin-top: 16px;
}

.upload-progress-bar {
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Help tooltips */
.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: help;
  position: relative;
  margin-left: 6px;
  flex-shrink: 0;
}

/* A help tip must be reachable without a mouse. :hover alone made every one of these
   invisible on a tablet or phone — which is a large share of the people administering a
   signage install — and unreachable by keyboard. Tapping toggles .is-open; focus shows it too. */
/* The visible marker is 18px, which is fine to look at and far too small to hit with a thumb —
   about half the ~44px touch guideline. Now that tapping a tip is how touch users read it at
   all, extend the HIT AREA with a transparent inset overlay rather than inflating the circle,
   so the target is comfortable without the marker dominating a heading. */
.help-tip::before {
  content: '';
  position: absolute;
  inset: -13px;
  border-radius: 50%;
}

.help-tip:hover::after,
.help-tip:focus-visible::after,
.help-tip.is-open::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  white-space: normal;
  width: 250px;
  z-index: 1000;
  box-shadow: var(--shadow);
  margin-bottom: 6px;
  line-height: 1.4;
}

/* Table wrapper: enables horizontal scroll when table min-width exceeds viewport */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Mobile hamburger toggle */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 44px;
  height: 44px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 150;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 140;
  }
  .sidebar-backdrop.open { display: block; }
  .nav-link { min-height: 44px; padding: 10px 14px; }
  /* ⚠️ İKİ SEÇİCİ, VE BU ZORUNLU. Tek başına `.main-wrapper` burada hiçbir şey yapmıyordu:
     `body.rail-ready .main-wrapper` (dosyanın başında) daha özgül ve özgüllük medya
     sorgusundan bağımsız kazanır. Sonuç, kenar çubuğu ekran dışına kaydığı hâlde içeriğin
     200 piksel sağda durması ve sağdaki ögelerin kırpılmasıydı. rail-ready kaldırılmıyor:
     masaüstünde menünün yerini açan ve menü parlamasını önleyen sınıf o. */
  .main-wrapper,
  body.rail-ready .main-wrapper { margin-left: 0; }
  .content { padding: 16px; padding-top: 68px; }
  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .device-grid { grid-template-columns: 1fr; }
  .content-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .info-grid { grid-template-columns: 1fr; }
  .remote-container { flex-direction: column; }
  .remote-controls { width: 100%; flex-direction: row; flex-wrap: wrap; }
  /* max-height + scrolling body are now on the base .modal (pinned header/footer); just widen. */
  .modal { width: 95vw; }
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
  }
  .tab { white-space: nowrap; flex-shrink: 0; }
  .playlist-item { flex-wrap: wrap; }

  /* Dashboard stats stack to single column */
  .dash-stats-row { flex-direction: column; }
  .dash-stats-row .info-card { flex: none; }

  /* Content-library 3-up toolbar stacks vertically */
  .content-toolbar { flex-direction: column; }
  .content-toolbar > div[style*="width:320px"] { width: auto !important; }

  /* Schedule controls: allow wrap and widen select to full row */
  .schedule-controls { gap: 8px; }
  .schedule-controls > select { flex: 1 1 100%; }
  .schedule-controls > button,
  .schedule-controls > span { flex: 0 1 auto; }

  /* Tap targets: minimum 44px height for interactive elements */
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 36px; padding: 8px 12px; }
  .btn-icon { min-width: 40px; min-height: 40px; }

  /* Form inputs: 16px font to prevent iOS focus zoom; 44px tap target */
  .input,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="url"],
  input[type="search"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px;
    min-height: 44px;
  }
  .pairing-input { font-size: 24px; letter-spacing: 6px; }

  /* Modals: adjust padding at 95vw so content doesn't touch edges */
  .modal-header,
  .modal-footer { padding: 14px 16px; }
  .modal-body { padding: 16px; }

  /* Toast container: full-width bar instead of 280px fixed to right */
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
  .toast { min-width: 0; width: 100%; }
}

@media (max-width: 480px) {
  .content-grid { grid-template-columns: 1fr; }
  .assign-content-grid { grid-template-columns: 1fr 1fr; }
}


/* =====================================================================
   OPERASYON KONSOLU
   Dark rail, dense light content. Appended as a layer so it settles ties
   with the rules above by document order; the mobile block stays last.
   ===================================================================== */

/* ---- the rail ------------------------------------------------------- */
.sidebar-header { padding: 14px 14px; border-bottom: 1px solid var(--sidebar-border); color: var(--sidebar-fg-strong); }
.sidebar-footer { padding: 10px 14px; border-top: 1px solid var(--sidebar-border); color: var(--sidebar-fg); }


/* ══ GIRIS SAHNESI ═════════════════════════════════════════════════════════
   Oynaticinin eslestirme ve bekleme ekranlariyla ayni dil: lacivert zemin,
   devre motifi, camsi kart. Musterinin gordugu ILK ekran, urunun geri kalanina
   en az benzeyen ekran olmamali.

   ⚠️ TEK DUNYA — ACIK TEMAYI IZLEMEZ, VE BU BILINCLI. Panel acik/koyu destekliyor
   ama bu ekran KIMLIK DOGRULAMA ONCESI bir yuzey, tipki oynaticinin eslestirme
   ekrani gibi; o ekranlar da tek dunyali. Bu yuzden renkler panelin --bg-*
   tokenlerinden DEGIL, burada tanimli kendi tokenlerinden geliyor: kullanicinin
   tema tercihi bu sayfayi yarim aydinlatamaz.

   Yan faydasi logo: sayfa her zaman koyu oldugu icin tek bir kilit varyanti
   yetiyor. Iki varyant arasinda tema'ya gore secim yapmak gerekseydi, ikisi de
   ~480KB oldugu icin ya bir megabayt indirilir ya da yanlisi gosterilirdi. */
.auth-stage {
  --auth-text:   #f7faff;
  --auth-dim:    #9aacc7;
  /* Bir kademe soluk, ama hala 4.74:1 — gradyanin EN ACIK ucune gore olculdu,
     cunku metin oranin en dusuk oldugu yerde de okunmali. */
  --auth-faint:  #7f92ad;
  --auth-notice: #ffbf47;
  --auth-line:   rgba(55, 133, 255, 0.32);

  position: fixed; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 4vh 4vw;
  overflow-y: auto;
  color: var(--auth-text);
  background: radial-gradient(90% 70% at 50% 30%, #091d3a 0%, #06142b 68%);
}
.auth-shell { position: relative; width: 400px; max-width: 100%; }

/* ── Marka blogu ────────────────────────────────────────────────────────────
   Oynaticinin eslestirme ekranindaki olculer: kilit GENIS, altinda genis harf
   arali kli bir alt baslik, sonra kart. Ilk hali 48px'lik bir logo ve 13px'lik
   bir cumleydi — teknik olarak dogru ama oynaticinin yaninda cekingen duruyordu,
   ve bu ekran musterinin urunu ilk gordugu yer. */
.auth-brand { text-align: center; margin-bottom: 36px; }
.auth-brand img {
  display: block; margin: 0 auto;
  width: min(19rem, 78%); height: auto;
}
/* PLAYER alt basligiyla ayni muamele: buyuk harf, genis aralik, sonundaki
   bosluk text-indent ile telafi ediliyor ki blok gercekten ortalansin. */
.auth-kicker {
  margin-top: 14px;
  color: var(--auth-dim);
  font-size: 0.82rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.42em; text-indent: 0.42em;
}
.auth-brand .auth-sub { margin-top: 16px; font-size: 0.9rem; color: var(--auth-faint); }
.auth-brand .auth-note { margin-top: 8px; font-size: 0.8rem; color: var(--auth-notice); }

/* Dekoratif; asla seslendirilmiyor. Kartin ARKASINDA durur, ustunde degil. */
.auth-circuit {
  position: absolute; left: 50%; top: 22%; transform: translate(-50%, -50%);
  width: min(60rem, 92%); height: auto;
  color: #51a3ff; opacity: 0.07; pointer-events: none;
}

.auth-card {
  position: relative;
  background: rgba(10, 31, 62, 0.78);
  border: 1px solid var(--auth-line);
  border-radius: 16px;
  padding: 24px;
}
/* Form denetimleri sahnenin icinde: panelin acik temasindaki input renkleri
   burada yanlis olurdu. */
.auth-card .input,
.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"] {
  background: rgba(6, 20, 43, 0.72);
  border-color: var(--auth-line);
  color: var(--auth-text);
}
.auth-card .input::placeholder { color: #617594; }
.auth-card .input:focus { border-color: #2583ff; }
.auth-card label { color: var(--auth-dim); }
.auth-card .btn-secondary {
  background: transparent; color: var(--auth-text); border: 1px solid var(--auth-line);
}
.auth-card .btn-secondary:hover { border-color: #2583ff; background: rgba(37, 131, 255, 0.10); }
/* Kartin disindaki yardimci baglantilar (sifremi unuttum, destek, yasal). */
.auth-stage a { color: #8fc0ff; }
.auth-stage .btn-primary { color: #fff; }

/* ── Tema seçici ────────────────────────────────────────────────────────────
   Yan rayda duruyor, yani rengini içerik alanının değil RAYIN tokenlerinden
   alır (--sidebar-*). Ray her iki temada da koyu olduğu için bu denetim tema
   değiştiğinde neredeyse hiç değişmez — istenen de bu: kullanıcının temayı
   değiştirmek için bastığı düğmenin, bastığı anda altından kayması iyi
   olmazdı. */
.theme-switch {
  display: flex;
  gap: 2px;
  padding: 2px;
  margin-bottom: 10px;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.18);
}
.theme-switch button {
  flex: 1 1 0;
  display: flex; align-items: center; justify-content: center;
  padding: 5px 0;
  border: 0; border-radius: calc(var(--radius) - 2px);
  background: transparent; color: var(--sidebar-fg);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.theme-switch button:hover { background: var(--sidebar-hover); color: var(--sidebar-fg-strong); }
/* Seçili durum aria-pressed ÜZERİNDEN okunuyor, ayrı bir sınıf üzerinden değil:
   böylece görsel durum ile ekran okuyucunun duyduğu durum ayrışamaz. */
.theme-switch button[aria-pressed="true"] {
  background: var(--sidebar-hover);
  color: var(--sidebar-fg-strong);
}
.theme-switch button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Yalnızca ekran okuyucu için: düğmelerin görünen tek içeriği bir ikon, ve bir
   ikonun adı yoktur. */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.sidebar .nav-links { padding: 8px 6px; }

.nav-link {
  gap: 9px;
  padding: 7px 10px;
  min-height: 0;
  color: var(--sidebar-fg);
  font-size: 12.5px;
  margin-bottom: 1px;
  border-left: 2px solid transparent;
}
.nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-fg-strong); }
.nav-link.active { background: var(--sidebar-hover); color: #ffffff; border-left-color: #60a5fa; font-weight: 600; }

.sidebar .btn-icon { color: var(--sidebar-fg); min-width: 0; min-height: 0; padding: 6px; }
.sidebar .btn-icon:hover { background: var(--sidebar-hover); color: var(--sidebar-fg-strong); }
.sidebar .connection-status, .sidebar .version-status { color: var(--sidebar-fg); font-size: 11.5px; }
.sidebar .version-badge { background: var(--accent); color: #ffffff; }

/* Anything that sits ON the rail needs rail-appropriate ink: the accent is
   blue-700 for contrast against white content, which is far too dark on
   slate-900. The rail gets blue-400 instead. */
.sidebar .logo { color: #60a5fa; }
.sidebar .workspace-switcher-button {
  background: var(--sidebar-hover); border-color: var(--sidebar-border);
  color: var(--sidebar-fg-strong); font-size: 12.5px; padding: 6px 9px;
}
.sidebar .workspace-switcher-button:hover { border-color: #475569; }
.sidebar .workspace-switcher-static { color: var(--sidebar-fg-strong); font-size: 12.5px; }
.sidebar .sidebar-header .logo svg { width: 22px; height: 22px; }

/* ---- controls: 32px, not 44px --------------------------------------- */
.btn { min-height: var(--control-h); padding: 0 12px; font-size: 12.5px; font-weight: 600; }
.btn-secondary { border-color: var(--border-light); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: #94a3b8; }
.btn-danger { background: var(--danger-dim); color: var(--danger-ink); border: 1px solid #fecaca; }
.btn-danger:hover { background: var(--danger); color: #ffffff; border-color: var(--danger); }
.btn-sm { min-height: 26px; padding: 0 9px; font-size: 12px; }
.btn-icon { min-width: 30px; min-height: 30px; padding: 6px; }

.input { min-height: var(--control-h); padding: 6px 10px; font-size: 12.5px; border-color: var(--border-light); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12); }

/* ---- page chrome ---------------------------------------------------- */
.page-header { margin-bottom: 16px; }
.page-header h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.page-header .subtitle { font-size: 12px; }

/* ---- the fleet reads as rows ---------------------------------------- */
.device-card {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: stretch;
  border-radius: var(--radius);
}
.device-card:hover { border-color: var(--accent); background: var(--accent-soft); box-shadow: none; transform: none; }
.device-card-preview { background: var(--preview-bg); border-right: 1px solid var(--border); }
.device-card-status { top: 5px; right: 5px; background: var(--preview-chip); backdrop-filter: none; color: var(--text-primary); border: 1px solid var(--border); }
.device-card-body { padding: 8px 14px; display: flex; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; }
.device-card-name { font-size: 13px; margin-bottom: 0; }
.device-card-meta { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.device-card-select { top: 6px; left: 6px; background: var(--preview-chip); border: 1px solid var(--border); }

/* The thumbnail is 132px wide in a row, not a 300px card: the placeholder's
   48px icon and its caption were built for the card and overflow here. */
.device-card-preview { aspect-ratio: auto; height: 100%; min-height: 62px; }
.device-card-preview .no-preview { gap: 0; }
.device-card-preview .no-preview span { display: none; }
.device-card-preview .no-preview svg { width: 22px; height: 22px; opacity: 0.45; }
.device-card-preview .device-card-status .device-status-badge { font-size: 10px; padding: 2px 7px; }
.device-card-progress { padding: 4px 8px 5px; font-size: 10px; }

/* ---- numerals and tables -------------------------------------------- */
/* Numbers an operator compares down a column must not shift as they tick. */
.device-card-meta, .badge, .stat-value, td, th { font-variant-numeric: tabular-nums; }

.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table-wrap th {
  text-align: left; padding: 7px 12px; background: var(--bg-card-hover); color: var(--text-muted);
  font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; font-weight: 600;
  border-bottom: 1px solid var(--border-light);
}
.table-wrap td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tbody tr:hover { background: var(--accent-soft); }

/* Amber, green and red at full saturation are fills, not text: on a light
   ground only the ink shades clear 4.5:1. */
.device-status-badge.provisioning, .device-status-badge.degraded { color: var(--warning-ink); }
.device-status-badge.online, .device-status-badge.healthy { color: var(--success-ink); }
.device-status-badge.offline { color: var(--danger-ink); }

/* Status reads as ink on tint here, not as a glow on black. */
.status-dot.online, .status-dot.healthy, .status-dot.degraded { box-shadow: none; }

/* ---- modals --------------------------------------------------------- */
.modal-overlay { background: rgba(15, 23, 42, 0.45); }
.modal-header h3 { font-size: 15px; font-weight: 700; }

/* ---- phones: density is a desktop affordance ------------------------ */
@media (max-width: 768px) {
  .btn { min-height: 44px; padding: 10px 16px; font-size: 13px; }
  .btn-sm { min-height: 36px; padding: 8px 12px; }
  .btn-icon { min-width: 40px; min-height: 40px; }
  .input { min-height: 44px; padding: 10px 12px; font-size: 14px; }
  .nav-link { min-height: 44px; padding: 10px 14px; font-size: 14px; }
  .device-card { grid-template-columns: 1fr; }
  .device-card-preview { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ===================== TRIGGERS DIALOG =====================
 *
 * ⚠️ This form used `.modal-backdrop`, which is defined nowhere — so it rendered unstyled and
 * un-positioned at the end of the page. It now uses the same .modal-overlay/.modal/.modal-header/
 * .modal-body/.modal-footer skeleton as every other dialog; what follows is only the extra it
 * genuinely needs, which is a wider shell and the two-column assignment grid.
 */

/* Wider than the 440px default: this form has paired numeric fields and a two-column assignment
   grid, and at 440px both wrap into a single column of forty rows. */
.modal.tg-modal { width: 640px; }

.tg-section { padding-bottom: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.tg-section:last-child { border-bottom: 0; margin-bottom: 0; }

.tg-legend {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.tg-blurb { font-size: 12px; color: var(--text-secondary); margin: -4px 0 12px; }
.tg-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; line-height: 1.45; }

/* Paired fields (max duration + lease) sit side by side; they are read together. */
.tg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.tg-sources { display: flex; gap: 18px; margin-top: 2px; }

.tg-check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.tg-check input { margin: 0; }

/* Enabled belongs beside Save, not lost in the middle of the form: it is the one control that
   decides whether any of the rest happens. margin-right:auto pushes the buttons right. */
.tg-enabled { margin-right: auto; color: var(--text-secondary); }

.tg-empty {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.tg-col { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 0 0 8px; }

.assign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* The assignment lists can be long — a hundred screens is normal — so each column scrolls rather
   than pushing Save out of reach. */
.assign-grid > div { max-height: 210px; overflow-y: auto; padding-right: 4px; }
.assign-grid label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; padding: 4px 0; cursor: pointer;
}
.assign-grid label input { margin: 0; flex-shrink: 0; }

@media (max-width: 700px) {
  .tg-row, .assign-grid { grid-template-columns: 1fr; }

}

/* ---------------------------------------------------------------------------------------------
   Schedule: Outlook-style calendar chrome. Everything is built on the existing variables; the
   grid geometry (HOUR_PX and friends) stays in JS because the drag maths depends on it.
   --------------------------------------------------------------------------------------------- */
.sched-shell { display: flex; gap: 14px; align-items: flex-start; }
.sched-rail {
  width: 232px; flex: 0 0 232px; display: flex; flex-direction: column; gap: 14px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px;
}
.sched-rail.collapsed { display: none; }
.sched-rail h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.sched-mini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; font-size: 11px; }
.sched-mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 12px; font-weight: 600; }
.sched-mini-dow { text-align: center; color: var(--text-muted); font-size: 10px; padding: 2px 0; }
.sched-mini-day {
  text-align: center; padding: 4px 0; border-radius: var(--radius); cursor: pointer; color: var(--text-secondary);
  background: transparent; border: 1px solid transparent; font: inherit; line-height: 1.2;
}
.sched-mini-day:hover { background: var(--bg-card-hover); }
.sched-mini-day.out { color: var(--text-muted); opacity: .55; }
.sched-mini-day.today { color: var(--accent); font-weight: 700; }
.sched-mini-day.selected { border-color: var(--accent); }
.sched-mini-day.busy::after { content: ''; display: block; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); margin: 1px auto 0; }
.sched-cal-list { display: flex; flex-direction: column; gap: 2px; max-height: 40vh; overflow: auto; }
.sched-cal-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: var(--radius); cursor: pointer;
  font-size: 13px; color: var(--text-primary); user-select: none;
}
.sched-cal-item:hover { background: var(--bg-card-hover); }
.sched-cal-item input { width: auto; margin: 0; accent-color: var(--accent); }
.sched-cal-item .name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sched-cal-swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 12px; }
.sched-cal-swatch.group { border: 1.5px dashed rgba(255,255,255,.7); box-sizing: border-box; }
.sched-main { flex: 1; min-width: 0; }
.sched-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.sched-toolbar .spacer { flex: 1; }
.sched-datelabel {
  font: inherit; font-size: 15px; font-weight: 600; color: var(--text-primary); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius); padding: 4px 8px; cursor: pointer;
}
.sched-datelabel:hover { border-color: var(--border); background: var(--bg-card-hover); }
.sched-views { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.sched-views button {
  font: inherit; font-size: 12px; padding: 5px 10px; background: var(--bg-input); color: var(--text-secondary);
  border: 0; border-right: 1px solid var(--border); cursor: pointer;
}
.sched-views button:last-child { border-right: 0; }
.sched-views button.active { background: var(--accent); color: #fff; }
.sched-kbd { font-size: 11px; color: var(--text-muted); }
.sched-frame { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-primary); }
.sched-allday { display: grid; border-bottom: 2px solid var(--border); background: var(--bg-secondary); min-height: 26px; }
.sched-allday-label { font-size: 10px; color: var(--text-muted); padding: 5px 6px; text-align: right; }
.sched-allday-cell { border-left: 1px solid var(--border); padding: 3px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sched-chip, .sched-pill {
  display: block; font-size: 11px; line-height: 1.3; padding: 2px 6px; border-radius: 3px; color: #fff; cursor: pointer;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; opacity: .95; border: 0; text-align: left; font-family: inherit; width: 100%;
}
.sched-chip.group, .sched-pill.group, .sched-block.group { border: 1.5px dashed rgba(255,255,255,.65); }
.sched-scroll { position: relative; overflow: auto; max-height: calc(100vh - 300px); }
.sched-grid { display: grid; min-width: 0; }
.sched-corner, .sched-daycol-head { background: var(--bg-secondary); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 6; }
.sched-daycol-head { padding: 6px 4px; text-align: center; border-left: 1px solid var(--border); font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.sched-daycol-head .num { display: inline-block; min-width: 24px; line-height: 24px; border-radius: 12px; font-weight: 600; }
.sched-daycol-head.today .num { background: var(--accent); color: #fff; }
.sched-daycol-head.selected { box-shadow: inset 0 -2px 0 var(--accent); }
.sched-hour-label { padding: 2px 6px; font-size: 10px; color: var(--text-muted); border-bottom: 1px solid var(--border); text-align: right; }
.sched-hour { position: relative; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); background: var(--bg-primary); }
.sched-hour.work { background: var(--bg-card); }
.sched-hour.offday { background: var(--bg-primary); opacity: .92; }
.sched-block {
  position: absolute; border-radius: 3px; padding: 2px 4px; font-size: 10px; color: #fff; overflow: hidden; cursor: grab;
  z-index: 1; opacity: .93; line-height: 1.25; box-sizing: border-box; border-left: 3px solid rgba(0,0,0,.25);
}
.sched-block .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-block .what { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-block.continues { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.sched-block.continued { border-top-left-radius: 0; border-top-right-radius: 0; }
.sched-resize-grip { position: absolute; left: 0; right: 0; bottom: 0; height: 10px; cursor: ns-resize; background: linear-gradient(to bottom, transparent, rgba(0,0,0,.28)); }
.sched-ghost {
  position: absolute; left: 2px; right: 2px; border-radius: 3px; z-index: 5; pointer-events: none; background: var(--accent);
  opacity: .55; color: #fff; font-size: 10px; padding: 2px 4px; line-height: 1.2; border: 1px solid rgba(255,255,255,.8); overflow: hidden;
}
.sched-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--danger); z-index: 4; pointer-events: none; }
.sched-now::before { content: ''; position: absolute; left: -5px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.sched-month { display: grid; grid-template-columns: repeat(7, 1fr); }
.sched-month-dow { padding: 6px 4px; text-align: center; font-size: 11px; color: var(--text-secondary); background: var(--bg-secondary); border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); }
.sched-month-cell {
  min-height: 96px; border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px;
  display: flex; flex-direction: column; gap: 2px; background: var(--bg-primary); box-sizing: border-box; min-width: 0;
}
.sched-month-cell.out { background: var(--bg-secondary); }
.sched-month-cell.out .sched-month-daynum { color: var(--text-muted); opacity: .6; }
.sched-month-cell.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.sched-month-cell.drop { background: var(--accent-dim); }
.sched-month-daynum {
  align-self: flex-end; font: inherit; font-size: 12px; font-weight: 600; color: var(--text-secondary); background: transparent;
  border: 0; border-radius: 12px; min-width: 24px; line-height: 24px; text-align: center; cursor: pointer; padding: 0 4px;
}
.sched-month-daynum:hover { background: var(--bg-card-hover); }
.sched-month-cell.today .sched-month-daynum { background: var(--accent); color: #fff; }
.sched-pill { font-size: 11px; }
.sched-pill .tm { opacity: .85; margin-right: 4px; }
.sched-pill.dragging { opacity: .35; }
.sched-more { font: inherit; font-size: 11px; color: var(--accent); background: transparent; border: 0; text-align: left; cursor: pointer; padding: 1px 4px; }
.sched-more:hover { text-decoration: underline; }
.sched-pop {
  position: fixed; z-index: 2100; width: 320px; max-width: calc(100vw - 16px); background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 12px; font-size: 13px;
}
.sched-pop h3 { margin: 0 0 4px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.sched-pop .sw { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.sched-pop .meta { color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.sched-pop .row { display: flex; gap: 8px; margin-top: 8px; }
.sched-pop .row > * { flex: 1; min-width: 0; }
.sched-pop label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.sched-pop .input { background: var(--bg-input); }
.sched-pop-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 10px; }
.sched-pop-actions .left { margin-right: auto; }
.sched-daystrip { display: none; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.sched-daystrip button { flex: 1; min-width: 40px; padding: 6px 4px; font-size: 11px; }
.sched-daystrip button.on { background: var(--accent); color: #fff; border-color: transparent; }
.sched-empty { margin: 0 0 8px; padding: 8px 12px; border-radius: var(--radius); background: var(--bg-secondary); border: 1px solid var(--border); color: var(--text-muted); font-size: 12px; }
@media (max-width: 900px) {
  .sched-rail { position: absolute; z-index: 20; box-shadow: var(--shadow); }
  .sched-shell { position: relative; }
}
@media (max-width: 700px) {
  .sched-month-cell { min-height: 56px; padding: 2px; }
  .sched-pill .tm, .sched-pill .lbl { display: none; }
  .sched-pill { height: 6px; padding: 0; border-radius: 3px; }
  .sched-kbd { display: none; }
}

/* Templates library (#/templates) — js/views/templates.js */
.tpl-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-bottom: 8px; }
.tpl-card { display: flex; flex-direction: column; }
.tpl-card .content-item-body { flex: 1; }
.tpl-card .content-item-name { font-size: 14px; font-weight: 600; }
.tpl-card-revoked { border-color: var(--danger); opacity: 0.9; }
.tpl-preview { color: var(--text-muted); }
.tpl-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.tpl-meta code, .tpl-callout code { font-size: 11px; background: var(--bg-input); padding: 1px 4px; border-radius: 4px; overflow-wrap: anywhere; }
.tpl-desc { font-size: 12px; color: var(--text-secondary); margin-top: 6px; line-height: 1.4; overflow-wrap: anywhere; }
.tpl-badges { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; }
.tpl-badge { display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border); white-space: nowrap; }
.tpl-badge-slide { color: var(--accent); border-color: var(--accent-dim); }
.tpl-badge-code { color: #c084fc; border-color: #7e22ce; }
.tpl-badge-ok { color: var(--success); border-color: var(--success-dim); }
.tpl-badge-warn { color: var(--warning); border-color: var(--warning-dim); background: rgba(245, 158, 11, 0.08); }
.tpl-badge-new { color: #fff; background: var(--accent); border-color: var(--accent); }
.tpl-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tpl-tag { font-size: 10px; color: var(--text-muted); background: var(--bg-primary); border-radius: 4px; padding: 1px 6px; }
.tpl-warn-text { color: var(--warning); font-size: 12px; overflow-wrap: anywhere; }
.tpl-banner-danger { background: var(--danger-dim); color: #fecaca; font-size: 12px; padding: 6px 12px; overflow-wrap: anywhere; }
.tpl-callout { background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: 13px; color: var(--text-secondary); }
.tpl-callout p { margin: 6px 0; }
.tpl-callout strong { color: var(--text-primary); }
.tpl-callout-warn { border-left-color: var(--warning); }
.tpl-callout-error { border-left-color: var(--danger); color: #fca5a5; overflow-wrap: anywhere; }
.tpl-callout-ok { border-left-color: var(--success); }
.tpl-small { font-size: 12px; padding: 8px 10px; }
.tpl-catalog { margin-bottom: 28px; }
.tpl-catalog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.tpl-catalog-head h3 { font-size: 16px; margin: 0; }
.tpl-list { margin: 8px 0 0 18px; font-size: 13px; }
.tpl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tpl-table th, .tpl-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tpl-table th { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.tpl-break { overflow-wrap: anywhere; }
.tpl-use { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 20px; }
.tpl-use-preview { min-width: 0; }
.tpl-frame-wrap { aspect-ratio: 16 / 9; background: #000; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 6px 0 12px; }
.tpl-frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.tpl-image-field { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tpl-image-thumb { width: 72px; height: 48px; border-radius: 4px; background: var(--bg-input); display: flex; align-items: center; justify-content: center; overflow: hidden; text-align: center; }
.tpl-image-thumb img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 800px) { .tpl-use { grid-template-columns: 1fr; } }

/* ─── Data sources (views/data-sources.js) ─────────────────────────────────────────────────────
   --ds-accent is set per type on the element (icon tiles, cards) so one rule set tints them all. */
.ds-page { max-width: 1280px; }
.ds-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.ds-hero h1 { font-size: 24px; font-weight: 700; margin: 0 0 6px; color: var(--text-primary); }
.ds-hero p { margin: 0; max-width: 680px; color: var(--text-secondary); font-size: 14px; line-height: 1.55; }
.ds-cta { display: inline-flex; align-items: center; gap: 8px; }
.ds-loading { display: flex; justify-content: center; padding: 48px 0; }
.ds-muted { color: var(--text-muted); font-size: 12px; margin: 0; }
.ds-spacer { flex: 1; }
.ds-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

.ds-icon { flex: none; display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 11px;
  color: var(--ds-accent); background: color-mix(in srgb, var(--ds-accent) 15%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ds-accent) 30%, transparent); }
.ds-icon-sm { width: 36px; height: 36px; border-radius: 10px; }
.ds-icon-sm svg { width: 19px; height: 19px; }

/* gallery */
.ds-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.ds-tile { display: flex; gap: 14px; align-items: flex-start; text-align: left; padding: 16px; cursor: pointer;
  background: var(--bg-card); color: inherit; border: 1px solid var(--border); border-radius: var(--radius-lg);
  transition: border-color var(--transition), transform var(--transition), background var(--transition); font: inherit; }
.ds-tile:hover, .ds-tile:focus-visible { border-color: var(--ds-accent); background: var(--bg-card-hover); transform: translateY(-1px); outline: none; }
.ds-tile:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ds-accent) 35%, transparent); }
.ds-tile-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ds-tile-title { font-weight: 600; font-size: 14.5px; color: var(--text-primary); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ds-tile-pitch { font-size: 12.5px; line-height: 1.45; color: var(--text-secondary); }
.ds-tag { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px;
  color: var(--ds-accent); background: color-mix(in srgb, var(--ds-accent) 16%, transparent); }
.ds-tag-muted { color: var(--text-secondary); background: var(--bg-input); }

.ds-empty { padding: 28px; border: 1px dashed var(--border-light); border-radius: 16px;
  background: radial-gradient(1200px 300px at 10% -20%, rgba(59,130,246,.10), transparent 60%), var(--bg-secondary); }
.ds-empty h2 { margin: 0 0 6px; font-size: 20px; color: var(--text-primary); }
.ds-empty > p { margin: 0 0 20px; max-width: 640px; color: var(--text-secondary); font-size: 14px; line-height: 1.55; }
.ds-how { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 22px; }
.ds-how div { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text-secondary); line-height: 1.45; }
.ds-how b { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; }

/* cards */
.ds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; align-items: start; }
@media (max-width: 480px) { .ds-grid { grid-template-columns: 1fr; } }
.ds-card { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 18px; overflow: hidden;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); transition: border-color var(--transition); }
.ds-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--ds-accent); opacity: .85; }
.ds-card:hover { border-color: var(--border-light); }
.ds-card-head { display: flex; gap: 12px; align-items: center; }
.ds-card-id { min-width: 0; flex: 1; }
.ds-card-id h3 { margin: 0; font-size: 15.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-card-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-card-sub code { color: #7dd3fc; font-size: 11.5px; }
.ds-status { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.ds-status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ds-status-ok { color: var(--success); background: rgba(34,197,94,.12); }
.ds-status-ok i { box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: ds-pulse 2.4s infinite; }
.ds-status-pending { color: var(--warning); background: rgba(245,158,11,.12); }
.ds-status-error { color: #f87171; background: rgba(239,68,68,.12); }
@keyframes ds-pulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.55); } 70% { box-shadow: 0 0 0 6px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
@media (prefers-reduced-motion: reduce) { .ds-status-ok i { animation: none; } .ds-tile:hover { transform: none; } }
.ds-headline { padding: 10px 12px; border-radius: var(--radius); background: color-mix(in srgb, var(--ds-accent) 8%, var(--bg-input)); font-size: 13px; }
.ds-hl { display: flex; gap: 8px; align-items: baseline; min-width: 0; color: var(--text-primary); }
.ds-hl em { flex: none; font-style: normal; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ds-accent); }
.ds-hl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-meta { margin: 0; display: grid; gap: 6px; font-size: 12.5px; }
.ds-meta div { display: flex; justify-content: space-between; gap: 12px; }
.ds-meta dt { color: var(--text-secondary); }
.ds-meta dd { margin: 0; color: var(--text-primary); max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-card-error { font-size: 12px; line-height: 1.45; color: #fca5a5; background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25); padding: 8px 10px; border-radius: var(--radius); }
.ds-vars-toggle { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 8px 12px; font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--text-primary); background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.ds-vars-toggle:hover { border-color: var(--border-light); }
.ds-vars-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.ds-vars-toggle svg { transition: transform var(--transition); }
.ds-vars-drawer { display: flex; flex-direction: column; gap: 8px; }
.ds-vars-drawer[hidden] { display: none; }
.ds-card-actions { display: flex; gap: 6px; align-items: center; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.is-busy { opacity: .65; cursor: progress; }

/* variables list */
.ds-var-list { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-input); }
.ds-var { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px; align-items: center; padding: 5px 8px; border-bottom: 1px solid rgba(255,255,255,.04); }
.ds-var:last-child { border-bottom: 0; }
.ds-var-tag { justify-self: start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; color: #7dd3fc; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; cursor: copy; }
.ds-var-tag:hover, .ds-var-tag:focus-visible { border-color: #0ea5e9; background: rgba(14,165,233,.08); outline: none; }
.ds-var-tag.is-copied { border-color: var(--success); color: var(--success); }
.ds-var-val { font-size: 12px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-var-val.is-empty { color: var(--text-muted); font-style: italic; }
.ds-var-search { width: 100%; }
.ds-hint { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--text-secondary); }

/* modal */
.ds-overlay { padding: 16px; }
.modal.ds-modal { width: 760px; max-width: 100%; max-height: min(92vh, 900px); background: var(--bg-secondary); }
.ds-modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); flex: none; }
.ds-modal-titles { flex: 1; min-width: 0; }
.ds-modal-titles h2 { margin: 0; font-size: 18px; font-weight: 650; color: var(--text-primary); }
.ds-modal-titles p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-secondary); }
.ds-modal-titles p:empty { display: none; }
.ds-x, .ds-back { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent;
  color: var(--text-secondary); font-size: 22px; line-height: 1; cursor: pointer; }
.ds-x:hover, .ds-back:hover { background: var(--bg-card); color: var(--text-primary); }
.ds-back[hidden] { display: none; }
.ds-modal-body { padding: 20px 22px; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 16px; }
.ds-modal-foot { display: flex; gap: 10px; align-items: center; padding: 14px 22px; border-top: 1px solid var(--border); flex: none; }
.ds-modal-foot[hidden] { display: none; }
.ds-form { display: flex; flex-direction: column; gap: 14px; }
.ds-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ds-field .input { width: 100%; }
.ds-label { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.ds-field-hint { font-size: 11.5px; line-height: 1.45; color: var(--text-secondary); margin: 0; }
.ds-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ds-row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; }
.ds-row-url { display: grid; grid-template-columns: 110px 1fr; gap: 12px; }
@media (max-width: 600px) { .ds-row2, .ds-row3, .ds-row-url { grid-template-columns: 1fr; } .ds-modal-foot { flex-wrap: wrap; } }
.ds-post-only[hidden], .ds-auth[hidden], .ds-lock[hidden] { display: none; }
.ds-check { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--text-primary); cursor: pointer; padding-bottom: 8px; }
.ds-fieldset { margin: 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; gap: 12px; }
.ds-fieldset legend { padding: 0 6px; font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.ds-seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 9px; width: fit-content; max-width: 100%; }
.ds-seg label { cursor: pointer; }
.ds-seg input { position: absolute; opacity: 0; pointer-events: none; }
.ds-seg span { display: block; padding: 6px 12px; border-radius: 7px; font-size: 12.5px; color: var(--text-secondary); }
.ds-seg input:checked + span { background: var(--accent); color: #fff; }
.ds-seg input:focus-visible + span { box-shadow: 0 0 0 2px var(--accent-hover); }
.ds-adv { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
.ds-adv > summary { padding: 11px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--text-primary); }
.ds-adv-body { padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.ds-callout { padding: 12px 14px; border-radius: var(--radius); font-size: 12.5px; line-height: 1.5; color: var(--text-primary);
  background: rgba(22,163,74,.08); border: 1px solid rgba(22,163,74,.3); }
.ds-callout ol { margin: 6px 0 0; padding-left: 20px; color: var(--text-secondary); }
.ds-ok-text { color: #4ade80; }
.ds-err-text { color: #f87171; }

/* test result */
.ds-result:empty { display: none; }
.ds-result { display: flex; flex-direction: column; gap: 10px; }
.ds-testing { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--text-secondary); }
.ds-alert { display: flex; flex-direction: column; gap: 4px; padding: 11px 14px; border-radius: var(--radius); font-size: 13px; line-height: 1.45; }
.ds-alert-ok { color: #86efac; background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); }
.ds-alert-error { color: #fca5a5; background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); }
.ds-alert-error span { color: var(--text-primary); }
.ds-sample-title { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-secondary); }
.ds-sample-title .ds-muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.ds-sample-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.ds-sample-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ds-sample-table th, .ds-sample-table td { padding: 7px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
.ds-sample-table th { background: var(--bg-card); vertical-align: top; }
.ds-sample-table th code { display: block; margin-top: 2px; font-size: 10.5px; color: var(--text-muted); font-weight: 400; }
.ds-sample-table tr:last-child td { border-bottom: 0; }
.ds-sample-table td { color: var(--text-primary); max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.ds-colkey { font: inherit; font-weight: 600; color: var(--text-primary); background: none; border: 0; padding: 0; cursor: pointer; border-bottom: 1px dashed var(--text-muted); }
.ds-colkey:hover, .ds-colkey:focus-visible { color: var(--accent); border-bottom-color: var(--accent); outline: none; }
.ds-raw { margin: 0; padding: 12px 14px; max-height: 260px; overflow: auto; font-size: 11.5px; color: var(--text-primary); }

/* manual table editor */
.ds-grid-editor { overflow: auto; max-height: 340px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-input); }
.ds-edit-table { border-collapse: collapse; width: 100%; }
.ds-edit-table th, .ds-edit-table td { padding: 0; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); min-width: 120px; }
.ds-edit-table thead th { position: sticky; top: 0; z-index: 1; background: var(--bg-card); }
.ds-edit-table .ds-th-x { min-width: 32px; width: 32px; border-right: 0; text-align: center; }
.ds-th { display: flex; align-items: center; }
.ds-cell { width: 100%; min-width: 0; padding: 8px 10px; font: inherit; font-size: 13px; color: var(--text-primary); background: transparent; border: 0; outline: none; }
.ds-cell:focus { background: rgba(59,130,246,.12); box-shadow: inset 0 0 0 2px var(--accent); }
.ds-cell-head { font-weight: 600; }
.ds-del { flex: none; width: 24px; height: 24px; margin: 0 4px; border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 16px; line-height: 1; }
.ds-del:hover, .ds-del:focus-visible { background: rgba(239,68,68,.15); color: #f87171; outline: none; }
.ds-grid-tools { display: flex; gap: 8px; align-items: center; }

/* ─── Admin → Sales & discounts (components/promotions-admin.js) ─────────────────────────────── */
.promo-warn { color: var(--warning); background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); padding: 10px 12px; border-radius: var(--radius); font-size: 13px; margin: 0 0 12px; }
.promo-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.promo-row { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
.promo-main { flex: 1; min-width: 0; font-size: 13px; }
.promo-sub { color: var(--text-secondary); font-size: 12px; margin-top: 3px; overflow-wrap: anywhere; }
.promo-status { flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 999px; }
.promo-live { color: #4ade80; background: rgba(34,197,94,.12); }
.promo-scheduled { color: #c4b5fd; background: rgba(139,92,246,.14); }
.promo-ended { color: var(--text-muted); background: var(--bg-input); }
.promo-actions { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }
@media (max-width: 600px) { .promo-row { flex-wrap: wrap; } .promo-row .promo-actions { width: 100%; } }
.promo-new { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
.promo-new > summary { padding: 11px 14px; font-weight: 600; font-size: 13px; cursor: pointer; }
.promo-form { padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.promo-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; }
.promo-form label[hidden] { display: none; }
.promo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.promo-plans { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.promo-plans legend { font-size: 12.5px; font-weight: 600; padding: 0 4px; }
.promo-plans label { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
.promo-preview { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.promo-preview:empty { display: none; }
.promo-preview-h { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); }
.promo-preview span { display: inline-block; min-width: 90px; color: var(--text-secondary); }
.promo-preview b { color: #4ade80; }
.promo-note { font-size: 12px; color: var(--text-secondary); margin: 0; line-height: 1.5; }
.billing-sale { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(139,92,246,.18), rgba(34,197,94,.10)); border: 1px solid rgba(139,92,246,.4); font-size: 14px; }
.billing-sale-tag { background: #8b5cf6; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; }
.billing-sale-end { margin-left: auto; color: var(--text-secondary); font-size: 12.5px; }
.billing-was { color: var(--text-muted); font-weight: 500; font-size: .7em; margin-right: 4px; }
.promo-form .btn:disabled { opacity: .5; cursor: not-allowed; }
/* ─── Platform area (views/admin.js, #/platform/<section>) ──────────────────────────────────────
   The platform group is instance-wide administration; a violet accent keeps it visually apart
   from the org- and workspace-scoped groups above it. */
.nav-group-platform > .nav-group-toggle .nav-group-label { color: #c4b5fd; }
.nav-group-platform .nav-link.active { box-shadow: inset 3px 0 0 #8b5cf6; }
.platform-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: -6px 0 20px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.platform-tab { padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-secondary); text-decoration: none; }
.platform-tab:hover { color: var(--text-primary); background: var(--bg-card); }
.platform-tab.active { color: #fff; background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.platform-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.platform-stat { display: flex; flex-direction: column; gap: 2px; padding: 18px; border-radius: var(--radius-lg); background: var(--bg-card); border: 1px solid var(--border);
  text-decoration: none; color: inherit; position: relative; overflow: hidden; transition: border-color .2s, transform .2s; }
.platform-stat::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, #8b5cf6, #22c55e); }
.platform-stat:hover { border-color: rgba(139,92,246,.5); transform: translateY(-1px); }
.platform-stat-n { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.platform-stat-l { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.platform-stat-s { font-size: 12px; color: var(--text-muted); }
.platform-attention { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.platform-attention li a { display: block; padding: 10px 14px; border-radius: var(--radius); text-decoration: none; font-size: 13.5px; font-weight: 600; }
.platform-attention .att-warn a { color: #fcd34d; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); }
.platform-attention .att-info a { color: #c4b5fd; background: rgba(139,92,246,.1); border: 1px solid rgba(139,92,246,.3); }
.platform-empty { color: var(--text-secondary); font-size: 13px; margin: 0; }
.platform-version { color: var(--text-muted); font-size: 12px; }
.platform-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.platform-filters input[type="search"] { flex: 1 1 240px; }
.platform-filters select { width: auto; }
.platform-count { color: var(--text-muted); font-size: 12px; margin-left: auto; }
tr[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .platform-stat:hover { transform: none; } }

/* Members → This workspace | Whole organization (views/workspace-members.js) */
.members-tabs { display: flex; gap: 4px; margin: 0 0 16px; padding: 3px; width: fit-content; max-width: 100%; flex-wrap: wrap;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px; }
.members-tabs[hidden] { display: none; }
.members-tab { border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 8px; cursor: pointer; }
.members-tab.active { background: var(--accent); color: #fff; }
.org-members-intro { color: var(--text-secondary); font-size: 13px; margin: 0 0 12px; }
.org-members-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.org-members-table th { text-align: left; color: var(--text-muted); font-weight: 500; padding: 8px; border-bottom: 1px solid var(--border); }
.org-members-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.org-role-pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; color: #c4b5fd; background: rgba(139,92,246,.14); }
.ws-chip { display: inline-block; margin: 0 4px 4px 0; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--bg-input); border: 1px solid var(--border); }
.ws-chip em { font-style: normal; color: var(--text-muted); margin-left: 4px; }
.platform-subhead { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); margin: 4px 0 10px; }
.platform-minis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 20px; }
.platform-mini { display: flex; flex-direction: column; gap: 1px; padding: 12px 14px; border-radius: var(--radius); background: var(--bg-card); border: 1px solid var(--border); text-decoration: none; color: inherit; }
.platform-mini:hover { border-color: rgba(139,92,246,.5); }
.platform-mini-n { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.platform-mini-l { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.platform-mini-s { font-size: 11px; color: var(--text-muted); }
.cleanup-rules { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; font-size: 13px; }
.cleanup-rules label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.cleanup-rules ul { margin: 0; padding-left: 18px; color: var(--text-secondary); display: grid; gap: 4px; }
.cleanup-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cleanup-bytes { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.cleanup-never { color: #fcd34d; font-weight: 600; }
.cleanup-note { font-size: 12px; color: var(--text-secondary); margin: 12px 0 0; line-height: 1.5; }
.cleanup-summary { margin-bottom: 16px; padding: 12px 14px; border-radius: var(--radius); background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); font-size: 13px; }
.cleanup-skipped { margin-top: 8px; color: #fcd34d; }
.cleanup-skipped ul { margin: 4px 0 0; padding-left: 18px; color: var(--text-secondary); }
.org-card[hidden] { display: none; }
.cleanup-steps { margin: 14px 0 0; padding-left: 20px; font-size: 13px; color: var(--text-secondary); display: grid; gap: 4px; }
.cleanup-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip-btn { font: inherit; font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 999px; cursor: pointer; background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border); }
.chip-btn:hover { color: var(--text-primary); border-color: var(--border-light); }
.chip-btn.chip-ready { color: #fca5a5; border-color: rgba(239,68,68,.35); }
.notice-pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--bg-input); color: var(--text-secondary); white-space: nowrap; }
.notice-running { color: #fcd34d; background: rgba(245,158,11,.12); }
.notice-ready { color: #fca5a5; background: rgba(239,68,68,.14); }
.cleanup-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.cleanup-override { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); margin-left: auto; }
.cleanup-warn { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius); font-size: 13px; color: #fcd34d; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); }
.cleanup-actions .btn:disabled { opacity: .45; cursor: not-allowed; }
/* Overview → Needs your attention: expandable items */
.platform-attention { display: flex; flex-direction: column; gap: 8px; }
.att { border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.att > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; font-size: 13.5px; font-weight: 600; }
.att > summary::-webkit-details-marker { display: none; }
.att > summary span:first-child { flex: 1; }
.att-chev { width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .2s; margin-right: 4px; }
.att[open] .att-chev { transform: rotate(-135deg); }
.att-warn { border-color: rgba(245,158,11,.35); }
.att-warn > summary { color: #fcd34d; background: rgba(245,158,11,.1); }
.att-info { border-color: rgba(139,92,246,.35); }
.att-info > summary { color: #c4b5fd; background: rgba(139,92,246,.1); }
.att-body { padding: 12px 14px 14px; background: var(--bg-card); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.att-why { margin: 0; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.att-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.att-table th { text-align: left; color: var(--text-muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.att-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.att-go { align-self: flex-start; font-size: 13px; font-weight: 600; color: #a78bfa; text-decoration: none; }
.att-go:hover { text-decoration: underline; }
.att-go { border: 0; background: none; padding: 0; outline-offset: 3px; }

/* ═══ The release palette, dashboard-wide ═══════════════════════════════════════════════════════
   What made the Platform pages feel different, applied to the shared components every page is built
   from: gradient primary actions and active nav, a thin gradient bar on cards, and violet focus and
   hover states. Colours come from tokens (css/variables.css), so a white-label brand colour replaces
   all of it. Decoration only: no layout or copy changes. */

/* Primary actions and the active nav link */
.btn-primary { background: var(--grad-accent); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent-2) 22%, transparent); }
.btn-primary:hover { background: var(--grad-accent); filter: brightness(1.1); }
.btn-primary:disabled { filter: none; box-shadow: none; }
.nav-link.active { background: var(--grad-accent); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent-2) 25%, transparent); }
.nav-group-toggle:hover { color: var(--text-primary); }

/* Page headers: a short gradient rule under the title */
.page-header h1 { position: relative; padding-bottom: 8px; }
.page-header h1::after { content: ''; position: absolute; left: 0; bottom: 0; width: 40px; height: 3px; border-radius: 3px; background: var(--grad-bar); }

/* Cards: the gradient top bar */
/* No overflow:hidden here: dropdowns and popovers inside sections and modals must not be clipped.
   The bar rounds its own top corners instead. */
.settings-section, .info-card, .modal { position: relative; }
.settings-section::before, .info-card::before, .modal::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad-bar); opacity: .75; pointer-events: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.info-card::before { border-radius: var(--radius) var(--radius) 0 0; }
.settings-section { transition: border-color var(--transition); }
.settings-section:hover { border-color: color-mix(in srgb, var(--accent-2) 30%, var(--border)); }
.info-card { transition: border-color var(--transition), transform var(--transition); }
.info-card:hover { border-color: color-mix(in srgb, var(--accent-2) 45%, var(--border)); }
.info-card-label { color: color-mix(in srgb, var(--accent-2) 55%, var(--text-secondary)); font-weight: 700; }
.device-card:hover { border-color: color-mix(in srgb, var(--accent-2) 60%, var(--border)); box-shadow: 0 14px 34px rgba(0,0,0,.4), 0 0 0 1px color-mix(in srgb, var(--accent-2) 20%, transparent); }

/* Tabs, focus, empty states */
.tab.active { color: color-mix(in srgb, var(--accent-2) 65%, #fff); border-bottom-color: var(--accent-2); }
.input:focus, select.input:focus, textarea.input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 22%, transparent); }
.empty-state svg { color: var(--accent-2); opacity: .8; }
.members-tab.active { background: var(--grad-accent); }
.platform-tab.active { background: var(--grad-accent); }

@media (prefers-reduced-motion: reduce) { .device-card:hover { transform: none; } }

/* =====================================================================
 * İNCELEMELER VE RAPORLAR: İKİ SÜTUNLU BÖLMELER
 *
 * ⚠️ TANIM BURADA, SATIR İÇİNDE DEĞİL — VE BU ZORUNLU. Bu ızgaralar
 * görünüm dosyalarında satır içi stille yazılıydı; satır içi stil her zaman
 * stil sayfasını ezdiği için mobil medya sorgusu onlara hiç ulaşamıyordu.
 * 375 pikselte ölçülen kırpılma: incelemeler 51px, raporlar 103px.
 * Masaüstü görünümü birebir aynı; değişen tek şey, kuralın artık
 * geçersiz kılınabilir bir yerde olması.
 * ===================================================================== */
.rev-split { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: 16px; }
.rep-two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }

@media (max-width: 768px) {
  .rev-split, .rep-two { grid-template-columns: 1fr; }

  /* Uye satiri ad + rol + dugmeler tasiyor ve sarmiyordu: 375 pikselde olculen kirpilma 58px.
     Sinif uzerinden kural, satir ici stille catismiyor. */
  .member-row { flex-wrap: wrap; }
}
