/* =============================================
   CSS VARIABLES & THEME SYSTEM - CONSOLIDATED
   ============================================= */
[data-theme="light"], :root {
  /* Base Colors */
  --bg: #f4f6fb;
  --fg: #0f172a;
  --muted: #5b6478;

  /* Surface Colors */
  --card: rgba(255, 255, 255, 0.92);
  --border: rgba(15, 23, 42, 0.08);
  --surface: rgba(248, 250, 255, 0.9);

  /* Brand Colors */
  --nav: #1e293b;
  --navfg: #f8fbff;
  --navactive: #cf1b00;
  --primary: #cf1b00;
  --primary-dark: #a81600;
  --primary-color: #cf1b00;
  --accent: #cf1b00;
  --accent-dark: #a81600;
  --accent-light: rgba(207, 27, 0, 0.18);
  --neutral: #6b7280;
  --neutral-light: rgba(107, 114, 128, 0.18);

  /* Status Colors */
  --success: #0f9d70;
  --success-light: rgba(15, 157, 112, 0.12);
  --warning: #d97706;
  --warning-light: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-light: rgba(220, 38, 38, 0.12);
  --critical: #be185d;
  --critical-light: rgba(190, 24, 93, 0.12);
  --info: #2563eb;
  --info-light: rgba(37, 99, 235, 0.12);

  /* Shadows & Effects */
  --shadow: 0 24px 55px rgba(15, 23, 42, 0.12);
  --shadow-sm: 0 12px 25px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 45px 85px rgba(15, 23, 42, 0.18);
  --card-shadow: 0 28px 65px rgba(15, 23, 42, 0.12);
  --card-border: rgba(15, 23, 42, 0.08);
  --card-backdrop: 22px;

  /* Text Colors */
  --text-primary: #0f172a;
  --text-secondary: #5b6478;
  --text-muted: #9ca3af;

  /* Borders */
  --border-light: rgba(15, 23, 42, 0.06);
  --border-color: var(--border);

  /* Badge Defaults */
  --badge-bg: #f3f4f6;
  --badge-border: rgba(15, 23, 42, 0.08);
  --badge-color: #1f2937;
  --badge-muted: #6b7280;

  /* Layout Enhancements */
  --body-background: linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
  --sidebar-gradient: linear-gradient(180deg, rgba(17, 24, 39, 0.96) 0%, rgba(30, 41, 59, 0.98) 100%);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --navbar-background: rgba(255, 255, 255, 0.95);
  --navbar-border: rgba(15, 23, 42, 0.08);
  --navbar-shadow: 0 18px 40px rgba(15, 23, 42, 0.15);
  --fab-gutter: clamp(12px, 2vw, 24px);
  --font-size-base: 16px;
  --font-scale: 1;
}

[data-theme="dark"] {
  /* Base Colors */
  --bg: #050b1a;
  --fg: #ecf1ff;
  --muted: #8893b9;

  /* Surface Colors */
  --card: rgba(15, 23, 42, 0.78);
  --border: rgba(63, 78, 112, 0.45);
  --surface: rgba(8, 15, 32, 0.85);

  /* Brand Colors */
  --nav: #0b1220;
  --navfg: #e4ecff;
  --navactive: #cf1b00;
  --primary: #cf1b00;
  --primary-dark: #a81600;
  --primary-color: #cf1b00;
  --accent: #cf1b00;
  --accent-dark: #a81600;
  --accent-light: rgba(207, 27, 0, 0.28);
  --neutral: #cbd5f5;
  --neutral-light: rgba(148, 163, 184, 0.28);

  /* Status Colors */
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.12);
  --critical: #f472b6;
  --critical-light: rgba(244, 114, 182, 0.12);
  --info: #60a5fa;
  --info-light: rgba(96, 165, 250, 0.18);

  /* Shadows & Effects */
  --shadow: 0 28px 70px rgba(3, 7, 18, 0.65);
  --shadow-sm: 0 14px 32px rgba(3, 7, 18, 0.45);
  --shadow-lg: 0 48px 110px rgba(15, 23, 42, 0.7);
  --card-shadow: 0 32px 78px rgba(2, 6, 23, 0.72);
  --card-border: rgba(148, 163, 184, 0.18);
  --card-backdrop: 28px;

  /* Text Colors */
  --text-primary: #ecf1ff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Borders */
  --border-light: rgba(148, 163, 184, 0.15);
  --border-color: var(--border);

  /* Badge Defaults */
  --badge-bg: rgba(148, 163, 184, 0.12);
  --badge-border: rgba(148, 163, 184, 0.35);
  --badge-color: #e2e8f0;
  --badge-muted: #94a3b8;

  /* Layout Enhancements */
  --body-background: linear-gradient(180deg, #060b1a 0%, #01040d 100%);
  --sidebar-gradient: linear-gradient(180deg, rgba(10, 16, 31, 0.98) 0%, rgba(4, 9, 24, 0.98) 100%);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --navbar-background: rgba(8, 15, 32, 0.85);
  --navbar-border: rgba(207, 27, 0, 0.25);
  --navbar-shadow: 0 20px 48px rgba(3, 7, 18, 0.65);
  --fab-gutter: clamp(12px, 2vw, 24px);
  --font-size-base: 16px;
  --font-scale: 1;
}

@supports (padding: max(0px, env(safe-area-inset-right))) {
  :root,
  [data-theme="light"],
  [data-theme="dark"] {
    --fab-gutter: max(16px, calc(env(safe-area-inset-right) + 12px));
  }
}

/* =============================================
   BASE STYLES - OPTIMIZED & CONSOLIDATED
   ============================================= */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  color: var(--fg);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  line-height: 1.55;
  background: var(--body-background, var(--bg));
  transition: background 0.4s ease, color 0.3s ease;
}

body {
  display: flex;
  flex-direction: column;
  background: transparent;
  position: relative;
  isolation: isolate;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
}

body::before {
  background: var(--body-background, var(--bg));
  z-index: -3;
}

body::after {
  background: radial-gradient(32% 32% at 12% 8%, rgba(207, 27, 0, 0.12), transparent 65%),
              radial-gradient(30% 30% at 88% 12%, rgba(207, 27, 0, 0.08), transparent 70%);
  mix-blend-mode: soft-light;
  opacity: 0.75;
}

[data-theme="dark"] body::after {
  background: radial-gradient(26% 26% at 18% 12%, rgba(207, 27, 0, 0.3), transparent 70%),
              radial-gradient(30% 34% at 82% 10%, rgba(207, 27, 0, 0.18), transparent 72%);
  opacity: 0.4;
  mix-blend-mode: screen;
}

html {
  font-size: calc(var(--font-size-base, 16px) * var(--font-scale, 1));
  transition: font-size 0.18s ease;
}

html[data-font-size="small"],
body[data-font-size="small"] {
  --font-scale: 0.92;
}

html[data-font-size="medium"],
body[data-font-size="medium"] {
  --font-scale: 1;
}

html[data-font-size="large"],
body[data-font-size="large"] {
  --font-scale: 1.12;
}

/* ---------------------------------------------
   Offline UI utilities (toasts, icons, controls)
   --------------------------------------------- */

.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 9999;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-sm);
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.toast--success {
  border-color: var(--success);
}

.toast.toast--error {
  border-color: var(--danger);
}

.toast.toast--info {
  border-color: var(--info);
}

.btn-close {
  appearance: none;
  border: none;
  background: transparent;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.btn-close::before {
  content: '×';
  font-size: 1.1rem;
  line-height: 1;
}

.btn-close:hover {
  background: var(--neutral-light);
  color: var(--fg);
}

.btn-close-white {
  color: #fff;
}

.btn-close-white:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.twofa-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

[data-theme="dark"] .twofa-panel {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(148, 163, 184, 0.35);
}

.twofa-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 0.35rem 0;
  display: none;
  z-index: 20;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: block;
  padding: 0.55rem 1rem;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.92rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.dropdown-item:hover {
  background: rgba(207, 27, 0, 0.08);
  color: var(--primary);
}

.dropdown-divider {
  height: 1px;
  margin: 0.35rem 0;
  background: var(--border);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-backdrop.show {
  opacity: 1;
}

body.modal-open {
  overflow: hidden;
}

/* Icon base styles */
.fa,
.fas,
.far,
.fal,
.fab,
.ri {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25em;
  height: 1.25em;
  line-height: 1;
  text-align: center;
}

.fa-lg { font-size: 1.25em; }
.fa-sm { font-size: 0.875em; }
.fa-2x { font-size: 2em; }

.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.justify-content-end { justify-content: flex-end; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.text-center { text-align: center; }
.text-start { text-align: left; }
.text-end { text-align: right; }
.text-primary { color: var(--primary); }
.text-secondary { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 600; }
.fw-semibold { font-weight: 500; }
.fw-medium { font-weight: 500; }
.fw-light { font-weight: 300; }
.fst-italic { font-style: italic; }
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.ms-0 { margin-left: 0; }
.me-0 { margin-right: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.5rem; }
.ms-1 { margin-left: 0.25rem; }
.ms-2 { margin-left: 0.5rem; }
.ms-3 { margin-left: 0.75rem; }
.me-1 { margin-right: 0.25rem; }
.me-2 { margin-right: 0.5rem; }
.me-3 { margin-right: 0.75rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.my-3 { margin-top: 0.75rem; margin-bottom: 0.75rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.p-0 { padding: 0; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.w-100 { width: 100%; }
.h-100 { height: 100%; }
.position-relative { position: relative; }
.position-absolute { position: absolute; }
.position-fixed { position: fixed; }
.top-0 { top: 0; }
.end-0 { right: 0; }
.bottom-0 { bottom: 0; }
.start-0 { left: 0; }
.rounded { border-radius: 12px; }
.rounded-circle { border-radius: 999px; }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow); }
.bg-light { background: var(--neutral-light); }
.bg-dark { background: var(--bg); }
.bg-primary { background: var(--primary); color: #fff; }
.bg-success { background: var(--success); color: #fff; }
.bg-danger { background: var(--danger); color: #fff; }
.bg-warning { background: var(--warning); color: #1f2937; }
.bg-info { background: var(--info); color: #fff; }

.container {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 0 1rem;
  box-sizing: border-box;
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -0.75rem;
}

.row > [class*="col-"] {
  padding: 0 0.75rem;
  box-sizing: border-box;
  flex: 0 0 100%;
  max-width: 100%;
}

.col-6 {
  flex: 0 0 50%;
  max-width: 50%;
}

.col-12 {
  flex: 0 0 100%;
  max-width: 100%;
}

@media (min-width: 576px) {
  .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
  .col-sm-4 { flex: 0 0 33.333%; max-width: 33.333%; }
}

@media (min-width: 768px) {
  .col-md-3 { flex: 0 0 25%; max-width: 25%; }
  .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .col-md-6 { flex: 0 0 50%; max-width: 50%; }
  .col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
  .col-md-9 { flex: 0 0 75%; max-width: 75%; }
}

@media (min-width: 992px) {
  .col-lg-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
}
main.main {
  flex: 1;
  display: flex;
  gap: 24px;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (max-width: 1024px) {
  main.main {
    flex-direction: column;
    gap: 20px;
  }

  .container {
    padding: 28px 20px 40px;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 24px 18px 36px;
    gap: 20px;
  }

  .page-header,
  .section-header {
    gap: 16px;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 20px 16px 32px;
    gap: 18px;
  }

  .card,
  .column {
    padding: 14px;
  }

  .page-header {
    margin-bottom: 12px;
  }
}

.page-wrapper {
  width: 100%;
  color: var(--fg);
  padding: clamp(24px, 4vw, 48px) clamp(18px, 5vw, 56px) clamp(48px, 6vw, 72px);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.95) 0%, rgba(244, 248, 255, 0.82) 100%);
  border-radius: 28px;
  border: 1px solid var(--navbar-border);
  box-shadow: var(--navbar-shadow);
  backdrop-filter: blur(var(--card-backdrop));
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .page-wrapper {
  background: linear-gradient(155deg, rgba(15, 23, 42, 0.82) 0%, rgba(7, 13, 28, 0.88) 100%);
  border-color: var(--sidebar-border);
}

.is-hidden {
  display: none !important;
}

.nav {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  background: var(--nav);
  color: #fff;
  align-items: center;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 500;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.2);
}

.nav .brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
  font-weight: 600;
}

.nav .brand:hover,
.nav .brand:focus-visible {
  background: rgba(255, 255, 255, 0.12);
}

.brand-logo {
  height: 36px;
  width: auto;
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  background: var(--surface);
  padding: 4px;
}

.nav strong {
  font-size: 18px;
  letter-spacing: 0.3px;
}

.nav a {
  color: var(--navfg);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav a .mi {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.nav a.active,
.nav a:hover {
  background: var(--navactive);
  color: #fff;
  transform: translateY(-1px);
}

.subnav {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.subnav .btn {
  background-image: linear-gradient(135deg, var(--accent), var(--primary));
  color: #ffffff !important;
  border: 1px solid transparent !important;
  box-shadow: 0 12px 28px rgba(207, 27, 0, 0.22);
}

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
}

h2 {
  font-size: 26px;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 18px;
  color: var(--fg);
}

.section-header,
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header {
  margin-bottom: 16px;
}

.card,
.column {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  backdrop-filter: blur(calc(var(--card-backdrop) * 0.5));
  overflow: hidden;
}

.card::before,
.column::before {
  content: "";
  position: absolute;
  inset: -30% auto auto -35%;
  width: 65%;
  height: 65%;
  background: radial-gradient(ellipse at center, var(--accent-light, rgba(207, 27, 0, 0.16)), transparent 72%);
  pointer-events: none;
  z-index: 0;
  transform: rotate(18deg);
}

.card > *,
.column > * {
  position: relative;
  z-index: 1;
}

.card:hover,
.column:hover {
  transform: translateY(-4px);
  box-shadow: 0 38px 90px rgba(207, 27, 0, 0.18);
  border-color: rgba(207, 27, 0, 0.2);
}

.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 20px;
}

.column[data-status="todo"] {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.18), rgba(245, 158, 11, 0.06));
  border-color: rgba(217, 119, 6, 0.28);
}

.column[data-status="doing"] {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.18), rgba(59, 130, 246, 0.06));
  border-color: rgba(37, 99, 235, 0.28);
}

.column[data-status="done"] {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.18), rgba(16, 185, 129, 0.06));
  border-color: rgba(16, 185, 129, 0.28);
}

.task-card {
  position: relative;
  overflow: hidden;
}

.task-card[data-status="todo"] {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(245, 158, 11, 0.08));
  border-color: rgba(217, 119, 6, 0.32);
}

.task-card[data-status="doing"] {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(59, 130, 246, 0.08));
  border-color: rgba(37, 99, 235, 0.32);
}

.task-card[data-status="done"] {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(16, 185, 129, 0.08));
  border-color: rgba(16, 185, 129, 0.32);
}

.task-card[data-status="todo"]::before,
.task-card[data-status="doing"]::before,
.task-card[data-status="done"]::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border-top: 5px solid transparent;
  pointer-events: none;
}

.task-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.task-card-title strong {
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg, #111827);
}

.task-card-description {
  font-size: 0.85rem;
  color: var(--muted, #4b5563);
  line-height: 1.5;
  margin-bottom: 0.85rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-card-meta-block {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.task-card-meta-block .badge {
  align-self: flex-start;
  font-size: 0.7rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.task-card-meta-line {
  font-size: 0.75rem;
  font-weight: 500;
}

.task-card-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.task-card-inline-form .task-card-status {
  min-width: 120px;
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.12));
  background-color: rgba(255, 255, 255, 0.92);
}

.task-card-inline-form .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
}

.task-card-inline-form .btn i {
  font-size: 1rem;
}

.task-card-assign {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.75rem;
}

.task-card-assign select {
  flex: 1 1 180px;
  min-width: 160px;
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.1));
  background-color: rgba(255, 255, 255, 0.92);
}

.task-card-assign .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
}

.task-grid-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 12px;
}

.task-grid-table thead th {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  color: var(--muted, #64748b);
  border-bottom: none;
  padding: 0.75rem 1rem;
}

.task-grid-table tbody tr.task-row {
  background: var(--card, #ffffff);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(15, 23, 42, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.task-grid-table tbody tr.task-row td {
  padding: 0.9rem 1rem;
  vertical-align: middle;
  font-size: 0.9rem;
  color: var(--fg, #0f172a);
}

.task-grid-table tbody tr.task-row td:first-child {
  font-weight: 600;
  font-size: 1rem;
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;
}

.task-grid-table tbody tr.task-row td:last-child {
  width: 1%;
  white-space: nowrap;
  border-top-right-radius: 14px;
  border-bottom-right-radius: 14px;
}

.task-grid-table tbody tr.task-row:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

.task-grid-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.task-grid-inline-form select {
  min-width: 130px;
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.12));
}

.task-grid-inline-form .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
}

.task-grid-assign {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.75rem;
}

.task-grid-assign select {
  flex: 1 1 180px;
  min-width: 160px;
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.12));
}

.task-grid-assign .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
}

.task-card[data-status="todo"]::before {
  border-top-color: #f59e0b;
}

.task-card[data-status="doing"]::before {
  border-top-color: #3b82f6;
}

.task-card[data-status="done"]::before {
  border-top-color: #10b981;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  border: 1px solid var(--badge-border);
  background: var(--badge-bg);
  color: var(--badge-color);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.badge .badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.badge:is(:hover, :focus-visible) {
  transform: translateY(-1px);
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.insight {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.insight-label {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary, var(--muted));
}

.insight-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.1;
}

.insight-sub {
  font-size: 0.9rem;
  color: var(--text-muted, var(--muted));
}

.kpi-card {
  padding-bottom: 24px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.kpi-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 12px;
  background: var(--accent-light, rgba(207, 27, 0, 0.16));
  color: var(--accent, #cf1b00);
}

.kpi-card__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-card__trend {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(207, 27, 0, 0.12);
  color: var(--accent, #cf1b00);
}

.kpi-card--positive .kpi-card__icon {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.kpi-card--warning .kpi-card__icon {
  background: rgba(251, 191, 36, 0.16);
  color: #f59e0b;
}

.kpi-card--negative .kpi-card__icon {
  background: rgba(248, 113, 113, 0.16);
  color: #ef4444;
}

.kpi-card--positive .kpi-card__trend {
  background: rgba(34, 197, 94, 0.14);
  color: #15803d;
}

.kpi-card--warning .kpi-card__trend {
  background: rgba(251, 191, 36, 0.18);
  color: #b45309;
}

.kpi-card--negative .kpi-card__trend {
  background: rgba(248, 113, 113, 0.18);
  color: #b91c1c;
}

.kpi-charts {
  margin-top: 8px;
}

.chart-card {
  position: relative;
  padding: 20px;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.07);
}

.chart-card__head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  color: rgba(51, 65, 85, 0.78);
}

.chart-card__head i {
  font-size: 1.2rem;
  color: var(--accent, #cf1b00);
}

.ai-kpi-card {
  margin-top: 24px;
  border-radius: 20px;
  padding: 24px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(135deg, rgba(207, 27, 0, 0.08), rgba(15, 23, 42, 0.02));
  box-shadow: 0 20px 55px rgba(15, 23, 42, 0.12);
}

.ai-kpi-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.ai-kpi-card__title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ai-kpi-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--accent-light, rgba(207, 27, 0, 0.18));
  color: var(--accent, #cf1b00);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.ai-kpi-card__meta {
  margin-top: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: rgba(51, 65, 85, 0.72);
}

.ai-insight__list {
  margin: 12px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  color: rgba(30, 41, 59, 0.86);
}

.ri-spin {
  animation: riSpin 1s linear infinite;
}

@keyframes riSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.status-pill,
.item-status,
.project-status-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: 1px solid var(--badge-border);
  background: var(--badge-bg);
  color: var(--badge-color);
  text-transform: uppercase;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.status-pill .status-dot,
.item-status .status-dot,
.project-status-badge .status-dot,
.status-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.status-pill--tag {
  font-size: 11px;
  letter-spacing: 0.03em;
  border-style: dashed;
  padding: 4px 10px;
  color: var(--badge-muted);
}

.status-pill:is(:hover, :focus-visible),
.item-status:is(:hover, :focus-visible),
.project-status-badge:is(:hover, :focus-visible),
.status-badge:is(:hover, :focus-visible) {
  transform: translateY(-1px);
}

/* Status tone mappings */
.badge.status-todo,
.badge.status-pending,
.badge.status_pending,
.badge.badge-todo,
.badge.badge-pending,
.badge.badge_todo,
.badge.badge_pending,
.status-pill--todo,
.status-pill--pending,
.status-pill.status-todo,
.status-pill.status-pending,
.status-pill.status_pending,
.item-status.status-todo,
.item-status.status-pending,
.item-status.status_pending,
.project-status-badge.status-todo,
.project-status-badge.status-pending,
.project-status-badge.status_pending {
  text-transform: uppercase;
  background: var(--warning-light);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.45);
}

.badge.status-doing,
.badge.status-in-progress,
.badge.status-in_progress,
.badge.status-active,
.badge.status_active,
.badge.badge-doing,
.badge.badge-in-progress,
.badge.badge-in_progress,
.badge.badge-active,
.badge.badge_active,
.status-pill--doing,
.status-pill--in_progress,
.status-pill--in-progress,
.status-pill--active,
.status-pill.status-doing,
.status-pill.status-in-progress,
.status-pill.status-in_progress,
.status-pill.status-active,
.status-pill.status_active,
.item-status.status-doing,
.item-status.status-in-progress,
.item-status.status-in_progress,
.item-status.status-active,
.item-status.status_active,
.project-status-badge.status-doing,
.project-status-badge.status-in-progress,
.project-status-badge.status-in_progress,
.project-status-badge.status-active,
.project-status-badge.status_active {
  text-transform: uppercase;
  background: var(--info-light);
  color: var(--info);
  border-color: rgba(37, 99, 235, 0.45);
}

.badge.status-done,
.badge.status-completed,
.badge.status-complete,
.badge.status_completed,
.badge.status_complete,
.badge.badge-done,
.badge.badge-completed,
.badge.badge-complete,
.badge.badge_completed,
.badge.badge_complete,
.status-pill--done,
.status-pill--completed,
.status-pill--complete,
.status-pill.status-done,
.status-pill.status-completed,
.status-pill.status-complete,
.status-pill.status_completed,
.status-pill.status_complete,
.item-status.status-done,
.item-status.status-completed,
.item-status.status-complete,
.item-status.status_completed,
.item-status.status_complete,
.project-status-badge.status-done,
.project-status-badge.status-completed,
.project-status-badge.status-complete,
.project-status-badge.status_completed,
.project-status-badge.status_complete {
  text-transform: uppercase;
  background: var(--success-light);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.45);
}

.badge.status-overdue,
.badge.status-blocked,
.badge.status-cancelled,
.status-pill--overdue,
.status-pill--blocked,
.status-pill--cancelled,
.status-pill.status-overdue,
.status-pill.status-blocked,
.status-pill.status-cancelled,
.status-pill.status_overdue,
.status-pill.status_blocked,
.status-pill.status_cancelled,
.item-status.status-overdue,
.item-status.status-blocked,
.item-status.status-cancelled,
.item-status.status_overdue,
.item-status.status_blocked,
.item-status.status_cancelled,
.project-status-badge.status-overdue,
.project-status-badge.status-blocked,
.project-status-badge.status-cancelled,
.project-status-badge.status_overdue,
.project-status-badge.status_blocked,
.project-status-badge.status_cancelled {
  text-transform: uppercase;
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.45);
}

.badge.status-info,
.badge.status-scheduled,
.badge.status-planned,
.status-pill--info,
.status-pill--scheduled,
.status-pill--planned,
.status-pill.status-info,
.status-pill.status-scheduled,
.status-pill.status-planned,
.status-pill.status_info,
.status-pill.status_scheduled,
.status-pill.status_planned,
.item-status.status-info,
.item-status.status-scheduled,
.item-status.status-planned,
.item-status.status_info,
.item-status.status_scheduled,
.item-status.status_planned,
.project-status-badge.status-info,
.project-status-badge.status-scheduled,
.project-status-badge.status-planned,
.project-status-badge.status_info,
.project-status-badge.status_scheduled,
.project-status-badge.status_planned {
  text-transform: uppercase;
  background: var(--info-light);
  color: var(--info);
  border-color: rgba(37, 99, 235, 0.45);
}

.badge.status-success,
.badge.badge-success,
.status-pill--success,
.status-pill.status-success,
.item-status.status-success,
.project-status-badge.status-success {
  text-transform: uppercase;
  background: var(--success-light);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.45);
}

.badge.status-warning,
.badge.badge-warning,
.status-pill--warning,
.status-pill.status-warning,
.item-status.status-warning,
.project-status-badge.status-warning {
  text-transform: uppercase;
  background: var(--warning-light);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.45);
}

.badge.status-danger,
.badge.badge-danger,
.status-pill--danger,
.status-pill.status-danger,
.item-status.status-danger,
.project-status-badge.status-danger {
  text-transform: uppercase;
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.45);
}

.badge.status-primary,
.badge.status-progress,
.badge.badge-primary,
.status-pill--primary,
.status-pill.status-primary,
.item-status.status-primary,
.project-status-badge.status-primary,
.project-status-badge.status-progress {
  text-transform: uppercase;
  background: var(--accent-light, rgba(207, 27, 0, 0.18));
  color: var(--accent, #cf1b00);
  border-color: rgba(207, 27, 0, 0.32);
}

[data-theme="dark"] .badge.status-primary,
[data-theme="dark"] .badge.status-progress,
[data-theme="dark"] .badge.badge-primary,
[data-theme="dark"] .status-pill--primary,
[data-theme="dark"] .status-pill.status-primary,
[data-theme="dark"] .item-status.status-primary,
[data-theme="dark"] .project-status-badge.status-primary,
[data-theme="dark"] .project-status-badge.status-progress {
  background: rgba(207, 27, 0, 0.32);
  color: #ffe4dc;
  border-color: rgba(207, 27, 0, 0.55);
}

.status-pill--tag-due {
  background: var(--info-light);
  color: var(--info);
  border-color: rgba(37, 99, 235, 0.45);
}

.status-pill--tag-overdue {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.45);
}

.status-pill--tag-today,
.status-pill--tag-soon {
  background: var(--warning-light);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.45);
}

/* Bootstrap badge overrides for consistency */
.badge.bg-primary,
.badge.bg-success,
.badge.bg-danger,
.badge.bg-warning,
.badge.bg-info,
.badge.bg-dark,
.badge.bg-secondary,
.badge.bg-white,
.badge.bg-light {
  border: 1px solid transparent;
}

.badge.bg-primary,
.badge.bg-success,
.badge.bg-dark,
.badge.bg-danger {
  background-image: linear-gradient(135deg, var(--primary), var(--accent)) !important;
  color: #ffffff !important;
  border-color: transparent !important;
}

.badge.bg-warning {
  background: var(--warning-light) !important;
  color: var(--warning) !important;
  border-color: rgba(245, 158, 11, 0.45) !important;
}

.badge.bg-info {
  background: var(--info-light) !important;
  color: var(--info) !important;
  border-color: rgba(37, 99, 235, 0.45) !important;
}

.badge.bg-secondary {
  background: var(--neutral-light) !important;
  color: var(--neutral) !important;
  border-color: rgba(107, 114, 128, 0.35) !important;
}

.badge.bg-light,
.badge.bg-white {
  background: var(--badge-bg) !important;
  color: var(--badge-color) !important;
  border-color: var(--badge-border) !important;
}

/* Priority badges */
.badge.priority-low,
.badge-low,
.priority-low {
  background: var(--neutral-light);
  color: var(--neutral);
  border-color: rgba(107, 114, 128, 0.35);
}

[data-theme="dark"] .badge.priority-low,
[data-theme="dark"] .badge-low,
[data-theme="dark"] .priority-low {
  background: rgba(148, 163, 184, 0.32);
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.55);
}

.badge.priority-medium,
.badge-medium,
.priority-medium {
  background: var(--warning-light);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.45);
}

.badge.priority-high,
.badge-high,
.priority-high {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.45);
}

.badge.priority-critical,
.badge-critical,
.priority-critical {
  background: var(--critical-light);
  color: var(--critical);
  border-color: rgba(190, 24, 93, 0.45);
}

/* Progress indicators */
.badge-progress-low {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.45);
}

.badge-progress-medium {
  background: var(--warning-light);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.45);
}

.badge-progress-high {
  background: var(--success-light);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.45);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table thead {
  background: var(--surface);
}

.table th,
.table td {
  padding: 12px;

  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}

.table-card {
  padding: 0;
  overflow-x: auto;
}

.table-card .table {
  box-shadow: none;
  border-radius: 0;
}

.table-scroll {
  overflow-x: auto;
}

.table-scroll table {
  min-width: 640px;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: rgba(207, 27, 0, 0.06);
}


.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.65rem 1.35rem;
  border-radius: 12px;
  border: 1px solid transparent !important;
  background-image: linear-gradient(135deg, var(--primary), var(--accent));
  color: #ffffff !important;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.25;
  font-size: 0.92rem;
  text-decoration: none;
  min-height: 2.625rem;
  box-sizing: border-box;
  box-shadow: 0 18px 38px rgba(207, 27, 0, 0.25);
  transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.3s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 48px rgba(207, 27, 0, 0.32);
  filter: brightness(1.05);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 16px 32px rgba(207, 27, 0, 0.28);
  filter: saturate(1.05);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(207, 27, 0, 0.28), 0 12px 32px rgba(207, 27, 0, 0.22);
}

.btn:disabled,
.btn[aria-disabled="true"],
.btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-warning,
.btn-info,
.btn-light,
.btn-dark,
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-danger,
.btn-outline-warning,
.btn-outline-info,
.btn-outline-light,
.btn-outline-dark {
  background-image: linear-gradient(135deg, var(--primary), var(--accent));
  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: 0 18px 38px rgba(207, 27, 0, 0.2);
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-success:hover,
.btn-danger:hover,
.btn-warning:hover,
.btn-info:hover,
.btn-light:hover,
.btn-dark:hover,
.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-success:hover,
.btn-outline-danger:hover,
.btn-outline-warning:hover,
.btn-outline-info:hover,
.btn-outline-light:hover,
.btn-outline-dark:hover {
  filter: brightness(1.05);
  box-shadow: 0 26px 54px rgba(207, 27, 0, 0.34);
}

.btn-primary:active,
.btn-secondary:active,
.btn-success:active,
.btn-danger:active,
.btn-warning:active,
.btn-info:active,
.btn-light:active,
.btn-dark:active,
.btn-outline-primary:active,
.btn-outline-secondary:active,
.btn-outline-success:active,
.btn-outline-danger:active,
.btn-outline-warning:active,
.btn-outline-info:active,
.btn-outline-light:active,
.btn-outline-dark:active {
  filter: saturate(1.05);
  box-shadow: 0 16px 32px rgba(207, 27, 0, 0.28);
}

/* Toggle switches */
.toggle {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.toggle:hover {
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.toggle input[type="checkbox"] {
  appearance: none;
  width: 48px;
  height: 26px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.toggle input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 3px 6px rgba(15, 23, 42, 0.18);
  transition: transform 0.2s ease;
}

.toggle input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 8px 20px rgba(207, 27, 0, 0.25);
}

.toggle input[type="checkbox"]:checked::before {
  transform: translateX(22px);
}

.toggle input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 3px rgba(207, 27, 0, 0.25);
}

.toggle span {
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.4;
}

.toggle strong {
  color: var(--fg);
  font-weight: 600;
}

.toggle small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.toggle-stack {
  display: grid;
  gap: 12px;
}

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--danger);
  border: 1px solid var(--badge-border);
  font-size: 12px;
  margin-left: 4px;
}

.alert {
  background: var(--info-light);
  border: 1px solid rgba(37, 99, 235, 0.25);
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--info);
  font-weight: 500;
  transition: opacity 0.18s ease;
}

.alert.closing {
  opacity: 0;
}

.alert.success,
.alert.alert-success {
  background: var(--success-light);
  border-color: rgba(16, 185, 129, 0.35);
  color: var(--success);
}

.alert.error,
.alert.alert-danger,
.alert.alert-error {
  background: var(--danger-light);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}

.alert.info,
.alert.alert-info {
  background: var(--info-light);
  border-color: rgba(37, 99, 235, 0.25);
  color: var(--info);
}

.alert.warning,
.alert.alert-warning {
  background: var(--warning-light);
  border-color: rgba(245, 158, 11, 0.35);
  color: var(--warning);
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 10px;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

label {
  font-size: 14px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

form {
  display: grid;
  gap: 12px;
}

.modal .modal-content {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.footer {
  text-align: center;
  color: var(--muted);
  padding: 20px 16px 32px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  width:100%;
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.section-stack {
  display: grid;
  gap: 18px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.text-muted {
  color: var(--text-muted);
}

/* Floating actions */
.fab-stack {
  position: fixed;
  right: max(env(safe-area-inset-right, 0px), 0px);
  bottom: clamp(20px, 3vh, 32px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-end;
  z-index: 950;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.fab-stack--collapsed {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

.fab-stack--collapsed .fab {
  display: none;
}

.fab-stack-toggle {
  width: 38px;
  height: 38px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.16);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.fab-stack-toggle:hover {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}

.fab-stack-toggle i {
  font-size: 18px;
}

.fab-stack-peek {
  position: fixed;
  right: max(env(safe-area-inset-right, 0px), 0px);
  bottom: clamp(112px, 22vh, 168px);
  width: 42px;
  height: 48px;
  border-radius: 16px 0 0 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.26);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 951;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.fab-stack-peek:hover {
  transform: translateX(-2px);
}

.fab-stack-peek i {
  font-size: 20px;
}

.fab-stack-peek.is-visible {
  display: flex;
}

.fab {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  background: var(--primary);
  color: #fff;
}

.fab:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.22);
}

.fab.secondary {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
}
.fab--chat {
  background: var(--primary);
}

.fab--notes {
  background: var(--success);
}

.fab--ai {
  background: var(--warning);
  color: var(--fg);
}

.fab i {
  font-size: 24px;
}

.fab img {
  width: 26px;
  height: 26px;
}

.fab-icon {
  font-weight: 600;
  font-size: 18px;
}

.fab--hidden {
  display: none !important;
}

.floating-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  width: 360px;
  max-height: 72vh;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  z-index: 940;
}

.floating-panel.hidden {
  display: none;
}

.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.panel-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.panel-header .close {
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--fg);
}

.panel-body {
  padding: 14px;
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-panel-body {
  display: flex;
  gap: 14px;
  min-height: 320px;
}

.chat-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--card);
  position: relative;
}

.chat-thread > .muted {
  margin: auto;
  text-align: center;
}

.chat-window-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.notes-panel-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 360px;
}

.notes-controls {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 10px;
}

.notes-form {
  display: grid;
  gap: 10px;
}

.notes-form-actions {
  display: flex;
  justify-content: flex-end;
}

.notes-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--card);
}

.notes-item-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.note-heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.note-date {
  font-size: 12px;
  color: var(--muted);
}

.note-meta {
  font-size: 12px;
  color: var(--muted);
}

.note-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
}

.note-attachment a {
  color: var(--primary);
  font-weight: 500;
}

.widget-footer-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.ai-panel-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 320px;
}

.ai-chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.ai-message--user {
  justify-content: flex-end;
}

.ai-message--user .ai-message-content {
  background: var(--info);
  color: #fff;
}

.ai-message--assistant .ai-message-content {
  background: var(--surface);
  color: var(--fg);
}

.ai-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.ai-message-content {
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 80%;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1);
}

.ai-chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-chat-form textarea {
  resize: vertical;
}

.ai-chat-actions {
  display: flex;
  justify-content: flex-end;
}

.modal-widget-overview .modal-content {
  max-width: 960px;
}

.widget-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.widget-overview-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--card);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.widget-overview-icon {
  font-size: 28px;
  color: var(--primary);
}

.widget-overview-content h4 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.widget-overview-content p {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.widget-overview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.btn.text {
  background: transparent;
  border: none;
  padding: 0;
  min-height: auto;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.btn.text:hover {
  color: #861100;
  text-decoration: underline;
}

.btn.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.notes-form select[multiple] {
  min-height: 110px;
}

.notes-list {
  display: grid;
  gap: 12px;
}

.notes-item .note-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.notes-item .note-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.chat-body {
  display: flex;
  gap: 12px;
}

.chat-users {
  width: 140px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.chat-users-header {
  font-weight: 600;
  margin-bottom: 6px;
}

.chat-user-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
}

.chat-user {
  padding: 7px 10px;
  padding-right: 28px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
}

.chat-user:hover,
.chat-user.active,
.chat-user.open {
  background: linear-gradient(135deg, rgba(207, 27, 0, 0.16), rgba(255, 255, 255, 0.06));
  border-color: rgba(207, 27, 0, 0.45);
}

.chat-user.has-unread::after {
  content: '●';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--primary);
}

/* Collaboration */
.collab-messages {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.collab-entry {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--card);
}

.collab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 6px;
}

.collab-time {
  color: var(--muted);
  font-size: 12px;
}

.collab-body {
  margin-bottom: 6px;
  white-space: pre-wrap;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 12px;
}

.modal.open {
  display: flex;
}

.modal .modal-content {
  width: min(600px, calc(100vw - 32px));
  max-width: 600px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 32px 64px rgba(15, 23, 42, 0.35);
  padding: 20px;
}
.input-action {
  display: flex;
  gap: 10px;
  align-items: center;
}
.input-action input {
  flex: 1 1 auto;
  min-width: 0;
}
.input-action .btn {
  flex-shrink: 0;
  white-space: nowrap;
}
@media (max-width: 520px) {
  .modal .modal-content {
    padding: 16px;
  }
  .input-action {
    flex-direction: column;
    align-items: stretch;
  }
  .input-action .btn {
    width: 100%;
  }
}
.event-share-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.event-share-panel textarea {
  resize: none;
  min-height: 96px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--fg);
}
.event-share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.event-share-actions .btn {
  flex: 1 1 150px;
}
.event-share-panel .muted {
  font-size: 12px;
}

.modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal .close {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--fg);
}
.modal .modal-content.modal-sm {
  max-width: 420px;
}

.modal .modal-content.modal-wide {
  max-width: 960px;
  width: 100%;
}

.modal-body.modal-scroll {
  max-height: 70vh;
  overflow-y: auto;
}

.modal-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-stacked {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.chatLog {
  padding: 8px;
  overflow: auto;
  flex: 1;
}

.chatMsg {
  margin-bottom: 8px;
}

.chatForm {
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  padding: 8px;
}

.pref-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}

.muted-list {
  list-style: disc;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  display: grid;
  gap: 4px;
}

.notification-item {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 44px 12px 14px;
  background: var(--card);
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.notification-item:hover {
  background-color: rgba(99, 102, 241, 0.08);
}

.notification-item__content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.notification-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.notification-close:hover,
.notification-close:focus-visible {
  color: var(--danger);
}

.notification-item.is-unread {
  border-left: 4px solid var(--accent, #cf1b00);
}

/* Calendar */
.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-actions {
  display: flex;
  gap: 8px;
}

.calendar-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.calendar-grid {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  padding-bottom: 8px;
}

.calendar-grid::-webkit-scrollbar {
  height: 6px;
}

.calendar-grid::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.25);
  border-radius: 999px;
}

.calendar-weekday-row,
.calendar-week-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-width: 100%;
}

.calendar-weekday {
  padding: 10px;
  text-align: center;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.calendar-week-row {
  border-bottom: 1px solid var(--border);
}

.calendar-day {
  min-height: 110px;
  border-right: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 1024px) {
  .calendar-day {
    padding: 8px;
    min-height: 100px;
  }
}

@media (max-width: 768px) {
  .calendar-layout {
    flex-direction: column;
  }

  .calendar-weekday-row,
  .calendar-week-row {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .calendar-weekday {
    font-size: 0.85rem;
    padding: 8px 4px;
  }

  .calendar-day {
    padding: 6px;
    gap: 6px;
  }
}

@media (max-width: 520px) {
  .calendar-weekday {
    font-size: 0.75rem;
  }

  .calendar-day {
    min-height: 90px;
  }
}

.calendar-day:nth-child(7n) {
  border-right: none;
}

.calendar-day--muted {
  background: rgba(15, 23, 42, 0.03);
}

.calendar-day--today {
  border: 2px solid #2563eb;
  background: rgba(37, 99, 235, 0.05);
}

.calendar-day-body {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.calendar-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}

.calendar-chip.event {
  border-left: 4px solid #2563eb;
}

.calendar-chip.task {
  border-left: 4px solid #047857;
}

.calendar-chip .chip-time {
  font-weight: 600;
  font-size: 12px;
}

.calendar-aside {
  width: 280px;
  display: grid;
  gap: 16px;
}

.calendar-upcoming {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.calendar-upcoming:last-child {
  border-bottom: none;
}

/* Login */
body.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(1200px 800px at 50% -20%, rgba(207, 27, 0, 0.14) 0%, transparent 60%) no-repeat, var(--bg);
}

[data-theme="dark"] body.auth-page {
  background: radial-gradient(1200px 800px at 50% -20%, rgba(252, 165, 165, 0.16) 0%, transparent 65%) no-repeat, var(--bg);
}

.auth-main {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 16px 24px;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.auth-brand {
  text-align: center;
  margin-top: -68px;
}

.auth-brand img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 18px;
  background: var(--surface);
  padding: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.auth-title {
  text-align: center;
  font-size: 24px;
  font-weight: 600;
}

.input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.input-row .suffix {
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 10px;
}

.login-actions {
  margin-top: 6px;
  display: grid;
  gap: 10px;
}

.btn.primary.big {
  padding: 12px 16px;
  font-size: 16px;
  border-radius: 999px;
  background-image: linear-gradient(135deg, var(--primary), var(--accent)) !important;
  border: 1px solid transparent !important;
  color: #ffffff !important;
  box-shadow: 0 22px 45px rgba(207, 27, 0, 0.28);
}

a.link {
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 500;
}

a.link:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 1024px) {
  .container {
    padding: 24px 20px 36px;
  }

  .section-header,
  .page-header {
    align-items: flex-start;
    gap: 16px;
  }

  .kanban {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }

  .stats-row {
    flex-wrap: wrap;
    gap: 12px;
  }

  .stats-row > * {
    flex: 1 1 220px;
  }

  .calendar-aside {
    width: 100%;
  }
}

@media (max-width: 1024px) {
  .calendar-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .calendar-layout {
    flex-direction: column;
  }

  .calendar-grid {
    order: 1;
  }

  .calendar-aside {
    order: 2;
    width: 100%;
  }

  .calendar-weekday-row,
  .calendar-week-row {
    min-width: 100%;
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .calendar-weekday-row,
  .calendar-week-row {
    min-width: 100%;
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .calendar-day {
    padding: 8px;
    min-height: 92px;
  }

  .calendar-chip {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .calendar-chip .chip-time {
    font-size: 11px;
  }
}

@media (max-width: 720px) {
  .container {
    padding: 20px 14px 36px;
    gap: 18px;
  }

  .nav {
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .nav .brand {
    width: 100%;
    justify-content: space-between;
  }

  .nav a,
  .nav a.active {
    width: 100%;
    justify-content: flex-start;
  }

  .subnav {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .subnav .btn {
    width: 100%;
    justify-content: center;
  }

  .grid2 {
    grid-template-columns: 1fr;
  }

  .stats-row {
    flex-direction: column;
    gap: 10px;
  }

  .card,
  .column {
    padding: 14px;
  }

  .kanban {
    grid-template-columns: 1fr;
  }

  .calendar-weekday-row,
  .calendar-week-row {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    min-width: 100%;
  }

  .calendar-layout {
    flex-direction: column;
  }

  .calendar-grid {
    order: 1;
  }

  .calendar-aside {
    order: 2;
  }

  .modal .modal-content {
    max-width: 96%;
  }

  .table-scroll table {
    min-width: 520px;
  }

  .fab-stack {
    right: max(env(safe-area-inset-right, 0px), 0px);
    bottom: 16px;
  }

  .floating-panel {
    right: 12px;
    left: 12px;
    width: auto;
  }

  .notes-controls {
    grid-template-columns: 1fr;
  }

  .chat-panel-body {
    flex-direction: column;
  }

  .auth-card {
    padding: 32px 24px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 18px 12px 32px;
  }

  .nav .brand strong {
    font-size: 16px;
  }

  .subnav .btn {
    font-size: 14px;
  }

  .table-scroll table {
    min-width: 440px;
  }

  .modal .modal-content {
    padding: 16px;
  }

  .chat-window {
    max-width: 100%;
  }
}


.module-override-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.module-override-item + .module-override-item {
  margin-top: 8px;
}

.module-override-item > summary::-webkit-details-marker {
  display: none;
}

.module-override-item > summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.module-override-item form {
  width: 100%;
}

@media (max-width: 720px) {
  .module-override-item > summary {
    flex-direction: column;
  }

  .module-override-item form {
    padding-top: 6px;
  }

  .module-override-item form > div {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px !important;
  }

  .module-override-item form select {
    width: 100%;
  }
}
.ai-insight {
  white-space: pre-line;
  font-size: 14px;
  line-height: 1.5;
}

/* Profile — Font size controls */
.profile-font-settings {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-font-settings__label {
  font-weight: 600;
  color: var(--fg);
}

.profile-font-settings select {
  max-width: min(280px, 100%);
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.profile-font-settings select:focus {
  outline: 2px solid rgba(207, 27, 0, 0.35);
  outline-offset: 2px;
}

.font-size-preview {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s ease, background 0.2s ease;
}

.font-size-preview__heading {
  font-weight: 600;
  font-size: 1em;
}

.font-size-preview__text {
  margin: 0;
  font-size: 0.95em;
  color: var(--muted);
  line-height: 1.55;
}

.font-size-preview__button {
  align-self: flex-start;
  border: none;
  border-radius: 999px;
  padding: 0.6em 1.45em;
  font-weight: 600;
  font-size: 1em;
  color: #ffffff;
  background-image: linear-gradient(135deg, var(--primary), var(--accent));
  cursor: default;
  opacity: 0.88;
  transition: opacity 0.2s ease;
}

.font-size-preview__button:disabled {
  opacity: 0.9;
}

.font-size-preview[data-font-size="small"] {
  font-size: 0.95rem;
}

.font-size-preview[data-font-size="medium"] {
  font-size: 1.02rem;
}

.font-size-preview[data-font-size="large"] {
  font-size: 1.12rem;
}

.font-size-preview[data-font-size="small"] .font-size-preview__button {
  padding: 0.55em 1.3em;
}

.font-size-preview[data-font-size="large"] .font-size-preview__button {
  padding: 0.7em 1.6em;
}

@media (max-width: 720px) {
  .profile-font-settings select {
    width: 100%;
  }
}

/* Widget Stack */
.widget-stack {
  display: none !important;
}

.widget-panel {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  width: 380px;
  max-height: 70vh;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.25);
  display: none;
  flex-direction: column;
  z-index: 940;
}

.widget-panel.open {
  display: flex;
}

.widget-panel.multiple {
  position: fixed;
  left: auto;
  right: 24px;
  transform: none;
  width: 360px;
}

.widget-panel.multiple:nth-child(2) {
  right: 24px;
  bottom: 96px;
}

.widget-panel.multiple:nth-child(3) {
  right: 24px;
  bottom: 200px;
}

.widget-panel.multiple:nth-child(4) {
  right: 24px;
  bottom: 304px;
}

.widget-panel.multiple:nth-child(5) {
  right: 24px;
  bottom: 408px;
}

.widget-tab {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s ease;
}

.widget-tab:hover {
  background: var(--card);
}

.widget-tab.active {
  background: var(--card);
  border-color: rgba(207, 27, 0, 0.45);
  box-shadow: inset 0 -2px 0 rgba(207, 27, 0, 0.55);
}

.widget-content {
  padding: 16px;
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.widget-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
}

.widget-time {
  font-weight: 600;
  color: var(--accent, #cf1b00);
}

.widget-title {
  font-weight: 500;
  margin-top: 4px;
}

.widget-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}

.widget-close:hover {
  color: var(--fg);
}

/* Multiple Chat Windows */
.chat-window-dock {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  z-index: 930;
}

.chat-window {
  width: 320px;
  max-width: min(360px, 90vw);
  height: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px 16px 12px 12px;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.chat-window.minimized {
  height: auto;
}

.chat-window.minimized .chat-window-body {
  display: none;
}

.chat-window-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  background: var(--surface);
  cursor: default;
}

.chat-window-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
}

.chat-window-title small {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
}

.chat-window-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.chat-window-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.chat-window-btn:hover {
  background: rgba(15, 23, 42, 0.08);
  color: var(--fg);
}

.chat-window-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--card);
}

.chat-window-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--card);
  scroll-behavior: smooth;
}

.chat-window-log::-webkit-scrollbar {
  width: 6px;
}

.chat-window-log::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.18);
  border-radius: 99px;
}

.chat-window-placeholder {
  margin: auto;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.chat-bubble {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid rgba(15, 23, 42, 0.06);
  color: var(--fg);
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  align-self: flex-start;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.14);
}

.chat-bubble--outgoing {
  background-image: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  align-self: flex-end;
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(207, 27, 0, 0.22);
}

.chat-bubble-text {
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  align-items: center;
}

.chat-bubble--outgoing .chat-bubble-meta {
  color: rgba(255, 255, 255, 0.8);
}

.chat-bubble-attachment a {
  color: inherit;
  text-decoration: underline;
  font-weight: 500;
}

.chat-window-form {
  border-top: 1px solid var(--border);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
}

.chat-window-input {
  width: 100%;
  min-height: 56px;
  max-height: 140px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--fg);
  background: var(--card);
}

.chat-window-input:focus {
  outline: none;
  border-color: var(--accent, #cf1b00);
  box-shadow: 0 0 0 2px rgba(207, 27, 0, 0.18);
}

.chat-window-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.chat-window-attach {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
}

.chat-window-attach input[type="file"] {
  display: none;
}

.chat-window-attach span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.chat-window-submit {
  padding: 10px 18px;
  border-radius: 999px;
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 720px) {
  .widget-stack {
    position: fixed;
    left: 12px;
    bottom: 12px;
    transform: none;
    flex-direction: column;
    align-items: flex-start;
  }

  .widget-panel {
    left: 12px;
    right: 12px;
    width: auto;
    transform: none;
    max-height: 60vh;
  }

  .widget-panel.multiple {
    position: fixed;
    left: 12px;
    right: 12px;
    transform: none;
    width: auto;
  }

  .chat-window-dock {
    left: 12px;
    right: 12px;
    bottom: 96px;
    transform: none;
    justify-content: center;
  }

  .chat-window {
    width: 100%;
    max-width: none;
    height: 350px;
  }

  .fab-stack {
    right: max(env(safe-area-inset-right, 0px), 0px);
    bottom: clamp(96px, 18vh, 140px);
  }

  .floating-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 200px;
  }
}

/* Hide all floating elements on mobile */
@media (max-width: 720px) {
  .fab-stack {
    right: max(env(safe-area-inset-right, 0px), 0px);
    bottom: clamp(72px, 16vh, 120px);
  }

  .fab-stack-peek {
    display: none !important;
  }

  .widget-stack,
  .chat-window-dock,
  .floating-panel {
    display: none !important;
  }

  /* Show mobile menu button */
  .mobile-widget-toggle {
    display: block !important;
  }
}

.mobile-widget-toggle {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background-image: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--navfg, #fff);
  border: none;
  border-radius: 25px;
  font-weight: 600;
  cursor: pointer;
  z-index: 960;
  box-shadow: 0 18px 40px rgba(207, 27, 0, 0.28);
}

.mobile-widget-toggle:hover {
  filter: brightness(1.05);
}

/* Enhanced Navigation for Mobile */
.nav-links {
  display: none;
  flex-direction: column;
  width: 100%;
  gap: 8px;
  margin-top: 12px;
}

.nav-links.open {
  display: flex;
}

.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
}

.nav-toggle span {
  width: 24px;
  height: 3px;
  background: var(--navfg, #fff);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.nav-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.nav-toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

@media (max-width: 720px) {
  .nav-toggle {
    display: flex;
  }

  .nav-actions {
    order: -1;
    margin-bottom: 12px;
  }
}

@media (min-width: 721px) {
  .nav-links {
    display: flex;
    flex-direction: row;
    width: auto;
    margin-top: 0;
  }

  .nav-toggle {
    display: none;
  }
}

/* Enhanced Profile Menu */
.profile-menu {
  position: relative;
  display: inline-block;
}

.profile-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.15);
  min-width: 200px;
  z-index: 1000;
  display: none;
}

.profile-dropdown.open {
  display: block;
}

.profile-dropdown a {
  display: block;
  padding: 12px 16px;
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
}

.profile-dropdown a:hover {
  background: var(--surface);
}

.profile-dropdown a:last-child {
  border-bottom: none;
  color: var(--danger);
}

.profile-dropdown a:last-child:hover {
  background: var(--danger-light);
}

/* Security Settings Section */
.security-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
  background: var(--surface);
}

.security-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.security-item {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}

.security-item h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
}

.security-item p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* Calendar Integration in Tasks */
.task-calendar-integration {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.task-due-calendar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 13px;
}

.task-due-calendar .calendar-icon {
  width: 16px;
  height: 16px;
  fill: var(--accent, #cf1b00);
}

/* Enhanced World Clock Widget */
.world-clock-widget {
  display: grid;
  gap: 8px;
}

.world-clock-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 13px;
}

.world-clock-location {
  font-weight: 500;
}

.world-clock-time {
  font-weight: 600;
  color: var(--accent, #cf1b00);
}

.world-clock-offset {
  font-size: 11px;
  color: var(--muted);
}

/* Prayer Times Widget */
.prayer-times-widget {
  display: grid;
  gap: 8px;
}

.prayer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 13px;
}

.prayer-name {
  font-weight: 500;
}

.prayer-time {
  font-weight: 600;
  color: var(--accent, #cf1b00);
}

.prayer-current {
  border-left: 4px solid var(--accent, #cf1b00);
  background: rgba(207, 27, 0, 0.08);
}

/* Schedule Widget */
.schedule-widget {
  display: grid;
  gap: 8px;
}

.schedule-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.schedule-item:hover {
  background: rgba(207, 27, 0, 0.08);
}

.schedule-title {
  font-weight: 500;
}

.schedule-time {
  font-weight: 600;
  color: var(--accent, #cf1b00);
}

/* Reminder Widget */
.reminder-widget {
  display: grid;
  gap: 8px;
}

.reminder-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 13px;
  border-left: 4px solid #f59e0b;
}

.reminder-item.overdue {
  border-left-color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

.reminder-title {
  font-weight: 500;
}

.reminder-due {
  font-weight: 600;
  color: var(--accent, #cf1b00);
}

/* Notes Widget */
.notes-widget {
  display: grid;
  gap: 8px;
}

.notes-widget-item {
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.notes-widget-item:hover {
  background: rgba(207, 27, 0, 0.08);
}

.notes-widget-title {
  font-weight: 500;
  margin-bottom: 4px;
}

.notes-widget-date {
  font-size: 11px;
  color: var(--muted);
}

/* Calendar Widget */
.calendar-widget {
  display: grid;
  gap: 8px;
}

.calendar-widget-day {
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 13px;
}

.calendar-widget-date {
  font-weight: 600;
  margin-bottom: 6px;
}

.calendar-widget-events {
  display: grid;
  gap: 4px;
}

.calendar-widget-event {
  font-size: 11px;
  padding: 2px 6px;
  background: rgba(207, 27, 0, 0.12);
  border-radius: 4px;
  border-left: 2px solid rgba(207, 27, 0, 0.4);
}

/* Widget Styles */
.widget {
    margin-bottom: 2rem;
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.drag-handle {
    cursor: move;
    color: var(--text-muted);
}

.sortable-ghost {
    opacity: 0.4;
}
/* Dashboard Widget Board */
.widget-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  gap: 12px;
}
.widget-toolbar__title h2 {
  margin: 0;
  font-size: 1.4rem;
}
.widget-toolbar__subtitle {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}
.widget-toolbar__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.dashboard-widget {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border-light);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}
.dashboard-widget.is-dragging {
  opacity: 0.6;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
}
.dashboard-widget.placeholder {
  border: 2px dashed var(--primary);
  background: rgba(59, 130, 246, 0.08);
}
.dashboard-widget__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}
.dashboard-widget__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1rem;
}
.dashboard-widget__handle {
  border: none;
  background: transparent;
  cursor: grab;
  padding: 4px;
  font-size: 1.1rem;
  color: var(--muted);
}
.dashboard-widget__handle:focus-visible {
  outline: 2px solid var(--primary);
  border-radius: 4px;
}
.dashboard-widget__actions {
  display: flex;
  gap: 6px;
}
.dashboard-widget__actions .widget-action {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease;
  font-size: 1.1rem;
}
.dashboard-widget__actions .widget-action:hover {
  background: rgba(148, 163, 184, 0.12);
  color: var(--primary);
}
.dashboard-widget__body {
  padding: 16px;
}
.dashboard-widget__body.is-loading {
  opacity: 0.6;
}
.widget-loading {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.widget-empty-state {
  margin: 32px 0;
  text-align: center;
  padding: 48px 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.widget-empty-state h3 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}
.widget-empty-state p {
  margin-bottom: 16px;
  color: var(--muted);
}

.widget-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.widget-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  min-height: 180px;
  background: var(--card);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.widget-preview__icon {
  font-size: 28px;
  color: var(--primary);
}

.widget-preview__body h4 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.widget-preview__body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.widget-preview__actions {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
}
.widget-picker-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.widget-picker-panel {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow, 0 8px 24px rgba(15, 23, 42, 0.12));
  display: none;
}

.widget-picker-panel.is-open {
  display: block;
}

.widget-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.widget-picker-header h3 {
  margin: 0;
  font-size: 1rem;
}

.widget-picker-header .widget-picker-close {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  color: var(--muted);
  cursor: pointer;
}

.widget-picker-header .widget-picker-close:hover {
  color: var(--danger);
}

.widget-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.widget-picker-item.is-disabled {
  opacity: 0.45;
}
.widget-picker-item .widget-picker-icon {
  font-size: 1.5rem;
  color: var(--primary);
}
.widget-picker-item .widget-picker-info {
  flex: 1;
}
.widget-picker-title {
  font-weight: 600;
}
.widget-picker-desc {
  font-size: 0.85rem;
  color: var(--muted);
}
.widget-clock-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.widget-clock-row input {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.widget-clock-row .widget-clock-remove {
  border: none;
  background: rgba(248, 113, 113, 0.12);
  color: #dc2626;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
}
.widget-clock-row .widget-clock-remove:hover {
  background: rgba(220, 38, 38, 0.2);
}

/* Enhanced Project Cards */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.page-header--projects h2 {
  margin: 0;
  font-size: 1.6rem;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--card-shadow);
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
  border-color: var(--primary-color);
}

.project-title-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.project-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--fg, #1f2937);
}

.project-id {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  background: var(--surface);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.project-status-badge {
  padding: 0.35rem 0.85rem;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.project-meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.project-meta-item i {
  width: 14px;
  color: var(--primary-color);
}

.project-progress-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1rem 0;
}

.project-progress-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.project-card__heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  color: var(--fg);
}

.project-card__id {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-muted);
}

.project-card__meta {
  display: grid;
  gap: 0.35rem;
}

.project-card__meta span {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.project-card__progress {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.project-card__progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg);
}

.project-card__progress-label span {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.project-card__progress-track {
  width: 100%;
  height: 8px;
  background: var(--border-light);
  border-radius: 999px;
  overflow: hidden;
}

.project-card__progress-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.4s ease;
}

.project-card__progress--secondary .project-card__progress-bar {
  background: var(--info);
}

.project-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.progress-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg, #1f2937);
}

.progress-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-percentage {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary-color);
}

.project-progress-track {
  height: 10px;
  background: var(--border-light);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.project-progress-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
  position: relative;
}

.project-progress-bar.progress-green {
  background: linear-gradient(90deg, #16a34a, #22c55e);
}

.project-progress-bar.progress-blue {
  background: linear-gradient(90deg, #2563eb, #3b82f6);
}

.project-progress-bar.progress-yellow {
  background: linear-gradient(90deg, #eab308, #facc15);
}

.project-progress-bar.progress-orange {
  background: linear-gradient(90deg, #f97316, #fb923c);
}

.project-progress-bar.progress-red {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.project-requirements-section {
  background: var(--surface);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1rem;
}

.requirements-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.requirements-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.requirements-summary {
  display: flex;
  gap: 1rem;
  justify-content: space-around;
}

.requirement-stat {
  text-align: center;
  flex: 1;
}

.stat-number {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 500;
}

.project-card__footer {
  margin-top: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Enhanced project card styling for dark mode */
[data-theme="dark"] .project-card {
  background: var(--card, #334155);
  border-color: var(--border, #475569);
}

[data-theme="dark"] .project-name {
  color: var(--fg, #f1f5f9);
}

[data-theme="dark"] .project-meta-item {
  color: var(--text-muted, #94a3b8);
}

[data-theme="dark"] .progress-label {
  color: var(--fg, #f1f5f9);
}

[data-theme="dark"] .project-requirements-section {
  background: var(--surface, #1e293b);
}

[data-theme="dark"] .project-card__footer {
  border-color: var(--border, #475569);
}

/* Dark mode fixes for existing elements */
[data-theme="dark"] .subcard {
  background: var(--card) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .role-card {
  background: var(--card) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .checklist-section {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .checklist-header {
  color: var(--fg) !important;
}

[data-theme="dark"] .checklist-list {
  background: var(--card) !important;
}

[data-theme="dark"] .pref-card {
  background: var(--card) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .toggle {
  background: var(--card) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .toggle strong {
  color: var(--fg) !important;
}

[data-theme="dark"] .toggle small {
  color: var(--muted) !important;
}

[data-theme="dark"] .field-grid {
  background: var(--card) !important;
}

[data-theme="dark"] .field-label {
  color: var(--fg) !important;
}

[data-theme="dark"] .form-actions {
  background: var(--surface) !important;
}

[data-theme="dark"] .kanban {
  background: var(--surface) !important;
}

[data-theme="dark"] .column {
  background: var(--card) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .column h3 {
  color: var(--fg) !important;
}

[data-theme="dark"] .task-card {
  background: var(--card) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .column[data-status="todo"] {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.32), rgba(245, 158, 11, 0.18)) !important;
  border-color: rgba(245, 158, 11, 0.55) !important;
}

[data-theme="dark"] .column[data-status="doing"] {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.32), rgba(59, 130, 246, 0.18)) !important;
  border-color: rgba(59, 130, 246, 0.55) !important;
}

[data-theme="dark"] .column[data-status="done"] {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.32), rgba(16, 185, 129, 0.18)) !important;
  border-color: rgba(16, 185, 129, 0.55) !important;
}

[data-theme="dark"] .task-card[data-status="todo"] {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.36), rgba(245, 158, 11, 0.2)) !important;
  border-color: rgba(245, 158, 11, 0.58) !important;
}

[data-theme="dark"] .task-card[data-status="doing"] {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.36), rgba(59, 130, 246, 0.2)) !important;
  border-color: rgba(59, 130, 246, 0.58) !important;
}

[data-theme="dark"] .task-card[data-status="done"] {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.36), rgba(16, 185, 129, 0.2)) !important;
  border-color: rgba(16, 185, 129, 0.58) !important;
}

[data-theme="dark"] .task-card strong {
  color: var(--fg) !important;
}

[data-theme="dark"] .task-row {
  background: var(--card) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .task-row:hover {
  background: rgba(207, 27, 0, 0.12) !important;
}

[data-theme="dark"] .insights-grid {
  background: var(--surface) !important;
}

[data-theme="dark"] .insight {
  background: var(--card) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .insight-label {
  color: var(--muted) !important;
}

[data-theme="dark"] .insight-value {
  color: var(--primary) !important;
}

[data-theme="dark"] .insight-sub {
  color: var(--muted) !important;
}
[data-theme="dark"] .kpi-card__icon {
  background: rgba(207, 27, 0, 0.24);
  color: #fca5a5;
}
[data-theme="dark"] .kpi-card {
  background: rgba(15, 23, 42, 0.9) !important;
  border-color: rgba(148, 163, 184, 0.22) !important;
}
[data-theme="dark"] .chart-card,
[data-theme="dark"] .ai-kpi-card {
  background: rgba(15, 23, 42, 0.88) !important;
  border-color: rgba(148, 163, 184, 0.2) !important;
}
[data-theme="dark"] .chart-card__head {
  color: rgba(226, 232, 240, 0.8) !important;
}
[data-theme="dark"] .ai-kpi-card__meta {
  color: rgba(148, 163, 184, 0.78) !important;
}
[data-theme="dark"] .ai-insight__list {
  color: rgba(226, 232, 240, 0.88) !important;
}

[data-theme="dark"] .calendar-toolbar {
  background: var(--card) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .calendar-nav h2 {
  color: var(--fg) !important;
}

[data-theme="dark"] .calendar-grid {
  background: var(--card) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .calendar-weekday {
  background: var(--surface) !important;
  color: var(--muted) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .calendar-day {
  border-color: var(--border) !important;
}

[data-theme="dark"] .calendar-day--muted {
  background: rgba(15, 23, 42, 0.03) !important;
}

[data-theme="dark"] .calendar-day--today {
  border-color: #2563eb !important;
  background: rgba(37, 99, 235, 0.05) !important;
}

[data-theme="dark"] .calendar-aside .card {
  background: var(--card) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .calendar-aside h3 {
  color: var(--fg) !important;
}

[data-theme="dark"] .calendar-upcoming {
  border-color: var(--border) !important;
}

[data-theme="dark"] .calendar-upcoming strong {
  color: var(--fg) !important;
}

[data-theme="dark"] .calendar-upcoming .muted {
  color: var(--muted) !important;
}

/* Project Requirements Section Styling */
.requirements-section {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.requirements-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.requirements-header span {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent, #cf1b00);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.requirements-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 60px;
}

.requirement-item {
  background: var(--surface, #f9f9f9);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 1rem;
  transition: all 0.2s ease;
}

.requirement-item:hover {
  background: var(--card, #fff);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.requirement-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.requirement-item-title {
  font-weight: 600;
  color: var(--fg, #1f2937);
  margin: 0;
  flex-grow: 1;
}

.requirement-item-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: 1rem;
}

.requirement-item-description {
  color: var(--text-secondary, #6b7280);
  font-size: 0.9rem;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.requirement-item-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted, #9ca3af);
}

.requirement-item-priority {
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.requirement-item-priority.high {
  background: var(--danger-light);
  color: var(--danger);
}

.requirement-item-priority.medium {
  background: var(--warning-light);
  color: var(--warning);
}

.requirement-item-priority.low {
  background: var(--success-light);
  color: var(--success);
}

.requirement-item-priority.critical {
  background: var(--critical-light);
  color: var(--critical);
}

.requirement-form {
  background: var(--surface, #f9f9f9);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.requirement-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.requirement-form-group {
  display: flex;
  flex-direction: column;
}

.requirement-form-label {
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--fg, #374151);
  font-size: 0.9rem;
}

.requirement-form-control {
  padding: 0.75rem;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--card, #fff);
  color: var(--fg, #1f2937);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.requirement-form-control:focus {
  outline: none;
  border-color: var(--accent, #cf1b00);
  box-shadow: 0 0 0 3px rgba(207, 27, 0, 0.15);
}

.requirement-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #e5e7eb);
}

.requirement-empty {
  text-align: center;
  color: var(--text-muted, #9ca3af);
  font-style: italic;
  padding: 2rem;
}

.requirement-add-btn {
  background-image: linear-gradient(135deg, var(--primary), var(--accent)) !important;
  color: #ffffff !important;
  border: 1px solid transparent !important;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.requirement-add-btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(207, 27, 0, 0.28);
}

.requirement-action-btn {
  background: transparent;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary, #6b7280);
}

.requirement-action-btn:hover {
  background: var(--danger, #fee2e2);
  color: var(--danger, #dc2626);
  border-color: var(--danger, #dc2626);
}

.requirement-action-btn.edit:hover {
  background: var(--info, #dbeafe);
  color: var(--info, #2563eb);
  border-color: var(--info, #2563eb);
}

/* Dark mode support for requirements */
[data-theme="dark"] .requirements-section {
  background: var(--card, #1e293b);
  border-color: var(--border, #334155);
}

[data-theme="dark"] .requirements-header span {
  color: var(--accent, #cf1b00);
}

[data-theme="dark"] .requirement-item {
  background: var(--surface, #0f172a);
  border-color: var(--border, #334155);
}

[data-theme="dark"] .requirement-item:hover {
  background: var(--card, #1e293b);
}

[data-theme="dark"] .requirement-item-title {
  color: var(--fg, #e2e8f0);
}

[data-theme="dark"] .requirement-item-description {
  color: var(--text-secondary, #94a3b8);
}

[data-theme="dark"] .requirement-item-meta {
  color: var(--text-muted, #64748b);
}

[data-theme="dark"] .requirement-form {
  background: var(--surface, #0f172a);
  border-color: var(--border, #334155);
}

[data-theme="dark"] .requirement-form-label {
  color: var(--fg, #e2e8f0);
}

[data-theme="dark"] .requirement-form-control {
  background: var(--card, #1e293b);
  color: var(--fg, #e2e8f0);
  border-color: var(--border, #334155);
}

[data-theme="dark"] .requirement-form-control:focus {
  border-color: var(--primary, #fca5a5);
  box-shadow: 0 0 0 3px rgba(252, 165, 165, 0.1);
}

[data-theme="dark"] .requirement-empty {
  color: var(--text-muted, #64748b);
}

@media (max-width: 640px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .widget-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .widget-toolbar__actions {
    width: 100%;
    justify-content: flex-start;
  }
}
/* Security layout */
.security-layout {
  display: grid;
  gap: 16px;
}

@media (min-width: 1080px) {
  .security-layout {
    grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
    align-items: start;
  }
}

.security-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.security-card--highlight {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(37, 99, 235, 0.03));
  border: 1px solid rgba(37, 99, 235, 0.18);
}

.security-summary-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.security-summary-list li {
  color: var(--muted);
}

.security-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.security-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.security-meta strong {
  color: var(--fg);
}

[data-theme="dark"] .security-card--highlight {
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(37, 99, 235, 0.32);
}

.notification-test-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

@media (max-width: 540px) {
  .notification-test-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
.sidebar-nav-item {
    position: relative;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-nav-link i {
    width: 18px;
    text-align: center;
}

.sidebar-nav-link:hover {
    background: rgba(207, 27, 0, 0.12);
    color: var(--primary);
}

.sidebar-nav-link.active {
    background: rgba(207, 27, 0, 0.18);
    color: var(--primary);
    box-shadow: 0 0 0 1px rgba(207, 27, 0, 0.2);
}

.sidebar-submenu {
    margin-left: 34px;
    display: none;
    flex-direction: column;
    gap: 6px;
}

.sidebar-nav-item:hover > .sidebar-submenu {
    display: flex;
}

@media (max-width: 768px) {
    .sidebar-submenu {
        display: flex !important;
    }
}

.sidebar-submenu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar-submenu-link i {
    width: 18px;
    text-align: center;
}

.sidebar-submenu-link:hover {
    background: rgba(207, 27, 0, 0.12);
    color: var(--primary);
}

[data-theme="dark"] .sidebar-nav-link:hover,
[data-theme="dark"] .sidebar-submenu-link:hover {
    background: rgba(248, 113, 113, 0.12);
    color: #fca5a5;
}

[data-theme="dark"] .sidebar-nav-link.active {
    background: rgba(248, 113, 113, 0.18);
    color: #fca5a5;
    box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.3);
}

[data-theme="dark"] .sidebar-submenu-link:hover {
    color: #fca5a5;
}
