/* ============================================================================
   Forteresse Digitale — Design System
   Palette officielle fournie :
     - Original (Primary)     : #213566
     - 25% lighter            : #324677
     - 20% darker             : #202d4c
     - 25% more saturated     : #18316f
     - 20% less saturated     : #28385f
     - Inverted (Warm Gold)   : #deca99
     - Grayscale (Body Text)  : #444444
     - Midnight Blue Accent   : #191970
   ============================================================================ */

:root {
  --navy-original: #213566;
  --navy-lighter: #324677;
  --navy-darker: #202d4c;
  --navy-saturated: #18316f;
  --navy-muted: #28385f;
  --navy-midnight: #191970;
  --gold-accent: #deca99;
  --gold-soft: #f5eedb;
  --gold-dark: #7a642c;

  --text-main: #444444;
  --text-heading: #202d4c;
  --text-secondary: #5c6880;
  --text-on-dark: #eef2fa;
  --text-on-dark-muted: #a9b6d1;

  --bg-app: #f4f6fa;
  --bg-card: #ffffff;
  --bg-subtle: #edf1f8;
  --bg-hover: #f7f9fd;

  --border-color: #dce2ee;
  --border-strong: #c2cce0;

  --success: #1f7a53;
  --success-bg: #e7f6ee;
  --warning: #9c6a10;
  --warning-bg: #fbf3df;
  --danger: #b42338;
  --danger-bg: #fdecef;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(32, 45, 76, 0.06), 0 1px 2px rgba(32, 45, 76, 0.04);
  --shadow-md: 0 8px 24px rgba(32, 45, 76, 0.09);
  --shadow-lg: 0 20px 50px rgba(24, 49, 111, 0.22);

  --sidebar-width: 268px;
  --topbar-height: 68px;
  --transition: 160ms ease;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
  color: var(--text-main);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

a {
  color: var(--navy-saturated);
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

/* ============================================================================
   Boot Loader
   ============================================================================ */
.boot-loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--navy-darker);
  color: var(--text-on-dark);
  z-index: 9999;
}

.boot-spinner, .spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(222, 202, 153, 0.25);
  border-top-color: var(--gold-accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================================
   Auth View (Connexion + MFA)
   ============================================================================ */
.auth-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1.05fr) minmax(360px, 1fr);
  background: var(--bg-app);
}

.auth-hero {
  background: linear-gradient(150deg, var(--navy-darker) 0%, var(--navy-original) 55%, var(--navy-saturated) 100%);
  color: #ffffff;
  padding: 56px 52px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-hero::before {
  content: "";
  position: absolute;
  width: 440px;
  height: 440px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(222, 202, 153, 0.14) 0%, rgba(222, 202, 153, 0) 70%);
  top: -120px;
  right: -120px;
  pointer-events: none;
}

.auth-hero::after {
  content: "";
  position: absolute;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(50, 70, 119, 0.55) 0%, rgba(50, 70, 119, 0) 70%);
  bottom: -110px;
  left: -80px;
  pointer-events: none;
}

.auth-hero-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.auth-hero-brand .brand-emblem {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(222, 202, 153, 0.45);
}

.auth-hero-content {
  position: relative;
  z-index: 1;
  max-width: 460px;
}

.auth-hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(222, 202, 153, 0.15);
  border: 1px solid rgba(222, 202, 153, 0.35);
  color: var(--gold-accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.auth-hero h1 {
  margin: 0 0 16px;
  font-size: 34px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-hero p {
  margin: 0 0 28px;
  color: var(--text-on-dark-muted);
  font-size: 15px;
  line-height: 1.6;
}

.auth-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 14px;
}

.auth-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-on-dark);
}

.auth-feature-dot {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(222, 202, 153, 0.14);
  color: var(--gold-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-hero-footer {
  position: relative;
  z-index: 1;
  font-size: 12.5px;
  color: var(--text-on-dark-muted);
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px 34px;
  box-shadow: var(--shadow-md);
}

.auth-card h2 {
  margin: 0 0 6px;
  color: var(--text-heading);
  font-size: 24px;
  font-weight: 700;
}

.auth-card .auth-subtitle {
  margin: 0 0 24px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.otp-input {
  text-align: center;
  font-size: 24px !important;
  font-weight: 700;
  letter-spacing: 0.28em;
  padding: 14px 16px !important;
  color: var(--navy-darker);
}

/* ============================================================================
   App Shell (Sidebar + Topbar + Main)
   ============================================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--navy-darker);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 200ms ease;
}

.sidebar-brand {
  height: var(--topbar-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-emblem {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--navy-original);
  border: 1px solid rgba(222, 202, 153, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--gold-accent);
  opacity: 0.9;
}

.sidebar-nav {
  flex: 1;
  padding: 18px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  padding: 14px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-on-dark-muted);
  opacity: 0.78;
}

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

.nav-item:hover {
  background: rgba(50, 70, 119, 0.55);
}

.nav-item.active {
  background: var(--navy-original);
  color: #ffffff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--gold-accent);
}

.nav-item.active svg {
  color: var(--gold-accent);
}

.nav-badge {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.nav-badge-ok {
  background: rgba(31, 122, 83, 0.25);
  color: #7ee2b4;
}

.nav-badge-warn {
  background: rgba(222, 202, 153, 0.22);
  color: var(--gold-accent);
}

.sidebar-footer {
  padding: 14px 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.12);
}

.user-mini-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy-lighter);
  border: 1px solid rgba(222, 202, 153, 0.45);
  color: var(--gold-accent);
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-mini-info {
  min-width: 0;
  flex: 1;
}

.user-mini-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-mini-role {
  font-size: 11.5px;
  color: var(--text-on-dark-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-on-dark);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition);
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.14);
}

.main-column {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 25;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 520px;
}

.search-box {
  position: relative;
  flex: 1;
}

.search-box input {
  width: 100%;
  padding: 10px 36px 10px 38px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-app);
  color: var(--text-main);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.search-box input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--navy-lighter);
  box-shadow: 0 0 0 3px rgba(33, 53, 102, 0.12);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
}

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

.main-content {
  padding: 26px 28px 48px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

/* ============================================================================
   Buttons, Forms & Badges
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform 90ms ease, box-shadow var(--transition);
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--navy-original);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--navy-saturated);
  box-shadow: 0 4px 12px rgba(24, 49, 111, 0.24);
}

.btn-gold {
  background: var(--gold-accent);
  color: var(--navy-darker);
}

.btn-gold:hover:not(:disabled) {
  background: #d3bd86;
}

.btn-secondary {
  background: #ffffff;
  color: var(--navy-muted);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--navy-lighter);
}

.btn-ghost {
  background: transparent;
  color: var(--navy-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-subtle);
}

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

.btn-danger:hover:not(:disabled) {
  background: #961c2d;
}

.btn-danger-outline {
  background: #ffffff;
  color: var(--danger);
  border-color: #f0c2c9;
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-bg);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 7px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--navy-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--navy-darker);
}

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

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-muted);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #ffffff;
  color: var(--text-main);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--navy-original);
  box-shadow: 0 0 0 3px rgba(33, 53, 102, 0.14);
}

.form-textarea {
  resize: vertical;
  min-height: 76px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 5px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-app);
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--navy-original);
  width: 16px;
  height: 16px;
}

/* Role & Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.badge-admin {
  background: var(--navy-darker);
  color: var(--gold-accent);
}

.badge-owner {
  background: var(--gold-soft);
  color: var(--gold-dark);
  border: 1px solid rgba(222, 202, 153, 0.9);
}

.badge-contributor {
  background: #e5ebf7;
  color: var(--navy-original);
}

.badge-viewer {
  background: #eff1f5;
  color: #4b5563;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ============================================================================
   Page Headers, Cards, Alerts & Stats
   ============================================================================ */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.015em;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-heading);
}

.card-body {
  padding: 20px 22px;
}

.alert {
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid #ecd69c;
  color: #6b4909;
}

.alert-info {
  background: #edf2fb;
  border: 1px solid #c7d5f0;
  color: var(--navy-darker);
}

.alert-danger {
  background: var(--danger-bg);
  border: 1px solid #f4c2c9;
  color: var(--danger);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: #edf1fa;
  color: var(--navy-original);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.gold {
  background: var(--navy-darker);
  color: var(--gold-accent);
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ============================================================================
   Breadcrumbs & Folder Explorer
   ============================================================================ */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13.5px;
}

.crumb-btn {
  border: none;
  background: transparent;
  color: var(--navy-lighter);
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.crumb-btn:hover {
  background: var(--bg-subtle);
  color: var(--navy-darker);
}

.crumb-current {
  color: var(--text-heading);
  font-weight: 700;
  padding: 4px 8px;
}

.crumb-sep {
  color: var(--text-secondary);
  opacity: 0.6;
}

.section-heading {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin: 22px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 16px;
}

.folder-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 140ms ease, box-shadow var(--transition), border-color var(--transition);
  position: relative;
}

.folder-card:hover {
  transform: translateY(-2px);
  border-color: var(--navy-lighter);
  box-shadow: var(--shadow-md);
}

.folder-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.folder-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--navy-original), var(--navy-lighter));
  color: var(--gold-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.folder-card-name {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-heading);
  word-break: break-word;
}

.folder-card-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 36px;
}

.folder-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--bg-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

.folder-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Dropzone Upload */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: #ffffff;
  padding: 22px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  transition: border-color var(--transition), background var(--transition);
}

.dropzone.drag-over {
  border-color: var(--navy-original);
  background: #eef3fc;
}

.dropzone-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: var(--gold-soft);
  color: var(--navy-darker);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dropzone-title {
  font-weight: 700;
  color: var(--text-heading);
  font-size: 14.5px;
}

.dropzone-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.upload-progress {
  width: 100%;
  margin-top: 10px;
}

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

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy-original), var(--navy-saturated));
  width: 0%;
  transition: width 120ms linear;
}

/* Tables (Documents, Users, Backups, Audit) */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--navy-muted);
  background: #f8faff;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #eef1f7;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.doc-row-click {
  cursor: pointer;
}

.doc-name-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.file-type-pill {
  min-width: 42px;
  height: 36px;
  padding: 0 7px;
  border-radius: 8px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.pill-pdf { background: #fce8eb; color: #a91c34; }
.pill-word { background: #e5eefc; color: #18316f; }
.pill-excel { background: #e5f5ec; color: #196b45; }
.pill-ppt { background: #fdf1e4; color: #a6540d; }
.pill-img { background: #f2ebfb; color: #5b2c91; }
.pill-txt { background: #edf1f7; color: #28385f; }

.doc-title-text {
  font-weight: 600;
  color: var(--text-heading);
  word-break: break-word;
}

.doc-sub-text {
  font-size: 12px;
  color: var(--text-secondary);
}

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

.empty-state {
  text-align: center;
  padding: 46px 24px;
  color: var(--text-secondary);
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--bg-subtle);
  color: var(--navy-lighter);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state h3 {
  margin: 0 0 6px;
  color: var(--text-heading);
  font-size: 16px;
}

.empty-state p {
  margin: 0 auto 16px;
  max-width: 420px;
  font-size: 13.5px;
}

/* ============================================================================
   MFA & Security View
   ============================================================================ */
.two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
}

.qr-setup-box {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: center;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 16px 0;
}

.qr-frame {
  background: #ffffff;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.qr-frame img {
  display: block;
  width: 176px;
  height: 176px;
}

.secret-code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy-darker);
  background: #ffffff;
  border: 1px dashed var(--navy-lighter);
  padding: 10px 12px;
  border-radius: 8px;
  letter-spacing: 0.08em;
  display: inline-block;
  margin: 8px 0;
}

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

.recovery-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy-darker);
  background: var(--gold-soft);
  border: 1px solid var(--gold-accent);
  border-radius: 8px;
  padding: 9px 12px;
  text-align: center;
  letter-spacing: 0.08em;
}

/* ============================================================================
   Modals & Share Dialog
   ============================================================================ */
.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(20, 31, 56, 0.58);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 80;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 140ms ease;
}

.modal-card.modal-lg {
  max-width: 680px;
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 18px 22px;
  background: var(--navy-darker);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h3 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
}

.modal-close {
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  background: #f9fafd;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.member-add-row {
  display: grid;
  grid-template-columns: 1fr 165px auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

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

.member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #ffffff;
}

.member-item.inherited {
  background: var(--bg-app);
  border-style: dashed;
}

.member-info {
  min-width: 0;
  flex: 1;
}

.member-name {
  font-weight: 600;
  color: var(--text-heading);
  font-size: 13.5px;
}

.member-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.member-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================================
   Document Viewer Overlay (PDF, Office, Images, Texte)
   ============================================================================ */
.viewer-root {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 44, 0.92);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.viewer-bar {
  height: 62px;
  background: var(--navy-darker);
  color: #ffffff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(222, 202, 153, 0.25);
  flex-shrink: 0;
}

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

.viewer-doc-name {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-doc-meta {
  font-size: 12px;
  color: var(--text-on-dark-muted);
}

.viewer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.viewer-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition);
}

.viewer-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
}

.viewer-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.viewer-btn-gold {
  background: var(--gold-accent);
  color: var(--navy-darker);
  border-color: var(--gold-accent);
}

.viewer-btn-gold:hover {
  background: #d2ba82;
}

.viewer-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 18px;
}

.viewer-frame {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow-lg);
}

.viewer-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100%;
  min-height: 100%;
}

.viewer-image {
  max-width: 100%;
  max-height: calc(100vh - 110px);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  transition: transform 150ms ease;
  background: #ffffff;
}

.viewer-fallback {
  background: #ffffff;
  color: var(--text-main);
  padding: 36px 40px;
  border-radius: 14px;
  max-width: 460px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #ffffff;
  background: rgba(16, 24, 44, 0.78);
  z-index: 2;
}

/* ============================================================================
   Toasts
   ============================================================================ */
.toast-root {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  max-width: 380px;
}

.toast {
  background: var(--navy-darker);
  color: #ffffff;
  padding: 13px 16px;
  border-radius: 10px;
  border-left: 4px solid var(--gold-accent);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  line-height: 1.4;
  animation: slideUp 160ms ease;
}

.toast-success { border-left-color: #36b37e; }
.toast-error { border-left-color: #ef4444; background: #4a1521; }

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

/* ============================================================================
   Responsive
   ============================================================================ */
.mobile-only {
  display: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 44, 0.55);
  z-index: 35;
}

@media (max-width: 960px) {
  .auth-view {
    grid-template-columns: 1fr;
  }
  .auth-hero {
    display: none;
  }
  .mobile-only {
    display: inline-flex;
  }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-column {
    margin-left: 0;
  }
  .topbar {
    padding: 0 16px;
  }
  .main-content {
    padding: 18px 16px 40px;
  }
  .form-row-2, .member-add-row {
    grid-template-columns: 1fr;
  }
}
