:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: 0.18s ease;
}

[data-theme="dark"] {
  --bg-app: #0d1117;
  --bg-surface: #161b22;
  --bg-elevated: #1c222b;
  --bg-hover: #242c37;
  --border: #2b3340;
  --text-primary: #f0f6fc;
  --text-secondary: #9aa5b4;
  --text-muted: #6e7785;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --success: #10b981;
  --warning: #f59e0b;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg-app: #f3f5f9;
  --bg-surface: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-hover: #eef2f7;
  --border: #dfe5ee;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --success: #059669;
  --warning: #d97706;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 268px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 18px;
  z-index: 40;
  transition: transform var(--transition), width var(--transition), padding var(--transition);
}

@media (min-width: 769px) {
  .app-shell.sidebar-collapsed .sidebar {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right: none;
    overflow: hidden;
  }
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 10px 4px;
}

.sectors-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item-tree,
.nav-subitem {
  gap: 6px;
  padding: 7px 10px;
}

.nav-subitem {
  font-size: 0.85rem;
}

.fav-nav-item {
  justify-content: space-between;
}

.fav-nav-item .nav-label-ellipsis {
  flex: 1;
  min-width: 0;
}

.fav-star-btn {
  color: var(--text-muted);
}

.fav-star-btn:hover {
  color: #f59e0b;
}

.fav-star-btn.is-favorite {
  color: #f59e0b;
}

.fav-star-btn.is-favorite svg {
  fill: #f59e0b;
}

.fav-sidebar-star {
  border: none;
  background: transparent;
  padding: 2px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.85;
  transition: opacity var(--transition), transform var(--transition);
}

.fav-sidebar-star:hover {
  opacity: 1;
  transform: scale(1.1);
}

.fav-sidebar-star svg {
  width: 14px;
  height: 14px;
}

.nav-caret {
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.nav-caret:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-caret svg {
  width: 13px;
  height: 13px;
}

.nav-label-ellipsis {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Main Area */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

.topbar {
  height: 62px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.breadcrumbs::-webkit-scrollbar {
  display: none;
}

.crumb-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.crumb-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.crumb-btn.current {
  color: var(--text-primary);
  font-weight: 600;
}

.crumb-sep {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  display: inline-flex;
  pointer-events: none;
}

.search-box input {
  width: 220px;
  padding: 8px 12px 8px 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--transition), width var(--transition);
}

.search-box input:focus {
  border-color: var(--accent);
}

.view-toggle {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Toolbar */
.toolbar {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sector-description {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.item-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-right-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sort-controls {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 4px 2px 8px;
  gap: 2px;
}

.sort-select {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  padding-right: 4px;
}

.sort-select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform 0.1s ease, border-color var(--transition);
}

.btn:active {
  transform: scale(0.98);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

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

.btn-icon {
  display: inline-flex;
}

/* Upload progress */
.upload-progress {
  margin: 0 20px 10px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.upload-progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  margin-bottom: 6px;
}

.progress-track {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #6366f1);
  transition: width 0.15s ease;
}

/* Content Scroll */
.content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 20px 24px;
  position: relative;
}

/* Dropzone */
.dropzone-overlay {
  position: sticky;
  top: 0;
  z-index: 25;
  height: 100%;
  min-height: 220px;
  background: rgba(59, 130, 246, 0.12);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.dropzone-card {
  text-align: center;
  color: var(--accent);
  font-weight: 600;
}

.dropzone-icon {
  margin-bottom: 8px;
}

/* File List View */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px 150px 196px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: background var(--transition), border-color var(--transition);
}

.file-row:hover {
  background: var(--bg-hover);
  border-color: var(--accent-soft);
}

.file-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  cursor: pointer;
}

.file-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--bg-elevated);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.file-icon.is-dir {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
}

.file-icon.is-text {
  color: var(--accent);
  background: var(--accent-soft);
}

.file-icon.is-image {
  color: #10b981;
  background: rgba(16, 185, 129, 0.14);
}

.file-icon.is-video {
  color: #a855f7;
  background: rgba(168, 85, 247, 0.14);
}

.file-icon.is-pdf {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.14);
}

.file-name-wrap {
  min-width: 0;
}

.file-name {
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-submeta {
  font-size: 0.76rem;
  color: var(--text-muted);
  display: none;
}

.file-size, .file-date {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.file-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.icon-spacer {
  width: 34px;
  height: 34px;
  display: inline-block;
  flex-shrink: 0;
  pointer-events: none;
}

.mobile-more-btn {
  display: none;
}

/* Context Menu Sheet */
.context-overlay {
  align-items: flex-end;
  padding: 0;
}

.context-sheet {
  max-width: 480px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.context-menu-items {
  padding: 10px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.context-menu-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.context-menu-btn:hover {
  background: var(--bg-hover);
}

.context-menu-btn.danger {
  color: var(--danger);
  border-color: var(--danger-soft);
}

/* File Grid View */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 12px;
}

.file-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
}

.file-card:hover {
  transform: translateY(-2px);
  background: var(--bg-hover);
  border-color: var(--accent-soft);
}

.file-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.file-card .file-icon {
  width: 42px;
  height: 42px;
}

.file-card .file-name {
  cursor: pointer;
  font-weight: 600;
}

.file-card-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.file-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* Desktop Server Tree View */
.dual-tree-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  height: calc(100dvh - 150px);
  min-height: 420px;
}

.dual-pane {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.pane-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pane-title-group {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pane-title-group strong {
  font-size: 0.9rem;
}

.pane-path {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pane-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.pane-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.pane-tree {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pane-files {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tree-node-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.83rem;
  color: var(--text-secondary);
  user-select: none;
}

.tree-node-row:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tree-node-row.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.tree-caret {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.tree-node-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pane-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.84rem;
}

.pane-file-row:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}

.pane-file-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.pane-file-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pane-file-size {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.pane-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.pane-file-row[draggable="true"] {
  cursor: grab;
}

.pane-file-row.dragging {
  opacity: 0.45;
}

.dual-pane.pane-drop-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent-soft);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-secondary);
}

.empty-icon {
  color: var(--text-muted);
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-bottom: 6px;
}

/* Settings View */
.settings-container {
  max-width: 860px;
  margin: 12px auto 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-header {
  margin-bottom: 16px;
}

.card-header h2 {
  font-size: 1.08rem;
  margin-bottom: 4px;
}

.card-header p {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.field-full {
  grid-column: 1 / -1;
}

.field input,
.field select,
.add-sector-form input,
.modal-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
}

.field input:focus,
.field select:focus,
.add-sector-form input:focus,
.modal-input:focus {
  border-color: var(--accent);
}

.form-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.add-sector-form {
  display: grid;
  grid-template-columns: 1fr 1.2fr auto;
  gap: 10px;
  margin-bottom: 16px;
}

.sectors-admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sector-admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.sector-admin-info strong {
  display: block;
  font-size: 0.94rem;
}

.sector-admin-info span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sector-admin-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-sm {
  max-width: 440px;
}

.modal-editor {
  max-width: 960px;
  height: min(84dvh, 760px);
}

.modal-media {
  max-width: 1020px;
  max-height: 90dvh;
}

.media-stage {
  padding: 16px;
  background: var(--bg-app);
  display: grid;
  place-items: center;
  overflow: auto;
  max-height: calc(90dvh - 60px);
}

.media-preview-img,
.media-preview-video {
  max-width: 100%;
  max-height: calc(86dvh - 92px);
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: #000;
}

.media-preview-pdf {
  width: 100%;
  height: min(78dvh, 720px);
  border: none;
  border-radius: var(--radius-sm);
  background: #fff;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-message {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.editor-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.editor-filename {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-dirty {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  color: var(--warning);
}

.editor-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-textarea {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 16px 18px;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.55;
}

.editor-footer {
  padding: 8px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  min-width: 220px;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.success {
  border-left-color: var(--success);
}

/* Mobile Helpers */
.mobile-only {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.mobile-bottom-bar {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 6px 10px;
  justify-content: space-around;
  align-items: center;
  flex-shrink: 0;
}

.mobile-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.mobile-action.primary {
  color: var(--accent);
  font-weight: 600;
}

@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: inline-flex;
  }

  .mobile-bottom-bar.mobile-only {
    display: flex;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 35;
  }

  .topbar {
    padding: 0 8px;
    gap: 6px;
  }

  .topbar-right {
    gap: 6px;
  }

  .topbar-quick-actions {
    flex-shrink: 0;
    gap: 2px;
  }

  .search-icon {
    left: 7px;
  }

  .search-box input {
    width: 68px;
    padding: 7px 6px 7px 26px;
  }

  .search-box input:focus {
    width: 88px;
  }

  .toolbar {
    padding: 10px 14px;
  }

  .content-scroll {
    padding: 4px 12px 16px;
  }

  .file-row {
    grid-template-columns: minmax(0, 1fr) 38px;
    padding: 10px 12px;
    gap: 8px;
  }

  .file-actions .icon-btn:not(.mobile-more-btn),
  .file-actions .icon-spacer,
  .file-card-actions .icon-btn:not(.mobile-more-btn),
  .file-card-actions .icon-spacer {
    display: none;
  }

  .mobile-more-btn {
    display: inline-grid;
  }

  .file-size,
  .file-date {
    display: none;
  }

  .file-submeta {
    display: block;
  }

  .form-grid,
  .add-sector-form {
    grid-template-columns: 1fr;
  }

  .sector-admin-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-editor {
    height: 100dvh;
    max-width: 100%;
    border-radius: 0;
  }

  .modal-overlay {
    padding: 0;
  }

  .modal-sm {
    margin: 16px;
  }

  .toast-container {
    bottom: 70px;
    left: 12px;
    right: 12px;
  }
}

/* Auth Screen & v2 Security UI */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-app);
}

.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-title {
  font-size: 20px;
  font-weight: 700;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.auth-version {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: -6px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.auth-submit-btn {
  width: 100%;
  justify-content: center;
  padding: 10px 16px;
}

.user-profile-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

.user-profile-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.user-profile-info strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.user-profile-actions {
  display: flex;
  gap: 6px;
}

.btn-xs {
  padding: 4px 9px;
  font-size: 12px;
}

.user-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.usr-permissions-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.usr-permissions-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.usr-permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.usr-perm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.usr-perm-item select {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.audit-logs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.audit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.audit-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.audit-action {
  font-weight: 600;
  color: var(--accent);
}

.audit-meta {
  color: var(--text-muted);
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Multi-select checkboxes & Selection Bar */
.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 20px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.selection-all-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.selection-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.item-select-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.file-row.selected,
.file-card.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.file-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.modal-audit {
  width: 100%;
  max-width: 920px;
  height: min(84dvh, 740px);
  display: flex;
  flex-direction: column;
}

.audit-filter-input {
  background: var(--bg-app);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.84rem;
  min-width: 180px;
}

.audit-modal-body {
  flex: 1;
  min-height: 0;
  padding: 14px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.audit-modal-body .audit-row {
  flex-shrink: 0;
}

.storage-meter-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 4px;
}

.storage-meter-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.storage-meter-label {
  font-size: 11px;
  color: var(--text-muted);
}

.file-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.file-grid .file-thumb {
  width: 48px;
  height: 48px;
}

.share-result-box {
  display: flex;
  gap: 8px;
  align-items: center;
}

.share-result-box input {
  flex: 1;
  background: var(--bg-app);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
}

.twofa-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.twofa-qr-wrap {
  display: flex;
  justify-content: center;
  padding: 10px;
  background: #ffffff;
  border-radius: var(--radius-sm);
}

.twofa-qr {
  width: 170px;
  height: 170px;
  display: block;
}

.twofa-mobile-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.twofa-secret-text {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-app);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  word-break: break-all;
  text-align: center;
}

.twofa-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.twofa-recovery-list {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  white-space: pre-wrap;
  text-align: center;
}

.search-scope-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.search-scope-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.media-preview-audio {
  width: min(460px, 90%);
}

.topbar-quick-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.icon-btn-badge {
  position: relative;
}

.nav-count-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  pointer-events: none;
}

.nav-count-badge.has-items {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.user-menu-wrap {
  position: relative;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 215px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 60;
}

.user-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  font-size: 13px;
}

.user-dropdown-header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.user-dropdown-item:hover {
  background: var(--bg-hover);
}

.user-dropdown-item.danger {
  color: var(--danger);
}

.user-dropdown-item.danger:hover {
  background: var(--danger-soft);
}

.user-dropdown-version {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding: 6px 10px 2px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}
