:root {
  --app-bg: #f4f7fb;
  --app-surface: rgba(255,255,255,0.92);
  --app-border: rgba(15, 23, 42, 0.08);
  --app-text: #0f172a;
  --app-muted: #64748b;
  --app-primary: #1d4ed8;
  --app-primary-dark: #1e3a8a;
  --app-secondary: #0f766e;
  --app-accent: #dc2626;
  --app-warning: #d97706;
  --app-success: #15803d;
  --app-shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
  --app-shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.06);
  --app-radius: 20px;
  --app-radius-sm: 14px;
  --sidebar-width: 280px;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.08), transparent 22%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.08), transparent 20%),
    var(--app-bg);
  color: var(--app-text);
  min-height: 100vh;
}

body.lawapp-shell {
  padding-top: 76px;
}

a {
  text-decoration: none;
}

.app-navbar {
  min-height: 76px;
  backdrop-filter: blur(16px);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(30, 64, 175, 0.88));
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(255,255,255,0.18), rgba(255,255,255,0.08));
  color: #fff;
}

.nav-icon-btn {
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  width: 44px;
  height: 44px;
}

.app-user-chip .nav-link {
  color: inherit;
  padding: 0;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.app-sidebar {
  position: fixed;
  top: 76px;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--app-border);
  overflow-y: auto;
  z-index: 1020;
}

.sidebar-section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--app-muted);
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.app-sidebar .nav-link {
  display: flex;
  align-items: center;
  min-height: 48px;
  border-radius: 14px;
  color: #334155;
  font-weight: 600;
  padding: 0.75rem 1rem;
  transition: all 0.2s ease;
}

.app-sidebar .nav-link:hover,
.app-sidebar .nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--app-primary), var(--app-primary-dark));
  box-shadow: 0 14px 28px rgba(29, 78, 216, 0.18);
}

.app-main {
  margin-left: var(--sidebar-width);
  padding: 1.5rem 1.5rem 2rem;
}

.custom-container,
.page-shell {
  max-width: 100%;
}

.page-header {
  background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(255,255,255,0.82));
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-soft);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: clamp(1.6rem, 2vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
}

.card {
  border: 1px solid rgba(255,255,255,0.75);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-soft);
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,255,255,0.9));
  overflow: hidden;
}

.card-header,
.modal-header {
  border-bottom: 1px solid var(--app-border);
}

.card-header {
  background: rgba(248, 250, 252, 0.9);
  padding: 1rem 1.25rem;
  font-weight: 700;
}

.card-body,
.modal-body {
  padding: 1.25rem;
}

.dashboard-stats .card {
  position: relative;
  isolation: isolate;
  min-height: 180px;
}

.dashboard-stats .card::after {
  content: '';
  position: absolute;
  inset: auto -30px -30px auto;
  width: 120px;
  height: 120px;
  background: rgba(255,255,255,0.14);
  border-radius: 50%;
}

.card.text-white h2 {
  font-size: 2.1rem;
  font-weight: 800;
}

.table-container,
.table-responsive {
  border-radius: calc(var(--app-radius) - 4px);
}

.table thead th {
  background: #f8fafc;
  color: #334155;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--app-border);
  padding: 0.95rem 1rem;
}

.table tbody td {
  padding: 1rem;
  border-color: rgba(148, 163, 184, 0.16);
}

.table-hover tbody tr:hover {
  background: rgba(37, 99, 235, 0.04);
}

.form-control,
.form-select,
.input-group-text,
.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
  border-radius: 14px !important;
  min-height: 48px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: none !important;
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(29, 78, 216, 0.45);
  box-shadow: 0 0 0 0.25rem rgba(37, 99, 235, 0.12) !important;
}

.input-group-modern .input-group-text,
.input-group-modern .btn {
  border-radius: 14px !important;
}

.btn {
  border-radius: 14px;
  font-weight: 700;
  padding: 0.7rem 1.05rem;
}

.btn-primary,
.bg-primary {
  background: linear-gradient(135deg, var(--app-primary), var(--app-primary-dark)) !important;
  border-color: transparent !important;
}

.btn-success,
.bg-success {
  background: linear-gradient(135deg, #16a34a, #166534) !important;
  border-color: transparent !important;
}

.btn-info,
.bg-info {
  background: linear-gradient(135deg, #0891b2, #155e75) !important;
  border-color: transparent !important;
}

.btn-warning,
.bg-warning {
  background: linear-gradient(135deg, #f59e0b, #b45309) !important;
  border-color: transparent !important;
  color: #fff !important;
}

.btn-outline-primary {
  border: 1px solid rgba(29, 78, 216, 0.22);
  color: var(--app-primary);
}

.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-success:hover,
.btn-outline-danger:hover {
  transform: translateY(-1px);
}

.badge {
  border-radius: 999px;
  padding: 0.5rem 0.75rem;
  font-weight: 700;
}

.alert {
  border: 1px solid transparent;
  border-radius: 16px;
}

.toast {
  backdrop-filter: blur(16px);
}

.login-page {
  background: linear-gradient(135deg, #0f172a, #172554 45%, #0f766e);
}

.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-shell {
  width: min(1120px, 100%);
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.28);
  border-radius: 28px;
  backdrop-filter: blur(18px);
}

.login-panel {
  min-height: 680px;
  padding: 3rem;
  color: #fff;
  background: radial-gradient(circle at top, rgba(255,255,255,0.16), transparent 30%),
              linear-gradient(160deg, rgba(37,99,235,0.78), rgba(15,23,42,0.9));
}

.login-panel h1 {
  color: #fff;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.05;
  margin-bottom: 1rem;
}

.login-feature-list {
  display: grid;
  gap: 0.85rem;
  margin-top: 2rem;
}

.login-feature-list div {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: rgba(255,255,255,0.92);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  font-weight: 800;
  margin-bottom: 0.9rem;
}

@media (max-width: 991.98px) {
  body.lawapp-shell {
    padding-top: 76px;
  }

  .app-sidebar {
    width: 100%;
    max-width: 320px;
    box-shadow: var(--app-shadow);
  }

  .app-main {
    margin-left: 0;
    padding: 1rem;
  }

  .page-header {
    padding: 1rem;
  }
}


.hero-panel,
.modern-card,
.stat-card,
.calendar-shell-card .card-body,
.modern-modal {
  border-radius: 24px;
}

.hero-panel {
  background: linear-gradient(135deg, rgba(37,99,235,.08), rgba(15,23,42,.04));
  border: 1px solid rgba(148,163,184,.2);
  padding: 1.75rem;
  box-shadow: 0 10px 30px rgba(15,23,42,.06);
}

.quick-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 1.5rem;
  min-height: 170px;
  background: #fff;
  border: 1px solid rgba(148,163,184,.16);
  box-shadow: 0 12px 28px rgba(15,23,42,.06);
}

.stat-card-primary { border-left: 4px solid #2563eb; }
.stat-card-success { border-left: 4px solid #16a34a; }
.stat-card-warning { border-left: 4px solid #f59e0b; }
.stat-card-dark { border-left: 4px solid #0f172a; }
.stat-label { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; margin-bottom: .5rem; }
.stat-value { font-size: 2rem; font-weight: 800; color: #0f172a; line-height: 1.1; }
.stat-meta { font-size: .9rem; color: #64748b; margin-top: .5rem; }
.stat-icon { position: absolute; right: 1.25rem; bottom: 1rem; font-size: 2rem; color: rgba(37,99,235,.14); }

.modern-card {
  border: 1px solid rgba(148,163,184,.16);
  box-shadow: 0 14px 34px rgba(15,23,42,.06);
}

.modern-card-header {
  background: transparent;
  border-bottom: 1px solid rgba(148,163,184,.15);
  padding: 1.1rem 1.25rem;
}

.timeline-list { display: grid; gap: 1rem; }
.timeline-item { display: grid; grid-template-columns: 72px 1fr; gap: 1rem; align-items: start; }
.timeline-date {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
  text-align: center;
  border-radius: 16px;
  padding: .85rem .5rem;
}
.timeline-content {
  padding: 1rem;
  border: 1px solid rgba(148,163,184,.16);
  border-radius: 18px;
  background: #fff;
}
.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .95rem 0;
  border-bottom: 1px solid rgba(148,163,184,.12);
}
.metric-row:last-child { border-bottom: 0; }
.empty-state-icon {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eff6ff;
  color: #2563eb;
  font-size: 1.5rem;
}

.calendar-page #calendar {
  min-height: 720px;
}
.calendar-page .fc {
  --fc-border-color: rgba(148,163,184,.18);
  --fc-page-bg-color: #fff;
  --fc-neutral-bg-color: #f8fafc;
  --fc-today-bg-color: rgba(37,99,235,.08);
}
.calendar-page .fc .fc-toolbar-title {
  font-size: 1.2rem;
  font-weight: 700;
}
.calendar-page .fc .fc-button {
  border-radius: 12px;
  text-transform: capitalize;
  box-shadow: none;
}
.calendar-page .fc-daygrid-event,
.calendar-page .fc-timegrid-event {
  border-radius: 10px;
  padding: 2px 6px;
}

@media (max-width: 991.98px) {
  .quick-action-grid { grid-template-columns: 1fr; }
  .timeline-item { grid-template-columns: 1fr; }
}


/* Phase 3 dashboard and management refinements */
.hero-panel {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(29, 78, 216, 0.92));
  color: #fff;
  border-radius: var(--app-radius);
  padding: 1.6rem;
  box-shadow: var(--app-shadow);
}
.hero-panel::after {
  content: '';
  position: absolute;
  right: -30px;
  bottom: -50px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.22), rgba(255,255,255,0));
}
.hero-panel .hero-kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  font-size: 0.78rem;
  opacity: 0.78;
}
.hero-panel .hero-title {
  font-size: clamp(1.7rem, 2.2vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}
.hero-panel .hero-subtitle {
  max-width: 60ch;
  color: rgba(255,255,255,0.8);
}
.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.hero-actions .btn {
  box-shadow: none;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
.stat-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--app-border);
  border-radius: calc(var(--app-radius) - 2px);
  padding: 1.15rem;
  box-shadow: var(--app-shadow-soft);
  min-height: 118px;
}
.stat-card-icon {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
  flex-shrink: 0;
}
.stat-card-primary .stat-card-icon { background: linear-gradient(135deg, #2563eb, #1e3a8a); }
.stat-card-success .stat-card-icon { background: linear-gradient(135deg, #16a34a, #166534); }
.stat-card-warning .stat-card-icon { background: linear-gradient(135deg, #f59e0b, #b45309); }
.stat-card-danger .stat-card-icon { background: linear-gradient(135deg, #ef4444, #991b1b); }
.stat-card-info .stat-card-icon { background: linear-gradient(135deg, #06b6d4, #155e75); }
.stat-card-label {
  color: var(--app-muted);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-card-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
}
.stat-card-meta {
  color: var(--app-muted);
  font-size: 0.92rem;
}
.section-card-title {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 0;
}
.panel-subtitle {
  color: var(--app-muted);
  font-size: 0.92rem;
}
.timeline-list {
  display: grid;
  gap: 1rem;
}
.timeline-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 0.95rem;
  align-items: start;
}
.timeline-date {
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 16px;
  text-align: center;
  padding: 0.7rem 0.5rem;
  font-weight: 800;
  line-height: 1.1;
}
.timeline-date small {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.timeline-content {
  border: 1px solid var(--app-border);
  border-radius: 16px;
  padding: 0.95rem 1rem;
  background: #fff;
}
.quick-links-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}
.quick-link-tile {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(248,250,252,0.9);
  border: 1px solid var(--app-border);
  color: var(--app-text);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.quick-link-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--app-shadow-soft);
}
.quick-link-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dbeafe;
  color: #1d4ed8;
}
.mini-metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
.mini-metric {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--app-border);
  border-radius: 18px;
  padding: 1rem 1.1rem;
}
.mini-metric-label {
  color: var(--app-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.76rem;
  font-weight: 700;
}
.mini-metric-value {
  font-size: 1.35rem;
  font-weight: 800;
}
.toolbar-card {
  border-radius: 18px;
}
.toolbar-form .form-control,
.toolbar-form .form-select {
  min-height: 44px;
}
.table-shell .table tbody td:first-child {
  font-weight: 600;
}
@media (max-width: 1199px) {
  .stat-grid, .mini-metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 991px) {
  .app-main { margin-left: 0; }
  .app-sidebar { position: static; width: 100%; top: 0; }
}
@media (max-width: 767px) {
  .stat-grid, .mini-metric-row, .quick-links-grid { grid-template-columns: 1fr; }
  .hero-panel { padding: 1.25rem; }
  .timeline-item { grid-template-columns: 1fr; }
  .timeline-date { width: 72px; }
}
