/* PawCast Control – Dashboard Styles
   Consistent with local PawCast UI design system */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --bg: #0f1117;
  --surface: #1e2330;
  --surface2: #252b3b;
  --border: #2d3748;
  --text: #e2e8f0;
  --muted: #64748b;
  --accent: #6366f1;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
}
body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
header h1 {
  font-size: 1.1rem;
  font-weight: 700;
}
header small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.1rem;
}
.hdr-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
}
.hdr-account {
  position: relative;
}
.hdr-account-trigger {
  min-height: 2.4rem;
  padding-right: 0.5rem;
  padding-left: 0.75rem;
  border-radius: 999px;
}
.hdr-user {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
}
.hdr-user-label {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}
.hdr-account .hdr-account-menu {
  left: auto;
  top: calc(100% + 0.5rem);
  right: max(0.5rem, env(safe-area-inset-right));
  width: min(220px, calc(100vw - 1rem - env(safe-area-inset-right)));
  min-width: 0;
  max-width: calc(100vw - 1rem - env(safe-area-inset-right));
  gap: 0.35rem;
  padding: 0.5rem;
  border-radius: 12px;
  border-color: #374151;
  transform: none;
  transform-origin: top right;
  background: rgba(37, 43, 59, 0.98);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.44);
}
.hdr-account-menu .btn {
  justify-content: flex-start;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-weight: 500;
}
.hdr-account-menu .btn:hover:not(:disabled) {
  border-color: #3b465d;
  background: rgba(99, 102, 241, 0.08);
  filter: none;
}
.hdr-account-menu .btn:active:not(:disabled) {
  background: rgba(99, 102, 241, 0.12);
}
.hdr-account-menu .btn + .btn {
  margin-top: 0;
}
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(135deg, #1f6feb 0%, #0f766e 100%);
  color: #f8fafc;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.user-avatar-sm {
  width: 1.9rem;
  height: 1.9rem;
  font-size: 0.7rem;
}
.user-avatar-md {
  width: 2.3rem;
  height: 2.3rem;
  font-size: 0.82rem;
}
.user-avatar-lg {
  width: 4.5rem;
  height: 4.5rem;
  font-size: 1.3rem;
}
.profile-avatar-field {
  .hdr-account-menu {
    right: max(0.5rem, env(safe-area-inset-right));
    top: calc(100% + 0.45rem);
    width: calc(100vw - 1rem - env(safe-area-inset-right));
    max-width: min(220px, calc(100vw - 1rem - env(safe-area-inset-right)));
  }
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.08);
}
.profile-avatar-preview {
  display: inline-flex;
}
.profile-avatar-visual {
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
}
.profile-avatar-copy {
  flex: 1;
}
.profile-avatar-copy label {
  display: block;
  margin-bottom: 0.45rem;
  font-weight: 600;
}
.users-user-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.hdr-notifications {
  position: relative;
}
.notifications-icon-btn {
  position: relative;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  justify-content: center;
  border-radius: 999px;
}
.notifications-popover {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: min(440px, 92vw);
  max-height: min(70vh, 680px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111722;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42);
  z-index: 2300;
}
.live-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 0.74rem;
  color: var(--muted);
}
.live-badge.on {
  border-color: #166534;
  background: #0f2a1b;
  color: #86efac;
}
.live-badge.off {
  border-color: #7f1d1d;
  background: #2b1616;
  color: #fda4af;
}
.live-badge.wait {
  border-color: #334155;
  background: #1e293b;
  color: #cbd5e1;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: 7px;
  border: none;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  filter: brightness(1.12);
}
.btn:active:not(:disabled) {
  filter: brightness(0.9);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}
.btn-icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
}
.btn-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn-icon-only {
  min-width: 2rem;
  justify-content: center;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.9rem;
}

/* Status dot */
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.dot.on {
  background: var(--success);
  box-shadow: 0 0 5px #22c55e88;
}
.dot.off {
  background: var(--danger);
  box-shadow: 0 0 5px #ef444488;
}
.dot.wait {
  background: #94a3b8;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}
input:focus {
  border-color: var(--accent);
}

/* Login overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 1000;
}
.login-box {
  width: 360px;
  padding: 2rem;
}
.login-box h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
}
.login-box .btn {
  width: 100%;
  justify-content: center;
  margin-top: 0.5rem;
}
.login-error {
  color: var(--danger);
  font-size: 0.8rem;
  text-align: center;
  margin-top: 0.5rem;
}

/* Main container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

/* Dashboard toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.toolbar h2 {
  font-size: 1rem;
  font-weight: 600;
}
.toolbar-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.toolbar-dropdown {
  position: relative;
}
.toolbar-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  min-width: 170px;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.38rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #141b28;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
  z-index: 60;
}
.toolbar-dropdown-trigger {
  display: inline-flex;
  align-items: center;
}
.toolbar-dropdown-caret {
  font-size: 0.72rem;
  color: var(--muted);
}
.toolbar-dropdown.open .toolbar-dropdown-trigger {
  border-color: #475569;
  background: #1a2234;
}
.toolbar-dropdown.open .toolbar-dropdown-menu {
  display: flex;
}
.toolbar-dropdown.open .toolbar-dropdown-caret {
  color: #c7d2fe;
}
.toolbar-dropdown-menu .btn {
  width: 100%;
  justify-content: flex-start;
}
.notifications-unread {
  position: absolute;
  top: -0.25rem;
  right: -0.28rem;
  min-width: 1rem;
  height: 1rem;
  border-radius: 999px;
  border: 1px solid #7f1d1d;
  background: #b91c1c;
  color: #fff;
  font-size: 0.63rem;
  line-height: 1;
  padding: 0 0.24rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Device grid */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

/* Device card */
.device-card {
  cursor: default;
  transition: border-color 0.15s;
}
.device-card:hover {
  border-color: var(--accent);
}
.device-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.device-card-header .dot {
  margin-top: 1px;
}
.device-card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  flex: 1;
}
.device-card-header .device-id {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface2);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}
.device-card-body {
  font-size: 0.82rem;
  color: var(--muted);
}
.device-card-body .row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
}
.device-card-body .row .val {
  color: var(--text);
}
.device-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.45rem;
}
.device-group-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #334155;
  background: #121c2d;
  color: #c7d2e6;
  border-radius: 999px;
  padding: 0.12rem 0.44rem;
  font-size: 0.68rem;
}
.device-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* Skeleton loading cards */
.skeleton-card {
  pointer-events: none;
  padding: 1.2rem;
}
.skeleton-line {
  height: 0.85rem;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--surface2) 25%,
    var(--border) 50%,
    var(--surface2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  margin-bottom: 0.6rem;
}
.skeleton-title {
  height: 1.1rem;
  width: 55%;
  margin-bottom: 0.9rem;
}
.skeleton-short {
  width: 40%;
}
@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Register modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 420px;
  max-width: 90vw;
}
.modal h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
}
.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
.modal-shell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.modal-shell-head h3 {
  margin-bottom: 0;
}
#audit-modal .modal-shell-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
}
.bulk-modal {
  width: min(920px, 96vw);
  max-height: calc(100vh - 2.5rem);
  overflow: auto;
}
.bulk-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.4fr);
  gap: 0.9rem;
}
.bulk-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #171c27;
}
.bulk-card h4 {
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
}
.bulk-card .tab-strip {
  margin: 0;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: #131925;
}
.bulk-card .tab-strip .tab-btn {
  font-size: 0.75rem;
  padding: 0.28rem 0.58rem;
}
.bulk-card-body {
  padding: 0.6rem 0.65rem;
}
.bulk-device-list {
  max-height: 320px;
  overflow: auto;
  display: grid;
  gap: 0.35rem;
}
.bulk-device-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.36rem 0.45rem;
  font-size: 0.8rem;
}
.bulk-device-row .muted {
  font-size: 0.74rem;
  color: var(--muted);
}
.bulk-weekdays {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 0.36rem;
  margin-top: 0.45rem;
}
.bulk-weekdays label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.bulk-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}
.bulk-results {
  margin-top: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.bulk-results table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.bulk-results th,
.bulk-results td {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.5rem;
  text-align: left;
}
.bulk-results tbody tr:last-child td {
  border-bottom: none;
}
.bulk-pill {
  display: inline-flex;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.7rem;
}
.bulk-pill.ok {
  color: #9ef1b7;
  border-color: #1f6d3c;
  background: #0f2a1b;
}
.bulk-pill.queue {
  color: #f6d38b;
  border-color: #87611f;
  background: #322712;
}
.bulk-pill.fail {
  color: #fecaca;
  border-color: #9f1d2a;
  background: #35141a;
}
.bulk-group-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.45rem;
  align-items: center;
}
.detail-header-actions {
  margin-top: 0;
}
.users-modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.85rem;
}
.users-modal-tab {
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  user-select: none;
  white-space: nowrap;
}
.users-modal-tab:hover { color: var(--text); }
.users-modal-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.users-modal-panel { display: none; }
.users-modal-panel.active { display: block; }
.users-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #171c27;
}
.users-card h4 {
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
}
.users-card-body {
  padding: 0.65rem;
}
.users-card .form-group {
  margin-bottom: 0.7rem;
}
.users-table-wrap {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.users-table th,
.users-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.5rem;
  text-align: left;
  vertical-align: middle;
}
.users-table tbody tr:last-child td {
  border-bottom: none;
}
.users-table .actions {
  width: 132px;
}
.users-form-actions {
  display: flex;
  gap: 0.45rem;
  justify-content: flex-end;
  margin-top: 0.65rem;
}
.users-form-hint {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.notification-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}
.notification-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.notification-switch input {
  accent-color: var(--accent);
}
.notification-head {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
  background: #121927;
  padding: 0.58rem 0.62rem 0.44rem;
}
.notification-tabs {
  display: flex;
  gap: 0.36rem;
  margin-top: 0.45rem;
}
.notification-tab {
  border: 1px solid var(--border);
  background: #1b2434;
  color: #c7d2e8;
  border-radius: 999px;
  padding: 0.2rem 0.52rem;
  font-size: 0.74rem;
  cursor: pointer;
}
.notification-tab.active {
  background: #334155;
  border-color: #475569;
  color: #fff;
}
.notification-list {
  border-top: 1px solid var(--border);
  overflow: hidden;
  background: #111722;
}
.notification-item {
  display: grid;
  grid-template-columns: 132px 1fr auto auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.52rem 0.68rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.notification-item:last-child {
  border-bottom: none;
}
.notification-item .kind {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.notification-item .message {
  color: #dbe4f3;
  overflow-wrap: anywhere;
}
.notification-item .time {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
  justify-self: end;
}
.notification-item.level-success .kind {
  color: #7ce3a2;
}
.notification-item.level-error .kind {
  color: #fda4af;
}
.notification-item.level-info .kind {
  color: #93c5fd;
}
.notification-row-actions {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  justify-self: end;
}
.notification-empty {
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0.8rem 0.68rem;
}

.group-admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(340px, 1.2fr);
  gap: 0.9rem;
}
.group-list {
  display: grid;
  gap: 0.45rem;
  max-height: 380px;
  overflow: auto;
  padding-right: 0.2rem;
}
.group-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #171c27;
  padding: 0.5rem 0.58rem;
  display: grid;
  gap: 0.35rem;
}
.group-item.active {
  border-color: var(--accent);
  background: #1d2340;
}
.group-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.55rem;
}
.group-item-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #e7ecf8;
}
.group-item-meta {
  color: var(--muted);
  font-size: 0.74rem;
}
.group-item-actions {
  display: flex;
  gap: 0.38rem;
}
.group-device-list {
  max-height: 290px;
  overflow: auto;
  display: grid;
  gap: 0.28rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.42rem 0.5rem;
  background: #101827;
}
.group-device-list label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #d3dcf1;
  font-size: 0.79rem;
}

/* Device detail modal */
.device-detail-overlay {
  align-items: flex-start;
  padding: 2.75rem 1rem 1rem;
  overflow-y: auto;
}
.device-detail-modal {
  width: min(1560px, 99vw);
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
}
.device-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.detail-subtitle {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: -0.45rem;
}
.tab-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.65rem;
}
.tab-btn {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  border-radius: 7px;
  padding: 0.36rem 0.78rem;
  font-size: 0.82rem;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.detail-content {
  min-height: 220px;
  overflow: auto;
  padding-right: 0.15rem;
}
.detail-content.settings-mode {
  overflow: hidden;
}
.detail-loading {
  color: var(--muted);
  padding: 1.5rem 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading-text {
  font-size: 0.9rem;
  color: var(--text);
}
.loading-subtext {
  font-size: 0.78rem;
  color: var(--muted);
}
.detail-error {
  color: var(--danger);
  border: 1px solid #7f1d1d;
  background: #2b1616;
  border-radius: 8px;
  padding: 0.8rem;
  font-size: 0.84rem;
}
.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  color: var(--muted);
  font-size: 0.84rem;
}
.detail-row .val {
  color: var(--text);
  text-align: right;
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.3rem;
}
.detail-schedule-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.detail-table thead {
  background: var(--surface2);
}
.detail-table th,
.detail-table td {
  text-align: left;
  padding: 0.55rem 0.72rem;
  border-bottom: 1px solid var(--border);
}
.detail-table tbody tr:last-child td {
  border-bottom: none;
}
.detail-select {
  width: 100%;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.32rem 0.5rem;
  font-size: 0.82rem;
}
.detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.72rem;
  border-top: 1px solid var(--border);
  background: #171c27;
}
.detail-toolbar-wrap {
  row-gap: 0.45rem;
}
.detail-select-inline {
  width: auto;
  min-width: 220px;
  max-width: 360px;
}
.detail-toolbar-hint {
  color: var(--muted);
  font-size: 0.76rem;
}
.detail-footnote {
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.55rem 0.72rem;
  border-top: 1px solid var(--border);
  background: #171c27;
}
.preview-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.preview-source-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.preview-source-switch .switch-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 38px;
  height: 20px;
}
.preview-source-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.preview-source-switch .switch-slider {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #243044;
  border: 1px solid #334155;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
  position: relative;
  display: block;
}
.preview-source-switch .switch-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: transform 0.18s ease;
}
.preview-source-switch input:checked + .switch-slider {
  background: #4338ca;
  border-color: #5b52e9;
}
.preview-source-switch input:checked + .switch-slider::after {
  transform: translateX(17px);
  background: #fff;
}

.proxy-thumb-wrap {
  width: 72px;
  height: 42px;
  border-radius: 6px;
  background: #0b0f17;
  border: 1px solid var(--border);
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.proxy-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.proxy-thumb.loaded {
  opacity: 1;
}
.proxy-thumb.failed {
  opacity: 0.25;
}
.proxy-thumb-xs {
  width: 56px;
  height: 32px;
}
.proxy-thumb-sm {
  width: 72px;
  height: 42px;
}
.proxy-thumb-media {
  width: 100%;
  height: 100%;
}
.proxy-thumb-modal {
  width: 320px;
  height: 190px;
}

.transfer-progress {
  margin: 0.6rem 0.72rem 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #101622;
  padding: 0.5rem 0.6rem;
}
.transfer-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.transfer-progress-head strong {
  color: var(--text);
  font-size: 0.78rem;
}
.transfer-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: #0a0f19;
  border: 1px solid #1f2937;
  overflow: hidden;
}
.transfer-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  transition: width 0.2s ease;
}
.media-upload-drop {
  margin: 0.65rem 0.72rem 0;
  border: 2px dashed #334155;
  border-radius: 10px;
  background: #111722;
  color: #a0b2cf;
  text-align: center;
  padding: 0.8rem 0.6rem;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
  display: grid;
  gap: 0.2rem;
}
.media-upload-drop:hover,
.media-upload-drop.over {
  border-color: #6366f1;
  background: #1a2232;
  color: #dbe4ff;
}
.media-upload-drop-icon {
  display: inline-flex;
  justify-content: center;
  color: #9fb0ff;
}
.media-upload-drop .btn-icon {
  width: 20px;
  height: 20px;
  margin: 0 auto;
}

.media-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.8rem;
  padding: 0.72rem;
}
.media-tile {
  position: relative;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    transform 0.15s ease;
}
.media-tile:hover {
  border-color: #55617a;
  transform: translateY(-1px);
}
.media-tile-thumb {
  position: relative;
  height: 138px;
  background: #0b0f17;
}
.media-tile-thumb .proxy-thumb-wrap {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  display: block;
}
.media-tile-thumb .proxy-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-tile-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  border-radius: 999px;
  padding: 0.18rem 0.46rem;
  font-size: 0.68rem;
  border: 1px solid #36445e;
  background: rgba(9, 14, 22, 0.82);
  color: #d7dee8;
  z-index: 2;
}
.media-tile-badge-duration {
  left: auto;
  right: 0.5rem;
  border-color: #2b5c3d;
  color: #96f0b4;
}
.media-tile-desc {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 0.55rem;
  font-size: 0.72rem;
  color: #c9d7ea;
  line-height: 1.35;
  background: linear-gradient(
    180deg,
    rgba(4, 8, 14, 0.05) 20%,
    rgba(4, 8, 14, 0.85) 100%
  );
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.media-tile:hover .media-tile-desc {
  opacity: 1;
}
.media-tile-body {
  padding: 0.55rem 0.62rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}
.media-tile-title {
  font-size: 0.83rem;
  font-weight: 600;
  color: #edf2ff;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.media-tile-name {
  font-size: 0.72rem;
  color: #a8b3c8;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.media-tile-meta {
  font-size: 0.7rem;
  color: #8292ac;
}
.media-tile-actions {
  display: flex;
  gap: 0.45rem;
  border-top: 1px solid var(--border);
  padding: 0.5rem 0.6rem 0.6rem;
  background: #171c27;
}

.tl-board {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.tl-row-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.05fr) minmax(460px, 1.9fr) minmax(
      220px,
      0.85fr
    );
  gap: 0.8rem;
  align-items: stretch;
}
.tl-col-media,
.tl-col-timeline,
.tl-col-effects {
  min-width: 0;
}
.tl-scroll {
  max-height: 420px;
  overflow: auto;
  padding-right: 0.2rem;
}
.tl-col-media .tl-scroll,
.tl-col-effects .tl-scroll {
  height: 520px;
  max-height: 520px;
}
.tl-lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}
.tl-lib-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: grab;
}
.tl-lib-card:hover {
  border-color: var(--accent);
}
.tl-lib-meta {
  min-width: 0;
}
.tl-lib-name {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.tl-lib-sub {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.tl-fx-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}
.tl-fx-card {
  background: var(--surface2);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-size: 0.78rem;
  cursor: grab;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.tl-fx-card:hover {
  border-color: var(--accent);
  color: #cdd0ff;
}
.tl-fx-symbol {
  font-size: 0.92rem;
  color: #9eb7ff;
  min-width: 1.2rem;
  text-align: center;
}
.tl-dropzone {
  min-height: 240px;
  max-height: 560px;
  overflow: auto;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  background: #121722;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.tl-col-timeline .tl-dropzone {
  height: 520px;
  max-height: 520px;
}
.tl-dropzone.over {
  border-color: var(--accent);
}
.tl-edit-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tl-edit-item.over {
  border-color: var(--accent);
}
.tl-edit-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tl-drag-handle {
  color: var(--muted);
  user-select: none;
  cursor: grab;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.tl-edit-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  flex: 1;
}
.tl-edit-title strong {
  font-size: 0.8rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.tl-edit-title span {
  font-size: 0.72rem;
  color: var(--muted);
}
.tl-edit-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}
.tl-edit-controls label {
  font-size: 0.75rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.tl-edit-controls input,
.tl-edit-controls select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.26rem 0.42rem;
  font-size: 0.76rem;
}
.tl-trim-wrap {
  margin-top: 0.15rem;
}
.tl-trim-bar {
  position: relative;
  height: 20px;
  border-radius: 4px;
  background: #141b29;
  border: 1px solid #283547;
  overflow: hidden;
  cursor: pointer;
}
.tl-trim-range {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(99, 102, 241, 0.35);
  pointer-events: none;
}
.tl-trim-handle {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  margin-left: -4px;
  background: #6366f1;
  border-radius: 3px;
  cursor: ew-resize;
  z-index: 2;
}
.tl-trim-handle.active,
.tl-trim-handle:hover {
  background: #818cf8;
}
.tl-trim-handle-in {
  border-right: 2px solid rgba(255, 255, 255, 0.35);
}
.tl-trim-handle-out {
  border-left: 2px solid rgba(255, 255, 255, 0.35);
}
.tl-trim-tc {
  margin-top: 0.2rem;
  font-size: 0.68rem;
  color: #74839d;
  display: flex;
  justify-content: space-between;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.tl-trim-disabled {
  font-size: 0.72rem;
  color: #6f809c;
  background: #141b29;
  border: 1px dashed #2b3a4f;
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
}
.tl-gap-row {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  background: #0f1521;
}
.tl-trans-slot {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.45rem;
}
.tl-trans-slot.over {
  border-color: var(--accent);
}
.tl-trans-empty {
  color: var(--muted);
  font-size: 0.74rem;
}
.tl-trans-active {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}
.tl-trans-label {
  color: var(--muted);
  font-size: 0.72rem;
  min-width: 220px;
}
.tl-trans-active label {
  font-size: 0.74rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.tl-trans-active input,
.tl-trans-active select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.26rem 0.42rem;
  font-size: 0.74rem;
}
.tl-trans-symbol {
  width: 1.2rem;
  text-align: center;
  font-size: 0.92rem;
  color: #9eb7ff;
}
.tl-trans-compact {
  gap: 0.4rem;
}
.tl-trans-compact select {
  min-width: 170px;
}
.tl-trans-compact input {
  width: 78px;
  text-align: right;
}

.settings-index-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.62rem 0.72rem;
  background: #171c27;
}
.settings-index-title {
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.45rem;
  font-weight: 600;
}
.settings-index-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.settings-index-list-vertical {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
}
.settings-index-btn {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  border-radius: 7px;
  padding: 0.32rem 0.6rem;
  font-size: 0.76rem;
  cursor: pointer;
}
.settings-index-btn.active {
  color: #fff;
  border-color: var(--accent);
  background: #3940b7;
}
.settings-split {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}
.settings-index-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
}
.settings-content-scroll {
  max-height: calc(100vh - 240px);
  overflow: auto;
  padding-right: 0.2rem;
}
.settings-panel-grid {
  gap: 0.6rem;
}

.detail-action-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1800;
  background: rgba(2, 6, 12, 0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.detail-action-modal {
  width: min(640px, 96vw);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.detail-action-modal-lg {
  width: min(940px, 98vw);
}
.detail-action-modal h3 {
  margin-bottom: 0.75rem;
  font-size: 0.98rem;
}
.detail-action-modal-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1.2fr);
  gap: 0.85rem;
}
.detail-action-preview {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #141a25;
  padding: 0.6rem;
}
.detail-action-preview .proxy-thumb-wrap {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
}
.detail-action-preview .proxy-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.detail-action-preview-meta {
  margin-top: 0.55rem;
  font-size: 0.76rem;
  color: var(--muted);
  display: grid;
  gap: 0.22rem;
}
.detail-action-form {
  display: grid;
  gap: 0.58rem;
}
.detail-action-form label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.detail-select-textarea {
  min-height: 116px;
  font-family: inherit;
  resize: vertical;
}
.media-edit-filename-label {
  margin-top: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem !important;
  opacity: 0.75;
}
.media-edit-filename-input {
  font-size: 0.82rem;
}
.detail-action-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.58rem;
}
.text-slide-preview {
  min-height: 124px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.8rem;
  font-size: 1rem;
  line-height: 1.3;
}
.detail-action-modal-text-slide .detail-action-modal-layout {
  grid-template-columns: minmax(260px, 0.8fr) minmax(340px, 1.2fr);
}
.text-slide-preview-panel {
  align-self: stretch;
}
.text-slide-preview-panel .text-slide-preview {
  min-height: 240px;
  max-height: 320px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  font-size: 56px;
  font-weight: 600;
  background: #000;
  color: #fff;
  overflow: hidden;
  word-break: break-word;
}
.text-slide-size-row {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 0.55rem;
  align-items: center;
}
.text-slide-size-row input[type="range"] {
  width: 100%;
  accent-color: #6366f1;
}
.text-slide-size-input {
  text-align: right;
}
.text-slide-color-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #151c2a;
  padding: 0.45rem 0.52rem;
  display: grid;
  gap: 0.4rem;
}
.text-slide-color-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  color: #bac6db;
  font-size: 0.76rem;
}
.text-slide-color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.text-slide-color-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #3b475e;
  background: var(--swatch, #000);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease;
}
.text-slide-color-btn:hover {
  transform: translateY(-1px);
  border-color: #a5b4fc;
}
.text-slide-color-btn.active {
  border-color: #eef2ff;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5);
}
.text-slide-color-picker {
  width: 36px;
  height: 24px;
  padding: 0;
  border: 1px solid #3b475e;
  border-radius: 6px;
  background: #0f172a;
  cursor: pointer;
}
.preview-stage {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(340px, 1fr);
  gap: 0.7rem;
  padding: 0.72rem;
  align-items: start;
}
.preview-stage-media {
  background: #0b0f17;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: grid;
  min-height: 0;
  position: relative;
  width: 100%;
  min-width: 0;
  align-self: start;
}
.preview-stage-stack {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  overflow: hidden;
  display: grid;
  background:
    radial-gradient(circle at top, rgba(99, 102, 241, 0.1), transparent 48%),
    linear-gradient(180deg, #0f1522 0%, #05070d 100%);
}
.preview-stage-media .proxy-thumb-wrap,
.preview-stage-stack > video,
.preview-stage-stack > .preview-stage-placeholder,
.preview-stage-stack > .preview-stage-status {
  position: absolute;
  inset: 0;
}
.preview-stage-media .proxy-thumb-wrap {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  display: block;
  transition: opacity 0.18s ease;
}
.preview-stage-media .proxy-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #05070d;
}
.preview-stage-media .preview-stage-video,
.preview-stage-media .preview-stage-image,
.preview-stage-media .preview-stage-video-layer {
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  object-fit: contain;
  background: #05070d;
  display: block;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.proxy-thumb-preview {
  width: 100%;
  height: 100%;
}
.preview-stage-stack.is-video-ready .preview-stage-video-layer,
.preview-stage-video-layer.loaded {
  opacity: 1;
}
.preview-seq-row-compact {
  gap: 0.38rem;
}
.preview-seq-transition-inline {
  color: #7f8fa8;
  font-size: 0.71rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.preview-seq-item.transition {
  padding: 0.28rem 0.5rem;
  background: rgba(148, 163, 184, 0.03);
}
.preview-seq-item.transition.current {
  outline-color: #64748b;
}
.preview-seq-item.transition .preview-seq-progress {
  background: linear-gradient(
    90deg,
    rgba(100, 116, 139, 0.22),
    rgba(100, 116, 139, 0.04)
  );
}
.preview-seq-item.transition .meta {
  color: #7f8fa8;
  font-size: 0.68rem;
}
.preview-stage-stack.is-video-ready .preview-stage-thumb-wrap {
  opacity: 0;
}
.preview-stage-stack.is-cache-miss .preview-stage-thumb-wrap,
.preview-stage-stack.is-video-loading .preview-stage-thumb-wrap,
.preview-stage-stack.is-video-failed .preview-stage-thumb-wrap,
.preview-stage-stack.preview-stage-stack-thumbnail .preview-stage-thumb-wrap {
  opacity: 1;
}
.preview-stage-stack.preview-stage-stack-transition .preview-stage-video-layer {
  z-index: 1;
}
.preview-stage-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  color: #c7d2fe;
  background: radial-gradient(
    circle at top,
    rgba(99, 102, 241, 0.16),
    rgba(5, 7, 13, 0.92) 60%
  );
  z-index: 0;
}
.preview-stage-stack.preview-stage-stack-media .preview-stage-placeholder,
.preview-stage-stack.is-video-ready .preview-stage-status,
.preview-stage-stack.preview-stage-stack-thumbnail .preview-stage-status {
  display: none;
}
.preview-stage-status {
  inset: auto 0 0 0;
  padding: 0.7rem 0.85rem;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  text-align: left;
  color: #dbe7ff;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  background: linear-gradient(
    180deg,
    rgba(5, 7, 13, 0) 0%,
    rgba(5, 7, 13, 0.86) 88%
  );
  z-index: 2;
  pointer-events: none;
}
.preview-stage-status[hidden] {
  display: none;
}
.preview-stage-info {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.62rem;
  background: #171c27;
  font-size: 0.8rem;
  color: var(--muted);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0.48rem;
  min-height: 0;
}
.preview-stage-info-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.48rem;
  align-items: stretch;
}
.preview-stage-info-card {
  border: 1px solid #243042;
  border-radius: 8px;
  background: #101621;
  padding: 0.58rem 0.62rem;
  min-width: 0;
  height: 132px;
  display: grid;
  align-content: start;
}
.preview-stage-info-top {
  display: grid;
  gap: 0.24rem;
  align-content: start;
}
.preview-stage-info-card-title {
  color: #dbe4f3;
  font-size: 0.76rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.preview-seq-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101621;
  overflow: auto;
  min-height: 120px;
  max-height: 280px;
}
.preview-seq-item {
  position: relative;
  padding: 0.44rem 0.5rem;
  border-bottom: 1px solid #1f2937;
  overflow: hidden;
}
.preview-seq-item:last-child {
  border-bottom: none;
}
.preview-seq-item.current {
  outline: 1px solid #4f46e5;
  outline-offset: -1px;
}
.preview-seq-item.media {
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.62),
    rgba(16, 22, 33, 0.9)
  );
}
.preview-seq-item.transition {
  padding: 0.28rem 0.5rem;
  background: rgba(148, 163, 184, 0.03);
}
.preview-seq-item.transition.current {
  outline-color: #64748b;
}
.preview-seq-progress {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(
    90deg,
    rgba(79, 70, 229, 0.35),
    rgba(79, 70, 229, 0.08)
  );
  pointer-events: none;
}
.preview-seq-item.transition .preview-seq-progress {
  background: linear-gradient(
    90deg,
    rgba(100, 116, 139, 0.22),
    rgba(100, 116, 139, 0.04)
  );
}
.preview-seq-progress-static {
  transition: width 0.2s ease;
}
.preview-seq-progress-anim {
  width: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  animation: previewSeqProgress var(--preview-progress-duration, 6s) linear both;
  animation-delay: var(--preview-progress-delay, 0s);
}
@keyframes previewSeqProgress {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}
.preview-seq-row {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.preview-seq-row strong {
  color: #e8eefc;
  font-size: 0.78rem;
  max-width: 75%;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.preview-seq-row .meta {
  font-size: 0.72rem;
  color: #9cb0cb;
  white-space: nowrap;
}
.preview-seq-transition {
  position: relative;
  z-index: 1;
  margin-top: 0.16rem;
  font-size: 0.7rem;
  color: #8ea3c1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.preview-seq-item.transition .preview-seq-transition {
  display: none;
}
.preview-seq-item.transition .meta {
  color: #7f8fa8;
  font-size: 0.68rem;
}
.preview-stage-desc {
  color: #bac6db;
  line-height: 1.4;
  min-width: 0;
  overflow: auto;
  scrollbar-width: thin;
}
.preview-stage-info-card-desc .preview-stage-desc {
  height: 100%;
}
.preview-stage-desc.empty {
  color: #7f8fa8;
}
.preview-toolbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}
.preview-render-card {
  margin: 0 0.72rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #171c27;
  padding: 0.7rem 0.78rem;
  display: grid;
  gap: 0.45rem;
}
.preview-render-card.live {
  border-color: #4f46e5;
  background: linear-gradient(
    180deg,
    rgba(49, 46, 129, 0.3),
    rgba(23, 28, 39, 0.92)
  );
}
.preview-render-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.7rem;
}
.preview-render-title {
  font-size: 0.78rem;
  color: #c7d2fe;
  font-weight: 600;
}
.preview-render-subtitle {
  margin-top: 0.18rem;
  font-size: 0.76rem;
  color: #dbe4f3;
}
.preview-render-progress {
  max-width: none;
}
.preview-render-meta {
  font-size: 0.73rem;
  color: #a8b8d4;
  line-height: 1.35;
}
.preview-cache-panel {
  margin: 0.72rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #171c27;
}
.preview-cache-panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.72rem 0.78rem;
  border-bottom: 1px solid var(--border);
  background: #111722;
}
.preview-cache-panel-copy {
  min-width: 0;
}
.preview-cache-panel-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #e6edf8;
}
.preview-cache-panel-meta {
  margin-top: 0.16rem;
  font-size: 0.73rem;
  color: #9cb0cb;
  line-height: 1.35;
}
.preview-cache-panel-summary {
  font-size: 0.74rem;
  color: #c7d2fe;
  white-space: nowrap;
}
.preview-cache-panel-body {
  display: grid;
  gap: 0;
}
.preview-cache-panel.collapsed .preview-cache-panel-head {
  border-bottom: none;
}
.preview-cache-panel .detail-toolbar {
  border-top: none;
}
.preview-cache-panel .detail-table {
  font-size: 0.79rem;
  min-width: 980px;
}
.preview-cache-table-wrap {
  overflow-x: auto;
}
.preview-cache-actions {
  display: inline-flex;
  gap: 0.32rem;
  align-items: center;
}
.preview-cache-size {
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
}
.preview-cache-error {
  margin-top: 0.24rem;
  font-size: 0.72rem;
  color: #fecaca;
  max-width: 230px;
  line-height: 1.24;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cache-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.1rem 0.42rem;
  font-size: 0.71rem;
}
.cache-pill.ok {
  border-color: #1f6d3c;
  color: #9ef1b7;
  background: #0f2a1b;
}
.cache-pill.warn {
  border-color: #9f1d2a;
  color: #fecaca;
  background: #35141a;
}
.cache-pill.live {
  border-color: #4338ca;
  color: #c7d2fe;
  background: #1e1b4b;
}
.cache-row-actions {
  display: inline-flex;
  gap: 0.32rem;
  align-items: center;
}
.cache-progress-wrap {
  width: 100%;
  max-width: 180px;
  height: 7px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: #0b1321;
  overflow: hidden;
}
.cache-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #22c55e, #4ade80);
}
.cache-progress-fill.warn {
  background: linear-gradient(90deg, #ef4444, #f97316);
}
.cache-progress-fill.active {
  background: linear-gradient(90deg, #6366f1, #818cf8);
}

/* Token display */
.token-display {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.75rem;
  font-family: monospace;
  font-size: 0.8rem;
  word-break: break-all;
  margin: 0.75rem 0;
  user-select: all;
}
.token-warning {
  font-size: 0.78rem;
  color: var(--warning);
  margin-bottom: 0.5rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
}
.empty-state p {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  z-index: 2000;
  animation: slideIn 0.3s ease;
}
.toast.error {
  border-color: var(--danger);
}
.toast.success {
  border-color: var(--success);
}
@keyframes slideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 1rem;
  }
  .device-grid {
    grid-template-columns: 1fr;
  }
  header {
    padding: 0.75rem 1rem;
  }
  .device-detail-overlay {
    padding-top: 1rem;
  }
  .device-detail-header {
    flex-direction: column;
  }
  .detail-header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .device-detail-modal {
    width: 100vw;
    max-height: none;
  }
  .detail-action-modal-layout {
    grid-template-columns: 1fr;
  }
  .detail-action-two-col {
    grid-template-columns: 1fr;
  }
  .media-tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }
  .detail-select-inline {
    min-width: 140px;
    max-width: none;
    width: 100%;
  }
  .bulk-grid {
    grid-template-columns: 1fr;
  }
  .bulk-weekdays {
    grid-template-columns: 1fr;
  }
  .group-admin-grid {
    grid-template-columns: 1fr;
  }
  .toolbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .notifications-popover {
    right: -0.5rem;
    width: min(92vw, 380px);
  }
  .hdr-account-menu {
    right: max(0.5rem, env(safe-area-inset-right));
    top: calc(100% + 0.45rem);
    width: calc(100vw - 1rem - env(safe-area-inset-right));
    max-width: min(220px, calc(100vw - 1rem - env(safe-area-inset-right)));
  }
  .notification-item {
    grid-template-columns: 1fr;
    gap: 0.28rem;
  }
  .preview-stage {
    grid-template-columns: 1fr;
  }
  .preview-stage-info-panels {
    grid-template-columns: 1fr;
  }
  .preview-stage-info-card {
    height: 120px;
  }
  .preview-toolbar-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .preview-cache-panel-head {
    grid-template-columns: 1fr auto;
  }
  .preview-cache-panel-summary {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1200px) {
  .tl-row-grid {
    grid-template-columns: 1fr;
  }
  .tl-scroll {
    max-height: 260px;
  }
  .tl-dropzone {
    max-height: 420px;
  }
  .tl-col-media .tl-scroll,
  .tl-col-effects .tl-scroll,
  .tl-col-timeline .tl-dropzone {
    height: 360px;
    max-height: 360px;
  }
  .settings-split {
    grid-template-columns: 1fr;
  }
  .settings-index-sidebar {
    position: static;
  }
  .settings-index-list-vertical {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .settings-content-scroll {
    max-height: none;
    overflow: visible;
  }
}

/* Users Management UI */
.users-permissions-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.users-permissions-table th,
.users-permissions-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  text-align: left;
}
.users-permissions-table th {
  background: var(--surface2);
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.users-permissions-table tr:last-child td {
  border-bottom: none;
}
.users-permissions-table .cb-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  width: 100%;
}
.users-badge {
  display: inline-flex;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
}
.users-badge-global {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.users-badge-device {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}
