/* ============================================================
   LexCloud — app.css
   Dark/Light theme, layout, components
   ============================================================ */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  --bg-primary:    #0f1117;
  --bg-secondary:  #1a1d27;
  --bg-card:       #1e2130;
  --border:        #2a2d3e;
  --text-primary:  #e2e8f0;
  --text-secondary:#8892a4;
  --accent:        #6366f1;
  --accent-hover:  #4f46e5;
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;

  --sidebar-width: 240px;
  --header-height: 64px;
  --radius:        8px;
  --radius-sm:     4px;
  --radius-lg:     12px;
  --shadow:        0 4px 24px rgba(0,0,0,.45);
  --shadow-sm:     0 1px 6px rgba(0,0,0,.3);
  --transition:    0.2s ease;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Light theme overrides */
body.light-theme {
  --bg-primary:    #f0f2f8;
  --bg-secondary:  #ffffff;
  --bg-card:       #ffffff;
  --border:        #dde1ec;
  --text-primary:  #1a1d27;
  --text-secondary:#5a6380;
  --shadow:        0 4px 24px rgba(0,0,0,.10);
  --shadow-sm:     0 1px 6px rgba(0,0,0,.08);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img, svg { display: block; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ── App Layout ────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  transition: transform var(--transition), width var(--transition);
  overflow: hidden;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo .logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo .logo-icon svg { width: 20px; height: 20px; color: #fff; }
.sidebar-logo .logo-text { flex: 1; }
.sidebar-logo .logo-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .3px;
}
.sidebar-logo .logo-sub {
  font-size: .72rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.nav-section-label {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-secondary);
  padding: 16px 20px 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover {
  background: rgba(99,102,241,.10);
  color: var(--text-primary);
}
.nav-link.active {
  background: rgba(99,102,241,.15);
  color: var(--accent);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sidebar-user .user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .user-role {
  font-size: .7rem;
  color: var(--text-secondary);
  margin-top: 1px;
}
.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .8rem;
  transition: all var(--transition);
}
.btn-logout svg { width: 14px; height: 14px; }
.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239,68,68,.08);
}

/* ── Main Content Area ─────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Header ────────────────────────────────────────────── */
.top-header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 4px;
}
.header-hamburger svg { width: 22px; height: 22px; }
.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.header-title .page-subtitle {
  font-size: .72rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 2px;
}
.header-search {
  position: relative;
  flex: 0 0 260px;
}
.header-search input {
  width: 100%;
  padding: 7px 12px 7px 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: .85rem;
  outline: none;
  transition: border-color var(--transition);
}
.header-search input:focus { border-color: var(--accent); }
.header-search .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  width: 16px; height: 16px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
  position: relative;
}
.header-btn svg { width: 18px; height: 18px; }
.header-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}
.notification-badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 16px; height: 16px;
  background: var(--danger);
  border-radius: 50%;
  font-size: .6rem;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  border: 2px solid var(--bg-secondary);
}
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: .82rem;
  transition: all var(--transition);
}
.user-menu-btn .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: .68rem;
  font-weight: 700;
  color: #fff;
}
.user-menu-btn:hover { background: var(--bg-card); }
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 300;
  overflow: hidden;
  display: none;
}
.user-dropdown.open { display: block; }
.user-dropdown-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.user-dropdown-header .ud-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-primary);
}
.user-dropdown-header .ud-email {
  font-size: .72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: .82rem;
  color: var(--text-secondary);
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.user-dropdown-item svg { width: 15px; height: 15px; }
.user-dropdown-item:hover { background: rgba(99,102,241,.1); color: var(--text-primary); }
.user-dropdown-item.danger:hover { background: rgba(239,68,68,.1); color: var(--danger); }
.header-user-wrap { position: relative; }

/* ── Page Content ──────────────────────────────────────────── */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h3, .card-header h4 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-primary);
}
.card-body { padding: 20px; }

/* ── Stats Cards ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.stat-card-label {
  font-size: .78rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stat-card-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.stat-card-icon svg { width: 18px; height: 18px; }
.stat-card-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.stat-card-sub {
  font-size: .75rem;
  color: var(--text-secondary);
}
.stat-card-progress {
  margin-top: 4px;
}

/* ── Progress Bar ──────────────────────────────────────────── */
.progress {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width .4s ease;
}
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th.sortable {
  cursor: pointer;
  user-select: none;
}
thead th.sortable:hover { color: var(--text-primary); }
thead th.sort-asc::after  { content: ' ↑'; color: var(--accent); }
thead th.sort-desc::after { content: ' ↓'; color: var(--accent); }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.03); }
tbody tr.selected { background: rgba(99,102,241,.08); }
tbody td {
  padding: 11px 14px;
  color: var(--text-primary);
  vertical-align: middle;
}
.td-muted { color: var(--text-secondary); }
.td-mono { font-family: 'Courier New', monospace; font-size: .78rem; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: rgba(255,255,255,.06); color: var(--text-primary); }
.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover { background: #059669; }
.btn-sm {
  padding: 5px 10px;
  font-size: .78rem;
}
.btn-sm svg { width: 13px; height: 13px; }
.btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
}
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: .875rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-control::placeholder { color: var(--text-secondary); opacity: .7; }
select.form-control {
  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='%238892a4' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-control.error { border-color: var(--danger); }
.form-hint {
  font-size: .72rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.form-error {
  font-size: .72rem;
  color: var(--danger);
  margin-top: 4px;
  display: none;
}
.form-error.visible { display: block; }

/* Checkbox & Radio */
.check-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: .85rem;
  color: var(--text-secondary);
}
.check-wrap input[type=checkbox],
.check-wrap input[type=radio] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.check-wrap:hover { color: var(--text-primary); }

/* Password toggle */
.input-group {
  position: relative;
}
.input-group .form-control { padding-right: 40px; }
.input-toggle-btn {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0;
  line-height: 1;
}
.input-toggle-btn:hover { color: var(--text-primary); }
.input-toggle-btn svg { width: 16px; height: 16px; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }
.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn .2s ease;
}
.modal-dialog.modal-lg { max-width: 720px; }
.modal-dialog.modal-sm { max-width: 380px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text-primary); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-info    { background: rgba(59,130,246,.12); border-color: rgba(59,130,246,.3); color: #93c5fd; }
.alert-success { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.3); color: #6ee7b7; }
.alert-warning { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); color: #fcd34d; }
.alert-danger  { background: rgba(239,68,68,.12);  border-color: rgba(239,68,68,.3);  color: #fca5a5; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}
.badge-active   { background: rgba(16,185,129,.15); color: var(--success); }
.badge-inactive { background: rgba(239,68,68,.15);  color: var(--danger); }
.badge-warning  { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-info     { background: rgba(59,130,246,.15); color: var(--info); }
.badge-accent   { background: rgba(99,102,241,.15); color: var(--accent); }
.badge-secondary{ background: var(--border);        color: var(--text-secondary); }

/* Role badges */
.role-badge { padding: 2px 8px; border-radius: 99px; font-size: .7rem; font-weight: 600; }
.role-super_admin { background: rgba(239,68,68,.15); color: #fca5a5; }
.role-admin       { background: rgba(99,102,241,.15); color: #a5b4fc; }
.role-legal       { background: rgba(245,158,11,.15); color: #fcd34d; }
.role-cs_team     { background: rgba(16,185,129,.15); color: #6ee7b7; }
.role-editor      { background: rgba(59,130,246,.15); color: #93c5fd; }
.role-viewer      { background: var(--border); color: var(--text-secondary); }

/* Action badges for audit */
.action-badge { padding: 2px 8px; border-radius: var(--radius-sm); font-size: .7rem; font-weight: 600; font-family: monospace; }
.action-LOGIN         { background: rgba(59,130,246,.15); color: #93c5fd; }
.action-LOGOUT        { background: var(--border); color: var(--text-secondary); }
.action-UPLOAD        { background: rgba(16,185,129,.15); color: #6ee7b7; }
.action-DOWNLOAD      { background: rgba(99,102,241,.15); color: #a5b4fc; }
.action-DELETE        { background: rgba(239,68,68,.15); color: #fca5a5; }
.action-LOGIN_FAILED  { background: rgba(239,68,68,.2); color: #f87171; font-weight: 700; }
.action-SHARE         { background: rgba(245,158,11,.15); color: #fcd34d; }
.action-CREATE_FOLDER { background: rgba(16,185,129,.12); color: #6ee7b7; }
.action-MOVE          { background: rgba(59,130,246,.12); color: #93c5fd; }
.action-RESTORE       { background: rgba(16,185,129,.15); color: #6ee7b7; }
.action-REVOKE        { background: rgba(239,68,68,.12); color: #fca5a5; }

/* ── File Grid ─────────────────────────────────────────────── */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  padding: 4px 0;
}
.file-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  user-select: none;
}
.file-item:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  transform: translateY(-1px);
}
.file-item.selected {
  border-color: var(--accent);
  background: rgba(99,102,241,.08);
}
.file-item-checkbox {
  position: absolute;
  top: 8px; left: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}
.file-item:hover .file-item-checkbox,
.file-item.selected .file-item-checkbox { opacity: 1; }
.file-item-icon { width: 52px; height: 52px; }
.file-item-icon svg { width: 100%; height: 100%; }
.file-item-name {
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  max-width: 100%;
}
.file-item-meta {
  font-size: .7rem;
  color: var(--text-secondary);
  text-align: center;
}
.folder-item .file-item-icon { color: var(--warning); }

/* ── File List ─────────────────────────────────────────────── */
.file-list { width: 100%; }
.file-row td { vertical-align: middle; }
.file-row-name {
  display: flex;
  align-items: center;
  gap: 10px;
}
.file-row-name .row-icon { width: 28px; height: 28px; flex-shrink: 0; }
.file-row-name .row-icon svg { width: 100%; height: 100%; }

/* ── Breadcrumb ────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .82rem;
  flex-wrap: wrap;
}
.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}
.breadcrumb-item a { color: var(--text-secondary); }
.breadcrumb-item a:hover { color: var(--accent); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 500; }
.breadcrumb-sep { color: var(--border); }

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  padding: 16px 0 4px;
}
.page-btn {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: .82rem;
  transition: all var(--transition);
  cursor: pointer;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-btn svg { width: 14px; height: 14px; }

/* ── Toast Notifications ───────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: .85rem;
  color: var(--text-primary);
  max-width: 340px;
  animation: toastIn .25s ease;
  transition: opacity .3s ease, transform .3s ease;
}
.toast.hiding { opacity: 0; transform: translateX(20px); }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-icon svg { width: 16px; height: 16px; }
.toast-body { flex: 1; }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-msg { font-size: .8rem; color: var(--text-secondary); }
.toast-close {
  background: none; border: none;
  color: var(--text-secondary); padding: 0;
  flex-shrink: 0; cursor: pointer;
}
.toast-close svg { width: 14px; height: 14px; }
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-success .toast-icon { color: var(--success); }
.toast.toast-error   { border-left: 3px solid var(--danger); }
.toast.toast-error   .toast-icon { color: var(--danger); }
.toast.toast-warning { border-left: 3px solid var(--warning); }
.toast.toast-warning .toast-icon { color: var(--warning); }
.toast.toast-info    { border-left: 3px solid var(--info); }
.toast.toast-info    .toast-icon { color: var(--info); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Drop Zone ─────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(99,102,241,.06);
  color: var(--text-primary);
}
.dropzone-icon { width: 48px; height: 48px; margin: 0 auto 12px; opacity: .5; }
.dropzone-icon svg { width: 100%; height: 100%; }
.dropzone h4 { font-size: .95rem; font-weight: 600; margin-bottom: 6px; }
.dropzone p  { font-size: .8rem; }

/* ── Context Menu ──────────────────────────────────────────── */
.context-menu {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 9000;
  min-width: 180px;
  overflow: hidden;
  display: none;
  animation: ctxIn .12s ease;
}
.context-menu.open { display: block; }
@keyframes ctxIn {
  from { opacity: 0; transform: scale(.95); }
  to   { opacity: 1; transform: scale(1); }
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: .82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.ctx-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.ctx-item:hover { background: rgba(99,102,241,.1); color: var(--text-primary); }
.ctx-item.danger:hover { background: rgba(239,68,68,.1); color: var(--danger); }
.ctx-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Skeleton Loading ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--border) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-wave {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text.w-80 { width: 80%; }
.skeleton-text.w-60 { width: 60%; }
.skeleton-text.w-40 { width: 40%; }
.skeleton-rect { height: 80px; }

/* ── Upload Progress ───────────────────────────────────────── */
.upload-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.upload-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.upload-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: .8rem;
}
.upload-item-name {
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
}
.upload-item-status { color: var(--text-secondary); }

/* ── Folder Tree ───────────────────────────────────────────── */
.folder-tree {
  font-size: .82rem;
  padding: 4px 0;
}
.tree-node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-node:hover { background: rgba(99,102,241,.1); color: var(--text-primary); }
.tree-node.active { background: rgba(99,102,241,.15); color: var(--accent); }
.tree-node svg { width: 14px; height: 14px; flex-shrink: 0; }
.tree-node-toggle { color: var(--text-secondary); flex-shrink: 0; }
.tree-children { padding-left: 16px; }
.tree-children.collapsed { display: none; }

/* ── Sidebar Left Panel (files page) ──────────────────────── */
.file-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.file-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-secondary);
}
.file-sidebar-title {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding: 0 4px;
}
.dept-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}
.dept-tab {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  border: none;
  background: none;
  text-align: left;
  transition: all var(--transition);
}
.dept-tab:hover { background: rgba(99,102,241,.1); color: var(--text-primary); }
.dept-tab.active { background: rgba(99,102,241,.15); color: var(--accent); }

/* ── File Manager Top Bar ──────────────────────────────────── */
.file-topbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  flex-wrap: wrap;
}
.file-topbar-left { flex: 1; min-width: 0; }
.file-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.view-btn {
  padding: 5px 10px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
}
.view-btn svg { width: 16px; height: 16px; }
.view-btn.active { background: var(--accent); color: #fff; }
.view-btn:hover:not(.active) { background: var(--bg-card); color: var(--text-primary); }
.file-main-panel { flex: 1; overflow-y: auto; padding: 16px 20px; }
.bulk-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  display: none;
  align-items: center;
  gap: 12px;
  z-index: 50;
}
.bulk-bar.visible { display: flex; }
.bulk-count { font-size: .85rem; color: var(--text-secondary); flex: 1; }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-state-icon {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  opacity: .3;
}
.empty-state-icon svg { width: 100%; height: 100%; }
.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.empty-state p { font-size: .85rem; }

/* ── Filter Bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 0;
}
.filter-bar .form-control { width: auto; min-width: 150px; }
.filter-bar .header-search { flex: 0 0 220px; }

/* ── Two column grid ───────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ── Activity Feed ─────────────────────────────────────────── */
.activity-feed { display: flex; flex-direction: column; }
.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.activity-icon svg { width: 15px; height: 15px; }
.activity-body { flex: 1; min-width: 0; }
.activity-text {
  font-size: .82rem;
  color: var(--text-primary);
  line-height: 1.4;
}
.activity-text strong { color: var(--text-primary); }
.activity-time {
  font-size: .72rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* ── Storage Chart (CSS bars) ──────────────────────────────── */
.storage-chart { display: flex; flex-direction: column; gap: 14px; }
.storage-chart-row { }
.storage-chart-label {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.storage-chart-label strong { color: var(--text-primary); }

/* ── Login Page ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.login-header {
  padding: 32px 36px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.login-logo {
  width: 52px; height: 52px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.login-logo svg { width: 28px; height: 28px; color: #fff; }
.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.login-sub {
  font-size: .82rem;
  color: var(--text-secondary);
}
.login-body { padding: 28px 36px; }
.login-footer {
  padding: 14px 36px;
  text-align: center;
  font-size: .72rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

/* TOTP */
.totp-step { display: none; }
.totp-step.active { display: block; }
.totp-code-input {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: .4em;
  padding: 12px;
}
.totp-timer {
  text-align: center;
  margin-top: 12px;
  font-size: .8rem;
  color: var(--text-secondary);
}
.totp-timer .count { color: var(--accent); font-weight: 700; }

/* Shake animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}
.shake { animation: shake .4s ease; }

/* ── Users page ────────────────────────────────────────────── */
.user-avatar-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar-cell .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-avatar-cell .uname { font-weight: 500; color: var(--text-primary); font-size: .85rem; }
.user-avatar-cell .uemail { font-size: .72rem; color: var(--text-secondary); }

/* ── Shares page ───────────────────────────────────────────── */
.share-token {
  font-family: 'Courier New', monospace;
  font-size: .75rem;
  color: var(--text-secondary);
  background: var(--bg-primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.copy-link-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-top: 12px;
}
.copy-link-box input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: .82rem;
  outline: none;
}

/* ── Responsive — Tablet 768px ─────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }
  .main-content { margin-left: 0; }
  .header-hamburger { display: flex; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
  }
  .sidebar-overlay.open { display: block; }
  .file-sidebar { display: none; }
  .file-sidebar.open { display: block; position: fixed; z-index: 150; height: 100vh; top: 0; left: 0; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .login-body { padding: 24px 20px; }
  .login-header { padding: 24px 20px 20px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control { width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .header-search { display: none; }
}

/* ── Utilities ─────────────────────────────────────────────── */
.flex  { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-sm { font-size: .82rem; }
.text-xs { font-size: .72rem; }
.text-muted { color: var(--text-secondary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: 'Courier New', monospace; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.section-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title svg { width: 16px; height: 16px; color: var(--accent); }

/* ── 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: var(--text-secondary); }

/* ── Patch: JS class name aliases ──────────────────────────── */
/* files.js uses .file-grid-item; CSS defines .file-item */
.file-grid-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 12px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; transition: all var(--transition); position: relative; user-select: none; }
.file-grid-item:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); transform: translateY(-1px); }
.file-grid-item.selected { border-color: var(--accent); background: rgba(99,102,241,.08); }
.file-grid-icon { width: 52px; height: 52px; }
.file-grid-icon svg { width: 100%; height: 100%; }
.file-grid-name { font-size: .78rem; font-weight: 500; color: var(--text-primary); text-align: center; word-break: break-all; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; max-width: 100%; }
.file-grid-meta { font-size: .7rem; color: var(--text-secondary); text-align: center; }
.file-select-check { position: absolute; top: 8px; left: 8px; opacity: 0; transition: opacity var(--transition); }
.file-grid-item:hover .file-select-check,
.file-grid-item.selected .file-select-check { opacity: 1; }

/* files.js uses .folder-tree-item; CSS defines .tree-node */
.folder-tree-item { display: flex; align-items: center; gap: 4px; padding: 5px 8px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-secondary); transition: all var(--transition); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .82rem; }
.folder-tree-item:hover { background: rgba(99,102,241,.1); color: var(--text-primary); }
.folder-tree-item.active { background: rgba(99,102,241,.15); color: var(--accent); }
.folder-tree-children { padding-left: 12px; }
.tree-chevron { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-secondary); transition: transform var(--transition); }
.tree-chevron svg { width: 14px; height: 14px; transition: transform var(--transition); }
.tree-folder-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--warning); }
.tree-folder-icon svg { width: 16px; height: 16px; }
.tree-folder-name { overflow: hidden; text-overflow: ellipsis; }
.tree-loading, .tree-empty { font-size: .78rem; color: var(--text-secondary); padding: 6px 8px; }

/* Badge aliases: JS uses .badge-success/.badge-danger */
.badge-success { background: rgba(16,185,129,.15);  color: var(--success); padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; display: inline-flex; align-items: center; }
.badge-danger  { background: rgba(239,68,68,.15);   color: var(--danger);  padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; display: inline-flex; align-items: center; }
.badge-warning { background: rgba(245,158,11,.15);  color: var(--warning); padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; display: inline-flex; align-items: center; }
.badge-info    { background: rgba(59,130,246,.15);  color: var(--info);    padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; display: inline-flex; align-items: center; }

/* Form input aliases: users.html/shares.html use .form-input/.form-select */
.form-input, .form-select { width: 100%; padding: 8px 12px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: .9rem; transition: border-color var(--transition); outline: none; }
.form-input:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-input::placeholder { color: var(--text-secondary); opacity: .7; }
.form-select { cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* List view helpers */
.row-actions { display: flex; align-items: center; gap: 4px; }
.folder-row { cursor: pointer; }
.folder-row:hover td { background: rgba(99,102,241,.05); }
.folder-name-link { font-weight: 500; color: var(--text-primary); }
.folder-row-icon svg { width: 100%; height: 100%; color: var(--warning); }

/* Spinner for loading states */
.loading-spinner-wrap { display: flex; align-items: center; justify-content: center; padding: 60px 20px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Dept dot in sidebar tabs */
.dept-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; margin-right: 4px; }

/* Fix: user-menu chevron SVG had no sizing rule — would default to 300px */
.user-menu-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Reusable small inline icon wrapper (16px) */
.icon-sm { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex-shrink: 0; vertical-align: middle; }
.icon-sm svg { width: 100%; height: 100%; }
