/* ═══════════════════════════════════════════════════════════════════
   DataRoom — Global Stylesheet
   ═══════════════════════════════════════════════════════════════════ */

/* ── Variables ────────────────────────────────────────────────────── */
:root {
  /* Brand */
  --primary:          #5B5BD6;
  --primary-dark:     #4747B2;
  --primary-light:    #EEF2FF;
  --primary-text:     #ffffff;

  /* Surface */
  --bg:               #F1F5F9;
  --bg-login:         linear-gradient(135deg, #1e293b 0%, #334155 100%);
  --surface:          #ffffff;
  --surface-raised:   #f8fafc;
  --border:           #e2e8f0;
  --border-light:     #f1f5f9;

  /* Text */
  --text:             #0f172a;
  --text-muted:       #64748b;
  --text-light:       #94a3b8;

  /* Status */
  --success:          #10b981;
  --success-bg:       #ecfdf5;
  --warning:          #f59e0b;
  --warning-bg:       #fffbeb;
  --danger:           #ef4444;
  --danger-bg:        #fef2f2;
  --danger-dark:      #dc2626;

  /* File type colors */
  --color-folder:     #f59e0b;
  --color-image:      #3b82f6;
  --color-doc:        #ef4444;
  --color-sheet:      #10b981;
  --color-archive:    #8b5cf6;
  --color-video:      #ec4899;
  --color-audio:      #06b6d4;
  --color-code:       #6b7280;
  --color-pdf:        #ef4444;

  /* Sidebar */
  --sidebar-bg:       #111827;
  --sidebar-border:   rgba(255,255,255,.06);
  --sidebar-text:     #94a3b8;
  --sidebar-active-bg: rgba(255,255,255,.08);
  --sidebar-active-text: #f1f5f9;
  --sidebar-hover-bg: rgba(255,255,255,.05);
  --sidebar-w:        248px;

  /* Shadows */
  --shadow-sm:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:        0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:        0 10px 40px rgba(0,0,0,.15);
  --shadow-xl:        0 20px 60px rgba(0,0,0,.22);

  /* Radius */
  --radius-sm:        6px;
  --radius-md:        10px;
  --radius-lg:        14px;
  --radius-xl:        20px;

  /* Typography */
  --font:             'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Transition */
  --transition:       150ms cubic-bezier(.4,0,.2,1);
}

/* ── Reset ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 15px; }  /* overridden by JS font-scale */
body { font-family: var(--font); color: var(--text); background: var(--bg); height: 100%; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── App body ─────────────────────────────────────────────────────── */
.app-body { background: var(--bg); overflow: hidden; height: 100vh; }

/* ── App Shell ────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  overflow: hidden;
  transition: transform var(--transition);
  z-index: 100;
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  overflow: hidden;
}
.sidebar-logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo img { width: 20px; height: 20px; object-fit: contain; }
.sidebar-logo-icon { color: #fff; width: 16px; height: 16px; }
.sidebar-company {
  font-size: .9rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-close { display: none !important; color: var(--sidebar-text); }
.sidebar-nav { flex: 1; padding: .75rem .5rem; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  white-space: nowrap;
}
.nav-item:hover  { background: var(--sidebar-hover-bg); color: var(--sidebar-active-text); }
.nav-item.active { background: var(--sidebar-active-bg); color: #fff; }
.nav-item.active svg { color: var(--primary); }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: .85rem 1rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.sidebar-user { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.sidebar-user-info { min-width: 0; }
.sidebar-username {
  font-size: .83rem;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-role { font-size: .72rem; color: var(--sidebar-text); }
.sidebar-logout { color: var(--sidebar-text); }
.sidebar-logout:hover { color: var(--danger); }
.sidebar-copyright {
  padding: .6rem 1rem .75rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: .15rem;
  font-size: .65rem;
  color: var(--sidebar-text);
  opacity: .6;
}

/* ── Avatar ───────────────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; margin: 0 auto 1.25rem; }

/* ── Main Content ─────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Top Bar ──────────────────────────────────────────────────────── */
.topbar {
  height: 56px;
  min-height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-menu { display: none !important; }
.topbar-search {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}
.topbar-search svg {
  position: absolute;
  left: .75rem;
  color: var(--text-muted);
  pointer-events: none;
}
.topbar-search input {
  width: 100%;
  height: 36px;
  padding: 0 2.5rem 0 2.25rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  color: var(--text);
  font-size: .875rem;
  transition: border-color var(--transition), background var(--transition);
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.topbar-search kbd {
  position: absolute;
  right: .6rem;
  font-size: .65rem;
  background: var(--border);
  color: var(--text-muted);
  padding: .1rem .35rem;
  border-radius: 4px;
  pointer-events: none;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.topbar-avatar { cursor: pointer; }

/* Font size switcher */
.font-size-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2px;
}
.fs-btn {
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font);
  font-weight: 600;
  line-height: 1;
  padding: 3px 7px;
  transition: all var(--transition);
}
.fs-btn:nth-child(1) { font-size: .7rem; }
.fs-btn:nth-child(2) { font-size: .875rem; }
.fs-btn:nth-child(3) { font-size: 1.05rem; }
.fs-btn:hover { color: var(--primary); background: var(--primary-light); }
.fs-btn.active { background: var(--primary); color: #fff; }

/* ── Views ────────────────────────────────────────────────────────── */
.view {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.5rem;
}
.view.active { display: flex; flex-direction: column; gap: 1rem; }
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.view-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
}

/* ── Breadcrumb ───────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .85rem;
  flex-wrap: wrap;
}
.breadcrumb a, .breadcrumb .crumb {
  display: flex; align-items: center; gap: .3rem;
  color: var(--text-muted);
  padding: .2rem .4rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.breadcrumb a:hover { color: var(--primary); background: var(--primary-light); }
.breadcrumb .crumb-sep { color: var(--border); user-select: none; }
.breadcrumb .crumb-current { font-weight: 600; color: var(--text); }

/* ── Toolbar ──────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 .15rem;
}
.view-toggle { color: var(--text-muted); }
.view-toggle.active { color: var(--primary); background: var(--primary-light); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg);
  border-color: #c1cad4;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-dark); border-color: var(--danger-dark); }
.btn-full { width: 100%; justify-content: center; padding: .7rem; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: .85rem; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ── Forms ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-input[readonly] { background: var(--bg); color: var(--text-muted); cursor: default; }
.form-input-sm { height: 32px; font-size: .8rem; padding: 0 .6rem; }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .6rem center; padding-right: 2rem; }
.req { color: var(--danger); }

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  color: var(--text);
  cursor: pointer;
}
.checkbox-label input[type=checkbox],
.checkbox-label input[type=radio] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-raised);
  gap: .75rem;
}
.card-title { font-size: .9rem; font-weight: 600; color: var(--text); }
.card-body { padding: 1.25rem; }

/* ── File Grid ────────────────────────────────────────────────────── */
.file-container { flex: 1; overflow-y: auto; padding: .25rem 0; }
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
  padding: .25rem .1rem;
}
.file-grid.list-view {
  grid-template-columns: 1fr;
  gap: .2rem;
}

/* Grid item */
.file-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem .75rem .75rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  user-select: none;
}
.file-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.file-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.file-name {
  font-size: .78rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.file-meta {
  font-size: .7rem;
  color: var(--text-muted);
  text-align: center;
}
.file-actions-hover {
  position: absolute;
  top: .4rem;
  right: .4rem;
  display: none;
  gap: 2px;
}
.file-item:hover .file-actions-hover { display: flex; }
.file-action-btn {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: rgba(255,255,255,.9);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
}
.file-action-btn:hover { background: var(--surface); color: var(--text); border-color: #c1cad4; }
.file-action-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

/* List view item */
.file-grid.list-view .file-item {
  flex-direction: row;
  align-items: center;
  padding: .5rem .75rem;
  border-radius: var(--radius-md);
  gap: .75rem;
}
.file-grid.list-view .file-icon { width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0; }
.file-grid.list-view .file-name { text-align: left; flex: 1; }
.file-grid.list-view .file-meta { margin-left: auto; text-align: right; white-space: nowrap; }
.file-grid.list-view .file-actions-hover { position: static; display: flex; margin-left: .25rem; }

/* File type icon backgrounds */
.icon-folder { background: #fef3c7; color: var(--color-folder); }
.icon-image  { background: #eff6ff; color: var(--color-image); }
.icon-doc    { background: #fef2f2; color: var(--color-doc); }
.icon-sheet  { background: #ecfdf5; color: var(--color-sheet); }
.icon-archive{ background: #f5f3ff; color: var(--color-archive); }
.icon-video  { background: #fdf2f8; color: var(--color-video); }
.icon-audio  { background: #ecfeff; color: var(--color-audio); }
.icon-code   { background: #f9fafb; color: var(--color-code); }
.icon-pdf    { background: #fef2f2; color: var(--color-pdf); }
.icon-default{ background: var(--bg); color: var(--text-muted); }

/* ── Empty State ──────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .75rem;
  padding: 4rem 1rem;
  color: var(--text-muted);
  text-align: center;
}
.empty-state svg { opacity: .3; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text); }
.empty-state p  { font-size: .875rem; max-width: 320px; }

/* ── Drop Overlay ─────────────────────────────────────────────────── */
.drop-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(91,91,214,.12);
  backdrop-filter: blur(2px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.drop-overlay.active { display: flex; }
.drop-message {
  background: var(--surface);
  border: 2.5px dashed var(--primary);
  border-radius: var(--radius-xl);
  padding: 3rem 4rem;
  display: flex; flex-direction: column; align-items: center;
  gap: 1rem;
  color: var(--primary);
  font-weight: 600;
}
.drop-message p { font-size: 1.1rem; }

/* ── Upload Drawer ────────────────────────────────────────────────── */
.upload-drawer {
  position: fixed;
  bottom: 1.25rem; right: 1.25rem;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  overflow: hidden;
}
.upload-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem 1rem;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  font-size: .85rem; font-weight: 600;
}
.upload-list { max-height: 240px; overflow-y: auto; padding: .5rem; }
.upload-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .4rem .5rem;
  border-radius: var(--radius-sm);
  font-size: .78rem;
}
.upload-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.upload-item-status { font-size: .72rem; white-space: nowrap; }
.upload-item-status.done   { color: var(--success); }
.upload-item-status.error  { color: var(--danger); }
.upload-item-status.upload { color: var(--primary); }

/* ── Modals ───────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  z-index: 400;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; animation: fadeIn .15s ease; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: slideUp .2s ease;
}
.modal-sm { max-width: 380px; }
.modal-lg { max-width: 600px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: .95rem; font-weight: 700; }
.modal-body { padding: 1.25rem; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: .5rem;
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface-raised);
}

@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity:0; } to { transform: translateY(0); opacity:1; } }

/* ── Context Menu ─────────────────────────────────────────────────── */
.context-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  z-index: 500;
  overflow: hidden;
  animation: fadeIn .1s ease;
}
.ctx-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .9rem;
  font-size: .85rem;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
}
.ctx-item:hover { background: var(--bg); }
.ctx-item-danger { color: var(--danger); }
.ctx-item-danger:hover { background: var(--danger-bg); }
.ctx-divider { height: 1px; background: var(--border); margin: .2rem 0; }

/* ── Toast ────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center;
  gap: .5rem;
  z-index: 600;
  pointer-events: none;
}
.toast {
  background: #1e293b;
  color: #f1f5f9;
  padding: .65rem 1.1rem;
  border-radius: var(--radius-lg);
  font-size: .84rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: .5rem;
  animation: slideUp .2s ease;
  pointer-events: all;
  max-width: 380px;
}
.toast.success { background: #065f46; }
.toast.error   { background: #991b1b; }
.toast.warning { background: #92400e; }

/* ── Table ────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; overflow-y: auto; }

/* Audit view — card fills remaining height, table scrolls, pagination stays pinned */
#view-audit { padding-bottom: 0; }
#view-audit .card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#view-audit .table-wrap {
  flex: 1;
  min-height: 0;
}
#view-audit .pagination {
  flex-shrink: 0;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.table th, .table td {
  padding: .65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.table th {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: var(--surface-raised);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tbody tr:hover { background: var(--bg); }
.table td { color: var(--text); max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* ── Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .18rem .55rem;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-success { background: var(--success-bg); color: #065f46; }
.badge-danger  { background: var(--danger-bg);  color: #991b1b; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-muted   { background: var(--bg); color: var(--text-muted); }

/* ── Perm chips ───────────────────────────────────────────────────── */
.perm-chips { display: flex; flex-wrap: wrap; gap: .25rem; }
.perm-chip  {
  display: inline-block;
  padding: .12rem .4rem;
  border-radius: 4px;
  font-size: .65rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* ── Stats Row ────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--text); letter-spacing: -.03em; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: .15rem; font-weight: 500; }
.stat-icon  { width: 36px; height: 36px; border-radius: 10px; display:flex;align-items:center;justify-content:center; margin-bottom: .6rem; }

/* ── Alert ────────────────────────────────────────────────────────── */
.alert {
  padding: .65rem .9rem;
  border-radius: var(--radius-md);
  font-size: .83rem;
  margin-bottom: .75rem;
}
.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fecaca; }

/* ── Settings ─────────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.settings-card .card-body { padding: 1.25rem; }
.profile-avatar-wrap { display: flex; justify-content: center; margin-bottom: 1.25rem; }
.totp-status { margin-bottom: 1rem; }

/* Font scale */
.font-scale-wrap { display: flex; flex-direction: column; gap: .75rem; }
.font-scale-labels {
  display: flex; justify-content: space-between;
  font-size: .72rem; color: var(--text-muted); user-select: none;
}
.font-scale-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%; height: 6px;
  border-radius: 99px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.font-scale-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
  cursor: pointer;
  transition: box-shadow var(--transition);
}
.font-scale-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px var(--primary-light);
}
.font-scale-slider::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
  cursor: pointer;
}
.font-scale-preview {
  display: flex; align-items: baseline; gap: .5rem;
  padding: .65rem .9rem;
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.font-scale-preview span:first-child {
  color: var(--text-muted); font-size: .75rem; white-space: nowrap;
}
.font-scale-preview span:last-child {
  color: var(--text); font-weight: 500;
}

/* ── Audit Filters ────────────────────────────────────────────────── */
.audit-filters { flex-wrap: wrap; gap: .5rem; }

/* ── Pagination ───────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: .35rem; padding: .75rem;
  border-top: 1px solid var(--border-light);
}
.page-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .8rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.page-btn:hover  { background: var(--bg); border-color: #c1cad4; color: var(--text); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── User modal grid ──────────────────────────────────────────────── */
.user-modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.perms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .35rem; }

/* ── Spinner ──────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Search results ───────────────────────────────────────────────── */
.search-results { flex: 1; overflow-y: auto; }
.search-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 0 .75rem;
  font-size: .85rem; color: var(--text-muted); font-weight: 500;
}

/* ── Q&A ──────────────────────────────────────────────────────────── */
.qa-list { display: flex; flex-direction: column; gap: .4rem; margin-top: 1.25rem; }

.qa-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all var(--transition);
}
.qa-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.qa-item-main   { flex: 1; min-width: 0; }
.qa-item-title  { font-size: .9rem; font-weight: 600; color: var(--text); margin-bottom: .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qa-item-meta   { font-size: .78rem; color: var(--text-muted); }
.qa-item-right  { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; flex-shrink: 0; }
.qa-answer-count{ display: flex; align-items: center; gap: .3rem; font-size: .75rem; color: var(--text-muted); }

.qa-loading { padding: 2rem; text-align: center; color: var(--text-muted); font-size: .875rem; }
.qa-empty   {
  display: flex; flex-direction: column; align-items: center;
  gap: .75rem; padding: 3rem 1rem;
  color: var(--text-muted); text-align: center; font-size: .875rem;
}
.qa-empty svg { opacity: .3; }

/* Question detail */
.qa-question-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.qa-question-header {
  padding: 1.25rem 1.5rem .75rem;
  border-bottom: 1px solid var(--border-light);
}
.qa-question-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .4rem;
  line-height: 1.35;
}
.qa-question-meta { font-size: .8rem; color: var(--text-muted); display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.qa-question-body { padding: 1.25rem 1.5rem; font-size: .9rem; line-height: 1.7; color: var(--text); white-space: pre-wrap; }

/* Answers */
.qa-answers { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.75rem; }
.qa-no-answers { text-align: center; color: var(--text-muted); font-size: .85rem; padding: 1.5rem; }

.qa-answer {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.qa-answer-admin {
  border-color: var(--primary);
  background: linear-gradient(to bottom, var(--primary-light), var(--surface));
}
.qa-answer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.25rem .5rem;
  border-bottom: 1px solid var(--border-light);
}
.qa-answer-author { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--text-muted); }
.qa-answer-date   { color: var(--text-muted); font-size: .75rem; }
.qa-answer-body   { padding: .875rem 1.25rem; font-size: .875rem; line-height: 1.65; color: var(--text); white-space: pre-wrap; }

/* Reply box */
.qa-reply-box { margin-top: .25rem; }
.qa-textarea {
  height: auto;
  resize: vertical;
  padding: .65rem .75rem;
  line-height: 1.6;
  font-size: .875rem;
}

/* ── Scrollbar ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #c1cad4; }

/* ── Text utilities ───────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.mono        { font-family: 'SF Mono', 'Fira Code', monospace; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .sidebar-close { display: flex !important; }
  .topbar-menu { display: flex !important; }
  .topbar-search kbd { display: none; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .user-modal-grid { grid-template-columns: 1fr; }
  .perms-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .audit-filters { flex-direction: column; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .view { padding: 1rem; }
  .stats-row { grid-template-columns: 1fr; }
}
