:root {
  /* Color tokens — matched to the AxSys Cloud logo's blue family */
  --bg: #f4f7fb;
  --card: #ffffff;
  --border: #e6ebf2;
  --border-strong: #d3dce6;
  --text: #10182b;
  --muted: #6b7686;
  --muted-2: #97a1ae;
  --accent: #1f5b96;
  --accent-hover: #184a7c;
  --accent-soft: #e9f1fa;
  --accent2: #2f7bc4;
  --danger: #d13438;
  --danger-soft: #fdecea;
  --success: #1a7f43;
  --success-soft: #eafaf0;
  --warning: #a9720c;
  --warning-soft: #fdf3e3;

  /* Scale */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-w: 224px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 43, 0.05);
  --shadow-md: 0 8px 24px rgba(16, 24, 43, 0.08);
  --shadow-lg: 0 20px 50px rgba(16, 24, 43, 0.18);
  --transition: 0.15s ease;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f18;
    --card: #131a26;
    --border: #232c3b;
    --border-strong: #303c4f;
    --text: #eef2f7;
    --muted: #93a0b3;
    --muted-2: #6b7686;
    --accent: #5aa8dd;
    --accent-hover: #78bcec;
    --accent-soft: #16283b;
    --accent2: #2f7bc4;
    --danger: #ff6b6b;
    --danger-soft: #3a1f21;
    --success: #4ade80;
    --success-soft: #12291c;
    --warning: #f2b93d;
    --warning-soft: #332508;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; height: 100%; }

.icon-svg { width: 18px; height: 18px; flex-shrink: 0; }
.icon-svg-sm { width: 15px; height: 15px; flex-shrink: 0; }
.icon-svg-lg { width: 26px; height: 26px; flex-shrink: 0; }
.icon-svg-xl { width: 30px; height: 30px; flex-shrink: 0; }

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1100px 520px at 100% -8%, var(--accent-soft) 0%, transparent 60%),
    radial-gradient(900px 480px at -8% 0%, var(--accent-soft) 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

button, input, select {
  font-family: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

button, .pill, .icon-btn, .btn-dark, .btn-primary, .btn-upload, .nav-item, .tab, .admin-tab, a {
  transition: background-color var(--transition), border-color var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
}

button:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(760px 520px at 15% 10%, color-mix(in srgb, var(--accent2) 22%, transparent) 0%, transparent 60%),
    radial-gradient(820px 620px at 100% 100%, var(--accent-soft) 0%, transparent 55%),
    var(--bg);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.logo-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

.auth-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
.auth-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-google:hover { border-color: var(--border-strong); background: var(--bg); }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin: 18px 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
}
.field input:focus, .field select:focus, input:focus, select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.checkbox-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; margin-right: 16px; }
.checkbox-label input { width: auto; }

.permission-list { max-height: 220px; overflow-y: auto; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.permission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.permission-name { font-size: 13px; font-weight: 600; }
#permissionsModalBox { max-width: 420px; max-height: 85vh; overflow-y: auto; }

.row-between { display: flex; justify-content: space-between; align-items: center; }
.link-muted { font-size: 13px; color: var(--accent); }
.link-muted:hover { color: var(--accent-hover); text-decoration: underline; }

.btn-primary {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  margin-top: 6px;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: translateY(1px); }

.auth-footer { text-align: center; font-size: 13px; color: var(--muted); margin-top: 18px; }

.auth-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

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

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.5);
  z-index: 40;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 22px; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11px; letter-spacing: 0.04em; color: var(--muted); }

.sidebar-close-btn { display: none; }

.sidebar-logout { margin-top: 10px; color: var(--muted); }
.sidebar-logout:hover { background: var(--danger-soft); color: var(--danger); }

.sidebar-corp-link {
  display: block;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
  padding: 4px;
}
.sidebar-corp-link:hover { color: var(--accent); }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .icon-svg { opacity: 0.75; }
.nav-item.active .icon-svg { opacity: 1; }

.sidebar-spacer { flex: 1; }

.storage-widget {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 12px;
}
.storage-widget .row-between { margin-bottom: 8px; color: var(--text); font-weight: 600; }
.progress-track { height: 6px; background: var(--border); border-radius: 6px; overflow: hidden; margin-bottom: 6px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.storage-widget .storage-detail { color: var(--muted); }

/* ---------- Main area ---------- */
.main { flex: 1; height: 100vh; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 10;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.menu-toggle-btn { position: absolute; left: 24px; }

.menu-toggle-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.search-box {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--muted);
  font-size: 14px;
}
.search-box input { border: none; background: transparent; outline: none; flex: 1; font-size: 14px; color: var(--text); }

.topbar-spacer { flex: 1; }

.btn-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-upload:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.btn-upload:active { transform: translateY(0); }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); background: var(--bg); }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.avatar:hover { opacity: 0.85; }

.content {
  padding: 28px 32px;
  flex: 1;
  min-width: 0;
  min-height: 0;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* Wraps just the file grid/table/empty-state on My Files, so the title, stat cards and filter
   row above it stay put while only the listing itself scrolls. The scrolling itself happens on
   .file-grid/.file-table-wrap (not this wrapper) so the table's sticky header has a real
   scrolling ancestor to stick against. */
.file-scroll-area { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.file-scroll-area .file-grid,
.file-scroll-area .file-table-wrap,
.file-scroll-area .empty-state { flex: 1; min-height: 0; overflow-y: auto; }

.page-title { font-size: 26px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
.page-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
a.stat-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.stat-icon.images { background: var(--success-soft); color: var(--success); }
.stat-icon.documents { background: var(--accent-soft); color: var(--accent); }
.stat-icon.videos { background: var(--danger-soft); color: var(--danger); }
.stat-icon.audio { background: var(--warning-soft); color: var(--warning); }

.stat-value { font-size: 18px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--muted); }

.filter-row { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }

.pill {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-spacer { flex: 1; }

.view-toggle { display: flex; gap: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; background: var(--card); }
.view-toggle .icon-btn { width: 28px; height: 28px; border: none; border-radius: 6px; }
.view-toggle .icon-btn.active { background: var(--accent-soft); color: var(--accent); }

.empty-state {
  background: var(--card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 60px 20px;
  text-align: center;
}
.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin: 0 auto 16px;
}
.empty-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.empty-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.profile-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }
.profile-name { font-size: 17px; font-weight: 700; }
.profile-sub { font-size: 13px; color: var(--muted); }

.profile-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 24px 0 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.profile-section-title:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 8px; max-width: 760px; }
.profile-field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.profile-value { font-size: 14px; font-weight: 500; }

.profile-status {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.profile-status.success { background: var(--success-soft); color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); }
.profile-status.error { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }

.profile-role-badge {
  margin-left: auto;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.profile-readonly-row { margin-bottom: 8px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 14px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel .profile-grid { grid-template-columns: 1fr 1fr; }
.field.full { grid-column: 1 / -1; }

.field-hint { display: block; font-size: 12px; margin-top: 4px; color: var(--muted); }
.field-hint.checking { color: var(--muted); }
.field-hint.ok { color: var(--success); }
.field-hint.error { color: var(--danger); }
.field-error { display: block; font-size: 12px; margin-top: 4px; color: var(--danger); }

.admin-tabs { display: flex; gap: 4px; margin-bottom: 18px; overflow-x: auto; }
.admin-tab {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.admin-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.admin-table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); -webkit-overflow-scrolling: touch; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; padding: 12px 16px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg); }
.admin-table select, .admin-table input[type=number] { padding: 6px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card); font-size: 13px; }

.inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; flex-wrap: wrap; }

.status-pill { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; }
.status-pill.ok { background: var(--success-soft); color: var(--success); }
.status-pill.blocked { background: var(--danger-soft); color: var(--danger); }

.member-list { display: flex; flex-direction: column; gap: 6px; }
.member-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; background: var(--bg); border-radius: var(--radius-sm); font-size: 13px; gap: 8px; }

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.file-grid[hidden], .file-table-wrap[hidden] { display: none; }

.file-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.file-card[draggable="true"], .file-table tr[draggable="true"] { cursor: grab; }
.file-card.dragging, .file-table tr.dragging { opacity: 0.4; }
.drop-target.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.admin-tab.drop-target.drag-over { background: var(--accent-soft); color: var(--accent); }

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

.star-btn { color: var(--muted-2); }
.star-btn.active { color: var(--warning); background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }

.file-card-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-card-name.preview-btn, .file-table .name-cell .preview-btn {
  cursor: pointer;
}
.file-card-name.preview-btn:hover, .file-table .name-cell .preview-btn:hover {
  color: var(--accent);
  text-decoration: underline;
}

.file-card-meta { font-size: 12px; color: var(--muted); }

.file-card-actions { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.file-card-actions .pill { flex: 1; text-align: center; }

/* File type badge colors, matching familiar Office/Windows associations */
.file-badge { width: 38px; height: 38px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-badge.badge-word { background: #e3ecfb; color: #2b579a; }
.file-badge.badge-excel { background: #e3f6ea; color: #217346; }
.file-badge.badge-powerpoint { background: #fde9e0; color: #c43e1c; }
.file-badge.badge-pdf { background: #fde2e2; color: #d13438; }
.file-badge.badge-text { background: #eef0f2; color: #5b6470; }
.file-badge.badge-archive { background: #f6ecd9; color: #a9720c; }
.file-badge.badge-image { background: #efe6fb; color: #7c3aed; }
.file-badge.badge-audio { background: #fff0f5; color: #d6336c; }
.file-badge.badge-video { background: #e3f0fb; color: #1864ab; }
.file-badge.badge-generic { background: var(--bg); color: var(--muted); }
.file-badge-sm { width: 28px; height: 28px; border-radius: 7px; }
.file-badge-sm .icon-svg { width: 15px; height: 15px; }

/* Details (list) view */
.file-table-wrap { overflow: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); -webkit-overflow-scrolling: touch; }
.file-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.file-table th {
  text-align: left;
  padding: 10px 16px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--card);
}
.file-table td { padding: 8px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.file-table tr:last-child td { border-bottom: none; }
.file-table .name-cell { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.file-table td.muted { color: var(--muted); white-space: nowrap; }

.folder-toggle { user-select: none; }
.chevron-icon { display: inline-flex; transition: transform var(--transition); flex-shrink: 0; color: var(--muted); }
.chevron-icon.expanded { transform: rotate(90deg); }
.folder-row:hover td, .file-row:hover td { background: var(--bg); }

/* "New" split button + dropdown, OneDrive/Drive style */
.new-menu { position: relative; display: inline-block; }

.new-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 190px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 20;
}

.new-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.new-menu-item:hover { background: var(--bg); }

/* Row "more actions" (kebab) menu — a single floating panel shared by every row, populated from
   that row's hidden .row-actions template and positioned next to whichever kebab was clicked. */
.kebab-btn.active { background: var(--accent-soft); color: var(--accent); }

.action-menu {
  position: fixed;
  z-index: 150;
  min-width: 190px;
  max-width: 260px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
}
.action-menu[hidden] { display: none; }

.action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.action-item:hover { background: var(--bg); }
.action-item.danger { color: var(--danger); }
.action-item.danger:hover { background: var(--danger-soft); }
.action-item .icon-svg-sm { flex-shrink: 0; color: var(--muted); }
.action-item.danger .icon-svg-sm { color: var(--danger); }

.action-divider { height: 1px; background: var(--border); margin: 6px 4px; }
.action-label { padding: 6px 10px 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted-2); }
.action-move-list { max-height: 180px; overflow-y: auto; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay[hidden] { display: none; }
.new-menu-dropdown[hidden] { display: none; }

/* File preview modal */
.preview-overlay { padding: 24px; z-index: 200; }
.preview-box {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 1100px;
  height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.preview-filename {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-header-actions { display: flex; gap: 6px; flex-shrink: 0; }
.preview-body {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: 0;
}
.preview-status {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 40px;
}
.preview-image { margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-frame { flex: 1; width: 100%; border: none; }
.preview-video { margin: auto; max-width: 100%; max-height: 100%; }
.preview-audio-wrap { margin: auto; width: 100%; padding: 0 24px; box-sizing: border-box; }
.preview-audio { width: 100%; }
.preview-text {
  flex: 1;
  width: 100%;
  margin: 0;
  padding: 20px 24px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  box-sizing: border-box;
}
.preview-doc {
  flex: 1;
  width: 100%;
  overflow: auto;
  box-sizing: border-box;
  padding: 32px 40px;
  background: #fff;
  color: #111;
}
.preview-doc img { max-width: 100%; }
.preview-doc table { border-collapse: collapse; }
.preview-doc table td, .preview-doc table th { border: 1px solid #ccc; padding: 4px 8px; }

.preview-sheet-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}
.preview-sheet-tab {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.preview-sheet-tab.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.preview-sheet-wrap {
  flex: 1;
  width: 100%;
  overflow: auto;
  background: #fff;
  box-sizing: border-box;
}
.preview-sheet {
  border-collapse: collapse;
  font-size: 12px;
  color: #111;
}
.preview-sheet td, .preview-sheet th {
  border: 1px solid #ddd;
  padding: 4px 8px;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .preview-box { height: 92vh; }
  .preview-doc, .preview-text { padding: 16px; }
}

.preview-epub-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: stretch;
  background: #fff;
}
.preview-epub-frame { flex: 1; min-width: 0; }
.preview-epub-nav {
  flex-shrink: 0;
  width: 40px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.preview-epub-nav:hover { background: var(--bg); color: var(--accent); }

.modal-box {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 100%;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
}

.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }

.modal-box input[type=text] {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.btn-dark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-dark:hover { opacity: 0.9; }
.btn-dark:active { transform: translateY(1px); }

/* =========================================================
   Responsive — tablet & mobile
   ========================================================= */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 20px; }
}

@media (max-width: 768px) {
  .app-shell { position: relative; }

  .menu-toggle-btn { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.open { display: block; }

  .sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    margin-left: auto;
    cursor: pointer;
  }

  .topbar { padding: 12px 16px; gap: 10px; }
  .search-box { max-width: none; }
  .btn-upload span { display: none; }
  .btn-upload { padding: 9px 12px; }

  .content { padding: 16px; }

  .page-title { font-size: 21px; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 32px; height: 32px; }
  .stat-value { font-size: 16px; }

  .profile-card, .file-grid > .file-card { padding: 16px; }
  .profile-grid, .tab-panel .profile-grid { grid-template-columns: 1fr; }
  .profile-header { gap: 12px; }

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

  .row-between { flex-wrap: wrap; gap: 10px; }

  .modal-box { max-width: 100%; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .file-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-card { padding: 24px 20px; }
  .profile-header { flex-direction: column; align-items: flex-start; }
  .profile-role-badge { margin-left: 0; }
}
