/* ========================================
   CSS Variables & Reset
   ======================================== */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary-color: #64748b;
  --success-color: #16a34a;
  --warning-color: #ca8a04;
  --danger-color: #dc2626;
  --background: #f8fafc;
  --surface: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

/* ========================================
   Typography
   ======================================== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.5em;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
  margin-bottom: 1rem;
}

/* ========================================
   Layout
   ======================================== */
.main-content {
  min-height: calc(100vh - 140px);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.container-sm {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ========================================
   Header
   ======================================== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
}

.logo-icon {
  font-size: 1.5rem;
}

.nav-main {
  display: flex;
  gap: 0.25rem;
  margin-left: 1.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.nav-link .nav-icon {
  font-size: 1rem;
}

.nav-link:hover {
  color: var(--primary-color);
  background: var(--primary-light);
  text-decoration: none;
}

.nav-link.active {
  color: var(--primary-color);
  background: var(--primary-light);
}

/* Mobile Menu Toggle (Hamburger) */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius);
}

.mobile-menu-toggle:hover {
  background: var(--background);
}

.hamburger-line {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all 0.3s;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* User Menu */
.user-menu {
  position: relative;
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.user-menu-toggle:hover {
  background: var(--background);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

.user-name {
  font-weight: 500;
  color: var(--text-primary);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-arrow {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.user-menu-toggle[aria-expanded="true"] .dropdown-arrow {
  transform: rotate(180deg);
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 110;
}

.user-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-header {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.dropdown-header strong {
  display: block;
  font-size: 0.9375rem;
}

.dropdown-divider {
  border-top: 1px solid var(--border-color);
  margin: 0.25rem 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.2s;
  font-size: 0.875rem;
}

.dropdown-item:hover {
  background: var(--background);
  text-decoration: none;
}

.dropdown-item-danger {
  color: var(--danger-color);
}

.dropdown-item-danger:hover {
  background: #fef2f2;
}

.dropdown-icon {
  width: 1.25rem;
  text-align: center;
  font-size: 1rem;
}

/* Mobile Navigation Drawer */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s;
}

.mobile-nav-overlay.show {
  display: block;
  opacity: 1;
}

.mobile-nav {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100vh;
  background: var(--surface);
  z-index: 210;
  display: flex;
  flex-direction: column;
  transition: left 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.mobile-nav.show {
  left: 0;
}

.mobile-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.mobile-nav-header .logo-text {
  font-weight: 700;
  font-size: 1.125rem;
}

.mobile-nav-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--text-secondary);
}

.mobile-nav-close:hover {
  background: var(--background);
  color: var(--text-primary);
}

.mobile-nav-links {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s;
}

.mobile-nav-link:hover {
  background: var(--background);
  text-decoration: none;
}

.mobile-nav-link.active {
  color: var(--primary-color);
  background: var(--primary-light);
}

.mobile-nav-link .nav-icon {
  font-size: 1.25rem;
  width: 1.5rem;
  text-align: center;
}

.mobile-nav-link-danger {
  color: var(--danger-color);
}

.mobile-nav-link-danger:hover {
  background: #fef2f2;
}

.mobile-nav-footer {
  padding: 1rem 0;
  border-top: 1px solid var(--border-color);
}

/* Responsive Header */
@media (max-width: 1024px) {
  .nav-main {
    display: none;
  }

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

  .user-name {
    display: none;
  }
}

@media (max-width: 480px) {
  .logo-text {
    display: none;
  }

  .logo-icon {
    font-size: 1.75rem;
  }
}

/* ========================================
   Footer
   ======================================== */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary:hover {
  background: #475569;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--background);
  border-color: var(--text-muted);
}

.btn-success {
  background: var(--success-color);
  color: white;
}

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

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1.0625rem;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
}

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

/* ========================================
   Forms
   ======================================== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group-inline {
  display: flex;
  gap: 1rem;
}

.form-group-inline .form-group {
  flex: 1;
  margin-bottom: 0;
}

.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-label-required::after {
  content: ' *';
  color: var(--danger-color);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background: var(--background);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--danger-color);
}

.form-input.success,
.form-select.success {
  border-color: var(--success-color);
}

/* Input Sizes */
.form-input-sm,
.form-select-sm {
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
}

.form-input-lg,
.form-select-lg {
  padding: 0.75rem 1rem;
  font-size: 1rem;
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.form-error {
  font-size: 0.8125rem;
  color: var(--danger-color);
  margin-top: 0.25rem;
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

/* Input Group */
.input-group {
  display: flex;
  position: relative;
}

.input-group .form-input {
  flex: 1;
}

.input-group .form-input:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.input-group .form-input:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group-text {
  display: flex;
  align-items: center;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  background: var(--background);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.input-group-text:first-child {
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
}

.input-group-text:last-child {
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.input-group .btn {
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.form-check-input {
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 0.125rem;
  cursor: pointer;
  accent-color: var(--primary-color);
}

.form-check-label {
  cursor: pointer;
  color: var(--text-primary);
  line-height: 1.4;
}

.form-check-inline {
  display: inline-flex;
  margin-right: 1rem;
}

/* Custom Checkbox */
.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.custom-checkbox input[type="checkbox"] {
  display: none;
}

.custom-checkbox .checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.custom-checkbox input:checked + .checkmark {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.custom-checkbox input:checked + .checkmark::after {
  content: '✓';
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
}

/* File Input */
.form-file {
  position: relative;
}

.form-file-input {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.form-file-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.form-file-label:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

.form-file-icon {
  font-size: 1.5rem;
  color: var(--text-muted);
}

.form-file-text {
  color: var(--text-secondary);
}

.form-file-text strong {
  color: var(--primary-color);
}

/* Search Input */
.search-input-wrapper {
  position: relative;
}

.search-input-wrapper .form-input {
  padding-left: 2.5rem;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input-wrapper .search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
}

.search-input-wrapper .search-clear:hover {
  background: var(--background);
  color: var(--text-primary);
}

/* Number Input with Stepper */
.number-input-wrapper {
  display: flex;
  align-items: stretch;
  max-width: 150px;
}

.number-input-wrapper .form-input {
  text-align: center;
  border-radius: 0;
  -moz-appearance: textfield;
}

.number-input-wrapper .form-input::-webkit-outer-spin-button,
.number-input-wrapper .form-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.number-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  background: var(--background);
  border: 1px solid var(--border-color);
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.number-btn:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: none;
}

.number-btn:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: none;
}

.number-btn:hover {
  background: var(--primary-light);
  color: var(--primary-color);
}

/* Password Requirements */
.password-requirements {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
}

.password-requirements li {
  color: var(--text-muted);
  padding: 0.125rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.password-requirements li::before {
  content: '○';
  font-size: 0.625rem;
}

.password-requirements li.valid {
  color: var(--success-color);
}

.password-requirements li.valid::before {
  content: '●';
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.form-actions-right {
  justify-content: flex-end;
}

.form-actions-spread {
  justify-content: space-between;
}

/* Responsive Forms */
@media (max-width: 600px) {
  .form-group-inline {
    flex-direction: column;
    gap: 0;
  }

  .form-group-inline .form-group {
    margin-bottom: 1.25rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }
}

/* ========================================
   Cards
   ======================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  margin: 0;
  font-size: 1.125rem;
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--background);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ========================================
   Landing Page
   ======================================== */
.landing-hero {
  background: linear-gradient(135deg, var(--primary-color), #1e40af);
  color: white;
  padding: 5rem 1rem;
  text-align: center;
}

.landing-hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.landing-hero p {
  font-size: 1.25rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 2rem;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-buttons .btn {
  min-width: 160px;
}

.btn-white {
  background: white;
  color: var(--primary-color);
}

.btn-white:hover {
  background: #f1f5f9;
}

.btn-outline-white {
  background: transparent;
  border: 2px solid white;
  color: white;
}

.btn-outline-white:hover {
  background: rgba(255, 255, 255, 0.1);
}

.landing-features {
  padding: 4rem 1rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  max-width: 1000px;
  margin: 0 auto;
}

.feature-card {
  text-align: center;
  padding: 2rem;
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.feature-card h3 {
  margin-bottom: 0.75rem;
}

.feature-card p {
  color: var(--text-secondary);
  margin: 0;
}

.landing-cta {
  background: var(--background);
  padding: 3rem 1rem;
  text-align: center;
}

.invite-notice {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
  padding: 1rem;
  max-width: 500px;
  margin: 2rem auto;
  color: #92400e;
}

/* ========================================
   Auth Pages
   ======================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--background);
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.auth-header p {
  color: var(--text-secondary);
  margin: 0;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.password-requirements {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding-left: 1rem;
}

.password-requirements li {
  margin-bottom: 0.25rem;
}

/* ========================================
   Dashboard
   ======================================== */
.dashboard {
  padding: 2rem 1rem;
}

.dashboard-header {
  margin-bottom: 2rem;
}

.dashboard-header h1 {
  margin-bottom: 0.5rem;
}

.dashboard-header p {
  color: var(--text-secondary);
  margin: 0;
}

.dashboard-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text-primary);
  min-width: 160px;
}

.action-btn:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.action-btn-icon {
  font-size: 2rem;
}

.action-btn-label {
  font-weight: 500;
}

/* Hierarchy Tree */
.hierarchy-section {
  margin-top: 2rem;
}

.hierarchy-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.toggle-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.tree-container {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  max-height: 500px;
  overflow-y: auto;
}

.tree-node {
  padding: 0.25rem 0;
}

.tree-node-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.tree-node-content:hover {
  background: var(--background);
}

.tree-toggle {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}

.tree-toggle:hover {
  color: var(--primary-color);
}

.tree-icon {
  font-size: 1rem;
}

.tree-label {
  flex: 1;
}

.tree-action {
  font-size: 0.8125rem;
  padding: 0.25rem 0.5rem;
  background: var(--primary-light);
  color: var(--primary-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.tree-node-content:hover .tree-action {
  opacity: 1;
}

.tree-children {
  padding-left: 1.5rem;
  display: none;
}

.tree-children.expanded {
  display: block;
}

/* ========================================
   Enhanced Hierarchy Tree Styles
   ======================================== */

/* Tree Toolbar */
.tree-toolbar {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--background);
  flex-wrap: wrap;
  align-items: center;
}

.tree-toolbar-group {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.tree-toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 0.5rem;
}

.toolbar-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  border: 1px solid var(--border-color);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.toolbar-btn:hover {
  background: var(--background);
  border-color: #1976d2;
  color: #1976d2;
}

.toolbar-btn.active {
  background: #1976d2;
  border-color: #1976d2;
  color: white;
}

/* View Toggle Buttons */
.view-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-toggle-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.view-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--border-color);
}

.view-toggle-btn.active {
  background: #1976d2;
  color: white;
}

.view-toggle-btn:hover:not(.active) {
  background: var(--background);
}

/* Search with Dropdown */
.tree-search-wrapper {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 390px;
}

.tree-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  padding-left: 2rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tree-search-input:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.tree-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  margin-top: 0.25rem;
}

.search-result-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  transition: background 0.15s ease;
}

.search-result-item:hover {
  background: var(--background);
}

.search-no-results {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Enhanced Tree Item Styling */
.tree-item {
  padding: 0.125rem 0;
}

.tree-item-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.tree-item-row:hover {
  background: rgba(25, 118, 210, 0.04);
}

.tree-item-row.selected {
  background: rgba(25, 118, 210, 0.08);
  border-left-color: #1976d2;
}

/* Tree Toggle Styles */
.tree-expander {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.625rem;
  transition: color 0.15s ease;
  flex-shrink: 0;
}

.tree-expander:hover {
  color: #1976d2;
}

.tree-expander.leaf {
  color: var(--text-muted);
  cursor: default;
}

/* Hierarchy Number */
.hierarchy-number {
  font-weight: 600;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.65rem;
  color: #1976d2;
  margin-right: 0.5rem;
  white-space: nowrap;
  min-width: 50px;
  display: inline-block;
  text-align: left;
  flex-shrink: 0;
}

/* Tree Indentation - updated for 24px */
.tree-children {
  padding-left: 24px;
}

/* Context Menu */
.tree-context-menu {
  position: fixed;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  padding: 0.25rem 0;
  animation: contextMenuFade 0.1s ease;
}

@keyframes contextMenuFade {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.context-menu-item {
  padding: 0.5rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: background 0.1s ease;
}

.context-menu-item:hover {
  background: var(--background);
}

.context-menu-item.danger {
  color: var(--danger-color);
}

.context-menu-item.danger:hover {
  background: #fef2f2;
}

.context-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.25rem 0;
}

.context-icon {
  width: 16px;
  text-align: center;
  font-size: 0.75rem;
}

/* Custom Folder Styles */
.folder-section {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--border-color);
}

.folder-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.folder-item:hover {
  background: var(--background);
}

.folder-item.selected {
  background: rgba(25, 118, 210, 0.08);
  border-left: 3px solid #1976d2;
}

.folder-icon {
  font-size: 1.125rem;
}

.folder-name {
  flex: 1;
  font-weight: 500;
}

.folder-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--background);
  padding: 0.125rem 0.375rem;
  border-radius: 999px;
}

/* Empty folder drop zone */
.folder-drop-zone {
  padding: 1rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0.5rem;
  transition: all 0.15s ease;
}

.folder-drop-zone.drag-over {
  border-color: #1976d2;
  background: rgba(25, 118, 210, 0.04);
  color: #1976d2;
}

/* Tree Action Buttons */
.tree-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.tree-item-row:hover .tree-actions {
  opacity: 1;
}

.tree-action-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  transition: all 0.15s ease;
}

.tree-action-btn:hover {
  background: var(--background);
  color: #1976d2;
}

.tree-action-btn.danger:hover {
  color: var(--danger-color);
  background: #fef2f2;
}

/* Shared Badge */
.shared-badge {
  font-size: 0.6875rem;
  padding: 0.125rem 0.375rem;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 999px;
  white-space: nowrap;
}

/* Level Badge for locations */
.tree-level-badge {
  font-size: 0.6875rem;
  padding: 0.125rem 0.375rem;
  background: var(--background);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  text-transform: capitalize;
}

/* ========================================
   Modal
   ======================================== */
.modal-overlay,
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.show,
.modal.show,
.modal[style*="display: flex"] {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(-20px);
  transition: transform 0.2s ease;
}

.modal-overlay.show .modal-content,
.modal.show .modal-content,
.modal[style*="display: flex"] .modal-content {
  transform: scale(1) translateY(0);
}

/* Modal Sizes */
.modal-sm .modal-content,
.modal-content.modal-sm {
  max-width: 400px;
}

.modal-lg .modal-content,
.modal-content.modal-lg {
  max-width: 700px;
}

.modal-xl .modal-content,
.modal-content.modal-xl {
  max-width: 900px;
}

.modal-full .modal-content,
.modal-content.modal-full {
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.modal-header h3,
.modal-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s;
  margin: -0.25rem -0.5rem -0.25rem 0.5rem;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--background);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-body-scrollable {
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--background);
  flex-shrink: 0;
}

.modal-footer-left {
  justify-content: flex-start;
}

.modal-footer-spread {
  justify-content: space-between;
}

/* Confirmation Modal */
.modal-confirm .modal-body {
  text-align: center;
  padding: 2rem 1.5rem;
}

.modal-confirm .modal-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.modal-confirm .modal-icon-warning {
  color: var(--warning-color);
}

.modal-confirm .modal-icon-danger {
  color: var(--danger-color);
}

.modal-confirm .modal-icon-success {
  color: var(--success-color);
}

.modal-confirm .modal-message {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0;
}

.modal-confirm .modal-footer {
  justify-content: center;
}

/* Modal Loading State */
.modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
}

.modal-loading .spinner {
  width: 40px;
  height: 40px;
}

/* Responsive Modal */
@media (max-width: 600px) {
  .modal-content {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .modal-overlay,
  .modal {
    padding: 0;
  }

  .modal-sm .modal-content,
  .modal-lg .modal-content,
  .modal-xl .modal-content {
    max-width: 100%;
  }
}

/* ========================================
   Alerts & Toasts
   ======================================== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.alert-icon {
  flex-shrink: 0;
  font-size: 1.25rem;
  line-height: 1;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.alert-message {
  font-size: 0.875rem;
  margin: 0;
}

.alert-close {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0.6;
  padding: 0;
  line-height: 1;
}

.alert-close:hover {
  opacity: 1;
}

.alert-success {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}

.alert-error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.alert-warning {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
}

.alert-info {
  background: var(--primary-light);
  border: 1px solid #93c5fd;
  color: #1e40af;
}

/* Alert with action */
.alert-action {
  flex-shrink: 0;
}

.alert-action .btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

/* Dismissible alert animation */
.alert.fade-out {
  animation: alertFadeOut 0.3s ease forwards;
}

@keyframes alertFadeOut {
  to {
    opacity: 0;
    transform: translateX(20px);
    height: 0;
    padding: 0;
    margin: 0;
  }
}

/* Banner alerts (full width) */
.alert-banner {
  border-radius: 0;
  margin-bottom: 0;
  border-left: none;
  border-right: none;
}

/* Toast Container */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 400px;
  width: 100%;
  pointer-events: none;
}

/* Toast */
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--text-primary);
  color: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: toastSlideIn 0.3s ease;
  pointer-events: all;
}

.toast-icon {
  flex-shrink: 0;
  font-size: 1.25rem;
  line-height: 1;
}

.toast-content {
  flex: 1;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0.7;
  padding: 0;
  line-height: 1;
}

.toast-close:hover {
  opacity: 1;
}

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

.toast-error {
  background: var(--danger-color);
}

.toast-warning {
  background: var(--warning-color);
  color: #1a1a1a;
}

.toast-info {
  background: var(--primary-color);
}

/* Toast progress bar */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 0 0 var(--radius) var(--radius);
  animation: toastProgress 4s linear forwards;
}

@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.fade-out {
  animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Responsive toasts */
@media (max-width: 480px) {
  #toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    max-width: none;
  }

  .toast {
    font-size: 0.875rem;
  }
}

/* ========================================
   Tables & Data Tables
   ======================================== */
.table-container {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

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

.table th,
.table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  font-weight: 600;
  background: var(--background);
  white-space: nowrap;
}

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

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

/* Data Table Component */
.data-table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
  flex-wrap: wrap;
}

.data-table-title {
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
}

.data-table-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--background);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.375rem 0.75rem;
  max-width: 300px;
  flex: 1;
}

.data-table-search input {
  border: none;
  background: none;
  flex: 1;
  font-size: 0.875rem;
  outline: none;
  min-width: 100px;
}

.data-table-actions {
  display: flex;
  gap: 0.5rem;
}

.data-table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  font-weight: 600;
  background: var(--background);
  white-space: nowrap;
  user-select: none;
}

.data-table th.sortable {
  cursor: pointer;
  transition: background 0.2s;
}

.data-table th.sortable:hover {
  background: var(--primary-light);
}

.data-table th .sort-icon {
  display: inline-block;
  margin-left: 0.5rem;
  opacity: 0.3;
  transition: opacity 0.2s;
}

.data-table th.sorted .sort-icon {
  opacity: 1;
  color: var(--primary-color);
}

.data-table th.sorted-desc .sort-icon {
  transform: rotate(180deg);
}

.data-table tbody tr {
  transition: background 0.2s;
}

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

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

.data-table tbody tr.selected {
  background: var(--primary-light);
}

/* Table Cell Variants */
.data-table .cell-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table .cell-center {
  text-align: center;
}

.data-table .cell-actions {
  text-align: right;
  white-space: nowrap;
}

.data-table .cell-compact {
  padding: 0.5rem 1rem;
}

.data-table .cell-nowrap {
  white-space: nowrap;
}

/* Table Status Badges */
.table-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

.table-badge-success {
  background: #dcfce7;
  color: var(--success-color);
}

.table-badge-warning {
  background: #fef3c7;
  color: var(--warning-color);
}

.table-badge-danger {
  background: #fee2e2;
  color: var(--danger-color);
}

.table-badge-info {
  background: var(--primary-light);
  color: var(--primary-color);
}

/* Data Table Footer with Pagination */
.data-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background: var(--background);
  gap: 1rem;
  flex-wrap: wrap;
}

.data-table-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.data-table-pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 0.5rem;
  border: 1px solid var(--border-color);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

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

.pagination-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.pagination-ellipsis {
  padding: 0 0.5rem;
  color: var(--text-muted);
}

/* Empty State */
.data-table-empty {
  padding: 3rem 1.5rem;
  text-align: center;
}

.data-table-empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.data-table-empty-text {
  color: var(--text-secondary);
  margin: 0;
}

/* Loading State */
.data-table-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
}

/* Responsive Data Table */
@media (max-width: 768px) {
  .data-table-header {
    flex-direction: column;
    align-items: stretch;
  }

  .data-table-search {
    max-width: none;
  }

  .data-table th,
  .data-table td {
    padding: 0.625rem 0.75rem;
  }

  .data-table-footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

/* Card-style table for mobile */
@media (max-width: 600px) {
  .data-table-responsive thead {
    display: none;
  }

  .data-table-responsive tbody tr {
    display: block;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
  }

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

  .data-table-responsive tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.375rem 0;
    border-bottom: none;
    text-align: right;
  }

  .data-table-responsive tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    text-align: left;
    padding-right: 1rem;
  }

  .data-table-responsive tbody td:first-child {
    font-weight: 600;
  }
}

/* ========================================
   Settings Page
   ======================================== */
.settings-page {
  padding: 2rem 1rem;
}

.settings-container {
  max-width: 800px;
  margin: 0 auto;
}

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}

.settings-section-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.settings-section-title {
  margin: 0;
  font-size: 1.125rem;
}

.settings-section-body {
  padding: 1.5rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.settings-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-column .settings-section {
  margin-bottom: 0;
}

.settings-container {
  max-width: 1100px;
}

/* Toggle Switches */
.settings-toggle-group {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.settings-toggle-group:last-of-type {
  border-bottom: none;
}

.settings-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.settings-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.settings-toggle input:checked + .toggle-slider {
  background-color: var(--primary-color);
}

.settings-toggle input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

.toggle-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.toggle-title {
  font-weight: 500;
  color: var(--text-primary);
}

.toggle-description {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Account Info Grid */
.account-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.info-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.info-value {
  font-weight: 500;
  color: var(--text-primary);
}

/* Role & Status Badges */
.role-badge, .status-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.role-creator {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f;
}

.role-admin {
  background: linear-gradient(135deg, #818cf8, #6366f1);
  color: white;
}

.role-user {
  background: var(--primary-light);
  color: var(--primary-color);
}

.status-active {
  background: #dcfce7;
  color: var(--success-color);
}

.status-pending {
  background: #fef3c7;
  color: var(--warning-color);
}

.status-suspended {
  background: #fee2e2;
  color: var(--danger-color);
}

/* Activity Summary */
.activity-last-login {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--background);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.activity-icon {
  font-size: 1.5rem;
}

.activity-last-login p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.activity-stats h4 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
}

.activity-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem;
  background: var(--background);
  border-radius: var(--radius);
  text-align: center;
}

.stat-count {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* Danger Zone */
.settings-section-danger {
  border-color: #fecaca;
}

.settings-section-danger .settings-section-header {
  background: #fef2f2;
  border-bottom-color: #fecaca;
}

.settings-section-danger .settings-section-title {
  color: var(--danger-color);
}

/* ========================================
   Utilities
   ======================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.hidden { display: none !important; }

/* ========================================
   Loading States & Spinners
   ======================================== */

/* Basic Spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

.spinner-xl {
  width: 64px;
  height: 64px;
  border-width: 5px;
}

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

/* Button Spinner */
.btn .spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: white;
}

.btn-secondary .spinner {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: var(--text-primary);
}

.btn-outline .spinner {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: var(--primary-color);
}

/* Button Loading State */
.btn-loading {
  position: relative;
  pointer-events: none;
}

.btn-loading .btn-text {
  visibility: hidden;
}

.btn-loading .spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 10;
}

.loading-overlay-dark {
  background: rgba(0, 0, 0, 0.5);
  color: white;
}

.loading-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Page Loading */
.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 1rem;
}

/* Skeleton Loader */
.skeleton {
  background: linear-gradient(90deg,
    var(--border-color) 0%,
    #e2e8f0 50%,
    var(--border-color) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

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

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
  width: 70%;
}

.skeleton-title {
  height: 1.5rem;
  width: 50%;
  margin-bottom: 1rem;
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton-image {
  width: 100%;
  height: 200px;
}

.skeleton-button {
  width: 100px;
  height: 38px;
}

.skeleton-input {
  height: 42px;
  width: 100%;
}

.skeleton-table-row {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.skeleton-table-row > div {
  flex: 1;
  height: 1rem;
}

/* Content Loading State */
.content-loading {
  position: relative;
  min-height: 100px;
}

.content-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Dots Loader */
.loader-dots {
  display: flex;
  gap: 0.375rem;
}

.loader-dots span {
  width: 8px;
  height: 8px;
  background: var(--primary-color);
  border-radius: 50%;
  animation: dotPulse 1.4s infinite ease-in-out both;
}

.loader-dots span:nth-child(1) { animation-delay: -0.32s; }
.loader-dots span:nth-child(2) { animation-delay: -0.16s; }
.loader-dots span:nth-child(3) { animation-delay: 0; }

@keyframes dotPulse {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Progress Bar */
.progress-bar {
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary-color);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-bar-striped .progress-bar-fill {
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.15) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.15) 75%,
    transparent 75%,
    transparent
  );
  background-size: 1rem 1rem;
}

.progress-bar-animated .progress-bar-fill {
  animation: progress-stripes 1s linear infinite;
}

@keyframes progress-stripes {
  from { background-position: 1rem 0; }
  to { background-position: 0 0; }
}

/* Loading Shimmer Effect */
.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: -150%;
  width: 150%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.4) 50%,
    transparent 100%
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  100% { left: 150%; }
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  .landing-hero h1 {
    font-size: 2rem;
  }

  .nav-main {
    display: none;
  }

  .dashboard-actions {
    flex-direction: column;
  }

  .action-btn {
    flex-direction: row;
    width: 100%;
    justify-content: flex-start;
    padding: 1rem 1.5rem;
  }

  .user-name {
    display: none;
  }
}

/* ========================================
   Manage Users Page
   ======================================== */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: var(--text-secondary);
  margin: 0;
}

/* Invite Form */
.invite-card {
  margin-bottom: 2rem;
}

.invite-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.invite-form .form-group {
  margin-bottom: 0;
}

.invite-form .form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.invite-form .form-group input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.invite-form .form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.invite-form .required {
  color: var(--danger-color);
}

/* Email Match Indicator */
.email-match-indicator {
  display: block;
  font-size: 0.8125rem;
  margin-top: 0.375rem;
  min-height: 1.2em;
}

.email-match-indicator.match {
  color: var(--success-color);
}

.email-match-indicator.no-match {
  color: var(--danger-color);
}

/* Role Selector */
.role-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.role-option {
  cursor: pointer;
}

.role-option input {
  display: none;
}

.role-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: all 0.2s;
  text-align: center;
}

.role-option:hover .role-card {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

.role-option input:checked + .role-card {
  border-color: var(--primary-color);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.role-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.role-name {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.role-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Card Header with Actions */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-header h2 {
  margin: 0;
  font-size: 1.125rem;
}

/* Loading Placeholder */
.loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--text-muted);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* Actions Cell */
.actions-cell {
  white-space: nowrap;
  text-align: right;
}

.actions-cell .btn {
  margin-left: 0.5rem;
}

.actions-cell .btn:first-child {
  margin-left: 0;
}

/* Button Variants */
.btn-warning {
  background: var(--warning-color);
  color: white;
}

.btn-warning:hover {
  background: #b45309;
}

/* Card spacing */
.card {
  margin-bottom: 1.5rem;
}

.card:last-child {
  margin-bottom: 0;
}

/* Responsive */
@media (max-width: 768px) {
  .invite-form .form-row {
    grid-template-columns: 1fr;
  }

  .role-selector {
    grid-template-columns: 1fr;
  }

  .actions-cell {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
  }

  .actions-cell .btn {
    margin-left: 0;
  }
}

/* ========================================
   Context Menu
   ======================================== */
.context-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 1000;
  padding: 0.5rem 0;
}

.context-menu-item {
  padding: 0.625rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: background-color 0.15s;
}

.context-menu-item:hover {
  background-color: var(--primary-light);
}

.context-menu-icon {
  font-size: 1rem;
}

/* ========================================
   Datablock Styles
   ======================================== */
.datablock-content {
  display: grid;
  gap: 1rem;
}

.datablock-field {
  display: grid;
  gap: 0.25rem;
}

.datablock-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.datablock-value {
  font-size: 1rem;
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  background: var(--background);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

/* ========================================
   Order List Styles
   ======================================== */
.order-list-container {
  max-height: 60vh;
  overflow-y: auto;
}

.order-list-group {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.order-list-group:last-child {
  margin-bottom: 0;
}

.order-list-equipment-header {
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--background);
  border-bottom: 1px solid var(--border-color);
  font-size: 1rem;
  font-weight: 600;
}

.order-list-equipment-header small {
  color: var(--text-secondary);
  font-weight: normal;
  margin-left: 0.5rem;
}

.order-list-group .table {
  margin: 0;
  border: none;
}

.order-list-group .table th,
.order-list-group .table td {
  padding: 0.5rem 1rem;
}

.order-list-group .table th:first-child,
.order-list-group .table td:first-child {
  width: 40px;
  text-align: center;
}

.order-list-group .table tbody tr:hover {
  background-color: var(--primary-light);
}

.qty-input {
  width: 80px;
  padding: 0.25rem 0.5rem;
  text-align: center;
}

/* Part row hover for context menu indication */
.part-row {
  cursor: context-menu;
}

.part-row:hover {
  background-color: var(--primary-light);
}
