:root {
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-full: 9999px;

  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --purple: #a855f7;
  --pink: #ec4899;
  --orange: #f97316;
  --teal: #14b8a6;
}

:root,
[data-theme="dark"] {
  --bg-base: #0d1117;
  --bg-elevated: #161b22;
  --bg-surface: #1c2128;
  --bg-hover: #21262d;
  --bg-active: #263040;

  --border-subtle: #21262d;
  --border-default: #30363d;
  --border-focus: #3b82f6;

  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --text-inverse: #0d1117;

  --primary-light: rgba(59, 130, 246, 0.15);
  --primary-border: rgba(59, 130, 246, 0.4);
  --success-bg: rgba(34, 197, 94, 0.15);
  --success-border: rgba(34, 197, 94, 0.4);
  --warning-bg: rgba(245, 158, 11, 0.15);
  --warning-border: rgba(245, 158, 11, 0.4);
  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-border: rgba(239, 68, 68, 0.4);
  --info-bg: rgba(6, 182, 212, 0.15);
  --info-border: rgba(6, 182, 212, 0.4);
  --purple-bg: rgba(168, 85, 247, 0.15);
  --purple-border: rgba(168, 85, 247, 0.4);
  --pink-bg: rgba(236, 72, 153, 0.15);
  --orange-bg: rgba(249, 115, 22, 0.15);
  --teal-bg: rgba(20, 184, 166, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  --shadow: rgba(0, 0, 0, 0.4);

  --sidebar-width: 240px;
  --header-height: 64px;
}

[data-theme="light"] {
  --bg-base: #f6f8fa;
  --bg-elevated: #ffffff;
  --bg-surface: #f6f8fa;
  --bg-hover: #eaeef2;
  --bg-active: #dfe3e8;

  --border-subtle: #d0d7de;
  --border-default: #d0d7de;
  --border-focus: #3b82f6;

  --text-primary: #1f2328;
  --text-secondary: #57606a;
  --text-muted: #6e7781;
  --text-inverse: #ffffff;

  --primary-light: rgba(59, 130, 246, 0.1);
  --primary-border: rgba(59, 130, 246, 0.3);
  --success-bg: rgba(34, 197, 94, 0.1);
  --success-border: rgba(34, 197, 94, 0.3);
  --warning-bg: rgba(245, 158, 11, 0.1);
  --warning-border: rgba(245, 158, 11, 0.3);
  --danger-bg: rgba(239, 68, 68, 0.1);
  --danger-border: rgba(239, 68, 68, 0.3);
  --info-bg: rgba(6, 182, 212, 0.1);
  --info-border: rgba(6, 182, 212, 0.3);
  --purple-bg: rgba(168, 85, 247, 0.1);
  --purple-border: rgba(168, 85, 247, 0.3);
  --pink-bg: rgba(236, 72, 153, 0.1);
  --orange-bg: rgba(249, 115, 22, 0.1);
  --teal-bg: rgba(20, 184, 166, 0.1);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  --shadow: rgba(0, 0, 0, 0.1);
}

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

html {
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

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

a:hover {
  color: var(--primary-hover);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-primary);
  margin: 0 0 var(--space-4) 0;
  font-weight: 600;
  line-height: 1.3;
}

p {
  color: var(--text-secondary);
  margin: 0 0 var(--space-4) 0;
}

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

.app-container {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-base);
}

.top-nav {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: var(--header-height);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  gap: 16px;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 140px;
}

.logo::before {
  content: "";
  display: inline-block;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--info));
  border-radius: var(--radius-md);
}

.nav-search {
  flex: 1;
  max-width: 480px;
  position: relative;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  padding: 10px 16px 10px 44px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 14px;
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

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

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.nav-search::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  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='%236e7681' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-size: contain;
}

.nav-links {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.nav-link {
  padding: 8px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

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

.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-content {
  display: none;
  position: absolute;
  background: var(--bg-elevated);
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  z-index: 200;
  top: 100%;
  left: 0;
  padding: 8px;
  margin-top: 4px;
}

.nav-dropdown:hover .nav-dropdown-content {
  display: block;
}

.nav-dropdown-content a {
  color: var(--text-secondary);
  padding: 10px 14px;
  text-decoration: none;
  display: block;
  font-size: 13px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-dropdown-content a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 16px;
}

.user-info {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.3;
}

.user-info .user-name {
  font-weight: 600;
  color: var(--text-primary);
}

.user-info .user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.btn-logout {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 50;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  margin-bottom: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all var(--transition-fast);
}

.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--primary);
  color: white;
}

.sidebar-link .icon {
  width: 20px;
  height: 20px;
  opacity: 0.8;
}

.sidebar-link .badge {
  margin-left: auto;
  background: var(--bg-hover);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.sidebar-link.active .badge {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px 32px;
  background: var(--bg-base);
  min-height: calc(100vh - var(--header-height));
}

.main-content.no-sidebar {
  margin-left: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.page-header-left {
  flex: 1;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px 0;
}

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

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

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

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

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

.btn-success:hover {
  background: #16a34a;
}

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
}

.view-toggle {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.view-toggle button {
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.view-toggle button:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.view-toggle button.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon.primary {
  background: var(--primary-light);
  color: var(--primary);
}

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

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

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

.kpi-icon.info {
  background: var(--info-bg);
  color: var(--info);
}

.kpi-content {
  flex: 1;
  min-width: 0;
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-value.success {
  color: var(--success);
}

.kpi-value.danger {
  color: var(--danger);
}

.kpi-change {
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
}

.kpi-change.positive {
  color: var(--success);
}

.kpi-change.negative {
  color: var(--danger);
}

.kpi-card.highlight {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
}

.kpi-card.highlight .kpi-label,
.kpi-card.highlight .kpi-value,
.kpi-card.highlight .kpi-change {
  color: white;
}

.kpi-card.highlight .kpi-icon {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

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

thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
}

th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

td {
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

tr:hover td {
  background: var(--bg-hover);
}

.table-wrapper {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.table-row-link {
  color: var(--primary);
  font-weight: 500;
}

.table-row-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.table-checkbox {
  width: 20px;
}

.table-actions {
  text-align: right;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.active,
.status-badge.paid,
.status-badge.successful,
.status-badge.converted,
.status-badge.complete {
  background: var(--success-bg);
  color: var(--success);
}

.status-badge.closed,
.status-badge.declined,
.status-badge.lost,
.status-badge.overdue,
.status-badge.rejected {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-badge.pending,
.status-badge.review,
.status-badge.on-hold {
  background: var(--warning-bg);
  color: var(--warning);
}

.status-badge.draft,
.status-badge.contacted {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.status-badge.new,
.status-badge.open,
.status-badge.outstanding {
  background: var(--primary-light);
  color: var(--primary);
}

.status-badge.qualified,
.status-badge.retainer_sent,
.status-badge.in_progress,
.status-badge.in-progress {
  background: var(--info-bg);
  color: var(--info);
}

.status-badge.refunded,
.status-badge.incomplete {
  background: var(--warning-bg);
  color: var(--warning);
}

.role-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

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

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

.role-badge.judge {
  background: var(--purple-bg);
  color: var(--purple);
}

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

.role-badge.paralegal {
  background: var(--info-bg);
  color: var(--info);
}

.role-badge.clerk {
  background: var(--teal-bg);
  color: var(--teal);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0;
}

.tab {
  padding: 12px 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition-fast);
}

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

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 8px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.tab.active .tab-count {
  background: var(--primary-light);
  color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

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

.form-group label,
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: all var(--transition-fast);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--bg-elevated);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236e7681' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-slow);
  backdrop-filter: blur(8px);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal,
.modal-content {
  background: var(--bg-elevated);
  border-radius: var(--radius-2xl);
  border: 1px solid var(--border-subtle);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(-20px) scale(0.95);
  transition: transform var(--transition-slow);
  box-shadow: var(--shadow-xl);
}

.modal-overlay.active .modal,
.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-content.modal-md {
  max-width: 560px;
}

.modal-content.modal-sm {
  max-width: 440px;
}

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

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  transition: color var(--transition-fast);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

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

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Case Detail Modal (Matters – case popup) */
#case-detail-modal.modal-overlay {
  padding: 16px;
  align-items: center;
  justify-content: center;
}

#case-detail-modal .modal.case-detail-modal-fixed {
  max-width: 900px;
  width: 100%;
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-2xl);
  border: 1px solid var(--border-default);
  box-shadow:
    var(--shadow-xl),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  background: var(--bg-elevated);
}

#case-detail-modal .modal.case-detail-modal-fixed .case-detail-header {
  flex-shrink: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03) 0%,
    transparent 100%
  );
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

#case-detail-modal .case-detail-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

#case-detail-modal .case-detail-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition:
    color var(--transition-fast),
    background var(--transition-fast);
}

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

#case-detail-modal .case-detail-body {
  padding: 16px 20px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#case-detail-modal .case-detail-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
  flex-shrink: 0;
}

#case-detail-modal .case-tab-btn {
  padding: 10px 18px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition:
    color var(--transition-fast),
    background var(--transition-fast),
    border-color var(--transition-fast);
}

#case-detail-modal .case-tab-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

#case-detail-modal .case-tab-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  border-bottom-color: var(--primary);
}

#case-detail-modal .case-tab-content-wrapper {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

#case-detail-modal .case-tab-content-wrapper::-webkit-scrollbar {
  width: 8px;
}

#case-detail-modal .case-tab-content-wrapper::-webkit-scrollbar-track {
  background: var(--bg-surface);
  border-radius: var(--radius-full);
}

#case-detail-modal .case-tab-content-wrapper::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}

#case-detail-modal .case-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  margin-bottom: 14px;
}

#case-detail-modal .case-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Notes area: full width, larger textarea */
#case-detail-modal .case-form-notes-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

#case-detail-modal .case-form-notes-textarea {
  min-height: 200px;
  resize: vertical;
  line-height: 1.5;
  font-family: inherit;
}

#case-detail-modal .case-form-notes-textarea::placeholder {
  color: var(--text-muted);
}

#case-detail-modal .case-form-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#case-detail-modal .case-form-input,
#case-detail-modal .case-form-select,
#case-detail-modal .case-form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

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

#case-detail-modal .case-form-display {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

#case-detail-modal .case-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

#case-detail-modal .case-tab-content h4 {
  margin: 0 0 16px 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

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

.contact-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 20px;
  position: relative;
  transition: all var(--transition-fast);
}

.contact-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-md);
}

.contact-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.contact-avatar.blue {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.contact-avatar.green {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

.contact-avatar.purple {
  background: linear-gradient(135deg, #a855f7, #7c3aed);
}

.contact-avatar.pink {
  background: linear-gradient(135deg, #ec4899, #db2777);
}

.contact-avatar.orange {
  background: linear-gradient(135deg, #f97316, #ea580c);
}

.contact-avatar.teal {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
}

.contact-avatar.red {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.contact-avatar.yellow {
  background: linear-gradient(135deg, #eab308, #ca8a04);
}

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

.contact-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 15px;
  margin-bottom: 2px;
}

.contact-role {
  font-size: 13px;
  color: var(--text-muted);
}

.contact-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.contact-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.contact-detail .icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.contact-menu {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.contact-menu:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.add-contact-card {
  background: var(--bg-surface);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-xl);
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 200px;
}

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

.add-contact-card .icon {
  width: 48px;
  height: 48px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 24px;
}

.add-contact-card:hover .icon {
  background: var(--primary);
  color: white;
}

.add-contact-card .text {
  font-weight: 600;
  color: var(--text-primary);
}

.add-contact-card .subtext {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.calendar-container {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.calendar-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-nav button {
  padding: 8px 12px;
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.calendar-nav button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.calendar-nav .today-btn {
  background: var(--bg-surface);
  font-weight: 500;
}

.calendar-week-view {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
}

.calendar-week-header {
  display: contents;
}

.calendar-week-header > div {
  padding: 12px 8px;
  text-align: center;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.calendar-week-header .day-name {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.calendar-week-header .day-number {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 4px;
}

.calendar-week-header .today {
  background: var(--primary);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}

.time-column {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
}

.time-slot {
  height: 60px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  border-bottom: 1px solid var(--border-subtle);
}

.day-column {
  border-right: 1px solid var(--border-subtle);
  position: relative;
}

.day-column:last-child {
  border-right: none;
}

.hour-slot {
  height: 60px;
  border-bottom: 1px solid var(--border-subtle);
}

.calendar-event {
  position: relative;
  display: block;
  margin: 2px 0;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-left: 3px solid;
  transition: opacity 0.15s;
  color: inherit;
}

.calendar-event:hover {
  opacity: 0.85;
}

.calendar-event.court {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.calendar-event.meeting {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
}

.calendar-event.deadline {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning);
}

.calendar-event.deposition {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info);
}

.calendar-event.intake {
  background: var(--purple-bg);
  color: var(--purple);
  border-color: var(--purple);
}

.calendar-event.hearing {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.calendar-event.task {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border-color: #3b82f6;
}

.calendar-event.call {
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
  border-color: #06b6d4;
}

/* Dashboard calendar event hover popover */
.event-hover-popover {
  position: fixed;
  z-index: 10000;
  min-width: 220px;
  max-width: 320px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: auto;
}

.event-hover-popover-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-size: 14px;
}

.event-hover-popover-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  margin-bottom: 10px;
}

.event-hover-popover-row {
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.event-hover-popover-row:last-of-type {
  margin-bottom: 0;
}

.event-hover-popover-label {
  display: inline-block;
  min-width: 48px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.event-hover-popover-desc {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  max-height: 80px;
  overflow-y: auto;
}

.calendar-event .event-time {
  font-size: 10px;
  opacity: 0.8;
  margin-bottom: 2px;
}

.calendar-event .event-title {
  font-weight: 600;
}

.calendar-event .event-location {
  font-size: 10px;
  opacity: 0.8;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calendar-day-header {
  padding: 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.calendar-day {
  min-height: 120px;
  height: 120px;
  padding: 8px;
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.calendar-events-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  margin-top: 4px;
}

.calendar-events-container::-webkit-scrollbar {
  width: 6px;
}

.calendar-events-container::-webkit-scrollbar-track {
  background: transparent;
}

.calendar-events-container::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}

.calendar-events-container::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.calendar-day:nth-child(7n) {
  border-right: none;
}

.calendar-day.other-month {
  background: var(--bg-base);
}

.calendar-tabs {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.calendar-tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition-fast);
}

.calendar-tab:hover {
  color: var(--text-primary);
}

.calendar-tab.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* Due Dates View Styles */
.due-dates-container {
  padding: 20px;
}

.due-dates-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.due-dates-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.due-dates-list {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.due-dates-date-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.due-dates-date-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.due-date-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  font-style: italic;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
}

.due-dates-date-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.due-date-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 2px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.due-date-row:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.due-date-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: var(--radius-md);
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.due-date-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.due-date-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: underline;
  cursor: pointer;
}

.due-date-row:hover .due-date-title {
  color: var(--primary);
}

.due-date-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.due-date-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.due-date-label {
  color: var(--text-muted);
  font-weight: 500;
  min-width: 70px;
}

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

.calendar-day-number {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.calendar-day.other-month .calendar-day-number {
  color: var(--text-muted);
}

.calendar-day.today .calendar-day-number {
  background: var(--primary);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-sidebar {
  width: 240px;
  padding: 20px;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
}

.mini-calendar {
  margin-bottom: 24px;
}

.mini-calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.mini-calendar-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.mini-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
  font-size: 12px;
}

.mini-calendar-day {
  padding: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.mini-calendar-day:hover {
  background: var(--bg-hover);
}

.mini-calendar-day.today {
  background: var(--primary);
  color: white;
}

.mini-calendar-day.selected {
  background: var(--primary-light);
  color: var(--primary);
}

.calendar-legend {
  margin-top: 20px;
}

.legend-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
}

.legend-dot.court {
  background: var(--danger);
}

.legend-dot.deadline {
  background: var(--warning);
}

.legend-dot.deposition {
  background: var(--success);
}

.legend-dot.meeting {
  background: var(--primary);
}

.quick-timer {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 20px;
  margin-bottom: 24px;
}

.quick-timer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.quick-timer-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.timer-recording {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--danger);
}

.timer-recording::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: var(--radius-full);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.quick-timer-form {
  display: flex;
  gap: 12px;
  align-items: center;
}

.quick-timer-form .form-control {
  flex: 1;
}

.timer-display {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-elevated);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.timer-stop {
  width: 44px;
  height: 44px;
  background: var(--danger);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-stop::before {
  content: "";
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 2px;
}

.time-entries-summary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 20px;
  margin-bottom: 24px;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.summary-date {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.summary-hours {
  font-size: 14px;
  color: var(--text-muted);
}

.weekly-summary {
  margin-bottom: 24px;
}

.weekly-summary-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.weekly-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.weekly-total-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
}

.weekly-total-change {
  font-size: 13px;
  font-weight: 500;
  color: var(--success);
}

.weekly-goal {
  display: flex;
  align-items: center;
  gap: 12px;
}

.weekly-goal-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.weekly-goal-progress {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
}

.weekly-goal-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.recent-matters {
  margin-top: 24px;
}

.recent-matters-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}

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

.matter-item:last-child {
  border-bottom: none;
}

.matter-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

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

.matter-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.matter-case {
  font-size: 12px;
  color: var(--text-muted);
}

.filters {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-size: 12px;
  color: var(--text-muted);
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 13px;
  color: var(--text-secondary);
}

.filter-pill .remove {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 10px;
}

.filter-pill .remove:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.clear-filters {
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 0;
}

.chart-container {
  padding: 20px;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.chart-container canvas {
  max-height: 300px;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.three-column {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}

.profile-header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 32px;
  font-weight: 600;
}

.profile-info h2 {
  font-size: 24px;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.profile-info p {
  color: var(--text-muted);
  font-size: 14px;
}

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

.info-item {
  padding: 16px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.info-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

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

.tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 12px;
  margin-right: 4px;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

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

.link:hover {
  text-decoration: underline;
}

.empty-state {
  text-align: center;
  padding: 60px 40px;
  color: var(--text-muted);
}

.empty-state .icon {
  width: 64px;
  height: 64px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: var(--text-muted);
  font-size: 28px;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  max-width: 360px;
  margin: 0 auto 20px;
}

.search-box {
  position: relative;
  margin-bottom: 16px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  font-size: 14px;
  background: var(--bg-surface);
  color: var(--text-primary);
}

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

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

.search-box::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  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='%236e7681' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-size: contain;
}

.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
}

.login-box {
  background: var(--bg-elevated);
  padding: 40px;
  border-radius: var(--radius-2xl);
  border: 1px solid var(--border-subtle);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-xl);
}

.login-logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin-bottom: 32px;
}

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 12px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  font-size: 14px;
  display: none;
  border: 1px solid var(--danger-border);
}

.action-links {
  display: flex;
  gap: 12px;
}

.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 200;
  margin-top: 4px;
}

.search-section {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.search-section:last-child {
  border-bottom: none;
}

.search-section-title {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-result-item {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

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

.search-result-name {
  font-weight: 500;
}

.search-result-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.search-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

.nav-link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.nav-link-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.notification-dot {
  position: relative;
}

.notification-dot::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-elevated);
}

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

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

.badge-billable {
  background: var(--success-bg);
  color: var(--success);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 500;
}

.badge-non-billable {
  background: var(--warning-bg);
  color: var(--warning);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 500;
}

.btn-warning {
  background: var(--warning);
  color: var(--text-inverse);
  border: none;
}

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

.calendar-tabs {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.calendar-tabs .tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  margin-bottom: 0;
}

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

.calendar-tabs .tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.week-grid,
.day-schedule {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.week-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 16px;
}

.week-day-header {
  text-align: center;
  font-weight: 500;
  padding: 8px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.day-hours {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.day-hour {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  min-height: 48px;
}

.hour-label {
  width: 80px;
  font-size: 12px;
  color: var(--text-muted);
}

.hour-events {
  flex: 1;
}

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

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

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

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

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

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

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

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

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

.filters-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.filter-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px 0;
}

.subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.subtab {
  padding: 6px 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: all var(--transition-fast);
}

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

.subtab.active {
  color: var(--primary);
  font-weight: 500;
}

.sortable th {
  cursor: pointer;
  user-select: none;
}

.sortable th:hover {
  background: var(--bg-hover);
}

.widget-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.widget {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 20px;
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.widget-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.widget-action {
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.widget-action:hover {
  text-decoration: underline;
}

.widget-config {
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.widget-config:hover {
  color: var(--text-primary);
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.task-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}

.task-checkbox.checked {
  background: var(--primary);
  border-color: var(--primary);
}

.task-content {
  flex: 1;
}

.task-title {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-due {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.task-due.overdue {
  color: var(--danger);
}

.activity-feed {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-icon.email {
  background: var(--primary-light);
  color: var(--primary);
}

.activity-icon.document {
  background: var(--warning-bg);
  color: var(--warning);
}

.activity-icon.task {
  background: var(--success-bg);
  color: var(--success);
}

.activity-icon.invoice {
  background: var(--purple-bg);
  color: var(--purple);
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.activity-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.activity-link {
  color: var(--primary);
}

.progress-bar {
  height: 6px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary);
  transition: width var(--transition-normal);
}

.progress-bar-fill.success {
  background: var(--success);
}

.avatar-stack {
  display: flex;
}

.avatar-stack .avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-elevated);
  margin-left: -8px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 600;
}

.avatar-stack .avatar:first-child {
  margin-left: 0;
}

.avatar-stack .avatar.more {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  margin-top: 16px;
}

.pagination-info {
  font-size: 14px;
  color: var(--text-muted);
}

.pagination-buttons {
  display: flex;
  gap: 8px;
}

.demo-info {
  text-align: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 13px;
}

.demo-info strong {
  color: var(--text-secondary);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

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

small {
  color: var(--text-muted);
  font-size: 12px;
}

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

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

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

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

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

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

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

.mt-2 {
  margin-top: 8px;
}

.mt-4 {
  margin-top: 16px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-4 {
  margin-bottom: 16px;
}

.p-2 {
  padding: 8px;
}

.p-4 {
  padding: 16px;
}

.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 8px;
}

.gap-4 {
  gap: 16px;
}

.w-full {
  width: 100%;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.font-bold {
  font-weight: 700;
}

.font-medium {
  font-weight: 500;
}

.rounded {
  border-radius: var(--radius-lg);
}

.rounded-full {
  border-radius: var(--radius-full);
}

.overflow-hidden {
  overflow: hidden;
}

.overflow-auto {
  overflow: auto;
}

.cursor-pointer {
  cursor: pointer;
}

.select-none {
  user-select: none;
}

.transition {
  transition: all var(--transition-normal);
}

.event-type-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.event-type-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.event-type-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

.event-type-btn input[type="radio"] {
  display: none;
}

.toggle-switch-sm {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
}

.toggle-switch-sm .toggle-slider {
  width: 36px;
  height: 20px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition-fast);
}

.toggle-switch-sm .toggle-slider::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform var(--transition-fast);
}

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

.toggle-switch-sm input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.toggle-switch-sm input {
  display: none;
}

.toggle-switch-sm .toggle-label {
  color: var(--text-muted);
}

.toggle-switch-sm input:checked ~ .toggle-label {
  color: var(--primary);
}

.attendees-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  min-height: 44px;
  align-items: center;
}

.attendees-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.attendees-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attendee-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
}

.attendee-pill .remove-attendee {
  cursor: pointer;
  opacity: 0.8;
  font-size: 14px;
  line-height: 1;
}

.attendee-pill .remove-attendee:hover {
  opacity: 1;
}

.mini-calendar-picker {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 12px;
}

.mini-calendar-picker .mini-calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.cal-nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.cal-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.mini-calendar-picker .mini-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
  font-size: 13px;
}

.mini-calendar-picker .cal-day-header {
  padding: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.mini-calendar-picker .cal-day {
  padding: 8px 4px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.mini-calendar-picker .cal-day:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.mini-calendar-picker .cal-day.other-month {
  color: var(--text-muted);
  opacity: 0.5;
}

.mini-calendar-picker .cal-day.today {
  font-weight: 600;
  color: var(--primary);
}

.mini-calendar-picker .cal-day.selected {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.mini-calendar {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 12px;
  margin-top: 8px;
}

.mini-calendar .mini-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.mini-cal-prev,
.mini-cal-next {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-cal-prev:hover,
.mini-cal-next:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.mini-cal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.mini-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 8px;
}

.mini-calendar-weekdays span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px;
}

.mini-calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mini-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mini-cal-day:hover:not(.empty) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.mini-cal-day.empty {
  cursor: default;
}

.mini-cal-day.today {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.mini-cal-day.selected {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.mini-cal-day.today.selected {
  outline: 2px solid white;
}

.location-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.remote-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  transition: 0.3s;
}

.switch .slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-secondary);
  transition: 0.3s;
}

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

.switch input:checked + .slider:before {
  transform: translateX(18px);
  background-color: white;
}

.switch .slider.round {
  border-radius: 22px;
}

.switch .slider.round:before {
  border-radius: 50%;
}

.event-type-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.event-type-group .event-type-btn {
  padding: 8px 16px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition-fast);
}

.event-type-group .event-type-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

.event-type-group .event-type-btn.active[data-event-type="hearing"] {
  background: #ef4444;
  border-color: #ef4444;
}

.event-type-group .event-type-btn.active[data-event-type="court"] {
  background: #dc2626;
  border-color: #dc2626;
}

.event-type-group .event-type-btn.active[data-event-type="deposition"] {
  background: #f59e0b;
  border-color: #f59e0b;
}

.event-type-group .event-type-btn.active[data-event-type="deadline"] {
  background: #eab308;
  border-color: #eab308;
}

.event-type-group .event-type-btn.active[data-event-type="meeting"] {
  background: #a855f7;
  border-color: #a855f7;
}

.event-type-group .event-type-btn.active[data-event-type="task"] {
  background: #3b82f6;
  border-color: #3b82f6;
}

.event-type-group .event-type-btn.active[data-event-type="intake"] {
  background: #22c55e;
  border-color: #22c55e;
}

.event-type-group .event-type-btn.active[data-event-type="call"] {
  background: #06b6d4;
  border-color: #06b6d4;
}

.availability-check {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-lg);
}

.availability-icon {
  width: 32px;
  height: 32px;
  background: var(--success);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

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

.availability-text strong {
  font-size: 13px;
  color: var(--text-primary);
}

.availability-text span {
  font-size: 12px;
  color: var(--text-muted);
}

.event-form-left,
.event-form-right {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.case-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
  margin-top: 4px;
}

.case-search-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.case-search-item:last-child {
  border-bottom: none;
}

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

.case-search-item.no-results {
  color: var(--text-muted);
  cursor: default;
}

.case-search-item.no-results:hover {
  background: transparent;
}

@media (max-width: 768px) {
  #event-modal .modal-body {
    grid-template-columns: 1fr !important;
  }
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.theme-toggle .icon-sun {
  display: block;
}

.theme-toggle .icon-moon {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

.action-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.action-card {
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-xl);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-card:hover {
  background: var(--primary);
  border-color: var(--primary);
}

/* Contacts – Clients and Leads stat cards and mini bar/line charts */
.client-stats-cards,
.leads-stats-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.client-stat-card,
.lead-stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.client-stat-header,
.lead-stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.client-stat-label,
.lead-stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.client-stat-value,
.lead-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.client-stat-secondary,
.lead-stat-secondary {
  font-size: 12px;
  color: var(--text-muted);
}

.client-stat-chart,
.lead-stat-chart {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 2px;
  height: 36px;
  min-height: 36px;
  margin-top: 4px;
}

.client-stat-chart .bar,
.lead-stat-chart .bar {
  flex: 1;
  min-width: 3px;
  border-radius: 2px 2px 0 0;
  background: var(--border-default);
  transition: height 0.2s ease;
}

.client-stat-card.verified .client-stat-chart .bar {
  background: var(--success, #22c55e);
}

.client-stat-card.unverified .client-stat-chart .bar {
  background: var(--warning, #f59e0b);
}

.client-stat-card.active .client-stat-chart .bar {
  background: var(--primary, #3b82f6);
}

.lead-stat-card.month .lead-stat-chart .bar {
  background: var(--primary, #3b82f6);
}

.lead-stat-card.retainer .lead-stat-chart .bar {
  background: var(--success, #22c55e);
}

.lead-stat-line-chart {
  height: 36px;
  min-height: 36px;
  margin-top: 4px;
  width: 100%;
}

.lead-stat-line-chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.lead-stat-line-chart .line {
  fill: none;
  stroke: var(--primary, #3b82f6);
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.client-stat-icon.verified,
.lead-stat-card .lead-stat-icon {
  color: var(--success, #22c55e);
}

.client-stat-icon.unverified {
  color: var(--warning, #f59e0b);
}

.client-stat-icon.active {
  color: var(--primary, #3b82f6);
}

.lead-stat-card.trend .lead-stat-value.trend-up {
  color: var(--success, #22c55e);
}

.lead-stat-card.trend .lead-stat-value.trend-down {
  color: var(--danger, #ef4444);
}

.action-card:hover * {
  color: white !important;
}

.action-card .icon {
  width: 48px;
  height: 48px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.action-card:hover .icon {
  background: rgba(255, 255, 255, 0.2);
}

.action-card .title {
  font-weight: 600;
  color: var(--text-primary);
}

.case-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.case-title-section {
  flex: 1;
}

.case-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.case-breadcrumb a {
  color: var(--text-muted);
}

.case-breadcrumb a:hover {
  color: var(--primary);
}

.case-main-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.case-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: var(--text-muted);
}

.case-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.client-summary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 20px;
}

.client-summary-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.client-summary-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  font-weight: 600;
}

.client-summary-info {
  flex: 1;
}

.client-summary-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 16px;
}

.client-summary-role {
  font-size: 13px;
  color: var(--text-muted);
}

.client-summary-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.case-details-section {
  margin-top: 20px;
}

.case-details-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.case-detail-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.case-detail-item:last-child {
  border-bottom: none;
}

.case-detail-icon {
  width: 36px;
  height: 36px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.case-detail-content {
  flex: 1;
}

.case-detail-label {
  font-size: 12px;
  color: var(--text-muted);
}

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

.case-detail-link {
  color: var(--primary);
  cursor: pointer;
}

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .three-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding: 16px;
  }

  .nav-links {
    display: none;
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .contacts-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
  }

  .page-actions {
    width: 100%;
  }
}

/* ===========================================
 APP LAYOUT - CaseFlow Sidebar Structure
 =========================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-base);
}

/* Left Sidebar */
.sidebar {
  width: var(--sidebar-width, 240px);
  background-color: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition:
    transform 0.2s ease,
    width 0.2s ease;
}

.sidebar.hidden {
  transform: translateX(-100%);
  width: 0;
  overflow: hidden;
  border-right: none;
}

.sidebar-header {
  padding: 16px 20px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-image {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 20px;
}

.nav-section-label {
  display: block;
  padding: 0 20px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
}

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

.nav-item.active {
  background-color: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
}

.nav-icon {
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: linear-gradient(135deg, var(--primary), #5b6ee8);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
  flex-shrink: 0;
}

.nav-item.active .nav-badge {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(255, 255, 255, 0.2);
}

/* Recent Matters in Sidebar */
.recent-matters-list {
  padding: 0 12px;
}

.recent-matter-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.recent-matter-item:hover {
  background-color: var(--bg-hover);
}

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

.matter-status-dot.active {
  background-color: var(--success);
}

.matter-status-dot.pending {
  background-color: var(--warning);
}

.matter-status-dot.closed {
  background-color: var(--danger);
}

.matter-status-dot.review {
  background-color: var(--primary);
}

.matter-name {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
}

.storage-indicator {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.storage-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.storage-bar {
  height: 6px;
  background-color: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
}

.storage-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--info));
  border-radius: 3px;
}

.storage-text {
  font-size: 11px;
  color: var(--text-muted);
}

/* Main Wrapper */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width, 240px);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  width: "full";
  transition: transform 0.25s ease;
}

.main-wrapper.moved {
  margin-left: 0;
}

/* Sidebar toggle in header (collapse = panel+arrow, expand = hamburger) */
.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-hover);
}

.sidebar-toggle-btn .sidebar-toggle-icon {
  display: block;
}

.sidebar-toggle-btn .icon-menu {
  display: none;
}

/* Top Header */
.top-header {
  height: var(--header-height, 64px);
  background-color: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-search {
  position: relative;
  width: 400px;
}

.header-search input {
  width: 100%;
  height: 40px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0 16px 0 44px;
  font-size: 14px;
  color: var(--text-primary);
}

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

.header-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.header-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.5;
  color: var(--text-muted);
}

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

.header-btn {
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
  color: var(--text-secondary);
  text-decoration: none;
}

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

.header-btn .icon-sun {
  display: none;
}

.header-btn .icon-moon {
  display: block;
}

[data-theme="light"] .header-btn .icon-sun {
  display: block;
}

[data-theme="light"] .header-btn .icon-moon {
  display: none;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 12px;
  margin-left: 8px;
  border-left: 1px solid var(--border-subtle);
}

.user-email {
  font-size: 13px;
  color: var(--text-secondary);
}

.btn-logout {
  padding: 8px 16px;
  background-color: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

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

/* ===========================================
 DASHBOARD PAGE STYLES
 =========================================== */

.dashboard-page {
  max-width: 1600px;
  margin: 0 auto;
}

/* Page Header */
.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 24px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px 0;
}

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

.page-actions {
  display: flex;
  gap: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

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

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

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

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 18px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* Metrics Grid */
.dashboard-sections {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.metric-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 32px;
  align-items: start;
}

.metric-card {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    border-color var(--transition-fast);
}

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.metric-card.highlight {
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.15),
    rgba(239, 68, 68, 0.05)
  );
  border-color: rgba(239, 68, 68, 0.3);
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.metric-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.metric-icon.primary {
  background-color: var(--primary-light);
  color: var(--primary);
}

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

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

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

.metric-icon-light {
  font-size: 24px;
}

.metric-trend {
  font-size: 12px;
  font-weight: 500;
}

.metric-trend.positive {
  color: var(--success);
}

.metric-trend.negative {
  color: var(--danger);
}

.metric-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.metric-label-small {
  font-size: 11px;
  color: var(--text-muted);
}

.metric-label-light {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 4px;
}

.metric-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-value-large {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-subtext {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.placeholder-view {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
  border: 1px dashed var(--border-default);
}

.mini-calendar-view {
  margin-top: 8px;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
}

.dashboard-main {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-flow: row dense;
  gap: 24px;
  align-items: start;
}

.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Widget Sizing */
.card.size-small,
.metric-card.size-small {
  grid-column: span 1;
}

.card.size-medium {
  grid-column: span 2;
}

.metric-card.size-medium {
  grid-column: span 2;
}

.card.size-large,
.metric-card.size-large {
  grid-column: span 1;
  grid-row: span 2;
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

.metric-card.size-large .placeholder-view {
  flex: 1;
  height: auto;
}

.metric-card.size-large canvas {
  max-height: 400px !important;
}

/* Leads by Campaigns pie chart: scale container with widget size */
.leads-chart-container {
  min-height: 120px;
  position: relative;
}

.metric-card.size-medium .leads-chart-container {
  height: 180px !important;
}

.metric-card.size-large .leads-chart-container {
  flex: 1;
  min-height: 200px;
  height: 280px !important;
}

.metric-card.size-large .table-container,
.metric-card.size-large .tasks-list,
.metric-card.size-large .events-list,
.metric-card.size-large .activity-feed {
  flex: 1;
  overflow-y: auto;
}

/* Recent Cases widget: compact table, max 10 rows visible */
.recent-cases-table-wrap {
  max-height: 320px;
  overflow-y: auto;
  overflow-x: auto;
}

.recent-cases-mini-table {
  font-size: 11px;
}

.recent-cases-mini-table th,
.recent-cases-mini-table td {
  padding: 4px 6px;
  line-height: 1.3;
}

.recent-cases-mini-table tbody tr {
  max-height: 32px;
}

/* Orders with Deadlines widget */
.orders-deadlines-list .orders-deadlines-table-wrap {
  max-height: 280px;
  overflow-y: auto;
}

/* Widget Menu Options */
.widget-options {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 100;
}

.widget-menu-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.widget-menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.card,
.metric-card {
  position: relative;
}

.widget-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 120px;
  display: none;
  flex-direction: column;
  padding: 4px;
  z-index: 101;
}

.widget-dropdown.show {
  display: flex;
}

.widget-dropdown-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.widget-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.widget-dropdown-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

.dashboard-grid .card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.dashboard-grid .card-body,
.dashboard-grid .table-container,
.dashboard-grid .activity-feed,
.dashboard-grid .events-list,
.dashboard-grid .tasks-list {
  flex: 1;
}

.size-toggle-group {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.size-btn {
  padding: 4px 8px;
  font-size: 11px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

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

.size-btn:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Customization Panel */
.customize-panel {
  position: fixed;
  top: 0;
  right: -350px;
  width: 350px;
  height: 100vh;
  background-color: var(--bg-elevated);
  border-left: 1px solid var(--border-subtle);
  z-index: 1000;
  transition: right var(--transition-normal);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}

.customize-panel.open {
  right: 0;
}

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

.widget-categories-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-subtle);
}

.widget-category {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-subtle);
}

.widget-category:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.widget-category.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-border);
}

.widget-category svg {
  flex-shrink: 0;
}

.customize-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.customize-footer {
  padding: 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 12px;
}

.widget-toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.widget-toggle-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.widget-drag-handle {
  cursor: grab;
  color: var(--text-muted);
}

.widget-drag-handle:active {
  cursor: grabbing;
}

/* Switches */
.switch-sm {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
}

.switch-sm input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-default);
  transition: 0.4s;
  border-radius: 18px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

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

input:focus + .slider-round {
  box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider-round:before {
  transform: translateX(14px);
}

/* Drag and Drop Styles */
.card.dragging {
  opacity: 0.5;
  border: 2px dashed var(--primary);
}

.dashboard-main,
.dashboard-sidebar {
  min-height: 100px;
}

.drop-indicator {
  height: 4px;
  background: var(--primary);
  border-radius: 2px;
  margin: -2px 0;
  display: none;
}

/* Cards */
.card {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.view-all-link {
  font-size: 13px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.view-all-link:hover {
  text-decoration: underline;
}

/* Activity Feed */
.activity-feed {
  padding: 0;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.activity-item {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.activity-icon.email {
  background-color: var(--primary-light);
}

.activity-icon.document {
  background-color: var(--purple-bg);
}

.activity-icon.task {
  background-color: var(--success-bg);
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.activity-title strong {
  font-weight: 600;
}

.activity-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 8px;
}

.activity-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.activity-desc.task-completed {
  text-decoration: line-through;
  color: var(--text-muted);
}

.activity-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

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

.activity-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background-color: var(--bg-surface);
  border-radius: var(--radius-md);
  margin-top: 8px;
}

.file-icon {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
}

.file-icon.pdf {
  background-color: var(--danger);
  color: white;
}

.file-name {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.file-size {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

/* Events List */
.events-list {
  padding: 8px 0;
  max-height: 350px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.event-item {
  display: flex;
  gap: 14px;
  padding: 12px 16px;
  transition: background var(--transition-fast);
  cursor: pointer;
}

.event-item:hover {
  background-color: var(--bg-hover);
}

.event-date {
  width: 44px;
  height: 48px;
  background-color: var(--bg-surface);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.event-item.court .event-date {
  background-color: var(--danger-bg);
}

.event-item.meeting .event-date {
  background-color: var(--primary-light);
}

.event-item.deadline .event-date {
  background-color: var(--warning-bg);
}

.event-day {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.event-month {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.event-details {
  flex: 1;
}

.event-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

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

/* Tasks List */
.tasks-list {
  padding: 8px 0;
  max-height: 350px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
}

.task-checkbox {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
}

.task-content {
  flex: 1;
}

.task-title {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.task-due {
  font-size: 12px;
  color: var(--text-muted);
}

.task-due.urgent {
  color: var(--danger);
  font-weight: 500;
}

/* Quick Stats */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 16px;
}

.quick-stat {
  text-align: center;
  padding: 12px 8px;
  background-color: var(--bg-surface);
  border-radius: var(--radius-md);
}

.quick-stat-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.quick-stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* Tables */
.table-container {
  overflow-x: auto;
}

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

.table-container th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

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

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

.table-container tr:hover td {
  background-color: var(--bg-hover);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-full);
}

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

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

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

.status-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

/* Responsive - Sidebar Layout */
@media (max-width: 1400px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .header-search {
    width: 280px;
  }

  .dashboard-sidebar {
    grid-template-columns: 1fr;
  }
}

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

  .page-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
  }

  .header-search {
    display: none;
  }

  .user-email {
    display: none;
  }
}

/* ===========================================
 FORM BUILDER PAGE - COMPLETE STYLES
 =========================================== */

.form-builder-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 88px);
  overflow: hidden;
}

.form-builder-page .page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.form-builder-page .page-header-left .page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary, #f8fafc);
  margin: 0 0 4px 0;
}

.form-builder-page .page-header-left .page-subtitle {
  font-size: 14px;
  color: var(--text-muted, #64748b);
  margin: 0;
}

.form-builder-page .page-header-right {
  display: flex;
  gap: 12px;
}

/* Build Mode Selector */
.build-mode-selector {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.build-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background-color: var(--bg-elevated, #111827);
  border: 2px solid var(--border-subtle, #1e293b);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.build-mode-btn:hover {
  border-color: var(--border-default, #334155);
  background-color: var(--bg-hover, #243044);
}

.build-mode-btn.active {
  border-color: #3b82f6;
  background-color: rgba(59, 130, 246, 0.1);
}

.build-mode-btn .mode-icon {
  font-size: 28px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface, #1a2234);
  border-radius: 10px;
}

.build-mode-btn.active .mode-icon {
  background-color: rgba(59, 130, 246, 0.2);
}

.build-mode-btn .mode-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
  margin-bottom: 2px;
}

.build-mode-btn .mode-desc {
  font-size: 13px;
  color: var(--text-muted, #64748b);
}

/* Builder Layout */
.builder-layout {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 1200px) {
  .builder-layout {
    grid-template-columns: 220px 1fr 260px;
  }
}

/* Builder Panels */
.builder-panel {
  background-color: var(--bg-elevated, #111827);
  border: 1px solid var(--border-subtle, #1e293b);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.builder-panel .panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle, #1e293b);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.builder-panel .panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
  margin: 0;
}

.panel-hint {
  font-size: 11px;
  color: var(--text-muted, #64748b);
}

/* LEFT PANEL: Field Types */
.panel-fields {
  overflow: hidden;
}

.field-types-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.field-type-category {
  padding: 8px 4px 6px;
  margin-top: 8px;
}

.field-type-category:first-child {
  margin-top: 0;
}

.category-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-type-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background-color: var(--bg-surface, #1a2234);
  border: 1px solid var(--border-subtle, #1e293b);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: grab;
  transition: all 0.15s ease;
  position: relative;
}

.field-type-item:hover {
  border-color: #3b82f6;
  background-color: var(--bg-hover, #243044);
  transform: translateX(2px);
}

.field-type-item:active {
  cursor: grabbing;
}

.field-type-item.featured {
  border-color: rgba(59, 130, 246, 0.3);
  background-color: rgba(59, 130, 246, 0.05);
}

.field-type-icon {
  font-size: 18px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-base, #0a0e17);
  border-radius: 8px;
  flex-shrink: 0;
}

.field-type-details {
  flex: 1;
  min-width: 0;
}

.field-type-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
}

.field-type-desc {
  font-size: 11px;
  color: var(--text-muted, #64748b);
  margin-top: 1px;
}

.featured-badge {
  position: absolute;
  top: -6px;
  right: 8px;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 700;
  color: white;
  background-color: #3b82f6;
  border-radius: 4px;
  text-transform: uppercase;
}

/* CENTER PANEL: Canvas */
.panel-canvas {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.form-name-input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
  padding: 0;
  margin-right: 12px;
}

.form-name-input:focus {
  outline: none;
}

.form-name-input::placeholder {
  color: var(--text-muted, #64748b);
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border-default, #334155);
  border-radius: 6px;
  color: var(--text-secondary, #94a3b8);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toolbar-btn:hover {
  background-color: var(--bg-hover, #243044);
  color: var(--text-primary, #f8fafc);
}

.toolbar-btn.primary {
  background-color: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

.toolbar-btn.primary:hover {
  background-color: #2563eb;
}

/* Form Canvas */
.form-canvas {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Form Steps */
.form-step {
  background-color: var(--bg-surface, #1a2234);
  border: 1px solid var(--border-subtle, #1e293b);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

.step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background-color: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-subtle, #1e293b);
}

.step-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.step-number {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  font-size: 13px;
  font-weight: 700;
  border-radius: 50%;
}

.step-title-input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary, #f8fafc);
  padding: 6px 10px;
  border-radius: 4px;
}

.step-title-input:focus {
  outline: none;
  background-color: var(--bg-hover, #243044);
}

.step-title-input::placeholder {
  color: var(--text-muted, #64748b);
}

.step-header-right {
  display: flex;
  gap: 4px;
}

.step-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted, #64748b);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.step-action-btn:hover {
  background-color: var(--bg-hover, #243044);
  color: var(--text-primary, #f8fafc);
}

.step-action-btn.danger:hover {
  background-color: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Drop Zone */
.step-body {
  min-height: 100px;
  padding: 12px;
}

.step-body.dropzone {
  transition: all 0.2s ease;
}

.step-body.dropzone.drag-over {
  background-color: rgba(59, 130, 246, 0.1);
  border: 2px dashed #3b82f6;
  border-radius: 0 0 10px 10px;
}

.dropzone-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border: 2px dashed var(--border-default, #334155);
  border-radius: 8px;
  text-align: center;
}

.placeholder-icon {
  font-size: 24px;
  margin-bottom: 8px;
  opacity: 0.6;
}

.placeholder-text {
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
  font-weight: 500;
}

.placeholder-hint {
  font-size: 11px;
  color: var(--text-muted, #64748b);
  margin-top: 4px;
}

/* Form Field in Canvas */
.canvas-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background-color: var(--bg-elevated, #111827);
  border: 1px solid var(--border-subtle, #1e293b);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.canvas-field:hover {
  border-color: var(--border-default, #334155);
}

.canvas-field.selected {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.canvas-field .field-drag {
  color: var(--text-muted, #64748b);
  cursor: grab;
  font-size: 12px;
}

.canvas-field .field-icon {
  font-size: 16px;
}

.canvas-field .field-info {
  flex: 1;
}

.canvas-field .field-label-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #f8fafc);
}

.canvas-field .field-type-tag {
  font-size: 10px;
  color: var(--text-muted, #64748b);
  background-color: var(--bg-surface, #1a2234);
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 2px;
  display: inline-block;
}

.canvas-field .field-required {
  color: #ef4444;
  font-size: 14px;
}

.canvas-field .field-delete {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  opacity: 0;
  transition: all 0.15s ease;
}

.canvas-field:hover .field-delete {
  opacity: 1;
}

.canvas-field .field-delete:hover {
  background-color: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Add Step Button - Inside Canvas */
.add-step-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  margin-bottom: 16px;
  padding: 14px;
  background: transparent;
  border: 2px dashed var(--border-default, #334155);
  border-radius: 10px;
  color: var(--text-secondary, #94a3b8);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.add-step-btn:hover {
  border-color: #3b82f6;
  color: #3b82f6;
  background-color: rgba(59, 130, 246, 0.05);
}

.add-step-btn .add-icon {
  font-size: 18px;
  font-weight: 700;
}

/* Mini drop placeholder for adding more fields */
.dropzone-placeholder.mini {
  padding: 12px;
  border: 1px dashed var(--border-default, #334155);
  border-radius: 6px;
  margin-top: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropzone-placeholder.mini .placeholder-text {
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

.dropzone-placeholder.mini:hover {
  border-color: #3b82f6;
  background-color: rgba(59, 130, 246, 0.05);
}

.dropzone-placeholder.mini:hover .placeholder-text {
  color: #3b82f6;
}

/* Highlight panel animation */
.panel-fields.highlight-panel {
  animation: panelPulse 1.5s ease;
}

@keyframes panelPulse {
  0%,
  100% {
    box-shadow: none;
  }

  50% {
    box-shadow:
      0 0 0 3px rgba(59, 130, 246, 0.3),
      inset 0 0 20px rgba(59, 130, 246, 0.1);
  }
}

/* Step body dropzone */
.step-body.dropzone {
  min-height: 80px;
  padding: 12px;
  transition: all 0.2s ease;
}

.step-body.dropzone.drag-over {
  background-color: rgba(59, 130, 246, 0.1);
  border: 2px dashed #3b82f6;
  border-radius: 0 0 10px 10px;
}

/* Publish button */
.toolbar-btn.publish-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
}

.toolbar-btn.publish-btn:hover {
  background: linear-gradient(135deg, #059669, #047857);
}

/* Form canvas padding */
.form-canvas {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* RIGHT PANEL: Properties */
.panel-right {
  overflow: hidden;
}

.properties-view,
.ai-chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* No Selection State */
.no-selection {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  text-align: center;
}

.no-selection-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.no-selection-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary, #f8fafc);
  margin-bottom: 4px;
}

.no-selection-hint {
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

/* Properties Form */
.properties-form {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.property-section {
  margin-bottom: 16px;
}

.property-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 6px;
}

.property-input,
.property-textarea {
  width: 100%;
  padding: 10px 12px;
  background-color: var(--bg-surface, #1a2234);
  border: 1px solid var(--border-default, #334155);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary, #f8fafc);
  transition: border-color 0.15s ease;
}

.property-input:focus,
.property-textarea:focus {
  outline: none;
  border-color: #3b82f6;
}

.property-textarea {
  min-height: 80px;
  resize: vertical;
}

.property-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary, #f8fafc);
}

.property-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: #3b82f6;
}

.property-divider {
  height: 1px;
  background-color: var(--border-subtle, #1e293b);
  margin: 20px 0;
}

.btn-block {
  width: 100%;
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.btn-danger:hover {
  background-color: #ef4444;
  color: white;
}

/* AI CHAT VIEW */
.ai-chat-view {
  display: none;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.chat-message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.ai-message .message-avatar {
  background-color: rgba(59, 130, 246, 0.15);
}

.user-message .message-avatar {
  background-color: rgba(34, 197, 94, 0.15);
}

.message-bubble {
  flex: 1;
  padding: 12px 14px;
  background-color: var(--bg-surface, #1a2234);
  border-radius: 12px;
  border-top-left-radius: 4px;
  font-size: 13px;
  color: var(--text-primary, #f8fafc);
  line-height: 1.5;
}

.user-message .message-bubble {
  background-color: rgba(59, 130, 246, 0.15);
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
}

.message-bubble p {
  margin: 0 0 8px 0;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.example-prompts {
  margin-top: 12px;
}

.example-prompt {
  padding: 10px 12px;
  background-color: var(--bg-base, #0a0e17);
  border: 1px solid var(--border-subtle, #1e293b);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #3b82f6;
  cursor: pointer;
  transition: all 0.15s ease;
}

.example-prompt:hover {
  background-color: var(--bg-hover, #243044);
  border-color: #3b82f6;
}

.chat-input-container {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border-subtle, #1e293b);
}

.chat-input {
  width: 100%;
  padding: 12px;
  background-color: var(--bg-surface, #1a2234);
  border: 1px solid var(--border-default, #334155);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary, #f8fafc);
  resize: none;
  margin-bottom: 10px;
}

.chat-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.chat-input::placeholder {
  color: var(--text-muted, #64748b);
}

.btn-generate {
  width: 100%;
  padding: 12px;
  font-size: 14px;
}

.btn-generate span {
  margin-right: 6px;
}

/* Loading state for AI */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
}

.ai-typing-dot {
  width: 8px;
  height: 8px;
  background-color: #3b82f6;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.ai-typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.ai-typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingBounce {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===========================================
 TOAST NOTIFICATION SYSTEM
 =========================================== */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background-color: var(--bg-elevated, #111827);
  border: 1px solid var(--border-subtle, #1e293b);
  border-radius: 10px;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  min-width: 300px;
  max-width: 450px;
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-visible {
  transform: translateX(0);
  opacity: 1;
}

.toast-hiding {
  transform: translateX(120%);
  opacity: 0;
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary, #f8fafc);
  line-height: 1.4;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted, #64748b);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.toast-close:hover {
  background-color: var(--bg-hover, #243044);
  color: var(--text-primary, #f8fafc);
}

.toast-success {
  border-left: 4px solid #22c55e;
  background: linear-gradient(
    90deg,
    rgba(34, 197, 94, 0.1) 0%,
    var(--bg-elevated, #111827) 20%
  );
}

.toast-error {
  border-left: 4px solid #ef4444;
  background: linear-gradient(
    90deg,
    rgba(239, 68, 68, 0.1) 0%,
    var(--bg-elevated, #111827) 20%
  );
}

.toast-warning {
  border-left: 4px solid #f59e0b;
  background: linear-gradient(
    90deg,
    rgba(245, 158, 11, 0.1) 0%,
    var(--bg-elevated, #111827) 20%
  );
}

.toast-info {
  border-left: 4px solid #3b82f6;
  background: linear-gradient(
    90deg,
    rgba(59, 130, 246, 0.1) 0%,
    var(--bg-elevated, #111827) 20%
  );
}

/* ===========================================
 TEMPLATES PAGE STYLES
 =========================================== */

.templates-page {
  max-width: 1400px;
  margin: 0 auto;
}

.templates-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Ensure filter dropdowns align properly with search box */
.templates-page .toolbar-left .filter-dropdown {
  display: flex;
  align-items: center;
}

.templates-page .toolbar-left .filter-dropdown select {
  min-width: 140px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  position: relative;
  width: 280px;
}

.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.5;
}

.search-box input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 38px;
  background-color: var(--bg-surface, #1a2234);
  border: 1px solid var(--border-default, #334155);
  border-radius: 8px;
  font-size: 14px;
  line-height: 38px;
  color: var(--text-primary, #f8fafc);
  transition: border-color 0.15s ease;
  box-sizing: border-box;
  vertical-align: middle;
}

.search-box input:focus {
  outline: none;
  border-color: #3b82f6;
}

.search-box input::placeholder {
  color: var(--text-muted, #64748b);
}

.filter-dropdown select {
  height: 40px;
  padding: 0 32px 0 12px;
  background-color: var(--bg-surface, #1a2234);
  border: 1px solid var(--border-default, #334155);
  border-radius: 8px;
  font-size: 14px;
  line-height: 38px;
  color: var(--text-primary, #f8fafc);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  box-sizing: border-box;
  vertical-align: middle;
}

.filter-dropdown select:focus {
  outline: none;
  border-color: #3b82f6;
}

.view-toggle {
  display: flex;
  background-color: var(--bg-surface, #1a2234);
  border: 1px solid var(--border-default, #334155);
  border-radius: 8px;
  overflow: hidden;
}

.view-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted, #64748b);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-btn:hover {
  color: var(--text-primary, #f8fafc);
  background-color: var(--bg-hover, #243044);
}

.view-btn.active {
  color: #3b82f6;
  background-color: rgba(59, 130, 246, 0.1);
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.template-card {
  background-color: var(--bg-elevated, #111827);
  border: 1px solid var(--border-subtle, #1e293b);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.template-card:hover {
  border-color: var(--border-default, #334155);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.template-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.template-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
  margin: 0 0 6px 0;
  line-height: 1.3;
}

.template-card-category {
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

.template-menu-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted, #64748b);
  font-size: 18px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.template-menu-btn:hover {
  background-color: var(--bg-hover, #243044);
  color: var(--text-primary, #f8fafc);
}

.template-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 160px;
  background-color: var(--bg-elevated, #111827);
  border: 1px solid var(--border-default, #334155);
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 100;
  display: none;
  overflow: hidden;
}

.template-dropdown.open {
  display: block;
}

.template-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-primary, #f8fafc);
  cursor: pointer;
  transition: background 0.15s ease;
}

.template-dropdown-item:hover {
  background-color: var(--bg-hover, #243044);
}

.template-dropdown-item.danger {
  color: #ef4444;
}

.template-dropdown-item.danger:hover {
  background-color: rgba(239, 68, 68, 0.1);
}

.template-card-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.template-stat {
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
}

.template-stat-value {
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
}

.template-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle, #1e293b);
}

.template-card-date {
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-badge.draft {
  background-color: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
}

.status-badge.published {
  background-color: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.status-badge.archived {
  background-color: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.templates-list {
  background-color: var(--bg-elevated, #111827);
  border: 1px solid var(--border-subtle, #1e293b);
  border-radius: 12px;
  overflow: hidden;
}

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

.templates-table th {
  padding: 14px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: var(--bg-surface, #1a2234);
  border-bottom: 1px solid var(--border-subtle, #1e293b);
}

.templates-table td {
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text-secondary, #94a3b8);
  border-bottom: 1px solid var(--border-subtle, #1e293b);
}

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

.templates-table tr:hover td {
  background-color: var(--bg-hover, #243044);
}

.templates-table .template-name-cell {
  font-weight: 500;
  color: var(--text-primary, #f8fafc);
  cursor: pointer;
}

.templates-table .template-name-cell:hover {
  color: #3b82f6;
}

.table-actions {
  display: flex;
  gap: 4px;
}

.table-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted, #64748b);
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.table-action-btn:hover {
  background-color: var(--bg-surface, #1a2234);
  color: var(--text-primary, #f8fafc);
}

.templates-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.6;
}

.empty-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
  margin: 0 0 8px 0;
}

.empty-desc {
  font-size: 14px;
  color: var(--text-muted, #64748b);
  margin: 0 0 24px 0;
}

.template-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.info-card {
  background-color: var(--bg-surface, #1a2234);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.info-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.info-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary, #f8fafc);
}

.template-dates {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--text-muted, #64748b);
  margin-bottom: 20px;
}

.share-link-section {
  margin-bottom: 20px;
}

.share-link-section label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 8px;
}

.share-link-row {
  display: flex;
  gap: 8px;
}

.share-link-row input {
  flex: 1;
  padding: 10px 14px;
  background-color: var(--bg-surface, #1a2234);
  border: 1px solid var(--border-default, #334155);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary, #f8fafc);
}

.template-preview-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
  margin: 0 0 12px 0;
}

.form-preview {
  background-color: var(--bg-surface, #1a2234);
  border-radius: 10px;
  padding: 16px;
}

.preview-step {
  margin-bottom: 16px;
}

.preview-step:last-child {
  margin-bottom: 0;
}

.preview-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.preview-step-number {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  font-size: 12px;
  font-weight: 700;
  border-radius: 50%;
}

.preview-step-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
}

.preview-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 34px;
}

.preview-field-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background-color: var(--bg-base, #0a0e17);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
}

.category-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background-color: var(--bg-surface, #1a2234);
  border: 1px solid var(--border-default, #334155);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.category-option:hover {
  border-color: #3b82f6;
  background-color: var(--bg-hover, #243044);
}

.category-option input {
  accent-color: #3b82f6;
}

.category-option span {
  font-size: 14px;
  color: var(--text-primary, #f8fafc);
}

.delete-warning {
  font-size: 15px;
  color: var(--text-primary, #f8fafc);
  margin: 0 0 8px 0;
}

.delete-note {
  font-size: 13px;
  color: var(--text-muted, #64748b);
  margin: 0;
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.btn-danger-outline:hover {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-actions-left,
.modal-actions-right {
  display: flex;
  gap: 8px;
}

.template-detail-modal {
  max-width: 800px;
}

.modal.modal-small {
  max-width: 440px;
}

/* ===========================================
 MESSAGING CENTER STYLES
 =========================================== */

.messages-layout {
  display: flex;
  height: calc(100vh - 160px);
  min-height: 500px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-default);
  width: 100%;
}

.conversations-panel {
  width: 340px;
  min-width: 300px;
  max-width: 380px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
}

.conversations-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-default);
  display: flex;
  gap: 8px;
  align-items: center;
  overflow: visible;
  flex-shrink: 0;
}

.conversations-header .btn-primary {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 6px 10px;
}

.conversations-search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 6px 12px;
}

.conversations-search input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.conversations-search svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-results-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

.conversations-filter-tabs {
  display: flex;
  padding: 8px 12px;
  gap: 4px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.filter-tab {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.filter-tab.active {
  color: var(--primary);
  background: var(--primary-light);
}

.bulk-select-btn {
  margin-left: auto;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--primary-light);
  border-bottom: 1px solid var(--border-default);
}

.bulk-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
}

.bulk-checkbox {
  display: flex;
  align-items: center;
  margin-right: 8px;
  flex-shrink: 0;
}

.bulk-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.conversation-item.selected {
  background: var(--primary-light);
}

.search-section {
  padding: 8px 0;
}

.search-section-label {
  display: block;
  padding: 6px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.search-result-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

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

.search-result-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.search-result-email {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

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

.conversation-item.active {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
}

.conversation-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

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

.conversation-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.conversation-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.conversation-preview {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-text {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-badge {
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.thread-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}

.thread-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 12px;
}

.thread-empty-state svg {
  opacity: 0.5;
}

.thread-empty-state h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
}

.thread-empty-state p {
  margin: 0;
  font-size: 14px;
}

.thread-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

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

.thread-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
  flex-shrink: 0;
}

.thread-client-details h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.thread-client-details span {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.messages-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(to bottom, var(--bg-base), var(--bg-surface));
  scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: var(--border-focus);
}

.thread-empty-messages {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  animation: messageSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.message:hover {
  transform: translateY(-1px);
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.own {
  align-self: flex-end;
  align-items: flex-end;
}

.message.other {
  align-self: flex-start;
  align-items: flex-start;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.6;
  position: relative;
  word-wrap: break-word;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message.own .message-bubble {
  background: linear-gradient(135deg, var(--primary) 0%, #5b6ee8 100%);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow:
    0 4px 12px rgba(59, 130, 246, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.1);
}

.message.own .message-bubble:hover {
  box-shadow:
    0 6px 16px rgba(59, 130, 246, 0.3),
    0 2px 6px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.message.other .message-bubble {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-bottom-left-radius: 4px;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.04);
}

.message.other .message-bubble:hover {
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.06);
  border-color: var(--border-focus);
}

.message-bubble p {
  margin: 0;
  word-wrap: break-word;
  letter-spacing: 0.01em;
}

.message-time {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.message.own .message-time {
  color: rgba(255, 255, 255, 0.75);
}

.message-sender-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding-left: 6px;
  animation: fadeInDown 0.3s ease;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-sender-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.message-sender-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  margin-right: 8px;
  opacity: 0.9;
}

.message.own .message-sender-label.own-label {
  display: inline;
  color: rgba(255, 255, 255, 0.85);
  opacity: 0.9;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 0 4px;
  flex-wrap: wrap;
}

.message.own .message-meta {
  justify-content: flex-end;
}

.message.other .message-meta {
  justify-content: flex-start;
}

.pin-indicator {
  display: inline-flex;
  align-items: center;
  color: var(--primary);
  opacity: 0.8;
  transition: all 0.2s ease;
}

.pin-indicator:hover {
  opacity: 1;
  transform: scale(1.1);
}

.message.own .pin-indicator {
  color: rgba(255, 255, 255, 0.9);
}

.form-share-message {
  background: linear-gradient(
    135deg,
    var(--bg-elevated) 0%,
    var(--bg-surface) 100%
  ) !important;
  border: 1.5px solid var(--border-default) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
}

.form-share-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px;
}

.form-share-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    var(--primary-light),
    rgba(59, 130, 246, 0.1)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.15);
  flex-shrink: 0;
}

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

.form-share-name {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: 0.01em;
}

.form-share-status {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: capitalize;
  font-weight: 500;
  opacity: 0.85;
}

.composer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-default);
  background: var(--bg-surface);
  flex-shrink: 0;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
}

.composer-input-wrapper {
  background: var(--bg-base);
  border: 2px solid var(--border-default);
  border-radius: 20px;
  padding: 12px 16px;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}

.composer-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: var(--bg-surface);
}

.composer-input-wrapper textarea {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14.5px;
  line-height: 1.6;
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 120px;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.composer-input-wrapper textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.client-search-results {
  max-height: 300px;
  overflow-y: auto;
}

.client-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

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

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

.client-info {
  flex: 1;
}

.client-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.client-email {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===========================================
 NEW CONVERSATION MODAL - ENHANCED UI
 =========================================== */

.new-conversation-modal {
  max-width: 560px;
  animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.new-conversation-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
  color: white;
  border-bottom: none;
  padding: 24px 28px;
  position: relative;
  overflow: hidden;
}

.new-conversation-header::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 70%
  );
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
  0%,
  100% {
    transform: rotate(0deg);
  }

  50% {
    transform: rotate(180deg);
  }
}

.modal-header-content {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.modal-icon-wrapper {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.new-conversation-header h3 {
  color: white;
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px 0;
  letter-spacing: -0.02em;
}

.modal-subtitle {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  margin: 0;
  font-weight: 400;
}

.new-conversation-header .modal-close {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  position: relative;
  z-index: 1;
}

.new-conversation-header .modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  transform: rotate(90deg);
}

.new-conversation-body {
  padding: 28px;
}

.conversation-type-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  background: var(--bg-surface);
  padding: 6px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
}

.conversation-type-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.conversation-type-tab svg {
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

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

.conversation-type-tab.active {
  color: var(--primary);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.conversation-type-tab.active svg {
  transform: scale(1.1);
}

.conversation-form {
  animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-group-enhanced {
  margin-bottom: 20px;
}

.form-label-with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.form-label-with-icon svg {
  color: var(--primary);
  flex-shrink: 0;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

.input-enhanced {
  width: 100%;
  padding: 14px 16px 14px 44px;
  background: var(--bg-surface);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
  outline: none;
}

.input-enhanced:focus {
  border-color: var(--primary);
  background: var(--bg-elevated);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.input-enhanced::placeholder {
  color: var(--text-muted);
}

.client-search-results {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 8px;
}

.empty-state-enhanced {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state-enhanced svg {
  margin-bottom: 16px;
  color: var(--text-muted);
}

.empty-state-enhanced p {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 6px 0;
}

.empty-state-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.client-search-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  cursor: pointer;
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
  margin-bottom: 6px;
  background: transparent;
  border: 1px solid transparent;
}

.client-search-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
  transform: translateX(2px);
}

.client-search-item:last-child {
  margin-bottom: 0;
}

.client-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

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

.client-name {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.client-email {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
}

.group-participants-list {
  max-height: 240px;
  overflow-y: auto;
  margin-top: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 80px;
  align-items: flex-start;
}

.group-participants-list:has(.empty-state-enhanced) {
  justify-content: center;
  align-items: center;
}

.participant-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 13px;
  color: var(--text-primary);
  animation: chipSlideIn 0.2s ease-out;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all var(--transition-fast);
  position: relative;
}

.participant-chip:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.15);
  transform: translateY(-1px);
}

@keyframes chipSlideIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.participant-chip-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.participant-chip-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.participant-chip-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.participant-chip-email {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.participant-chip-remove {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  margin-left: 4px;
  opacity: 0.7;
}

.participant-chip-remove:hover {
  background: var(--danger-bg);
  color: var(--danger);
  transform: rotate(90deg) scale(1.1);
  opacity: 1;
}

.participant-chip-remove:active {
  transform: rotate(90deg) scale(0.95);
}

.participant-chip-remove svg {
  width: 12px;
  height: 12px;
}

/* Group User Search Dropdown */
.group-user-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  animation: dropdownFadeIn 0.15s ease-out;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.group-user-search-dropdown-item {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background-color var(--transition-fast);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.group-user-search-dropdown-item:last-child {
  border-bottom: none;
}

.group-user-search-dropdown-item:hover {
  background: var(--bg-hover);
}

.group-user-search-dropdown-item:active {
  background: var(--bg-active);
}

.group-user-search-dropdown-action {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0;
  transform: scale(0.8);
  transition: all var(--transition-fast);
  pointer-events: none;
}

.group-user-search-dropdown-item:hover .group-user-search-dropdown-action {
  opacity: 1;
  transform: scale(1);
}

.group-user-search-dropdown-action svg {
  width: 16px;
  height: 16px;
}

.group-user-search-dropdown-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.group-user-search-dropdown-info {
  flex: 1;
  min-width: 0;
}

.group-user-search-dropdown-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-user-search-dropdown-email {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-user-search-dropdown-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Scrollbar styling for dropdown */
.group-user-search-dropdown::-webkit-scrollbar {
  width: 6px;
}

.group-user-search-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.group-user-search-dropdown::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}

.group-user-search-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.new-conversation-footer {
  padding: 20px 28px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-with-icon svg {
  flex-shrink: 0;
}

/* Search results sections */
.search-results-section {
  margin-bottom: 16px;
}

.search-results-section:last-child {
  margin-bottom: 0;
}

.search-results-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px 14px 6px;
  margin-bottom: 4px;
}

.forms-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.form-share-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.form-share-item:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.form-share-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.form-share-item-info {
  flex: 1;
}

.form-share-item-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-share-item-status {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* Phase 1 Enhanced Messaging Styles */

.thread-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legal-hold-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #f59e0b;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.thread-client-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.case-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

.case-badge:hover {
  background: rgba(59, 130, 246, 0.25);
}

.pinned-section {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  padding: 12px 16px;
}

.pinned-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.pinned-header svg {
  color: var(--warning);
}

.pinned-header button {
  margin-left: auto;
}

.pinned-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pinned-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-base);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.pinned-item-text {
  font-size: 13px;
  color: var(--text-primary);
}

.pinned-item-time {
  font-size: 11px;
  color: var(--text-muted);
}

.composer-mode {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.composer-mode-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}

.composer-mode-badge.internal-note {
  color: var(--warning);
}

.composer-actions-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.internal-note-toggle.active {
  background: var(--warning-bg);
  color: var(--warning);
}

.internal-note-bubble {
  background: linear-gradient(
    135deg,
    var(--warning-bg) 0%,
    rgba(251, 191, 36, 0.1) 100%
  ) !important;
  border: 1.5px solid var(--warning-border) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 2px 8px rgba(251, 191, 36, 0.15) !important;
}

.internal-note-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--warning);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.pin-indicator {
  color: var(--warning);
  display: inline-flex;
  align-items: center;
  opacity: 0.8;
  transition: all 0.2s ease;
}

.pin-indicator:hover {
  opacity: 1;
  transform: scale(1.1);
}

.templates-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.templates-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.template-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.template-item:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.template-item-content {
  flex: 1;
  min-width: 0;
}

.template-item-title {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.template-item-preview {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-item-actions {
  display: flex;
  gap: 4px;
}

.cases-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 12px;
}

.case-link-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.case-link-item:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.case-link-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.case-link-status {
  font-size: 11px;
}

.current-link {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-default);
}

.linked-case {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 8px 0 12px 0;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

/* Attachment Message Styles */
.attachment-message {
  padding: 0 !important;
}

.attachment-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-default);
  border-radius: 16px;
  min-width: 240px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.attachment-card:hover {
  border-color: var(--border-focus);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.message.own .attachment-card {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
}

.attachment-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    var(--primary-light),
    rgba(59, 130, 246, 0.1)
  );
  border-radius: 12px;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.15);
}

.message.own .attachment-icon {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.attachment-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.attachment-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.message.own .attachment-name {
  color: rgba(255, 255, 255, 0.95);
}

.attachment-size {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  opacity: 0.8;
}

.message.own .attachment-size {
  color: rgba(255, 255, 255, 0.7);
}

.attachment-card {
  position: relative;
  user-select: none;
}

.attachment-actions {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.attachment-menu-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.attachment-menu-btn:hover {
  background: var(--bg-hover);
}

.attachment-menu-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 180px;
  padding: 4px;
  animation: dropdownFadeIn 0.15s ease-out;
  transform-origin: bottom right;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.attachment-menu-item {
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background-color var(--transition-fast);
  border-radius: var(--radius-sm);
}

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

.attachment-menu-item svg {
  flex-shrink: 0;
  color: var(--text-secondary);
}

/* Context Menu Styles */
.context-menu {
  animation: contextMenuFadeIn 0.15s ease-out;
}

@keyframes contextMenuFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.context-menu-item {
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background-color var(--transition-fast);
  border-radius: var(--radius-sm);
}

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

.context-menu-item svg {
  flex-shrink: 0;
  color: var(--text-secondary);
}

/* Client List for Move Modal */
.client-list-for-move {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.client-item-for-move {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.client-item-for-move:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

.client-item-for-move.selected {
  background: var(--bg-hover);
  border-color: var(--primary);
  border-width: 2px;
}

.client-item-checkbox {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.client-item-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.client-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.client-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.client-item-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-item-email {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pending Attachments Preview */
.pending-attachments-preview {
  padding: 14px 16px;
  background: linear-gradient(to bottom, var(--bg-surface), var(--bg-base));
  border-bottom: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.pending-attachment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-default);
  border-radius: 14px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.pending-attachment-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.pending-attachment-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    var(--primary-light),
    rgba(59, 130, 246, 0.1)
  );
  border-radius: 10px;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.15);
}

.pending-attachment-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pending-attachment-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.pending-attachment-size {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  opacity: 0.85;
}

/* Notification Badge */
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-btn {
  position: relative;
}

#attachment-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Client View Modal Styles */
.client-view-modal {
  display: flex;
  flex-direction: column;
  width: 1000px !important;
  max-width: 95vw !important;
  height: 85vh !important;
  max-height: 90vh !important;
  overflow: hidden;
}

.client-tabs-container {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--card-bg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.client-tab-btn {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
}

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

.client-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
}

.client-tab-btn svg {
  flex-shrink: 0;
}

.tab-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  background: var(--bg-hover);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.client-tab-btn.active .tab-badge {
  background: var(--primary-light);
  color: var(--primary);
}

.client-tab-content {
  display: none;
  animation: fadeIn 0.2s ease-in;
}

.client-tab-content.active {
  display: block;
}

.client-payments-subtab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
}

.client-payments-subtab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.client-payments-subtab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.transaction-modal-tab-btn {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

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

.transaction-modal-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Transaction detail modal: fixed size, no jump when switching tabs */
#transaction-detail-modal .modal.transaction-detail-modal-box {
  max-width: 560px;
  width: 100%;
  height: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#transaction-detail-modal .modal.transaction-detail-modal-box .modal-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

#transaction-detail-modal .transaction-detail-modal-tabbar {
  display: flex;
  flex-shrink: 0;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 0 4px 0 0;
}

#transaction-detail-modal .transaction-detail-modal-panes {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

#transaction-detail-modal .transaction-modal-tab-content {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 20px 24px;
  overflow-y: auto;
  animation: transactionTabFade 0.15s ease-out;
}

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

#transaction-detail-modal .transaction-detail-table {
  width: 100%;
  font-size: 14px;
  border-collapse: collapse;
}

#transaction-detail-modal .transaction-detail-table td {
  padding: 10px 12px;
  vertical-align: top;
  border-bottom: 1px solid var(--border-subtle);
}

#transaction-detail-modal .transaction-detail-table td:first-child {
  color: var(--text-muted);
  font-weight: 500;
  width: 140px;
}

#transaction-detail-modal .transaction-detail-table tr:last-child td {
  border-bottom: none;
}

#transaction-detail-modal .transaction-detail-table .status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
}

#transaction-detail-modal .transaction-detail-code {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px;
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: var(--radius-md);
  word-break: break-all;
}

#transaction-detail-modal .transaction-tab-heading {
  margin: 0 0 12px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

#transaction-detail-modal .transaction-tab-intro,
#transaction-detail-modal .transaction-tab-muted {
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.5;
}

#transaction-detail-modal .transaction-tab-muted {
  color: var(--text-muted);
}

#transaction-detail-modal .transaction-form-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
}

#transaction-detail-modal .transaction-modal-tab-content label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

#transaction-detail-modal .transaction-modal-tab-content input[type="text"],
#transaction-detail-modal .transaction-modal-tab-content input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 12px;
}

#transaction-detail-modal .transaction-modal-tab-content input:focus {
  outline: none;
  border-color: var(--primary-border);
  box-shadow: 0 0 0 2px var(--primary-light);
}

#transaction-detail-modal .transaction-modal-tab-content .btn {
  margin-top: 4px;
}

.client-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.client-modal-body::-webkit-scrollbar {
  width: 8px;
}

.client-modal-body::-webkit-scrollbar-track {
  background: var(--bg-surface);
}

.client-modal-body::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

.client-modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.file-item {
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--card-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all var(--transition-fast);
}

.file-item:hover {
  border-color: var(--primary-border);
  background: var(--bg-hover);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* File Preview Modal Styles */
#file-preview-modal .modal {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

#file-preview-modal .modal-body {
  flex: 1;
  overflow: auto;
  padding: 0;
  background: var(--bg-base);
}

#file-preview-modal iframe {
  border: none;
  background: white;
}

.file-item a:hover {
  text-decoration: underline !important;
}

/* Lead View Modal Styles – fixed size so it doesn’t resize when switching tabs */
#view-lead-modal.modal-overlay {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.lead-view-modal {
  display: flex;
  flex-direction: row;
  max-width: 1100px;
  width: 92%;
  height: 88vh;
  min-height: 88vh;
  overflow: hidden;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  box-shadow:
    var(--shadow-xl),
    0 0 0 1px var(--border-default);
  border: 1px solid var(--border-default);
  transition:
    transform var(--transition-normal),
    opacity var(--transition-normal);
}

#view-lead-modal.modal-overlay.active .lead-view-modal {
  animation: leadModalIn 0.2s ease-out;
}

@keyframes leadModalIn {
  from {
    opacity: 0.96;
    transform: scale(0.98);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Lead Sidebar */
.lead-sidebar {
  width: 300px;
  min-width: 280px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
}

.lead-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
}

.lead-sidebar-header h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lead-edit-icon-btn {
  background: var(--bg-hover);
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.lead-edit-icon-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.lead-info-section {
  margin: 0 24px 20px;
  padding: 20px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.lead-name {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.lead-email {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.4;
  word-break: break-all;
}

.lead-sidebar .lead-info-item {
  margin-bottom: 0;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.lead-sidebar .lead-info-item:last-of-type {
  border-bottom: none;
}

.lead-info-item {
  margin-bottom: 18px;
}

.lead-info-label {
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.lead-info-value {
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.4;
}

.lead-contact-icons .lead-contact-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition:
    color var(--transition-fast),
    background var(--transition-fast);
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}

.lead-contact-icons .lead-contact-icon:hover {
  color: var(--primary);
  background: var(--bg-subtle);
}

.lead-sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding: 20px 24px 24px;
  border-top: 1px solid var(--border-default);
  background: var(--bg-surface);
}

.lead-sidebar-actions .btn-primary {
  width: 100%;
  padding: 12px 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition:
    background var(--transition-fast),
    transform var(--transition-fast);
}

.lead-sidebar-actions .btn-primary:not(:disabled):hover {
  transform: translateY(-1px);
}

.lead-sidebar-actions .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Lead Content Panel */
.lead-content-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-elevated);
}

.lead-modal-header {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-default);
  padding: 12px 20px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  background: var(--bg-surface);
}

.lead-modal-header .modal-close {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    color var(--transition-fast),
    background var(--transition-fast);
}

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

.lead-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 40px;
  background: var(--bg-elevated);
}

/* Lead Case Details form grid */
.lead-case-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 28px;
}

.lead-case-details-grid .form-group {
  margin-bottom: 0;
}

.lead-case-details-grid .form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.lead-case-details-grid .form-control {
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

/* Lead Sub-tabs – pill style */
.lead-subtabs-container {
  display: flex;
  gap: 6px;
  margin-bottom: 28px;
  padding: 4px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  width: fit-content;
  border: 1px solid var(--border-subtle);
}

.lead-subtab-btn {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: all var(--transition-fast);
}

.lead-subtab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.lead-subtab-btn.active {
  background: var(--bg-elevated);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-default);
}

.lead-subtab-content {
  display: none;
  animation: fadeIn 0.2s ease-in;
}

.lead-subtab-content.active {
  display: block;
}

/* Edit Information tab in lead modal */
#lead-subtab-edit-information .form-group {
  margin-bottom: 0;
}

#lead-subtab-edit-information .form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* Lead Files tab header */
.lead-files-tab-header {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lead-files-tab-title,
#lead-subtab-files h4 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* Lead Edit Information grid */
.lead-edit-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 28px;
}

/* Lead modal form actions (Save / Cancel) */
.lead-form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

.lead-view-modal .lead-form-actions .btn-primary,
.lead-view-modal .lead-form-actions .btn-secondary {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 500;
}

/* Add Lead modal */
.add-lead-modal-content {
  max-width: 640px;
  border-radius: var(--radius-xl);
  box-shadow:
    var(--shadow-xl),
    0 0 0 1px var(--border-default);
  overflow: hidden;
}

.add-lead-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-default);
}

.add-lead-modal-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 4px 0 0 0;
}

.add-lead-modal-body {
  padding: 24px 24px 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.add-lead-section {
  margin-bottom: 24px;
}

.add-lead-section:last-child {
  margin-bottom: 0;
}

.add-lead-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 12px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.add-lead-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}

.add-lead-grid .form-group {
  margin-bottom: 0;
}

.add-lead-full-width {
  grid-column: 1 / -1;
}

.add-lead-grid .form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.add-lead-grid .form-control {
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.add-lead-grid .required {
  color: var(--danger);
}

.add-lead-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-default);
  gap: 12px;
}

.lead-subtab-content {
  display: none;
  animation: fadeIn 0.2s ease-in;
}

.lead-subtab-content.active {
  display: block;
}

/* Lead Assigned To – searchable select */
.lead-assigned-to-wrap {
  position: relative;
}

.searchable-select-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.searchable-select-trigger:hover {
  border-color: var(--border-strong);
}

.searchable-select-trigger.open {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb, 59, 130, 246), 0.2);
}

.searchable-select-display {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
  text-align: left;
}

.searchable-select-display:empty::before {
  content: "Search and select...";
  color: var(--text-muted);
}

.searchable-select-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--text-primary);
}

.searchable-select-input::placeholder {
  color: var(--text-muted);
}

.searchable-select-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition:
    color var(--transition-fast),
    background var(--transition-fast);
}

.searchable-select-clear:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.searchable-select-chevron {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.searchable-select-dropdown {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  z-index: 50;
}

.searchable-select-dropdown.open {
  display: block;
}

.searchable-select-item {
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.searchable-select-item:hover {
  background: var(--bg-hover);
}

.searchable-select-empty {
  padding: 12px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}

/* Form Control Readonly */
.form-control-readonly {
  background: var(--bg-surface) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed;
  opacity: 0.7;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

.hidden {
  display: none;
}

/* Aging styles */
.aging-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.aging-card {
  background: #1e293b;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid #334155;
  transition: all 0.2s;
}

.aging-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.aging-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.aging-card.critical .aging-card-icon {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.aging-card.warning .aging-card-icon {
  background: rgba(251, 146, 60, 0.1);
  color: #fb923c;
}

.aging-card.healthy .aging-card-icon {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.aging-card.neutral .aging-card-icon {
  background: rgba(100, 116, 139, 0.1);
  color: #64748b;
}

.aging-card-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.aging-card-value {
  font-size: 28px;
  font-weight: 700;
  color: #f8fafc;
}

.aging-card-label {
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
}

.aging-card-sublabel {
  font-size: 11px;
  color: #64748b;
}

/* ===== TABS ===== */
.aging-tabs-container {
  margin-bottom: 24px;
}

.aging-tabs {
  display: flex;
  gap: 8px;
  background: #1e293b;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid #334155;
  overflow-x: auto;
  scrollbar-width: none;
}

.aging-tabs::-webkit-scrollbar {
  display: none;
}

.aging-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  color: #94a3b8;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.aging-tab:hover {
  background: #334155;
  color: #e2e8f0;
}

.aging-tab.active {
  background: #3b82f6;
  color: white;
}

.aging-tab svg {
  flex-shrink: 0;
}

.aging-tab-badge {
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.aging-tab.active .aging-tab-badge {
  background: rgba(255, 255, 255, 0.2);
}

/* ===== CHARTS ROW ===== */
.aging-charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.aging-chart-card {
  background: #1e293b;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #334155;
}

.aging-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.aging-chart-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #f8fafc;
}

.aging-chart-subtitle {
  font-size: 12px;
  color: #64748b;
}

.aging-chart-period {
  display: flex;
  gap: 4px;
  background: #0f172a;
  padding: 4px;
  border-radius: 8px;
}

.period-btn {
  padding: 6px 12px;
  background: transparent;
  color: #94a3b8;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.period-btn:hover {
  color: #e2e8f0;
}

.period-btn.active {
  background: #3b82f6;
  color: white;
}

/* ===== DISTRIBUTION CHART ===== */
.aging-distribution-chart {
  display: block;
}

.distribution-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.distribution-bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 60px;
  gap: 12px;
  align-items: center;
}

.distribution-label {
  font-size: 13px;
  color: #cbd5e1;
  font-weight: 500;
}

.distribution-bar-container {
  background: #0f172a;
  height: 32px;
  border-radius: 6px;
  overflow: hidden;
}

.distribution-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.distribution-bar.healthy {
  background: linear-gradient(90deg, #22c55e, #16a34a);
}

.distribution-bar.good {
  background: linear-gradient(90deg, #84cc16, #65a30d);
}

.distribution-bar.moderate {
  background: linear-gradient(90deg, #eab308, #ca8a04);
}

.distribution-bar.warning {
  background: linear-gradient(90deg, #fb923c, #f97316);
}

.distribution-bar.critical {
  background: linear-gradient(90deg, #ef4444, #dc2626);
}

.distribution-value {
  font-size: 14px;
  font-weight: 600;
  color: #f8fafc;
  text-align: right;
}

/* ===== TREND CHART ===== */
.aging-trend-chart {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aging-trend-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #64748b;
}

/* ===== FILTERS BAR ===== */
.aging-filters-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.aging-filters-left {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.aging-filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.aging-filter-group label {
  font-size: 12px;
  font-weight: 500;
  color: #cbd5e1;
}

.aging-filter-group select {
  padding: 8px 12px;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  min-width: 160px;
}

.aging-filter-group select:focus {
  outline: none;
  border-color: #3b82f6;
}

.aging-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  min-width: 250px;
}

.aging-search-box svg {
  color: #64748b;
  flex-shrink: 0;
}

.aging-search-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: #f8fafc;
  font-size: 13px;
}

.aging-search-box input:focus {
  outline: none;
}

.aging-search-box input::placeholder {
  color: #64748b;
}

/* ===== TABLE ===== */
.aging-table-card {
  background: #1e293b;
  border-radius: 12px;
  border: 1px solid #334155;
  overflow: hidden;
}

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

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

.aging-table thead {
  background: #0f172a;
}

.aging-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #334155;
  white-space: nowrap;
}

.aging-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.aging-table th.sortable:hover {
  color: #f8fafc;
}

.aging-table th.sortable svg {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.3;
  transition: opacity 0.2s;
}

.aging-table th.sortable:hover svg {
  opacity: 0.6;
}

.aging-table th.sortable.active svg {
  opacity: 1;
}

.aging-table th.sortable.desc svg {
  transform: rotate(180deg);
}

.aging-table tbody tr {
  border-bottom: 1px solid #334155;
  transition: background 0.2s;
}

.aging-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

.aging-table td {
  padding: 16px;
  font-size: 13px;
  color: #e2e8f0;
}

/* ===== TABLE CELL COMPONENTS ===== */
.aging-status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
}

.aging-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.aging-status-dot.critical {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.aging-status-dot.warning {
  background: #fb923c;
  box-shadow: 0 0 8px rgba(251, 146, 60, 0.5);
}

.aging-status-dot.healthy {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.aging-client-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.aging-client-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.aging-client-name {
  font-weight: 500;
  color: #f8fafc;
}

.aging-case-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.aging-case-name {
  font-weight: 500;
  color: #f8fafc;
}

.aging-case-id {
  font-size: 11px;
  color: #64748b;
}

.aging-practice-badge {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.aging-activity-type {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  font-size: 12px;
}

.aging-activity-type svg {
  width: 14px;
  height: 14px;
}

.aging-days-cell {
  font-weight: 600;
  font-size: 14px;
}

.aging-days-cell.critical {
  color: #ef4444;
}

.aging-days-cell.warning {
  color: #fb923c;
}

.aging-days-cell.healthy {
  color: #22c55e;
}

/* ===== ACTION BUTTONS ===== */
.aging-actions {
  display: flex;
  gap: 4px;
}

.aging-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: #94a3b8;
}

.aging-action-btn:hover {
  background: #334155;
  color: #f8fafc;
  transform: translateY(-1px);
}

.aging-action-btn.message:hover {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

/* ===== EMPTY STATE ===== */
.aging-table-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.aging-table-empty svg {
  color: #475569;
  margin-bottom: 16px;
}

.aging-table-empty h3 {
  font-size: 18px;
  font-weight: 600;
  color: #f8fafc;
  margin-bottom: 8px;
}

.aging-table-empty p {
  font-size: 14px;
  color: #64748b;
}

/* ===== PAGINATION ===== */
.aging-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-top: 1px solid #334155;
}

.pagination-info {
  font-size: 13px;
  color: #94a3b8;
}

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

.pagination-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: #94a3b8;
}

.pagination-btn:hover:not(:disabled) {
  background: #334155;
  color: #f8fafc;
}

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

.pagination-pages {
  display: flex;
  gap: 4px;
}

.pagination-page {
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
}

.pagination-page:hover {
  background: #334155;
  color: #f8fafc;
}

.pagination-page.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
  .aging-charts-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    gap: 16px;
  }

  .aging-summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .aging-filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .aging-filters-left {
    width: 100%;
  }

  .aging-filter-group select,
  .aging-search-box {
    width: 100%;
  }

  .table-container {
    overflow-x: scroll;
  }

  .aging-pagination {
    flex-direction: column;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .aging-summary-cards {
    grid-template-columns: 1fr;
  }

  .aging-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
  }
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

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