/* ============================================================
   Aqsanova — Node.js port
   Design tokens keep the existing palette; layout, type scale,
   spacing and components are rebuilt for a cleaner interface.
   ============================================================ */

:root {
  /* Surfaces */
  --bg-base: #030303;
  --bg-primary: #080808;
  --bg-secondary: #101010;
  --bg-card: #121212;
  --bg-elevated: #1a1a1a;
  --bg-sidebar: #0b0b0b;
  --bg-header: rgba(10, 10, 10, 0.86);
  --bg-input: #171717;
  --bg-hover: rgba(255, 255, 255, 0.045);

  /* Text */
  --text-primary: #fafafa;
  --text-secondary: #a3a3a3;
  --text-muted: #6f6f6f;

  /* Accent + status (unchanged palette) */
  --accent: #00c4cf;
  --accent-hover: #2ad6e0;
  --accent-contrast: #04191b;
  --accent-soft: rgba(0, 196, 207, 0.12);
  --accent-line: rgba(0, 196, 207, 0.35);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.12);

  /* Lines */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-subtle: rgba(255, 255, 255, 0.05);

  /* Shape */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 9px;
  --radius-lg: 13px;
  --radius-xl: 18px;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  /* Layout */
  --sidebar-w: 264px;
  --sidebar-collapsed: 76px;
  --header-h: 64px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.55);
  --ring: 0 0 0 3px rgba(0, 196, 207, 0.22);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --speed: 160ms;

  /* Aliases for legacy component variables */
  --border-color: var(--border);
  --border-light: var(--border-subtle);
  --border-hover: var(--border-strong);
  --border-focus: var(--accent);
  --bg-surface: var(--bg-card);
  --bg-tertiary: var(--bg-elevated);
  --radius-card: var(--radius-lg);
  --radius-button: var(--radius);
  --radius-md: var(--radius);
  --radius-full: 9999px;
  --text-base: 14px;
  --font-semibold: 600;
  --font-bold: 700;
  --leading-normal: 1.5;
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
  --accent-light: var(--accent-soft);
  --accent-subtle: var(--accent-soft);
  --accent-glow: rgba(0, 196, 207, 0.3);
  --accent-strong: rgba(0, 196, 207, 0.25);
  --success-light: var(--success-soft);
  --warning-light: var(--warning-soft);
  --danger-light: var(--danger-soft);
  --error-light: var(--danger-soft);
  --info-light: var(--info-soft);
}

[data-theme='light'] {
  --bg-base: #f4f6fa;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.9);
  --bg-input: #f8fafc;
  --bg-hover: rgba(15, 23, 42, 0.04);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #7b8798;

  --accent: #00828b;
  --accent-hover: #006a72;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(0, 130, 139, 0.1);
  --accent-line: rgba(0, 130, 139, 0.35);

  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.1);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.09);
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.09);

  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.18);
  --border-subtle: rgba(15, 23, 42, 0.06);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.12);
  --ring: 0 0 0 3px rgba(0, 130, 139, 0.2);

  --border-color: var(--border);
  --border-light: var(--border-subtle);
  --border-hover: var(--border-strong);
  --bg-surface: var(--bg-card);
  --bg-tertiary: var(--bg-elevated);
  --accent-light: var(--accent-soft);
  --accent-subtle: var(--accent-soft);
  --success-light: var(--success-soft);
  --warning-light: var(--warning-soft);
  --danger-light: var(--danger-soft);
  --error-light: var(--danger-soft);
  --info-light: var(--info-soft);
}

/* ------------------------------------------------------------ Reset */

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

::selection { background: var(--accent-soft); color: var(--text-primary); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ------------------------------------------------------------ Utilities */

.muted { color: var(--text-secondary); }
.small { font-size: 12px; }
.capitalize { text-transform: capitalize; }
.align-right { text-align: right; }
.mt { margin-top: 16px; }
.link { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 13px; }
.disabled-link { opacity: 0.5; pointer-events: none; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.only-mobile { display: none !important; }

/* ------------------------------------------------------------ App shell */

.app-shell, .app-layout { display: flex; min-height: 100vh; }

.main, .main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--speed) var(--ease);
}

.content, .page-content {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  padding: 28px 32px 56px;
}

/* ------------------------------------------------------------ Sidebar */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  transition: width var(--speed) var(--ease), transform var(--speed) var(--ease);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: var(--header-h);
  padding: 0 20px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-brand:hover { color: var(--text-primary); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand-name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent);
}

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

.nav-section { display: flex; flex-direction: column; gap: 2px; }

.nav-label {
  padding: 0 12px 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}

.nav-item i { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}

.nav-item.is-soon {
  color: var(--text-muted);
  cursor: default;
  opacity: 0.72;
}

.nav-item.is-soon:hover { background: transparent; color: var(--text-muted); }

.soon {
  margin-left: auto;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 9px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  padding: 6px;
  border-radius: var(--radius);
}

.sidebar-user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.sidebar-user-text strong {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-text small {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collapse-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  transition: color var(--speed) var(--ease), border-color var(--speed) var(--ease);
}

.collapse-btn:hover { color: var(--text-primary); border-color: var(--border-strong); }
.collapse-btn i { width: 16px; height: 16px; }
.collapse-btn i { transition: transform var(--speed) var(--ease); }

body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }
body.sidebar-collapsed .main { margin-left: var(--sidebar-collapsed); }
body.sidebar-collapsed .brand-name,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-item span,
body.sidebar-collapsed .nav-item .soon,
body.sidebar-collapsed .sidebar-user-text { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
body.sidebar-collapsed .sidebar-nav { padding: 16px 10px; }
body.sidebar-collapsed .sidebar-user { justify-content: center; padding: 0; }
body.sidebar-collapsed .sidebar-footer { flex-direction: column; }
body.sidebar-collapsed .collapse-btn i { transform: rotate(180deg); }

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--speed) var(--ease);
}

/* ------------------------------------------------------------ Topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--header-h);
  padding: 0 24px;
  background: var(--bg-header);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 0;
}

.breadcrumbs a { color: var(--text-secondary); font-weight: 500; }
.breadcrumbs a:hover { color: var(--text-primary); }
.crumb-home { display: inline-flex; }
.crumb-home i, .crumb-sep { width: 14px; height: 14px; color: var(--text-muted); }
.crumb-current {
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.migration-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.migration-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn i { width: 18px; height: 18px; }

.icon-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  color: #fff;
  background: var(--danger, #ef4444);
  border-radius: 99px;
  border: 2px solid var(--bg-surface);
  pointer-events: none;
  animation: badgeBounce 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dropdown */

.dropdown { position: relative; }

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 8px 0 4px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: transparent;
  color: var(--text-primary);
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}

.user-menu-btn:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.user-menu-name { font-size: 13px; font-weight: 600; }
.user-menu-btn .chevron { width: 14px; height: 14px; color: var(--text-muted); }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 232px;
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 50;
}

.dropdown-menu.show { display: block; }

.dropdown-identity {
  display: flex;
  flex-direction: column;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
  line-height: 1.4;
}

.dropdown-identity strong { font-size: 13px; }
.dropdown-identity span { font-size: 12px; color: var(--text-muted); }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}

.dropdown-item i { width: 16px; height: 16px; }
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ------------------------------------------------------------ Page head */

.page-head, .page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-head h1, .page-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin: 0;
}

.page-sub, .page-subtitle, .page-title p, .page-head p, .page-header p {
  margin-top: 5px;
  font-size: 13.5px;
  color: var(--text-secondary);
  max-width: 720px;
  line-height: 1.5;
}

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

/* ------------------------------------------------------------ Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease),
    color var(--speed) var(--ease), transform var(--speed) var(--ease);
}

.btn i { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

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

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

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

.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-ghost.danger, .btn-ghost.danger:hover { color: var(--danger); }
.btn-ghost.danger:hover { background: var(--danger-soft); }

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

button.btn-icon,
a.btn-icon,
.btn-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  line-height: 1;
  outline: none;
  box-shadow: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  flex-shrink: 0;
}
button.btn-icon:hover,
a.btn-icon:hover,
.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border);
  transform: translateY(-1px);
}
button.btn-icon:active,
a.btn-icon:active,
.btn-icon:active {
  transform: scale(0.96);
}
.btn-icon i,
.btn-icon svg {
  width: 15px;
  height: 15px;
}
.btn-icon.danger:hover,
.btn-icon.text-danger:hover {
  background: var(--danger-soft);
  color: var(--danger) !important;
  border-color: rgba(239, 68, 68, 0.25);
}

/* ════════════════════════════════════════════════════════════
   MODERN FILES & ACTION ICONS (Anti-90s Clean SaaS Design)
   ════════════════════════════════════════════════════════════ */

/* File Star Toggle Button */
.file-star-btn {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 0 !important;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: transform 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
}
.file-star-btn:hover {
  transform: scale(1.18);
  color: var(--warning);
}
.file-star-btn.is-starred {
  color: var(--warning);
}
.file-star-btn.is-starred svg,
.file-star-btn.is-starred i {
  fill: var(--warning);
  color: var(--warning);
}

/* File Type Badges (Vibrant, high-tech icon badges) */
.file-type-badge {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent);
  border: 1px solid var(--border-subtle);
}
.file-type-badge i,
.file-type-badge svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

/* Specific format badge accents */
.file-badge-pdf {
  background: rgba(239, 68, 68, 0.12) !important;
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.25) !important;
}
.file-badge-doc, .file-badge-docx {
  background: rgba(59, 130, 246, 0.12) !important;
  color: #3b82f6 !important;
  border-color: rgba(59, 130, 246, 0.25) !important;
}
.file-badge-xls, .file-badge-xlsx, .file-badge-csv {
  background: rgba(16, 185, 129, 0.12) !important;
  color: #10b981 !important;
  border-color: rgba(16, 185, 129, 0.25) !important;
}
.file-badge-jpg, .file-badge-jpeg, .file-badge-png, .file-badge-gif, .file-badge-webp, .file-badge-svg {
  background: rgba(168, 85, 247, 0.12) !important;
  color: #a855f7 !important;
  border-color: rgba(168, 85, 247, 0.25) !important;
}
.file-badge-zip, .file-badge-rar, .file-badge-7z, .file-badge-tar {
  background: rgba(245, 158, 11, 0.12) !important;
  color: #f59e0b !important;
  border-color: rgba(245, 158, 11, 0.25) !important;
}
.file-badge-code, .file-badge-js, .file-badge-ts, .file-badge-html, .file-badge-css, .file-badge-json {
  background: rgba(0, 196, 207, 0.12) !important;
  color: #00c4cf !important;
  border-color: rgba(0, 196, 207, 0.25) !important;
}

/* ------------------------------------------------------------ Modern File Manager Design */

.files-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.storage-meta-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.storage-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  background: rgba(0, 196, 207, 0.08);
  border: 1px solid rgba(0, 196, 207, 0.2);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 500;
}

.storage-pill i,
.storage-pill svg {
  width: 13px;
  height: 13px;
}

.storage-pill strong {
  font-weight: 700;
  color: var(--text-primary);
}

.storage-dot {
  opacity: 0.35;
}

.files-search-card {
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.files-search-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.files-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 2;
}

.files-search-input {
  width: 100% !important;
  height: 40px !important;
  padding: 0 14px 0 38px !important;
  font-size: 13.5px !important;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  box-sizing: border-box !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.files-search-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-subtle, rgba(0, 196, 207, 0.15));
}

.files-search-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Files Table Card & Header */
.files-table-card {
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.files-card-head {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.files-card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.files-head-icon {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.files-card-title-group h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.files-badge-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.files-current-folder-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 3px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
}

.files-current-folder-chip i,
.files-current-folder-chip svg {
  width: 14px;
  height: 14px;
}

/* Strict Table Layout & Perfect Column Alignment */
.files-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.files-table th {
  padding: 12px 18px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}

.files-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

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

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

/* Column Widths & Mathematical Alignment */
.files-table .col-name {
  width: auto;
  min-width: 220px;
  text-align: left !important;
}

.files-table .col-size {
  width: 105px;
  text-align: left !important;
}

.files-table .col-ext {
  width: 105px;
  text-align: left !important;
}

.files-table .col-date {
  width: 135px;
  text-align: left !important;
}

.files-table .col-actions {
  width: 180px;
  text-align: right !important;
}

.files-table th.col-actions,
.files-table td.col-actions {
  text-align: right !important;
}

/* File Name Cell Elements */
.file-name-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.file-star-form {
  margin: 0;
  display: inline-flex;
  flex-shrink: 0;
}

.file-star-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, color 0.15s ease;
}

.file-star-btn:hover {
  transform: scale(1.15);
  color: #f59e0b;
}

.file-star-btn i,
.file-star-btn svg {
  width: 15px;
  height: 15px;
}

.file-star-btn.is-starred {
  color: #f59e0b;
}

.file-star-btn.is-starred i,
.file-star-btn.is-starred svg {
  fill: #f59e0b;
}

/* File Type Badges (Refined, Modern & Uncluttered) */
.file-type-badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: transform 0.15s ease;
}

.file-type-badge i,
.file-type-badge svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.85;
}

.file-name-cell:hover .file-type-badge {
  transform: scale(1.04);
}

.file-info-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  gap: 2px;
}

.file-title-link {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s ease;
}

.file-title-link:hover {
  color: var(--accent);
}

.file-desc-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size-cell {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono, monospace);
}

.file-date-cell {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.file-ext-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Individual Sleek Action Micro-Buttons (NO clunky box wrapper) */
.file-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.inline-action-form {
  margin: 0;
  display: inline-flex;
}

.action-btn-item {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  transition: all 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.action-btn-item i,
.action-btn-item svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.8;
}

.action-btn-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.action-btn-item.action-preview:hover {
  background: rgba(0, 196, 207, 0.12) !important;
  color: var(--accent) !important;
  border-color: rgba(0, 196, 207, 0.35) !important;
}

.action-btn-item.action-download:hover {
  background: rgba(59, 130, 246, 0.12) !important;
  color: #3b82f6 !important;
  border-color: rgba(59, 130, 246, 0.35) !important;
}

.action-btn-item.action-share:hover {
  background: rgba(168, 85, 247, 0.12) !important;
  color: #a855f7 !important;
  border-color: rgba(168, 85, 247, 0.35) !important;
}

.action-btn-item.action-delete:hover {
  background: rgba(239, 68, 68, 0.12) !important;
  color: var(--danger) !important;
  border-color: rgba(239, 68, 68, 0.35) !important;
}

/* Responsiveness */
@media (max-width: 900px) {
  .files-table .col-ext {
    display: none;
  }
  .files-table .col-size {
    width: 95px;
  }
  .files-table .col-date {
    width: 125px;
  }
  .files-table .col-actions {
    width: 175px;
  }
}

@media (max-width: 680px) {
  .files-page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .files-head-actions {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .files-head-actions .btn {
    width: 100% !important;
    justify-content: center !important;
    height: 40px !important;
    font-size: 13px !important;
  }
  .files-head-actions .btn-primary {
    grid-column: span 2 !important;
    order: -1 !important;
  }
  .files-search-card {
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 12px !important;
  }
  .files-search-input-wrap {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  .files-search-actions {
    width: auto !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }
  .files-search-actions .btn {
    height: 40px !important;
    padding: 0 14px !important;
    white-space: nowrap !important;
  }
  .files-table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
  }
  .files-table .col-ext,
  .files-table .col-date {
    display: none !important;
  }
  .files-table .col-size {
    width: 65px !important;
    text-align: right !important;
    font-size: 11.5px !important;
    padding: 8px 6px !important;
  }
  .files-table .col-actions {
    width: 115px !important;
    text-align: right !important;
    padding-right: 8px !important;
  }
  .files-table .file-name-cell {
    min-width: 0 !important;
    max-width: 100% !important;
  }
  .files-table .file-info-stack {
    min-width: 0 !important;
    overflow: hidden !important;
  }
  .files-table .file-title-link {
    display: block !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  .action-btn-item {
    width: 28px;
    height: 28px;
    border-radius: 6px;
  }
  .action-btn-item i,
  .action-btn-item svg {
    width: 13px;
    height: 13px;
  }
  .file-actions-group {
    gap: 4px;
  }
}

@media (max-width: 440px) {
  .files-table .col-size {
    display: none !important;
  }
  .files-table .col-actions {
    width: 105px !important;
  }
}

/* Breadcrumb Navigation Bar */
.files-breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.files-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.files-back-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0, 196, 207, 0.08);
}

.files-back-btn i,
.files-back-btn svg {
  width: 14px;
  height: 14px;
}

.files-breadcrumb-sep {
  color: var(--text-muted);
  opacity: 0.5;
  font-size: 13px;
}

.files-folder-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.files-folder-title i,
.files-folder-title svg {
  width: 22px;
  height: 22px;
}

/* Universal Table Action & Alignment Utilities */
.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.tar { text-align: right !important; }
.tal { text-align: left !important; }
.tac { text-align: center !important; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------ Cards */

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

.card:last-child { margin-bottom: 0; }
.card-flush { padding: 0; overflow: hidden; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head.padded { padding: 18px 20px 0; margin-bottom: 12px; }

.card-head h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.grid-2 > .card { margin-bottom: 0; }
.grid-2.align-start { align-items: start; }

/* Stat cards */

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

.stat {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.stat-icon i { width: 19px; height: 19px; }
.tone-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.tone-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tone-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.tone-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.tone-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tone-neutral { background: var(--bg-hover); color: var(--text-secondary); }

.stat-body, .stat-meta { display: flex; flex-direction: column; min-width: 0; }

.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  margin-top: 3px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-value small { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.stat-hint { margin-top: 3px; font-size: 12px; color: var(--text-secondary); }

/* ------------------------------------------------------------ Tables */

.table-wrap, .table-container { width: 100%; overflow-x: auto; }

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

.table th, .data-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td, .data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.table tbody tr:last-child td, .data-table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover, .data-table tbody tr:hover { background: var(--bg-hover); }
.table .align-right, .data-table .align-right { text-align: right; }

.cell-strong { display: block; font-weight: 600; color: var(--text-primary); }
.data-table small { display: block; margin-top: 2px; font-size: 11.5px; }

.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person-text { display: flex; flex-direction: column; min-width: 0; }
.person-text a { color: var(--text-primary); font-weight: 600; }
.person-text a:hover { color: var(--accent); }
.person-text small { color: var(--text-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
}

.avatar-initials { background: var(--accent-soft); color: var(--accent); }
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.avatar-xl { width: 72px; height: 72px; font-size: 22px; border-radius: 18px; }

.badge-row { display: flex; flex-wrap: wrap; gap: 5px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.5;
}

.badge i { width: 11px; height: 11px; }
.badge-neutral { background: var(--bg-hover); color: var(--text-secondary); border-color: var(--border); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }

[data-theme='light'] .badge-success { color: #047857; }
[data-theme='light'] .badge-warning { color: #b45309; }
[data-theme='light'] .badge-danger { color: #b91c1c; }
[data-theme='light'] .badge-info { color: #1d4ed8; }

.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.row-actions form { margin: 0; display: inline-flex; }

.progress {
  width: 100%;
  height: 6px;
  margin-top: 6px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}

.progress span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.progress-sm { height: 4px; width: 110px; margin-top: 5px; }
.progress-lg { height: 9px; margin: 10px 0 8px; }

.amount-positive { color: var(--success); }
.amount-pending { color: var(--warning); }

/* Pagination */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.pagination-info { font-size: 12.5px; color: var(--text-secondary); }
.pagination-info strong { color: var(--text-primary); font-weight: 600; }
.pagination-links { display: flex; align-items: center; gap: 4px; }

.page-btn {
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  background: var(--bg-card);
}

.page-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.page-btn.is-disabled { opacity: 0.35; pointer-events: none; }
.page-btn i { width: 14px; height: 14px; }
.page-gap { padding: 0 4px; color: var(--text-muted); }

/* ------------------------------------------------------------ Filters + forms */

.filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.filters .grow { flex: 2 1 220px; }
.filters .field { flex: 1 1 150px; }
.filter-actions { display: flex; gap: 6px; padding-bottom: 1px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label,
.label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-hint { font-size: 11.5px; color: var(--text-muted); }
.req { color: var(--accent); }

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='search'],
input[type='tel'],
input[type='url'],
textarea {
  font-family: inherit;
  width: 100%;
  height: 40px;
  padding: 0 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13.5px;
  box-sizing: border-box;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease),
    background var(--speed) var(--ease);
}

textarea { height: auto; padding: 10px 11px; resize: vertical; line-height: 1.55; }

select {
  font-family: inherit;
  width: 100%;
  height: 42px;
  min-height: 42px;
  padding: 0 36px 0 14px !important;
  line-height: normal !important;
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239494b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-position: right 14px center;
  background-size: 16px 16px;
  background-repeat: no-repeat;
  cursor: pointer;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease),
    background-color var(--speed) var(--ease);
}

select:hover {
  background-color: var(--bg-input-focus, var(--bg-card));
  border-color: var(--border-hover, var(--border));
}

select option {
  background: #111822;
  color: #f1f5f9;
}

[data-theme="light"] select option {
  background: #ffffff;
  color: #0f172a;
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background-color: var(--bg-card);
}

input.is-invalid, select.is-invalid, textarea.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

input:disabled, select:disabled, textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.field-error { font-size: 12px; color: var(--danger); }

.input-icon { position: relative; }
.input-icon > i {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-icon input { padding-left: 34px; }

.input-with-action { position: relative; }
.input-with-action input { padding-right: 40px; }

.input-action {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
}

.input-action:hover { color: var(--text-primary); background: var(--bg-hover); }
.input-action i { width: 16px; height: 16px; }

.checkbox {
  display: inline-flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-card {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  margin-bottom: 14px;
}

.form-stack { display: flex; flex-direction: column; gap: 20px; }

.form-section { margin-bottom: 0; }

.form-section-head { margin-bottom: 18px; }
.form-section-head h2 { font-size: 15px; font-weight: 650; }
.form-section-head p { margin-top: 4px; font-size: 12.5px; color: var(--text-secondary); }

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

.form-grid .span-2 { grid-column: span 2; }

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 4px 0;
}

.form-actions.inline { padding-top: 6px; }

.narrow { max-width: 620px; }

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

.option-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}

.option-card:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.option-card input { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }
.option-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.option-body strong { font-size: 13px; }
.option-body small { font-size: 11.5px; color: var(--text-muted); }

.option-card:has(input:checked) {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* Permission matrix */

.perm-matrix { display: flex; flex-direction: column; gap: 8px; }
.perm-matrix[data-disabled] { opacity: 0.55; }

.perm-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-secondary);
}

.perm-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  list-style: none;
}

.perm-group summary::-webkit-details-marker { display: none; }
.perm-group summary::before {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(-45deg);
  margin-right: 2px;
  transition: transform var(--speed) var(--ease);
}

.perm-group[open] summary::before { transform: rotate(45deg); }
.perm-group summary > span:first-child { flex: 1; margin-right: auto; margin-left: 4px; }

.perm-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 16px;
  padding: 4px 14px 12px;
  border-top: 1px solid var(--border-subtle);
}

.perm-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: 12.5px;
}

.perm-item span:nth-of-type(1) { display: flex; flex-direction: column; flex: 1; }
.perm-item strong { font-weight: 500; color: var(--text-primary); font-size: 12.5px; }
.perm-item small { color: var(--text-muted); font-size: 11px; font-family: var(--font-mono); }
.perm-item .badge { margin-left: auto; }

.perm-summary { margin-bottom: 10px; }
.perm-module {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ------------------------------------------------------------ Dashboard bits */

.timeline { display: flex; flex-direction: column; gap: 2px; }

.timeline li {
  display: flex;
  gap: 11px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.timeline li:last-child { border-bottom: 0; padding-bottom: 0; }

.timeline-dot {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.timeline-dot i { width: 13px; height: 13px; }
.timeline-body { display: flex; flex-direction: column; min-width: 0; }
.timeline-body strong { font-size: 12.5px; font-weight: 500; }
.timeline-body small { font-size: 11px; color: var(--text-muted); }

.list { display: flex; flex-direction: column; }

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.list-row:last-child { border-bottom: 0; padding-bottom: 0; }
.list-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.list-main strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-main small { font-size: 11.5px; color: var(--text-muted); }

.file-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

.storage-value { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.storage-value .muted { font-size: 12.5px; font-weight: 500; letter-spacing: 0; }

.detail-list { display: flex; flex-direction: column; }

.detail-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12.5px;
}

.detail-list > div:last-child { border-bottom: 0; }
.detail-list span { color: var(--text-muted); }
.detail-list strong { font-weight: 600; text-align: right; }

.mini-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  transition: border-color var(--speed) var(--ease), transform var(--speed) var(--ease);
}

.mini-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.mini-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.mini-card h3 { font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 5px; }
.mini-card h3 a { color: var(--text-primary); }
.mini-card h3 a:hover { color: var(--accent); }
.mini-card p {
  font-size: 12.5px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}

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

.team-card { min-height: 170px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 44px 20px;
}

.empty-state i { width: 34px; height: 34px; color: var(--text-muted); opacity: 0.6; }
.empty-state h3 { margin-top: 4px; font-size: 14px; font-weight: 650; }
.empty-state p { font-size: 12.5px; color: var(--text-secondary); max-width: 420px; }
.empty-state .btn { margin-top: 10px; }
.empty-state.compact { padding: 28px 16px; }
.empty-state.compact i { width: 26px; height: 26px; }

/* Profile */

.profile-card { display: flex; flex-direction: column; gap: 16px; }

.profile-main { display: flex; align-items: center; gap: 16px; }
.profile-main h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 3px; }
.profile-main .muted { font-size: 13px; margin-bottom: 8px; }

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.profile-meta a, .profile-meta span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.profile-meta a:hover { color: var(--accent); }
.profile-meta i { width: 14px; height: 14px; color: var(--text-muted); }

.note-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-line;
}

/* ------------------------------------------------------------ Toasts (Pop down from Top Center) */

.toast-stack {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999998;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card, #13171f);
  background: rgba(18, 22, 28, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius, 10px);
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08);
  font-size: 13px;
  color: var(--text-primary, #f1f5f9);
  pointer-events: auto;
  animation: toast-in 280ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast:hover {
  transform: translateY(2px);
  box-shadow: 0 20px 40px -4px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.toast i { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.toast span { flex: 1; line-height: 1.45; }
.toast-success { border-left-color: var(--success, #10b981); }
.toast-success > i { color: var(--success, #10b981); }
.toast-error { border-left-color: var(--danger, #ef4444); }
.toast-error > i { color: var(--danger, #ef4444); }
.toast-warning { border-left-color: var(--warning, #f59e0b); }
.toast-warning > i { color: var(--warning, #f59e0b); }
.toast-info { border-left-color: var(--info, #00c4cf); }
.toast-info > i { color: var(--info, #00c4cf); }

.toast-close {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 0;
  border-radius: var(--radius-xs, 4px);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.toast-close:hover { background: rgba(255, 255, 255, 0.12); color: var(--text-primary); }
.toast-close i { width: 13px; height: 13px; margin: 0; }

@keyframes toast-in {
  0% {
    opacity: 0;
    transform: translateY(-28px) scale(0.94);
  }
  65% {
    transform: translateY(3px) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ------------------------------------------------------------ Real-time Minimal Live Notification Pills (Top Center) */
.live-mail-pill-stack {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: auto;
  max-width: calc(100vw - 32px);
}

.live-mail-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 8px;
  background: var(--bg-card, #13171f);
  background: rgba(18, 22, 28, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 28px -4px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 195, 207, 0.25);
  border-radius: 9999px;
  font-size: 12.5px;
  color: var(--text-primary, #f1f5f9);
  cursor: pointer;
  user-select: none;
  animation: liveMailPillIn 300ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: min(460px, calc(100vw - 32px));
}

.live-mail-pill:hover {
  transform: translateY(2px) scale(1.015);
  border-color: rgba(0, 195, 207, 0.45);
  box-shadow: 0 14px 32px -4px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 195, 207, 0.4);
}

.live-mail-pill.is-leaving {
  opacity: 0;
  transform: translateY(-24px) scale(0.92);
  pointer-events: none;
}

.live-mail-pill-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00c3cf 0%, #0284c7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 195, 207, 0.35);
}

.live-mail-pill-content {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.live-mail-pill-sender {
  font-weight: 700;
  color: var(--text-primary, #ffffff);
  white-space: nowrap;
  font-size: 12.5px;
}

.live-mail-pill-dot {
  color: var(--text-muted, #64748b);
  font-size: 11px;
}

.live-mail-pill-subject {
  color: var(--text-secondary, #94a3b8);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.live-mail-pill-close {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: transparent;
  border: 0;
  color: var(--text-muted, #94a3b8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 2px;
  transition: all 0.15s ease;
}

.live-mail-pill-close:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

@keyframes liveMailPillIn {
  0% {
    opacity: 0;
    transform: translateY(-28px) scale(0.92);
  }
  65% {
    transform: translateY(3px) scale(1.015);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Sidebar Nav Badges */
.sidebar-nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 9999px;
  background: rgba(0, 195, 207, 0.16);
  color: #00c4cf;
  border: 1px solid rgba(0, 195, 207, 0.35);
  line-height: 1.4;
  letter-spacing: -0.01em;
}

[data-theme="light"] .sidebar-nav-badge {
  background: rgba(0, 195, 207, 0.12);
  color: #0284c7;
  border-color: rgba(2, 132, 199, 0.3);
}

/* Light mode for live pills */
[data-theme="light"] .live-mail-pill {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(15, 23, 42, 0.12);
  color: #0f172a;
  box-shadow: 0 10px 28px -4px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(0, 195, 207, 0.3);
}

[data-theme="light"] .live-mail-pill:hover {
  border-color: rgba(0, 195, 207, 0.5);
  box-shadow: 0 14px 32px -4px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(0, 195, 207, 0.45);
}

[data-theme="light"] .live-mail-pill-sender {
  color: #0f172a;
}

[data-theme="light"] .live-mail-pill-subject {
  color: #475569;
}

[data-theme="light"] .live-mail-pill-close {
  color: #64748b;
}

[data-theme="light"] .live-mail-pill-close:hover {
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

/* ------------------------------------------------------------ Modal */

.modal-backdrop {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 10000 !important;
  display: none;
  align-items: center !important;
  justify-content: center !important;
  padding: 24px 16px !important;
  background: rgba(10, 15, 26, 0.78) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  box-sizing: border-box !important;
}

.modal-backdrop[hidden],
.modal-backdrop:not(.show):not([style*="display: flex"]):not(#confirm-modal) {
  display: none !important;
}

.modal-backdrop.show,
.modal-backdrop[style*="display: flex"],
#confirm-modal:not([hidden]) {
  display: flex !important;
}

.modal {
  width: 100% !important;
  max-width: 520px;
  max-height: min(90vh, calc(100vh - 48px)) !important;
  margin: auto !important;
  position: relative !important;
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
  overflow: hidden !important;
  background: var(--bg-card, #111822) !important;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.14)) !important;
  border-radius: var(--radius-xl, 14px) !important;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08) !important;
  display: flex !important;
  flex-direction: column !important;
  box-sizing: border-box !important;
}

.modal-head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  padding: 16px 18px !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  flex-shrink: 0 !important;
}

.modal-head h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 650; margin: 0; }
.modal-head h2 i { width: 17px; height: 17px; color: var(--warning); }

.modal-body { 
  padding: 20px 24px !important; 
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
}
.modal-body p { font-size: 13px; line-height: 1.6; color: var(--text-secondary); }

.modal-actions {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
  padding: 14px 20px !important;
  border-top: 1px solid var(--border-subtle) !important;
  flex-shrink: 0 !important;
}

/* ------------------------------------------------------------ Auth */

.auth-body { background: var(--bg-base); }

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100vh;
}

.auth-showcase {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 48px;
  overflow: hidden;
  background:
    radial-gradient(600px 400px at 8% 12%, var(--accent-soft), transparent 70%),
    radial-gradient(500px 380px at 100% 100%, rgba(139, 92, 246, 0.09), transparent 70%),
    var(--bg-primary);
  border-right: 1px solid var(--border);
}

.auth-showcase::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--border-subtle) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-subtle) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 30% 30%, #000 0, transparent 75%);
  pointer-events: none;
}

.auth-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  font-size: 16px;
  z-index: 1;
}

.auth-copy { position: relative; z-index: 1; max-width: 520px; }

.auth-copy h1 {
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.035em;
  font-weight: 700;
  margin-bottom: 14px;
}

.auth-copy > p {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 440px;
}

.auth-points { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }

.auth-points li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-points i {
  width: 28px;
  height: 28px;
  padding: 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--accent);
  flex-shrink: 0;
}

.auth-showcase-foot {
  position: relative;
  z-index: 1;
  font-size: 11.5px;
  color: var(--text-muted);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 40px 24px;
}

.auth-card {
  width: min(400px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 30px;
  box-shadow: var(--shadow-md);
}

.auth-head { margin-bottom: 22px; }

.auth-eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.auth-head h2 { font-size: 21px; font-weight: 700; letter-spacing: -0.025em; }
.auth-head p { margin-top: 5px; font-size: 13px; color: var(--text-secondary); }

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

.auth-help {
  display: flex;
  gap: 8px;
  padding-top: 4px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.auth-help i { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }
.auth-foot { font-size: 11.5px; color: var(--text-muted); }

/* ------------------------------------------------------------ Error page */

.blank-body { display: grid; place-items: center; padding: 24px; }

.error-page {
  width: min(560px, 100%);
  text-align: center;
  padding: 40px 24px;
}

.error-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--accent);
}

.error-icon i { width: 24px; height: 24px; }
.error-code { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; color: var(--text-muted); }
.error-page h1 { margin: 8px 0; font-size: 26px; letter-spacing: -0.03em; }
.error-page p { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; }
.error-actions { display: flex; justify-content: center; gap: 8px; margin-top: 22px; flex-wrap: wrap; }

.error-stack {
  margin-top: 18px;
  padding: 14px;
  max-height: 280px;
  overflow: auto;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ------------------------------------------------------------ Mobile nav */

.mobile-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 45;
  display: none;
  align-items: center;
  justify-content: space-around;
  height: 58px;
  padding: 0 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}

.mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1;
  padding: 7px 0;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
}

.mobile-nav a i { width: 18px; height: 18px; }
.mobile-nav a.active { color: var(--accent); background: var(--accent-soft); }

.mobile-nav-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mobile-nav-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  background: var(--danger, #ef4444);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  border-radius: 9999px;
  box-shadow: 0 0 0 1.5px var(--bg-card);
}

/* ------------------------------------------------------------ Responsive */

@media (max-width: 1180px) {
  .hide-lg { display: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }

  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
  body.sidebar-collapsed .main { margin-left: 0; }
  body.sidebar-collapsed .brand-name,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .nav-item span,
  body.sidebar-collapsed .nav-item .soon,
  body.sidebar-collapsed .sidebar-user-text { display: initial; }
  body.sidebar-collapsed .sidebar-brand { justify-content: flex-start; padding: 0 20px; }
  body.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 0 12px; }
  body.sidebar-collapsed .sidebar-footer { flex-direction: row; }
  body.sidebar-collapsed .collapse-btn { display: none; }

  .only-mobile { display: inline-flex !important; }
  .hide-md { display: none; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-showcase { display: none; }
  .migration-chip { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 22px 20px 48px; }
}

@media (max-width: 760px) {
  .page-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .page-head h1 { font-size: 22px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat { padding: 14px; gap: 11px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-icon i { width: 16px; height: 16px; }
  .stat-value { font-size: 20px; }

  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .perm-list { grid-template-columns: 1fr; }
  .hide-sm { display: none; }

  .toast-stack {
    top: 14px;
    bottom: auto;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    width: min(440px, calc(100vw - 24px));
    align-items: center;
  }

  .live-mail-pill-stack {
    top: 14px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    max-width: calc(100vw - 24px);
    align-items: center;
  }

  .topbar { padding: 0 14px; gap: 8px; }
  .user-menu-name { display: none; }
  .user-menu-btn .chevron { display: none; }
  .user-menu-btn { padding: 0 4px; }

  .content { padding: 18px 14px 96px; }
  .card { padding: 16px; }

  .mobile-nav { display: flex; }

  .filters { flex-direction: column; align-items: stretch; }
  .filter-actions { width: 100%; }
  .filter-actions .btn-primary { flex: 1; }

  .profile-main { align-items: flex-start; }
  .avatar-xl { width: 60px; height: 60px; font-size: 18px; }

  .pagination { flex-direction: column; align-items: flex-start; gap: 10px; }

  /* Smooth touch scrolling */
  .table-wrap, .table-container, .board {
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent iOS Safari auto-zoom on inputs */
  input[type='text'],
  input[type='email'],
  input[type='password'],
  input[type='number'],
  input[type='search'],
  input[type='tel'],
  input[type='url'],
  select,
  textarea {
    font-size: 16px !important;
  }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .page-actions:not(.files-head-actions) { flex-direction: column; }
  .page-actions:not(.files-head-actions) .btn { width: 100%; }
  .auth-card { padding: 22px; }
  .auth-panel { padding: 24px 14px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------ Projects & tasks */

[hidden] { display: none !important; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  margin-bottom: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.filter-bar select { width: auto; min-width: 140px; }
.filter-bar .filter-search, .filter-bar .search-input { position: relative; flex: 1 1 260px; display: flex; align-items: center; }
.filter-bar .filter-search input, .filter-bar .search-input input { width: 100%; padding-left: 36px; }
.filter-bar .filter-search i, .filter-bar .search-input i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}
.filter-bar .grow, .search-input.grow { flex: 1 1 260px; }

.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  font-size: 13px;
  color: var(--text-secondary);
}

.notice i { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.notice-info { background: var(--info-soft); border-color: rgba(59, 130, 246, 0.3); }
.notice-info i { color: var(--info); }
.notice strong { display: block; color: var(--text-primary); margin-bottom: 2px; }

.muted-copy { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }

/* ═════════════════════════════════════════════════════════════════
   Modern Projects Filter Hub & Ultra-Refined Project Cards
   ══════════════════════════════════════════════════════════════════ */

/* Filter Hub Wrapper */
.projects-filter-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 14px);
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: 0 4px 20px -3px rgba(0, 0, 0, 0.35);
}

/* Status Quick Tabs */
.projects-status-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.18);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: none;
}

.projects-status-tabs::-webkit-scrollbar {
  display: none;
}

.p-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  cursor: pointer;
}

.p-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.p-tab.active {
  color: var(--text-primary);
  background: rgba(0, 196, 207, 0.12);
  border-color: rgba(0, 196, 207, 0.3);
}

.p-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.p-tab.active .p-tab-count {
  background: var(--accent);
  color: #06111e;
}

.p-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.p-status-dot.active {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: pPulse 2s infinite ease-in-out;
}

.p-status-dot.planning {
  background: #38bdf8;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
}

.p-status-dot.on_hold {
  background: #f59e0b;
}

.p-status-dot.completed {
  background: #a855f7;
}

@keyframes pPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.9); }
}

/* Toolbar: Search input + Select pills */
.projects-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  flex-wrap: wrap;
}

.p-search-box {
  position: relative;
  flex: 1 1 280px;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  transition: all 0.18s ease;
}

.p-search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 196, 207, 0.15);
  background: rgba(0, 0, 0, 0.45);
}

.p-search-box input {
  width: 100%;
  height: 38px;
  padding: 0 40px 0 38px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13.5px;
  outline: none;
}

.p-search-box input::placeholder {
  color: var(--text-muted);
}

.p-search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.15s ease;
}

.p-search-box:focus-within .p-search-icon {
  color: var(--accent);
}

.p-search-clear {
  position: absolute;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.p-search-clear:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-primary);
}

.p-filters-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.p-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  height: 38px;
  min-height: 38px;
  box-sizing: border-box;
  transition: all 0.15s ease;
  overflow: hidden;
}

.p-select-wrap:hover,
.p-select-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle, rgba(0, 196, 207, 0.14));
}

.p-select-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 2;
}

.p-select-chevron {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 2;
}

.p-select-wrap select {
  position: relative;
  z-index: 1;
  width: 100% !important;
  height: 100% !important;
  min-height: 36px !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  outline: none !important;
  color: var(--text-primary) !important;
  font-family: inherit !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  padding: 0 32px 0 34px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

.p-select-wrap select option {
  background: var(--bg-card, #111a2e);
  color: var(--text-primary, #ffffff);
}

.p-clear-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 38px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(0, 196, 207, 0.08);
  border: 1px solid rgba(0, 196, 207, 0.22);
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
}

.p-clear-btn:hover {
  background: rgba(0, 196, 207, 0.16);
  border-color: var(--accent);
}

.p-clear-btn i {
  width: 13px;
  height: 13px;
}

@media (max-width: 768px) {
  .projects-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 10px !important;
  }
  .p-search-box {
    width: 100% !important;
    flex: 1 1 100% !important;
  }
  .p-filters-group {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .p-filters-group .p-select-wrap {
    width: 100% !important;
    height: 42px !important;
    min-height: 42px !important;
  }
  .p-filters-group .p-select-wrap:nth-child(3) {
    grid-column: span 2 !important;
  }
  .p-clear-btn {
    grid-column: span 2 !important;
    height: 40px !important;
    justify-content: center !important;
  }
}

@media (max-width: 440px) {
  .p-filters-group {
    grid-template-columns: 1fr !important;
  }
  .p-filters-group .p-select-wrap:nth-child(3) {
    grid-column: auto !important;
  }
  .p-clear-btn {
    grid-column: auto !important;
  }
}

/* Active Search Result Bar */
.p-results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ═════════════════════════════════════════════════════════════════
   Project Grid & Ultra-Premium Cards
   ══════════════════════════════════════════════════════════════════ */

/* ════════════════════════════════════════════════════════════
   MINIMAL PROFESSIONAL PROJECT CARDS (Clean SaaS Architecture)
   ════════════════════════════════════════════════════════════ */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 18px;
}

.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  background: linear-gradient(180deg, rgba(22, 28, 38, 0.7) 0%, rgba(14, 18, 25, 0.95) 100%);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-xl, 16px);
  padding: 20px 22px 18px;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.35);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.22s ease,
              box-shadow 0.22s ease;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--project-colour, var(--accent)) 50%, transparent 100%);
  opacity: 0.45;
  transition: opacity 0.25s ease, height 0.25s ease;
}

.project-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.project-card:hover::before {
  opacity: 1;
  height: 3px;
}

[data-theme="light"] .project-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .project-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 14px 30px -6px rgba(15, 23, 42, 0.09);
}

/* Card Header */
.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.project-card-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

/* Color-Tinted Project Monogram Badge */
.project-monogram-badge {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  letter-spacing: -0.01em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.project-card:hover .project-monogram-badge {
  transform: scale(1.05);
}

.project-card-titles {
  min-width: 0;
  flex: 1;
}

.project-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin: 0 0 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
  transition: color 0.15s ease;
}

.project-card:hover .project-title {
  color: var(--accent);
}

.project-client-sub {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.project-client-sub svg,
.project-client-sub i {
  width: 12px !important;
  height: 12px !important;
  flex-shrink: 0;
  opacity: 0.7;
}

/* Minimal Status Pill */
.project-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.project-status-pill .status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.project-status-pill.status-active {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.project-status-pill.status-active .status-dot {
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.project-status-pill.status-planning {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
}
.project-status-pill.status-planning .status-dot {
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

.project-status-pill.status-on_hold {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.25);
}
.project-status-pill.status-on_hold .status-dot {
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
}

.project-status-pill.status-completed {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.25);
}
.project-status-pill.status-completed .status-dot {
  background: #c084fc;
  box-shadow: 0 0 6px #c084fc;
}

.project-status-pill.status-cancelled,
.project-status-pill.status-archived {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.project-status-pill.status-cancelled .status-dot,
.project-status-pill.status-archived .status-dot {
  background: #94a3b8;
}

/* Light mode adjustments for status pills */
[data-theme="light"] .project-status-pill.status-active { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
[data-theme="light"] .project-status-pill.status-planning { color: #0369a1; background: #f0f9ff; border-color: #bae6fd; }
[data-theme="light"] .project-status-pill.status-on_hold { color: #b45309; background: #fffbeb; border-color: #fde68a; }
[data-theme="light"] .project-status-pill.status-completed { color: #6d28d9; background: #f5f3ff; border-color: #ddd6fe; }
[data-theme="light"] .project-status-pill.status-cancelled,
[data-theme="light"] .project-status-pill.status-archived { color: #475569; background: #f8fafc; border-color: #e2e8f0; }

/* Description */
.project-card-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 14px;
  min-height: 38px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card-desc.is-empty {
  color: var(--text-muted);
  opacity: 0.65;
  font-style: italic;
}

/* Minimal SaaS Metadata Pills Row */
.project-meta-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.project-pill {
  display: inline-flex;
  align-items: center;
  gap: 4.5px;
  padding: 3px 8.5px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
}

.project-pill svg,
.project-pill i {
  width: 11px !important;
  height: 11px !important;
  flex-shrink: 0;
  opacity: 0.85;
}

.project-pill .pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.project-pill.priority-critical {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.project-pill.priority-critical .pill-dot { background: #ef4444; }

.project-pill.priority-high {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}
.project-pill.priority-high .pill-dot { background: #f59e0b; }

.project-pill.priority-medium {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.2);
}
.project-pill.priority-medium .pill-dot { background: #3b82f6; }

.project-pill.priority-low {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.project-pill.priority-low .pill-dot { background: #94a3b8; }

.project-pill.pill-neutral {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.project-pill.pill-role {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .project-pill.pill-neutral {
  background: rgba(15, 23, 42, 0.04);
  color: var(--text-secondary);
  border-color: rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .project-pill.pill-role {
  background: rgba(15, 23, 42, 0.025);
  color: var(--text-muted);
  border-color: rgba(15, 23, 42, 0.05);
}

/* Light mode adjustments for priority pills */
[data-theme="light"] .project-pill.priority-critical { color: #dc2626; background: #fef2f2; border-color: #fecaca; }
[data-theme="light"] .project-pill.priority-high { color: #d97706; background: #fffbeb; border-color: #fde68a; }
[data-theme="light"] .project-pill.priority-medium { color: #2563eb; background: #eff6ff; border-color: #bfdbfe; }
[data-theme="light"] .project-pill.priority-low { color: #64748b; background: #f8fafc; border-color: #e2e8f0; }

/* Lead & Timeline Bar */
.project-lead-timeline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 13px;
}

.lead-assignee {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.lead-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

[data-theme="light"] .lead-avatar {
  border-color: rgba(15, 23, 42, 0.1);
}

.lead-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lead-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.timeline-date {
  display: inline-flex;
  align-items: center;
  gap: 4.5px;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--text-muted);
}

.timeline-date svg,
.timeline-date i {
  width: 12px !important;
  height: 12px !important;
  opacity: 0.75;
  flex-shrink: 0;
}

/* Progress Section */
.project-progress-wrap {
  margin-top: auto;
  margin-bottom: 14px;
}

.project-progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  margin-bottom: 6px;
}

.progress-title {
  color: var(--text-muted);
  font-weight: 500;
}

.progress-pct {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.project-progress-track {
  width: 100%;
  height: 4.5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

[data-theme="light"] .project-progress-track {
  background: rgba(15, 23, 42, 0.08);
}

.project-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Integrated Clean Financials Footer */
.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
}

[data-theme="light"] .project-card-footer {
  border-top-color: rgba(15, 23, 42, 0.06);
}

.fin-left {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
}

.fin-muted {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.fin-number {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.fin-unit {
  font-size: 10.5px;
  color: var(--text-muted);
}

.fin-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.fin-status {
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.fin-status.is-paid {
  color: #10b981;
  font-weight: 600;
}

.fin-status.is-muted {
  color: var(--text-muted);
}

.fin-link-text {
  font-size: 11.5px;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.fin-arrow-ico,
.fin-right svg {
  width: 13px !important;
  height: 13px !important;
  color: var(--text-muted);
  transition: transform 0.18s ease, color 0.18s ease;
  flex-shrink: 0;
}

.project-card:hover .fin-arrow-ico,
.project-card:hover .fin-right svg {
  transform: translateX(3px);
  color: var(--accent);
}

.project-card:hover .fin-link-text {
  color: var(--accent);
}

/* Project workspace */

.project-hero {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  margin-bottom: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--project-colour, var(--accent));
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}

.project-hero-body { flex: 1 1 520px; min-width: 0; }
.project-hero h1 { margin: 10px 0 8px; font-size: 24px; font-weight: 750; letter-spacing: -0.02em; }
.project-hero-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.6; max-width: 820px; white-space: pre-line; }
.project-hero-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-size: 12px; color: var(--text-muted); }
.project-hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.project-hero-meta i { width: 14px; height: 14px; }
.project-hero-meta strong { color: var(--text-secondary); font-weight: 600; }
.project-hero-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.project-hero-actions form { margin: 0; }

.section-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  overflow-x: auto;
}

.section-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
}

.section-tabs a:hover { background: var(--bg-hover); color: var(--text-primary); }
.section-tabs i { width: 15px; height: 15px; }

/* Board */

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(230px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  align-items: start;
}

.board-col {
  display: flex;
  flex-direction: column;
  min-width: 230px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  height: 600px;
  max-height: calc(100vh - 270px);
  min-height: 480px;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

@media (min-height: 860px) {
  .board-col {
    height: calc(100vh - 270px);
    max-height: calc(100vh - 270px);
  }
}

.board-col.drag-over {
  background: rgba(0, 196, 207, 0.08) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-subtle), inset 0 0 24px rgba(0, 196, 207, 0.09);
}

.board-col-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 4px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}

.board-col-head strong { font-weight: 650; color: var(--text-primary); }
.board-col-head .count {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--bg-hover);
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  color: var(--text-muted);
}

.board-col-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  flex: 1 1 0%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle, rgba(255, 255, 255, 0.15)) transparent;
}

/* Inside Slider (Sleek Minimal Scrollbar) */
.board-col-body::-webkit-scrollbar {
  width: 5px;
}
.board-col-body::-webkit-scrollbar-track {
  background: transparent;
}
.board-col-body::-webkit-scrollbar-thumb {
  background: var(--border-subtle, rgba(255, 255, 255, 0.14));
  border-radius: 999px;
}
.board-col-body::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.board-empty { padding: 16px 6px; font-size: 12px; color: var(--text-muted); text-align: center; }

.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--text-muted); }
.status-todo { background: #9ca3af; }
.status-in_progress { background: #3b82f6; }
.status-in_review { background: #f59e0b; }
.status-completed { background: #10b981; }
.status-cancelled { background: #ef4444; }

.task-card {
  padding: 11px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 7px;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.task-card[draggable="true"] {
  cursor: grab;
  user-select: none;
}

.task-card[draggable="true"]:active {
  cursor: grabbing;
}

.task-card[data-dragging="true"] {
  opacity: 0.35 !important;
  transform: scale(0.96) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
}

.task-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.task-card-top { display: flex; align-items: flex-start; gap: 7px; }
.priority-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; background: var(--text-muted); }
.priority-low { background: #9ca3af; }
.priority-medium { background: #3b82f6; }
.priority-high { background: #f59e0b; }
.priority-critical { background: #ef4444; }

.task-card-title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-primary);
  text-decoration: none;
  word-break: break-word;
}

.task-card-title:hover { color: var(--accent); }
.task-card-context { font-size: 10.5px; color: var(--text-muted); }
.task-project-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-project-chip span { width: 6px; height: 6px; border-radius: 2px; background: var(--project-colour, var(--accent)); flex-shrink: 0; }
.task-project-chip:hover { color: var(--accent); }
.task-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-size: 10.5px; color: var(--text-muted); }
.task-assignee { display: inline-flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-assignee.is-muted { color: var(--text-muted); }
.task-assignee i, .task-due i { width: 11px; height: 11px; }
.task-due { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.task-due.is-overdue { color: var(--danger); font-weight: 600; }
.task-card-stats { display: flex; align-items: center; gap: 10px; font-size: 10.5px; color: var(--text-muted); }
.task-card-stats span { display: inline-flex; align-items: center; gap: 4px; }
.task-card-stats i { width: 12px; height: 12px; }
.task-move { margin-top: 1px; }
.task-move select {
  width: 100%;
  height: 26px;
  padding: 0 6px;
  font-size: 10.5px;
  background: var(--bg-secondary);
  border-color: transparent;
  color: var(--text-muted);
}
.task-move select:hover { border-color: var(--border); color: var(--text-primary); }

.avatar-xs { width: 18px; height: 18px; font-size: 8.5px; }

.inline-panel { background: var(--bg-secondary); }
.checklist-inputs { display: grid; gap: 6px; }

/* Roadmap / people */

.split-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; }
.subhead { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 12px; }

.phase-list, .milestone-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.phase-row, .milestone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
}
.phase-main, .milestone-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.phase-main strong, .milestone-main strong { font-size: 12.5px; font-weight: 600; }
.phase-main small, .milestone-main small { font-size: 11px; color: var(--text-muted); }
.phase-main .badge { align-self: flex-start; }
.phase-actions { display: flex; align-items: center; gap: 2px; }
.phase-actions select { width: auto; height: 28px; padding: 0 6px; font-size: 10.5px; }
.phase-actions form { margin: 0; }
.milestone-row.is-done .milestone-main strong { color: var(--text-muted); text-decoration: line-through; }
.milestone-row form { margin: 0; }
.milestone-check {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.milestone-check i { width: 18px; height: 18px; }
.milestone-row.is-done .milestone-check, .checklist-row.is-done .milestone-check { color: var(--success); }
.milestone-check:disabled { cursor: default; opacity: 0.7; }

.compact-form { padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.field-row { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.field-row .field { flex: 1 1 110px; }
.field-row .btn { flex-shrink: 0; }

.people-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.person-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.person-row:last-child { border-bottom: 0; }
.person-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.person-main strong { font-size: 12.5px; font-weight: 600; }
.person-main small { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.person-row form { margin: 0; }
.add-member-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--border); }
.add-member-form .grow { flex: 2 1 240px; }
.add-member-form .field { flex: 1 1 130px; }

.billing-progress { margin-top: 16px; }
.billing-paid-only { font-size: 14px; color: var(--text-secondary); }

/* Task detail */

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.detail-side .card { padding: 16px; }
.task-brief { font-size: 13px; color: var(--text-secondary); line-height: 1.65; }
.task-brief p { white-space: normal; }
.task-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.task-facts div { display: flex; flex-direction: column; gap: 3px; }
.task-facts span { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.task-facts strong { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }

.checklist { display: flex; flex-direction: column; gap: 2px; }
.checklist-row { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.checklist-row:last-child { border-bottom: 0; }
.checklist-row.is-done > span:not(.milestone-check) { color: var(--text-muted); text-decoration: line-through; }
.checklist-row form { margin: 0; }
.inline-add { display: flex; gap: 8px; margin-top: 14px; }
.inline-add input { flex: 1; }

.comment-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.comment-row { display: flex; align-items: flex-start; gap: 10px; }
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.comment-head strong { font-size: 12px; font-weight: 650; }
.comment-head small { font-size: 10.5px; color: var(--text-muted); }
.comment-body p { font-size: 12.5px; color: var(--text-secondary); line-height: 1.55; }
.comment-form { padding-top: 14px; border-top: 1px solid var(--border); }
.comment-form textarea { width: 100%; }

.stack-sm { display: flex; flex-direction: column; gap: 11px; }
.danger-zone { border-color: rgba(239, 68, 68, 0.35); }
.danger-zone .muted-copy { margin-bottom: 12px; }
.color-input { padding: 4px; height: 42px; width: 86px; cursor: pointer; }

@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; align-items: start; }
  .detail-side .card { margin-bottom: 0; }
}

@media (max-width: 800px) {
  .split-2 { grid-template-columns: 1fr; gap: 20px; }
  .project-hero { flex-direction: column; }
  .project-hero-actions { width: 100%; }
  .project-hero-actions .btn { flex: 1; }
  .add-member-form .field, .add-member-form .grow { flex: 1 1 100%; }
  .task-facts { grid-template-columns: 1fr; }
  .filter-bar select { flex: 1 1 45%; min-width: 0; }
}

@media (max-width: 480px) {
  .board { grid-template-columns: repeat(5, 260px); }
  .project-grid { grid-template-columns: 1fr; }
  .project-hero h1 { font-size: 20px; }
  .project-hero-actions { flex-direction: column; }
  .project-hero-actions .btn { width: 100%; }
  .project-hero-actions form { width: 100%; }
  .project-hero-actions form .btn { width: 100%; }
}

/* ============================================================
   Enhanced Micro-interactions, Animations & Design Polish
   ============================================================ */

@keyframes pageFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes modalPopIn {
  0% { opacity: 0; transform: scale(0.96) translateY(-8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes overlayFadeIn {
  from { opacity: 0; backdrop-filter: blur(0px); }
  to { opacity: 1; backdrop-filter: blur(8px); }
}

@keyframes livePulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.live-dot {
  animation: livePulse 2s infinite ease-in-out !important;
}

@keyframes dropdownSlide {
  0% { opacity: 0; transform: translateY(8px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 196, 207, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(0, 196, 207, 0); }
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes floatGently {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes badgeBounce {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.12); }
  60% { transform: scale(0.96); }
}

/* Page, cards & table entrance */
.content {
  animation: pageFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform: none !important;
}

.card {
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease), transform var(--speed) var(--ease);
}

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

.stat {
  transition: transform var(--speed) var(--ease), border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.stat:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.stat-grid > :nth-child(1) { animation-delay: 40ms; }
.stat-grid > :nth-child(2) { animation-delay: 90ms; }
.stat-grid > :nth-child(3) { animation-delay: 140ms; }
.stat-grid > :nth-child(4) { animation-delay: 190ms; }

/* Interactive button effects */
.btn {
  transition: all var(--speed) var(--ease);
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-1.5px);
}

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

.btn-primary:hover {
  box-shadow: 0 4px 18px rgba(0, 196, 207, 0.35);
}

.btn-danger:hover {
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

/* Dropdown animation */
.dropdown-menu.show {
  display: block;
  animation: dropdownSlide 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Modal animation & blur */
.modal-backdrop {
  animation: overlayFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  backdrop-filter: blur(8px);
}

.modal {
  animation: modalPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Status dots & pulses */
.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: dotPulse 1.8s infinite ease-in-out;
}

.glow-accent {
  animation: pulseGlow 2.5s infinite;
}

/* Shimmer skeleton */
.shimmer {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.03) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s infinite;
}

/* ============================================================
   Invoices & Billing Styles
   ============================================================ */

.invoice-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 40px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.invoice-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.invoice-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.invoice-brand h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.invoice-meta-top {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.invoice-num {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.invoice-parties {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 32px;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}

.invoice-party-box h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 700;
}

.invoice-party-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.invoice-party-details {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.invoice-table-wrap {
  margin: 28px 0;
  overflow-x: auto;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
}

.invoice-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-strong);
}

.invoice-table th.tar, .invoice-table td.tar {
  text-align: right;
}

.invoice-table td {
  padding: 16px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.invoice-summary-box {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.invoice-totals {
  width: min(340px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.invoice-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.invoice-total-row.grand {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 4px;
}

.invoice-total-row.grand .amt {
  color: var(--accent);
}

.invoice-slip-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  margin-top: 20px;
}

.invoice-slip-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  display: grid;
  place-items: center;
  color: var(--accent);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* ============================================================
   Payroll Styles
   ============================================================ */

.payroll-breakdown {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 18px;
}

.payroll-column-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.payroll-column-card h3 {
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

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

.payroll-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.payroll-item-row:last-child {
  border-bottom: 0;
}

.payroll-net-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(0, 196, 207, 0.12) 0%, rgba(16, 185, 129, 0.12) 100%);
  border: 1px solid var(--accent-line);
  margin-top: 24px;
}

.payroll-net-banner .label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.payroll-net-banner .amount {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-mono);
}

/* ============================================================
   Notes Grid
   ============================================================ */

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 180px;
  position: relative;
  transition: all var(--speed) var(--ease);
}

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

.note-card.is-pinned {
  border-color: var(--accent-line);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg-card) 60px);
}

.note-pin-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  color: var(--accent);
}

.note-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.note-card-excerpt {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ============================================================
   Settings & Tabs
   ============================================================ */

.settings-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.settings-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--speed) var(--ease);
}

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

.settings-nav-item.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

@media print {
  body { background: #fff !important; color: #000 !important; }
  .sidebar, .topbar, .mobile-nav, .page-actions, .toast-stack, .btn, .no-print { display: none !important; }
  .main, .content { padding: 0 !important; margin: 0 !important; width: 100% !important; }
  .invoice-sheet, .card { box-shadow: none !important; border: 1px solid #ddd !important; background: #fff !important; }
  .invoice-num { color: #000 !important; }
  .invoice-party-name, .invoice-brand h2 { color: #000 !important; }
}


/* ============================================================
   PROJECT DASHBOARD & WORKSPACE — Pixel-Perfect Tabbed UI
   ============================================================ */

.project-dashboard-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.project-dashboard-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.project-dashboard-label .badge-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  box-shadow: 0 0 8px var(--accent-glow);
}

.project-dashboard-label .badge-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.project-dashboard-label .client-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  background: var(--accent-subtle);
  border: 1px solid var(--accent-line);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  transition: all var(--speed) var(--ease);
}
.project-dashboard-label .client-pill:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

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

/* 5 Overview Analytics Cards */
.project-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.project-stats-row .card {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  margin: 0;
}

.project-stats-row .stat-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.project-stats-row .stat-icon-wrap i {
  width: 20px;
  height: 20px;
}

.project-stats-row .stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.project-stats-row .stat-val {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.client-stat-card {
  text-decoration: none;
  color: inherit;
  transition: transform var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.client-stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent) !important;
}

/* ── Project Tabs Track ────────────────────────────────────── */
.project-dashboard-page {
  display: block;
  width: 100%;
}

.project-tabs-column {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.project-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  margin: 0 0 14px 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.project-tabs::-webkit-scrollbar { display: none; height: 0; }

.project-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  height: 38px;
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all 150ms ease;
  text-decoration: none;
}

.project-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.project-tab.active,
.project-tab[aria-selected="true"] {
  background: var(--bg-card);
  color: var(--accent-text, var(--accent));
  border-color: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

.project-tab-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.project-tab-label {
  line-height: 1;
}

.project-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-badge);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.project-tab-count--trash {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #ef4444 !important;
  border: 1px solid rgba(239, 68, 68, 0.25) !important;
}
.project-tab.project-tab--trash:hover,
.project-tab.project-tab--trash.active,
.project-tab.project-tab--trash[aria-selected="true"] {
  color: #ef4444 !important;
  border-color: #ef4444 !important;
}

.project-tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success-light);
}

.project-tab-panels {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 300px;
}

.project-tab-panel {
  /* Instant zero-flicker tab transitions */
  animation: none !important;
}
.project-tab-panel[hidden] {
  display: none !important;
}

.project-tab-panels > .project-tab-panel > .card {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 24px 28px !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Empty states inside project tabs */
.project-tab-panel .pd-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.project-tab-panel .pd-empty i {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  display: block;
  opacity: 0.2;
  color: var(--accent);
}

/* Kanban Board in Task Board tab */
.kb-board {
  display: flex;
  gap: 14px;
  width: 100%;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kb-col {
  flex: 1 1 280px;
  min-width: 260px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  max-height: 640px;
}

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

.kb-column-tasks {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 0%;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle, rgba(255, 255, 255, 0.15)) transparent;
}

.kb-column-tasks::-webkit-scrollbar {
  width: 5px;
}
.kb-column-tasks::-webkit-scrollbar-track {
  background: transparent;
}
.kb-column-tasks::-webkit-scrollbar-thumb {
  background: var(--border-subtle, rgba(255, 255, 255, 0.14));
  border-radius: 999px;
}
.kb-column-tasks::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Project Files list */
.project-files-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.pd-file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 28px 20px;
  text-align: center;
  margin-bottom: 16px;
  transition: all var(--speed) var(--ease);
  background: rgba(255, 255, 255, 0.01);
}
.pd-file-drop:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.fm-list-wrap {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.fm-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.fm-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--speed) var(--ease);
}
.fm-list-row:last-child {
  border-bottom: none;
}
.fm-list-row:hover {
  background: var(--bg-hover);
}

.fm-action-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  transition: all var(--speed) var(--ease);
}
.fm-action-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* Member card */
.member-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--speed) var(--ease);
}
.member-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

/* Modal overlay styling for site-wide popups */
.modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 10000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 24px 16px !important;
  background: rgba(10, 15, 26, 0.78) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  box-sizing: border-box !important;
}
.modal-overlay[hidden],
.modal-overlay:not(.show):not([style*="display: flex"]) {
  display: none !important;
}
.modal-overlay.show,
.modal-overlay[style*="display: flex"] {
  display: flex !important;
}
.modal-overlay .modal,
.modal-overlay .modal-card {
  width: 100% !important;
  max-width: 540px;
  max-height: min(90vh, calc(100vh - 48px)) !important;
  margin: auto !important;
  position: relative !important;
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
  overflow: hidden !important;
  background: var(--bg-card, #111822) !important;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.14)) !important;
  border-radius: var(--radius-xl, 14px) !important;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08) !important;
  animation: modalScaleIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
  display: flex !important;
  flex-direction: column !important;
  box-sizing: border-box !important;
}
@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-overlay .modal form,
.modal-overlay .modal-card form {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
}
.modal-overlay .modal-header {
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 16px 20px !important;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1)) !important;
}
.modal-overlay .modal-header h3 {
  margin: 0 !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  color: var(--text-primary) !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}
.modal-overlay .modal-close {
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  color: var(--text-muted) !important;
  padding: 6px !important;
  border-radius: 50% !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 120ms ease !important;
  flex-shrink: 0 !important;
}
.modal-overlay .modal-close:hover {
  color: var(--text-primary) !important;
  background: var(--bg-hover, rgba(255, 255, 255, 0.08)) !important;
  transform: rotate(90deg) !important;
}
.modal-overlay .modal-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  padding: 20px 24px !important;
}
.modal-overlay .modal-footer {
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
  padding: 14px 20px !important;
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1)) !important;
}

/* ════════════════════════════════════════════════════════════
   SITE PRELOADER — Global Animated Brand Loading Screen
   ════════════════════════════════════════════════════════════ */
.site-preloader {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s ease;
  overflow: hidden;
  user-select: none;
}

[data-theme="light"] .site-preloader {
  background: transparent !important;
}

.site-preloader.loaded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  pointer-events: auto;
}

.preloader-logo {
  width: 58px;
  max-width: 64px;
  height: auto;
  overflow: visible;
  display: block;
  filter: drop-shadow(0 4px 14px rgba(32, 216, 216, 0.45));
}

[data-theme="light"] .preloader-logo {
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.18));
}

[data-theme="dark"] .preloader-logo #hexBlack {
  fill: #060a10;
}

[data-theme="light"] .preloader-logo #hexBlack {
  fill: #0f172a;
}

/* ════════════════════════════════════════════════════════════
   SPA / PJAX INTERNAL LOADER & SEAMLESS PAGE TRANSITIONS
   ════════════════════════════════════════════════════════════ */
html[data-top-loader="0"] .app-progress-bar,
html[data-top-loader="0"] #appProgressBar,
body.no-top-loader .app-progress-bar,
body.no-top-loader #appProgressBar,
.app-progress-bar.is-disabled {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  height: 0 !important;
}

html[data-top-loader="0"] #appMainContent.content-nav-loading,
body.no-top-loader #appMainContent.content-nav-loading {
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
}

.app-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, #00c4cf 0%, #38ef7d 50%, #00c4cf 100%);
  background-size: 200% 100%;
  box-shadow: 0 0 10px rgba(0, 196, 207, 0.8), 0 0 5px rgba(0, 196, 207, 0.95);
  z-index: 99999999;
  opacity: 0;
  pointer-events: none;
  transition: width 0.22s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.2s ease;
}

.app-progress-bar.active {
  opacity: 1;
}

.app-progress-bar.finish {
  opacity: 0;
  transition: width 0.15s ease, opacity 0.22s ease 0.1s;
}

.app-progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.9));
  box-shadow: 0 0 14px #00c4cf, 0 0 8px #00c4cf;
  border-radius: 50%;
  opacity: 0.9;
}

/* Inner content loading state & smooth swap (zero flicker, zero layout jumping) */
#appMainContent.content-nav-loading {
  opacity: 1 !important;
  filter: none !important;
  transition: none !important;
  pointer-events: auto;
}

#appMainContent.animate-swap-in {
  animation: appContentSwapIn 0.12s ease-out forwards;
}

@keyframes appContentSwapIn {
  0% {
    opacity: 0.96;
    transform: none;
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

/* ════════════════════════════════════════════════════════════   THEME STUDIO — Settings → Appearance
   ════════════════════════════════════════════════════════════ */

.aq-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.aq-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: var(--font-bold);
    color: var(--accent);
}
.aq-subtitle {
    margin: 0;
    max-width: 640px;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-muted);
}

/* ─── Presets ─────────────────────────────────────────────── */
.aq-presets-filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.aq-filter-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-muted);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-default);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.aq-filter-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--bg-input-focus);
}
.aq-filter-btn.is-active {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
    box-shadow: 0 0 0 1px var(--accent-strong);
}

.aq-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 10px;
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-color);
}
.aq-preset {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px 10px 14px;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    transition: transform var(--duration-fast) var(--ease-spring),
                border-color var(--duration-fast) var(--ease-default),
                background var(--duration-fast) var(--ease-default),
                box-shadow var(--duration-fast) var(--ease-default);
}
.aq-preset:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    background: var(--bg-input-focus);
    box-shadow: var(--shadow-sm);
}
.aq-preset.is-active {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 0 0 1.5px var(--accent);
}
.aq-preset-name {
    font-size: 12.5px;
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}
.aq-logo-pill {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    background: rgba(0, 196, 207, 0.15);
    color: #00c4cf;
    border: 1px solid rgba(0, 196, 207, 0.35);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}
.aq-preset-hint {
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-muted);
}
.aq-preset-dots {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}
.aq-preset-dots i {
    width: 11px;
    height: 11px;
    border-radius: var(--radius-full);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/* ─── Studio grid ─────────────────────────────────────────── */
.aq-studio {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 22px;
    align-items: start;
}
.aq-controls { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* ─── Collapsible groups ──────────────────────────────────── */
.aq-group {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-input);
    overflow: hidden;
}
.aq-group-head {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    color: var(--text-primary);
    font-family: inherit;
    transition: background var(--duration-fast) var(--ease-default);
}
.aq-group-head:hover { background: var(--glass-bg-hover); }
.aq-group-ico {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    background: var(--accent-light);
}
.aq-group-ico svg { width: 15px; height: 15px; }
.aq-group-title {
    flex: 1;
    font-size: 13.5px;
    font-weight: var(--font-semibold);
}
.aq-group-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform var(--duration-normal) var(--ease-default);
}
.aq-group.is-collapsed .aq-group-chevron { transform: rotate(-90deg); }
.aq-group.is-collapsed .aq-group-body { display: none; }
.aq-group-body {
    padding: 4px 14px 14px;
    border-top: 1px solid var(--border-light);
}
.aq-group-help {
    margin: 10px 0 4px;
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--text-muted);
}

/* ─── Fields ──────────────────────────────────────────────── */
.aq-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 16px;
    padding: 11px 0;
    border-bottom: 1px dashed var(--border-light);
    transition: opacity var(--duration-fast) var(--ease-default);
}
.aq-field:last-child { border-bottom: none; }
.aq-field.is-off { opacity: 0.55; }
.aq-field:focus-within { opacity: 1; }
.aq-field-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.aq-field-text label {
    font-size: 12.5px;
    font-weight: var(--font-medium);
    color: var(--text-primary);
}
.aq-field-help {
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-muted);
}
.aq-field-control {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    min-width: 0;
}

/* Colour picker */
.aq-colour { display: flex; align-items: center; gap: 8px; }
.aq-color {
    -webkit-appearance: none;
    appearance: none;
    width: 38px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: transparent;
    cursor: pointer;
    overflow: hidden;
}
.aq-color::-webkit-color-swatch-wrapper { padding: 2px; }
.aq-color::-webkit-color-swatch { border: none; border-radius: calc(var(--radius-md) - 2px); }
.aq-color::-moz-color-swatch { border: none; border-radius: calc(var(--radius-md) - 2px); }
.aq-color:hover { border-color: var(--accent); }
.aq-hex {
    width: 90px;
    padding: 7px 9px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.02em;
    text-transform: lowercase;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
}
.aq-hex:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.aq-check-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}
.aq-check-inline input { accent-color: var(--accent); cursor: pointer; }

/* Range slider */
.aq-range {
    -webkit-appearance: none;
    appearance: none;
    width: 168px;
    height: 4px;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-strong) 100%);
    cursor: pointer;
    outline: none;
}
.aq-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: var(--radius-full);
    background: var(--accent);
    border: 2px solid var(--bg-primary);
    box-shadow: 0 0 0 1px var(--accent), 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform var(--duration-fast) var(--ease-spring);
}
.aq-range::-webkit-slider-thumb:hover { transform: scale(1.15); }
.aq-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: var(--radius-full);
    background: var(--accent);
    border: 2px solid var(--bg-primary);
}
.aq-range-value {
    min-width: 46px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Select / text / textarea */
.aq-select, .aq-text {
    min-width: 168px;
    padding: 8px 11px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
}
.aq-select:focus, .aq-text:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.aq-textarea {
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    resize: vertical;
}
.aq-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.aq-field[data-type="textarea"] { grid-template-columns: 1fr; }
.aq-field[data-type="textarea"] .aq-field-control { justify-content: stretch; }

/* Switch */
.aq-switch { display: inline-flex; cursor: pointer; }
.aq-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.aq-switch-track {
    position: relative;
    display: block;
    width: 42px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--bg-input-focus);
    border: 1px solid var(--border-color);
    transition: background var(--duration-normal) var(--ease-default),
                border-color var(--duration-normal) var(--ease-default);
}
.aq-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    transition: transform var(--duration-normal) var(--ease-spring), background var(--duration-fast) var(--ease-default);
}
.aq-switch input:checked + .aq-switch-track {
    background: var(--accent-light);
    border-color: var(--accent);
}
.aq-switch input:checked + .aq-switch-track .aq-switch-thumb {
    transform: translateX(18px);
    background: var(--accent);
}
.aq-switch input:focus-visible + .aq-switch-track { box-shadow: 0 0 0 3px var(--accent-light); }

/* ─── Live preview ────────────────────────────────────────── */
.aq-preview {
    position: sticky;
    top: calc(var(--header-height) + 16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-input);
    overflow: hidden;
}
.aq-preview-head {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    background: var(--glass-bg);
}
.aq-preview-live {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}
.aq-preview-dot {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    background: var(--success);
    animation: chatLive 2.2s infinite;
}
.btn-preview-mode {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all var(--duration-fast) var(--ease-default);
}
.btn-preview-mode:hover:not(.is-active) {
    color: var(--text-primary);
}
.btn-preview-mode.is-active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.aq-preview-note {
    display: block;
    margin-top: 4px;
    font-size: 10.5px;
    line-height: 1.5;
    color: var(--text-muted);
}
.aq-preview-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
}
.aq-swatches { display: flex; gap: 6px; }
.aq-swatch {
    flex: 1;
    height: 26px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: transform var(--duration-fast) var(--ease-spring);
}
.aq-swatch:hover { transform: scale(1.06); }
.aq-demo-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.aq-demo-row .btn { padding: 8px 14px; font-size: 12px; }
.aq-demo-card { padding: 14px !important; display: flex; flex-direction: column; gap: 10px; }
.aq-demo-card-head { display: flex; align-items: center; gap: 9px; }
.aq-demo-title { font-size: 12.5px; font-weight: var(--font-semibold); color: var(--text-primary); }
.aq-demo-sub { font-size: 10.5px; color: var(--text-muted); }
.aq-demo-input {
    width: 100%;
    padding: 9px 12px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    outline: none;
}
.aq-demo-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.aq-demo-chat { display: flex; flex-direction: column; gap: 7px; align-items: flex-start; }
.aq-demo-chat .chat-bubble { font-size: 12px; padding: 7px 11px; }
.aq-demo-chat .aq-demo-mine {
    align-self: flex-end;
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent), var(--accent-active));
    box-shadow: 0 4px 14px var(--accent-glow);
}
.aq-demo-table {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card);
}
.aq-demo-table-head,
.aq-demo-table-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    font-size: 11.5px;
}
.aq-demo-table-head {
    font-size: 10px;
    font-weight: var(--font-bold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--glass-bg);
    border-bottom: 1px solid var(--border-color);
}
.aq-demo-table-row + .aq-demo-table-row { border-top: 1px solid var(--border-light); }
.aq-demo-table-row span:first-child { color: var(--text-primary); }

/* ─── Save bar ────────────────────────────────────────────── */
.aq-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}
.aq-footer-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.aq-dirty {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    align-self: flex-start;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-size: 10.5px;
    font-weight: var(--font-semibold);
    color: var(--warning);
    background: var(--warning-light);
    border: 1px solid var(--warning-border);
}
.aq-footer-note { font-size: 11.5px; color: var(--text-muted); }
.aq-footer-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.aq-json { margin-top: 16px; }
.aq-json summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
}
.aq-json summary:hover { color: var(--accent); }
.aq-json .aq-textarea { margin-top: 10px; }

/* ─── Factory reset ───────────────────────────────────────── */
.aq-danger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin: 18px 0 0;
    padding: 14px 16px;
    border: 1px solid var(--error-border);
    border-radius: var(--radius-lg);
    background: var(--error-light);
}
.aq-danger-title { font-size: 12.5px; font-weight: var(--font-semibold); color: var(--error); }
.aq-danger-note { margin-top: 2px; font-size: 11.5px; color: var(--text-secondary); }

@media (max-width: 1024px) {
    .aq-studio { grid-template-columns: 1fr; }
    .aq-preview { position: static; }
}
@media (max-width: 640px) {
    .aq-field { grid-template-columns: 1fr; }
    .aq-field-control { justify-content: flex-start; flex-wrap: wrap; }
    .aq-range { width: 100%; }
    .aq-select, .aq-text { min-width: 0; width: 100%; }
    .aq-footer-actions { width: 100%; }
    .aq-footer-actions .btn { flex: 1; justify-content: center; }
}

/* --- Invoice list: collapsible row actions ---
   Each row keeps a single toggle in the Actions cell, and the whole row is a
   click target as well (links and the chevron keep their own behaviour).
   Expanding reveals a full-width panel in the row underneath, so a pending
   invoice can carry up to seven actions without stretching the table. Only
   one row is open at a time (enforced in toggleRowActions). */
.aq-actions-source { cursor: pointer; }
.aq-actions-toggle {
    padding: 6px 10px;
    min-width: 32px;
    justify-content: center;
    transition: background 0.15s ease;
}
/* lucide swaps the <i> for an <svg>, so rotate the rendered icon */
.aq-actions-toggle svg { transition: transform 0.2s ease; }
.aq-actions-toggle[aria-expanded="true"] {
    background: var(--bg-hover);
    color: var(--accent);
}
.aq-actions-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* The panel row spans the full table width so it reads as part of the row;
   the top gap separates it from the border-bottom of the row it belongs to. */
.aq-actions-row > td { padding: 14px 0 16px; }
.aq-actions-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    /* Matches the 16px content inset of the main row's cells, so the buttons
       line up with the columns above instead of starting further left. */
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.aq-actions-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
/* Destructive actions sit on the trailing edge on desktop */
.aq-actions-group--danger { margin-left: auto; }

@media (max-width: 640px) {
    .aq-actions-row > td { padding: 12px 0 14px; }
    .aq-actions-panel { padding: 12px; }
    .aq-actions-group--danger { margin-left: 0; width: 100%; }
    .aq-actions-group--danger:empty { display: none; }
    /* Full-width buttons read better than a wrapped row of small pills */
    .aq-actions-group .btn { flex: 1 1 auto; justify-content: center; }
}


/* ════════════════════════════════════════════════════════════   SETTINGS & ROLES STYLES
   ════════════════════════════════════════════════════════════ */

.settings-tabbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-input);
    overflow-x: auto;
    scrollbar-width: thin;
}
.settings-tabbar .setting-tab-btn {
    width: 46px;
    height: 42px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-default),
                color var(--duration-fast) var(--ease-default),
                border-color var(--duration-fast) var(--ease-default),
                transform var(--duration-fast) var(--ease-spring);
}
.settings-tabbar .setting-tab-btn svg {
    width: 19px;
    height: 19px;
}
.settings-tabbar .setting-tab-btn:hover:not(.active) {
    background: var(--bg-input-focus);
    color: var(--text-primary);
    border-color: var(--border-color);
    transform: translateY(-1px);
}
.settings-tabbar .setting-tab-btn.active {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
    box-shadow: 0 4px 14px var(--accent-glow);
}
.settings-panels { min-width: 0; }

.role-sync-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
}
.role-chipbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.role-chip {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-default);
}
.role-chip:hover:not(.active) {
    color: var(--text-primary);
    border-color: var(--accent);
}
.role-chip.active {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--text-primary);
    box-shadow: 0 0 0 1px var(--accent) inset;
}
.role-chip-name {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}
.role-chip-meta {
    font-size: 10.5px;
    opacity: .85;
}
.role-matrix-panel { min-width: 0; }
.role-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}
.role-level-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}
.role-members {
    margin-bottom: 20px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}
.role-members-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: block;
}
.role-members-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.role-member {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 6px;
    border-radius: var(--radius-full);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    font-size: 12px;
    transition: all 0.15s ease;
}
.role-member:hover {
    border-color: var(--accent);
    background: var(--bg-input-focus);
}
.role-member-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
}
.role-member-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
}
.role-member-name { font-weight: 500; }
.role-member-mail { display: none; }
.role-member-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.role-member-more {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    padding: 4px 10px;
}
.role-locked-note {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: var(--radius-md);
    background: rgba(0, 196, 207, 0.08);
    border: 1px solid rgba(0, 196, 207, 0.25);
    color: var(--accent);
    font-size: 12.5px;
}
.role-form-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}
.role-count {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}
.role-module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.role-module-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    overflow: hidden;
}
.role-module-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}
.role-perm-list {
    padding: 8px 12px;
    max-height: 260px;
    overflow-y: auto;
}
.role-perm-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 4px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}
.role-perm-item:hover {
    background: var(--bg-hover);
}
.role-perm-item input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--accent);
}
.role-form-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ═══════════════════════════════════════════════════════════════
   MARKDOWN — rendered output (.md-body) + authoring tools (.md-editor)
   Used by the project plan & agreement sections, on both the project
   dashboard and the public share page.
   ════════════════════════════════════════════════════════════════ */

.md-body > *:first-child { margin-top: 0; }
.md-body > *:last-child { margin-bottom: 0; }

.md-body p { margin: 0 0 10px; }

.md-body h1,
.md-body h2,
.md-body h3,
.md-body h4,
.md-body h5,
.md-body h6 {
    margin: 16px 0 8px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}
.md-body h1 { font-size: 1.25em; }
.md-body h2 { font-size: 1.15em; }
.md-body h3 { font-size: 1.05em; }
.md-body h4,
.md-body h5,
.md-body h6 { font-size: 1em; }

.md-body ul,
.md-body ol { margin: 0 0 10px; padding-left: 22px; }
.md-body ul { list-style: disc; }
.md-body ol { list-style: decimal; }
.md-body li { margin: 3px 0; }
.md-body li > p { margin: 0; }
.md-body li input.md-check {
    margin: 0 6px 0 0;
    vertical-align: middle;
    accent-color: var(--accent);
    cursor: default;
}

.md-body strong { font-weight: 700; color: var(--text-primary); }
.md-body em { font-style: italic; }
.md-body del { text-decoration: line-through; opacity: 0.7; }

.md-body code {
    font-family: var(--font-mono, monospace);
    font-size: 0.92em;
    padding: 1px 5px;
    background: var(--bg-input, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-color, var(--border));
    border-radius: var(--radius-xs, 4px);
}
.md-body .md-pre {
    margin: 0 0 10px;
    padding: 12px 14px;
    background: var(--bg-secondary, rgba(255, 255, 255, 0.02));
    border: 1px solid var(--border-color, var(--border));
    border-radius: var(--radius-md, 8px);
    overflow-x: auto;
}
.md-body .md-pre code {
    display: block;
    padding: 0;
    background: none;
    border: none;
    white-space: pre;
}

.md-body blockquote {
    margin: 0 0 10px;
    padding: 2px 0 2px 14px;
    border-left: 3px solid var(--accent);
    color: var(--text-secondary);
}

.md-body hr {
    margin: 14px 0;
    border: 0;
    border-top: 1px solid var(--border-color, var(--border));
}

.md-body a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.md-body a:hover {
    color: var(--accent-hover, #00b0ba);
}

.md-body .md-table-wrap {
    margin: 0 0 12px;
    overflow-x: auto;
}
.md-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}
.md-body th,
.md-body td {
    padding: 7px 10px;
    border: 1px solid var(--border-color, var(--border));
    text-align: left;
    vertical-align: top;
}
.md-body th {
    background: var(--bg-secondary, rgba(255, 255, 255, 0.04));
    color: var(--text-primary);
    font-weight: 700;
}
.md-body tbody tr:nth-child(even) td { background: var(--bg-input, rgba(255, 255, 255, 0.02)); }

.md-body li > ul,
.md-body li > ol {
    margin: 4px 0 0;
    padding-left: 20px;
}

.md-editor { margin-bottom: 4px; }

.md-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 6px;
}

.md-tool {
    min-width: 28px;
    height: 28px;
    padding: 0 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    color: var(--text-secondary);
    background: var(--bg-input, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-color, var(--border));
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    transition: all 0.15s ease;
}
.md-tool:hover {
    color: var(--text-primary);
    background: var(--bg-hover, rgba(255, 255, 255, 0.08));
    border-color: var(--accent);
}
.md-tool-wide { padding: 0 10px; font-weight: 500; }
.md-toolbar-sep { flex: 1 1 auto; }

.md-hint {
    margin-top: 5px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-muted);
}

.md-preview {
    margin-top: 10px;
    padding: 12px 14px;
    background: var(--bg-input, rgba(255, 255, 255, 0.04));
    border: 1px dashed var(--border-color, var(--border));
    border-radius: var(--radius-md, 8px);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}
.md-preview[hidden] { display: none !important; }


/* ════════════════════════════════════════════════════════════   CHAT — Trigger, popup and full-page conversation
   Shared by the project floating chat and /messages/{id}
   ════════════════════════════════════════════════════════════ */

/* ─── Floating trigger button ─────────────────────────────── */
.chat-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: var(--radius-full);
    padding: 0;
    cursor: pointer;
    z-index: 9999;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), #0097b0 55%, var(--purple));
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.07), 0 0 20px var(--accent-glow);
    transition: transform var(--duration-normal) var(--ease-spring), box-shadow var(--duration-normal) var(--ease-default);
}
.chat-fab:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.1), 0 0 30px var(--accent-glow);
}
.chat-fab:active { transform: translateY(-1px) scale(0.97); }
.chat-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.chat-fab-ico {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--duration-normal) var(--ease-default), transform var(--duration-normal) var(--ease-spring);
}
.chat-fab-ico svg { width: 23px; height: 23px; }
.chat-fab .chat-fab-ico-close { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.chat-fab.is-open .chat-fab-ico-chat { opacity: 0; transform: rotate(90deg) scale(0.6); }
.chat-fab.is-open .chat-fab-ico-close { opacity: 1; transform: rotate(0deg) scale(1); }

.chat-fab.has-unread::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    border: 2px solid var(--accent);
    animation: chatRing 2.4s var(--ease-smooth) infinite;
    pointer-events: none;
}

.chat-fab-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--error), var(--orange));
    color: #fff;
    font-size: 10.5px;
    font-weight: var(--font-bold);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-primary);
    box-shadow: 0 2px 10px var(--error-glow);
    transform: scale(0);
    transition: transform var(--duration-normal) var(--ease-spring);
}
.chat-fab-badge.show { transform: scale(1); }
.chat-fab-badge.pop { animation: chatBadgePop 0.45s var(--ease-bounce); }

/* ─── Overlay ─────────────────────────────────────────────── */
.chat-overlay {
    position: fixed;
    inset: 0;
    z-index: 9997;
    background: rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal) var(--ease-default), visibility var(--duration-normal);
}
.chat-overlay.is-open { opacity: 1; visibility: visible; }

/* ─── Popup shell (docked bottom-right above floating chat button) ─ */
.chat-popup {
    position: fixed;
    bottom: 90px;
    right: 22px;
    top: auto;
    left: auto;
    z-index: 9998;
    width: min(420px, calc(100vw - 36px));
    height: min(640px, calc(100vh - 120px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--radius-2xl);
    background: #111822; /* High-density elevated dark surface */
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity var(--duration-normal) var(--ease-default),
                transform var(--duration-normal) var(--ease-spring),
                visibility var(--duration-normal);
}
[data-theme="light"] .chat-popup {
    background: #ffffff !important;
    border: 1px solid #cbd5e1;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.08);
}
.chat-popup.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ─── Panel header ────────────────────────────────────────── */
.chat-popup-head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 13px 14px;
    flex-shrink: 0;
    background: #151f2c;
    border-bottom: 1px solid var(--border-color);
}
[data-theme="light"] .chat-popup-head {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.chat-head-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 14px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: var(--font-bold);
    font-size: 14px;
    background: linear-gradient(135deg, var(--warning), var(--rose));
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
    overflow: hidden;
}
.chat-head-avatar svg { width: 18px; height: 18px; }
.chat-head-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-head-avatar.has-live::after {
    content: '';
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 11px;
    height: 11px;
    border-radius: var(--radius-full);
    background: var(--success);
    border: 2px solid var(--bg-secondary);
}
.chat-head-text { min-width: 0; flex: 1; }
.chat-head-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 14px;
    font-weight: var(--font-bold);
    color: var(--text-primary);
    line-height: 1.3;
}
.chat-head-title > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-head-tag {
    flex-shrink: 0;
    padding: 1px 7px;
    border-radius: var(--radius-full);
    font-size: 9px;
    font-weight: var(--font-bold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--purple-text);
    background: var(--purple-light);
    border: 1px solid var(--purple-border);
}
.chat-head-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0 0;
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-dot-live {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    background: var(--success);
    flex-shrink: 0;
    animation: chatLive 2.2s infinite;
}
.chat-head-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.chat-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background var(--duration-fast) var(--ease-default),
                color var(--duration-fast) var(--ease-default),
                border-color var(--duration-fast) var(--ease-default),
                transform var(--duration-fast) var(--ease-default);
}
.chat-icon-btn svg { width: 16px; height: 16px; }
.chat-icon-btn:hover {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
    transform: translateY(-1px);
}

/* ─── Message scroll area ─────────────────────────────────── */
.chat-scroll,
.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--bg-primary);
    background-image: radial-gradient(120% 60% at 50% 0%, var(--accent-subtle), transparent 70%);
}
.chat-popup .chat-scroll { position: relative; }
.chat-scroll::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-scroll::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-scroll::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    background-clip: padding-box;
}
.chat-scroll::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover { background: var(--accent-strong); background-clip: padding-box; }

/* Day separator */
.chat-day {
    align-self: center;
    margin: 14px 0 8px;
    padding: 3px 12px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: var(--font-semibold);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-input);
    border: 1px solid var(--border-light);
}

/* Message row */
.chat-msg {
    display: flex;
    align-items: flex-end;
    gap: 9px;
    max-width: 86%;
    margin: 0;
    animation: chatMsgIn 0.32s var(--ease-spring) both;
}
.chat-msg.mine { flex-direction: row-reverse; margin-left: auto; }
.chat-msg.new-group { margin-top: 14px; }
.chat-msg.grouped { margin-top: 2px; }

.chat-avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 10.5px;
    font-weight: var(--font-bold);
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    box-shadow: 0 0 0 1px var(--border-color);
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-msg.grouped .chat-avatar { opacity: 0; }

.chat-stack { min-width: 0; display: flex; flex-direction: column; }
.chat-msg.mine .chat-stack { align-items: flex-end; }
.chat-author {
    margin: 0 0 3px 3px;
    font-size: 10.5px;
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
}

.chat-bubble {
    padding: 9px 13px;
    font-size: 13.5px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 16px 16px 16px 5px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--duration-fast) var(--ease-default), transform var(--duration-fast) var(--ease-default);
}
.chat-msg.grouped .chat-bubble { border-radius: 5px 16px 16px 5px; }
.chat-msg.mine .chat-bubble {
    color: #fff;
    border-color: transparent;
    border-radius: 16px 16px 5px 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-active));
    box-shadow: 0 4px 14px var(--accent-glow);
}
.chat-msg.mine.grouped .chat-bubble { border-radius: 16px 5px 5px 16px; }
.chat-msg:hover .chat-bubble { transform: translateY(-1px); }

.chat-msg.sending .chat-bubble { animation: chatBubblePulse 1.1s ease-in-out infinite; }
.chat-msg.failed .chat-bubble {
    background: var(--error-light);
    color: var(--error);
    border-color: var(--error-border);
    box-shadow: none;
    animation: none;
}

.chat-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
    padding: 0 4px;
    font-size: 10px;
    color: var(--text-muted);
}
.chat-msg:not(.last-of-group) .chat-meta { display: none; }
.chat-meta svg { width: 11px; height: 11px; opacity: 0.8; }
.chat-msg.sending .chat-meta { color: var(--text-disabled); }
.chat-msg.failed .chat-meta { color: var(--error); }

/* Per-message actions (edit / delete) + inline edit box */
.chat-msg-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
    opacity: 0;
    transition: opacity 0.12s ease;
}
.chat-msg:hover .chat-msg-actions,
.chat-msg:focus-within .chat-msg-actions { opacity: 1; }
.chat-msg-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.chat-msg-actions button:hover {
    background: rgba(127, 127, 127, 0.15);
    color: var(--text-primary);
}
.chat-msg-actions button svg { width: 11px; height: 11px; }
.chat-edit-box { display: flex; flex-direction: column; gap: 6px; }
.chat-edit-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    background: var(--bg-secondary, #15171c);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    resize: vertical;
}
.chat-edit-save,
.chat-edit-cancel {
    align-self: flex-end;
    padding: 4px 12px;
    border: 0;
    border-radius: var(--radius-md);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
}
.chat-edit-save { background: var(--accent); color: #fff; }
.chat-edit-cancel { background: rgba(127, 127, 127, 0.15); color: var(--text-secondary); }

/* Chat bubbles: allow auto-linked URLs to wrap and style them */
.chat-bubble a {
    color: inherit;
    text-decoration: underline;
    word-break: break-word;
}
.chat-msg.mine .chat-bubble a { color: inherit; font-weight: 600; }

/* Empty state + loading skeleton */
.chat-empty {
    margin: auto;
    padding: 26px 12px;
    text-align: center;
    color: var(--text-muted);
    animation: chatMsgIn 0.4s var(--ease-spring) both;
}
.chat-empty-ico {
    width: 54px;
    height: 54px;
    margin: 0 auto 12px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid var(--accent-strong);
}
.chat-empty-ico svg { width: 24px; height: 24px; }
.chat-empty p { margin: 0; font-size: 13px; color: var(--text-secondary); }
.chat-empty small { display: block; margin-top: 4px; font-size: 11.5px; color: var(--text-muted); }

.chat-skel { display: flex; align-items: flex-end; gap: 9px; margin-bottom: 14px; }
.chat-skel.mine { flex-direction: row-reverse; }
.chat-skel-avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    background: var(--bg-tertiary);
}
.chat-skel-bubble {
    height: 38px;
    border-radius: 16px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-elevated) 37%, var(--bg-tertiary) 63%);
    background-size: 400% 100%;
    animation: chatShimmer 1.4s ease-in-out infinite;
}

/* In-flight / typing indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 10px;
    animation: chatMsgIn 0.25s var(--ease-spring) both;
}
.chat-typing[hidden] { display: none; }
.chat-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    border-radius: 16px 16px 16px 5px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
}
.chat-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    animation: chatDot 1.2s infinite ease-in-out;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.32s; }
.chat-typing-label { font-size: 11px; color: var(--text-muted); }

/* Scroll-to-latest pill */
.chat-jump {
    position: absolute;
    right: 16px;
    bottom: 108px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: var(--font-semibold);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-default),
                transform var(--duration-normal) var(--ease-spring),
                color var(--duration-fast) var(--ease-default);
}
.chat-jump svg { width: 15px; height: 15px; }
.chat-jump.show { opacity: 1; transform: none; pointer-events: auto; }
.chat-jump:hover { color: var(--accent); border-color: var(--accent-strong); }
.chat-jump-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: var(--font-bold);
    color: #fff;
    background: var(--accent);
}
.chat-jump-count[hidden] { display: none; }

/* ─── Composer ────────────────────────────────────────────── */
.chat-foot {
    flex-shrink: 0;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
.chat-composer { display: flex; align-items: flex-end; gap: 8px; }
.chat-input-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    padding: 5px 14px;
    border-radius: 22px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: border-color var(--duration-fast) var(--ease-default),
                box-shadow var(--duration-fast) var(--ease-default),
                background-color var(--duration-fast) var(--ease-default);
}
.chat-input-wrap:hover {
    border-color: var(--border-hover);
}
.chat-input-wrap:focus-within {
    border-color: var(--accent);
    background: var(--bg-input-focus, var(--bg-surface));
    box-shadow: 0 0 0 3px var(--accent-subtle, rgba(0, 196, 207, 0.16));
}
.chat-input-wrap textarea.chat-input,
.chat-input-wrap textarea,
.chat-input,
#chatPanelInput,
#chatInput {
    flex: 1 1 auto;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 24px !important;
    max-height: 120px !important;
    padding: 5px 0 !important;
    margin: 0 !important;
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    background-color: transparent !important;
    border-radius: 0 !important;
    resize: none !important;
    font-family: inherit !important;
    font-size: var(--text-sm, 13.5px) !important;
    line-height: 1.5 !important;
    color: var(--text-primary) !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}
.chat-input-wrap textarea.chat-input:hover,
.chat-input-wrap textarea.chat-input:focus,
.chat-input-wrap textarea.chat-input:active,
.chat-input-wrap textarea:hover,
.chat-input-wrap textarea:focus,
.chat-input:hover,
.chat-input:focus,
.chat-input:active,
#chatPanelInput:hover,
#chatPanelInput:focus,
#chatInput:hover,
#chatInput:focus {
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    background-color: transparent !important;
}
.chat-input::placeholder {
    color: var(--text-muted);
    opacity: 0.75;
}
.chat-input:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.chat-send {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-active));
    box-shadow: 0 4px 14px var(--accent-glow);
    transition: transform var(--duration-fast) var(--ease-spring),
                box-shadow var(--duration-fast) var(--ease-default),
                opacity var(--duration-fast) var(--ease-default);
}
.chat-send svg { width: 17px; height: 17px; transition: transform var(--duration-normal) var(--ease-spring); }
.chat-send:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 8px 22px var(--accent-glow); }
.chat-send:hover svg { transform: translate(2px, -2px); }
.chat-send:active { transform: scale(0.94); }
.chat-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.chat-send.is-busy svg { opacity: 0; }
.chat-send.is-busy::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: var(--radius-full);
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    animation: chatSpin 0.65s linear infinite;
}

.chat-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 6px 2px 0;
    font-size: 10.5px;
    color: var(--text-disabled);
}
.chat-counter { font-variant-numeric: tabular-nums; }
.chat-counter.warn { color: var(--warning); }
.chat-counter.danger { color: var(--error); font-weight: var(--font-semibold); }

/* ─── Two-Pane Modern Chat Workspace (/messages) ─────────── */
.chat-app-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    height: calc(100vh - 165px);
    height: calc(100dvh - 165px);
    min-height: 560px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xl);
    overflow: hidden;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
    margin-bottom: 24px;
    position: relative;
}

.chat-sidebar-pane {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background: var(--bg-card);
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

.chat-sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.chat-sidebar-filter {
    padding: 8px 12px 4px;
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-card);
    flex-shrink: 0;
    overflow-x: auto;
}
.chat-filter-tab {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.chat-filter-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}
.chat-filter-tab.is-active {
    color: var(--accent);
    background: var(--accent-subtle);
    border-color: rgba(0, 196, 207, 0.3);
}

.chat-sidebar-search {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-card);
    flex-shrink: 0;
}

.chat-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.chat-conv-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    background: transparent;
}
.chat-conv-row:hover {
    background: rgba(255, 255, 255, 0.04);
    transform: translateX(2px);
}
.chat-conv-row.active {
    background: rgba(0, 196, 207, 0.09) !important;
    border-color: rgba(0, 196, 207, 0.25) !important;
    box-shadow: inset 3px 0 0 var(--accent);
}
.chat-conv-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.chat-conv-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13.5px;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.chat-conv-online-dot {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    border: 2px solid var(--bg-card);
}
.chat-unread-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--accent-contrast, #fff);
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.chat-main-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    position: relative;
}

.chat-main-pane .chat-shell {
    height: 100% !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    max-width: none !important;
    margin: 0 !important;
}

.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 24px;
    text-align: center;
    color: var(--text-muted);
}

/* Hover message action bar */
.chat-msg-actions-bar {
    position: absolute;
    right: 12px;
    top: -14px;
    display: none;
    align-items: center;
    gap: 3px;
    padding: 3px 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    z-index: 10;
    animation: chatMsgIn 0.18s ease-out;
}
.chat-msg:hover .chat-msg-actions-bar {
    display: inline-flex;
}
.chat-action-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.12s ease;
    padding: 0;
}
.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    transform: scale(1.1);
}
.chat-action-btn.btn-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

/* Quick Emoji Picker */
.chat-emoji-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.chat-emoji-btn:hover {
    color: var(--accent);
    background: rgba(0, 196, 207, 0.1);
}
.chat-emoji-popup {
    position: absolute;
    bottom: 64px;
    left: 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    padding: 8px 10px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    z-index: 40;
}
.chat-emoji-item {
    font-size: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: transform 0.12s ease, background 0.12s ease;
}
.chat-emoji-item:hover {
    transform: scale(1.25);
    background: rgba(255, 255, 255, 0.1);
}

/* ─── Responsive Messages Workspace (<= 768px) ────────────── */
@media (max-width: 768px) {
    /* Freeze outer page scrolling when on messages */
    body.is-messages-page {
        overflow: hidden !important;
        height: 100vh !important;
        height: 100dvh !important;
    }
    body.is-messages-page .app-shell,
    body.is-messages-page .main-content,
    body.is-messages-page .main {
        height: 100% !important;
        min-height: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        margin-left: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }
    body.is-messages-page .topbar {
        flex-shrink: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    body.is-messages-page .messages-page-header {
        display: none !important;
    }
    body.is-messages-page .content {
        flex: 1 1 0% !important;
        min-height: 0 !important;
        height: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .chat-app-container {
        grid-template-columns: 1fr !important;
        flex: 1 1 0% !important;
        min-height: 0 !important;
        height: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: none !important;
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        box-shadow: none !important;
        display: flex !important;
        flex-direction: column !important;
        position: relative !important;
    }

    /* Active Chat View: Fullscreen messenger */
    .chat-app-container.has-active-chat .chat-sidebar-pane {
        display: none !important;
    }
    .chat-app-container.has-active-chat .chat-main-pane {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 0% !important;
        min-height: 0 !important;
        height: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    .chat-app-container.has-active-chat .chat-main-pane .chat-shell {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 0% !important;
        min-height: 0 !important;
        height: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        margin: 0 !important;
    }

    /* Hide global mobile bottom nav in active chat view */
    body.is-messages-page.has-active-chat-view .mobile-nav,
    body.chat-keyboard-open .mobile-nav {
        display: none !important;
    }

    /* Conversation List View: Take full space above bottom nav */
    .chat-app-container:not(.has-active-chat) .chat-main-pane {
        display: none !important;
    }
    .chat-app-container:not(.has-active-chat) .chat-sidebar-pane {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 0% !important;
        min-height: 0 !important;
        height: 100% !important;
        width: 100% !important;
        border: none !important;
        background: var(--bg-card) !important;
    }
    .chat-sidebar-header {
        padding: 12px 14px !important;
        flex-shrink: 0 !important;
    }
    .chat-sidebar-filter {
        padding: 8px 12px !important;
        flex-shrink: 0 !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .chat-sidebar-search {
        padding: 8px 12px !important;
        flex-shrink: 0 !important;
    }
    .chat-sidebar-list {
        flex: 1 1 0% !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 6px 8px 84px !important; /* safe space above mobile nav */
    }

    /* Back button on mobile */
    .chat-back-mobile {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        border-radius: 50% !important;
        color: var(--text-primary) !important;
        text-decoration: none !important;
        background: transparent !important;
        transition: background 0.15s ease !important;
        flex-shrink: 0 !important;
    }
    .chat-back-mobile:active {
        background: rgba(255, 255, 255, 0.1) !important;
    }

    /* Clean, single-row chat header */
    .chat-shell-head {
        display: flex !important;
        align-items: center !important;
        flex-shrink: 0 !important;
        height: 56px !important;
        min-height: 56px !important;
        max-height: 56px !important;
        padding: 0 10px !important;
        gap: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        flex-wrap: nowrap !important;
        border-bottom: 1px solid var(--border-color) !important;
        background: var(--bg-card) !important;
        z-index: 10 !important;
    }
    .chat-head-avatar {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        border-radius: 11px !important;
        flex-shrink: 0 !important;
        font-size: 13px !important;
        font-weight: 700 !important;
    }
    .chat-head-text {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }
    .chat-head-title {
        font-size: 14.5px !important;
        font-weight: 700 !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .chat-head-title > span:first-child {
        max-width: none !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    .chat-head-sub {
        font-size: 11px !important;
        margin: 1px 0 0 !important;
        color: var(--text-muted) !important;
        display: flex !important;
        align-items: center !important;
        gap: 5px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .chat-head-actions {
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
        flex-shrink: 0 !important;
        margin-left: auto !important;
    }

    /* Compact expandable search */
    .chat-search {
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        width: auto !important;
        margin: 0 !important;
        order: 0 !important;
    }
    .chat-search-input {
        width: 34px !important;
        height: 34px !important;
        padding: 0 0 0 32px !important;
        border-radius: var(--radius-full) !important;
        background: transparent !important;
        border: 1px solid transparent !important;
        cursor: pointer !important;
        font-size: 16px !important;
        transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: center !important;
        color: transparent !important;
    }
    .chat-search-input:focus,
    .chat-search-input:not(:placeholder-shown) {
        width: min(190px, 48vw) !important;
        padding: 6px 12px 6px 30px !important;
        background: var(--bg-card) !important;
        border-color: var(--accent) !important;
        background-position: 9px center !important;
        color: var(--text-primary) !important;
        cursor: text !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45) !important;
        z-index: 25 !important;
    }
    .chat-search-dropdown {
        width: min(300px, 85vw) !important;
        right: 0 !important;
        left: auto !important;
    }

    .chat-icon-btn {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        border-radius: 50% !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
    }

    /* Message list container */
    .chat-scroll,
    .chat-messages {
        flex: 1 1 0% !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior-y: contain !important;
        padding: 12px 10px 8px !important;
    }
    .chat-msg {
        max-width: 88% !important;
    }
    .chat-bubble {
        font-size: 13.5px !important;
        padding: 8px 12px !important;
        border-radius: 16px !important;
    }

    /* Jump button */
    .chat-jump {
        bottom: 74px !important;
        right: 12px !important;
        padding: 5px 10px !important;
        font-size: 11px !important;
        z-index: 25 !important;
    }

    /* Bottom composer: pinned and always visible */
    .chat-foot {
        flex-shrink: 0 !important;
        position: relative !important;
        z-index: 30 !important;
        background: var(--bg-card) !important;
        border-top: 1px solid var(--border-color) !important;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .chat-composer {
        display: flex !important;
        align-items: flex-end !important;
        gap: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .chat-input-wrap {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        display: flex !important;
        align-items: center !important;
        padding: 6px 12px !important;
        border-radius: 20px !important;
        background: var(--bg-secondary) !important;
        border: 1px solid var(--border-color) !important;
        box-sizing: border-box !important;
    }
    .chat-input-wrap:focus-within {
        border-color: var(--accent) !important;
    }
    .chat-input-wrap textarea.chat-input,
    .chat-input-wrap textarea,
    .chat-input {
        flex: 1 1 auto !important;
        width: 100% !important;
        min-width: 0 !important;
        min-height: 24px !important;
        max-height: 110px !important;
        padding: 2px 0 !important;
        margin: 0 !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
        background: transparent !important;
        font-size: 16px !important; /* Prevents iOS auto-zoom */
        line-height: 1.4 !important;
        color: var(--text-primary) !important;
        resize: none !important;
    }
    .chat-send {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        border-radius: 50% !important;
        flex-shrink: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .chat-emoji-btn {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        flex-shrink: 0 !important;
        border-radius: 50% !important;
    }
    .chat-hint-shortcuts {
        display: none !important;
    }
    .chat-hint {
        justify-content: flex-end !important;
        margin: 2px 4px 0 !important;
    }
}
@media (min-width: 769px) {
    .chat-back-mobile {
        display: none !important;
    }
}

/* ─── Full-page chat shell (/messages/{id}) ───────────────── */
.chat-shell {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 190px);
    min-height: 420px;
    overflow: hidden;
    border-radius: var(--radius-2xl);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
    position: relative;
}
.chat-shell-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    flex-shrink: 0;
    background:
        linear-gradient(135deg, rgba(0, 196, 207, 0.10), rgba(139, 92, 246, 0.08)),
        var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}
.chat-presence {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-muted);
    min-width: 12px;
    text-align: right;
}

/* ─── Animations ──────────────────────────────────────────── */
@keyframes chatMsgIn {
    from { opacity: 0; transform: translateY(10px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes chatRing {
    0%   { transform: scale(0.92); opacity: 0.65; }
    70%  { transform: scale(1.45); opacity: 0; }
    100% { transform: scale(1.45); opacity: 0; }
}
@keyframes chatLive {
    0%   { box-shadow: 0 0 0 0 var(--success-glow); }
    70%  { box-shadow: 0 0 0 6px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes chatShimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
@keyframes chatDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}
@keyframes chatSpin { to { transform: rotate(360deg); } }
@keyframes chatBubblePulse {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 0.9; }
}
@keyframes chatBadgePop {
    0%   { transform: scale(0.4); }
    60%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
    .chat-fab {
        right: 16px;
        bottom: calc(var(--mobile-nav-height, 60px) + 14px);
        width: 50px;
        height: 50px;
        box-shadow: 0 8px 24px var(--accent-glow);
    }
    .chat-fab-ico svg { width: 20px; height: 20px; }

    .chat-popup {
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 88vh !important;
        height: 88dvh !important;
        max-height: calc(100dvh - 16px) !important;
        border-radius: 20px 20px 0 0 !important;
        border: 1px solid var(--border-color) !important;
        border-bottom: none !important;
        box-shadow: 0 -8px 36px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06) !important;
        transform: translateY(105%) !important;
        transform-origin: bottom center;
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, visibility 0.25s !important;
        z-index: 9998 !important;
    }
    .chat-popup::before {
        content: '';
        display: block;
        width: 38px;
        height: 4px;
        border-radius: 2px;
        background: var(--text-disabled, rgba(255, 255, 255, 0.3));
        opacity: 0.45;
        margin: 7px auto 0;
        flex-shrink: 0;
    }
    .chat-popup.is-open {
        transform: translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    .chat-overlay {
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .chat-popup-head {
        padding: 9px 12px 11px;
        gap: 8px;
    }
    .chat-popup .chat-head-avatar {
        width: 36px;
        height: 36px;
        border-radius: 11px;
    }
    .chat-popup .chat-head-title {
        font-size: 13.5px;
    }
    .chat-popup .chat-head-title > span:first-child {
        max-width: 150px;
    }
    .chat-popup .chat-head-sub {
        font-size: 11px;
    }
    .chat-popup .chat-head-actions {
        gap: 3px;
    }
    .chat-popup .chat-icon-btn {
        width: 34px;
        height: 34px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-msg,
    .chat-day,
    .chat-empty,
    .chat-typing,
    .chat-fab.has-unread::after,
    .chat-dot-live,
    .chat-skel-bubble,
    .chat-typing-dots span,
    .chat-msg.sending .chat-bubble,
    .chat-fab-badge.pop,
    .chat-send.is-busy::after {
        animation: none !important;
    }
    .chat-popup,
    .chat-overlay,
    .chat-jump,
    .chat-fab,
    .chat-fab-ico {
        transition-duration: 1ms !important;
    }
}



@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.animate-spin {
  animation: spin 0.75s linear infinite;
  display: inline-block;
}

/* ════════════════════════════════════════════════════════════
   MODERN EMAIL WORKSPACE / CLIENT (Spacious 2-Column Architecture)
   ============================================================ */

/* 2-Column Responsive Layout */
.mail-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: start;
  width: 100%;
}

/* Account Switcher Bar */
.mail-account-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 16px;
}
.mail-account-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.mail-account-pill:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.mail-account-pill.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
  font-weight: 600;
}
.mail-account-pill .acc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mail-account-pill .acc-badge {
  font-size: 10px;
  background: var(--accent);
  color: #04191b;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}

/* Left Folder Navigation Rail */
.mail-sidebar-card {
  position: sticky;
  top: 80px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mail-compose-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #00c4cf, #0ea5e9);
  color: #04191b;
  font-size: 13.5px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 196, 207, 0.25);
  transition: all 0.15s ease;
  text-decoration: none;
}
.mail-compose-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 196, 207, 0.35);
  color: #04191b;
}

.mail-nav-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 6px 8px 4px;
}
.mail-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
  position: relative;
}
.mail-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.mail-nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.mail-nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.mail-nav-item i {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.mail-nav-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #04191b;
  margin-left: auto;
}
.mail-nav-badge.badge-warning {
  background: var(--warning);
  color: #fff;
}
.mail-nav-badge.badge-neutral {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.mail-sync-box {
  margin-top: 14px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}
.mail-sync-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.mail-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
  flex-shrink: 0;
}
.mail-sync-box .btn-manage {
  margin-top: 8px;
  width: 100%;
  padding: 5px 8px;
  font-size: 11px;
  border-radius: var(--radius-xs);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s ease;
}
.mail-sync-box .btn-manage:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Right Main Email List Card */
.mail-list-card {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.mail-list-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.mail-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  flex: 1;
  max-width: 380px;
}
.mail-search-bar i {
  color: var(--text-muted);
  width: 14px;
  height: 14px;
}
.mail-search-bar input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 12.5px;
  width: 100%;
  outline: none;
}

.mail-filter-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.mail-filter-pill {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.mail-filter-pill:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.mail-filter-pill.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
  font-weight: 600;
}

/* Bulk Action Bar */
.mail-bulk-toolbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-primary);
}
.mail-bulk-toolbar.is-visible {
  display: flex;
}

/* Email Rows (Natural Scrolling, Spacious) */
.mail-table-container {
  display: flex;
  flex-direction: column;
  width: 100%;
}
.mail-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  border-left: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.mail-row:last-child {
  border-bottom: none;
}
.mail-row:hover {
  background: var(--bg-hover);
  border-left-color: rgba(0, 196, 207, 0.4);
}
.mail-row.is-unread {
  background: rgba(0, 196, 207, 0.03);
  border-left-color: var(--accent);
}
.mail-row.is-unread .mail-row-from {
  font-weight: 750;
  color: var(--text-primary);
}
.mail-row.is-unread .mail-row-subj {
  font-weight: 700;
  color: var(--text-primary);
}

.mail-row-check {
  cursor: pointer;
  flex-shrink: 0;
}
.mail-row-star {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.mail-row-star:hover {
  transform: scale(1.15);
}
.mail-row-star.is-starred {
  color: var(--warning);
}
.mail-row-star.is-starred svg {
  fill: var(--warning);
}

.mail-row-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00c4cf, #0ea5e9);
  color: #fff;
  font-weight: 700;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.mail-row-from {
  width: 180px;
  flex-shrink: 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mail-row-unread-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  flex-shrink: 0;
}

.mail-row-content {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mail-row-subj {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 320px;
}
.mail-row-snippet {
  font-size: 12.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.mail-row-date {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: right;
  min-width: 70px;
  flex-shrink: 0;
  white-space: nowrap;
}

.mail-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}
.mail-row:hover .mail-row-actions {
  opacity: 1;
}
.mail-row-act-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mail-row-act-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.mail-row-act-btn.danger:hover {
  color: var(--danger);
}

/* Dedicated Reading View */
.mail-reader-shell {
  max-width: 980px;
  margin: 0 auto;
  padding-bottom: 50px;
}
.mail-body-frame {
  width: 100%;
  min-height: 480px;
  border: none;
  background: #ffffff;
  border-radius: var(--radius-sm);
  display: block;
}

/* Responsive */
@media (max-width: 860px) {
  .mail-layout {
    grid-template-columns: 1fr;
  }
  .mail-sidebar-card {
    position: static;
  }
  .mail-row-from {
    width: 130px;
  }
}

/* ------------------------------------------------------------ Plan & Agreement Theme Modes */
#agreementDocCard[data-doc-theme="light"],
.agreement-card-light {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06) !important;
}

#agreementDocCard[data-doc-theme="light"] h1,
#agreementDocCard[data-doc-theme="light"] h2,
#agreementDocCard[data-doc-theme="light"] h3,
#agreementDocCard[data-doc-theme="light"] strong {
  color: #0f172a !important;
}

#agreementDocCard[data-doc-theme="light"] .text-muted,
#agreementDocCard[data-doc-theme="light"] p[style*="var(--text-muted)"],
#agreementDocCard[data-doc-theme="light"] span[style*="var(--text-muted)"] {
  color: #64748b !important;
}

#agreementDocCard[data-doc-theme="light"] .md-body,
#agreementDocCard[data-doc-theme="light"] .agreement-content {
  color: #334155 !important;
}

#agreementDocCard[data-doc-theme="light"] .md-body h1,
#agreementDocCard[data-doc-theme="light"] .md-body h2,
#agreementDocCard[data-doc-theme="light"] .md-body h3,
#agreementDocCard[data-doc-theme="light"] .md-body h4 {
  color: #0f172a !important;
  border-bottom-color: #e2e8f0 !important;
}

#agreementDocCard[data-doc-theme="light"] div[style*="var(--bg-secondary)"] {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

#agreementDocCard[data-doc-theme="light"] input[readonly] {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

#agreementDocCard[data-doc-theme="light"] .badge-neutral {
  background: #e2e8f0 !important;
  color: #334155 !important;
}
