  body {
    background-color: #f3f4f6;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
  }

  :root {
    --topbar-height: 60px;
    --color-sidebar-text: #94a3b8;
    --color-sidebar-text-active: #f1f5f9;
    --color-accent: #2563eb;
    --color-topbar-bg-start: #0f172a;
    --color-topbar-bg-end: #1e293b;
    --topbar-shadow:
      0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.15);
  }

  /* Horizontal Navigation */
  .horizontal-nav {
    background: linear-gradient(
      135deg,
      var(--color-topbar-bg-start) 0%,
      var(--color-topbar-bg-end) 100%
    );
    position: sticky;
    top: var(--topbar-height);
    z-index: 150;
    padding: 0.375rem 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    width: 100%;
    box-sizing: border-box;
  }
  .horizontal-nav .nav {
    display: flex;
    flex-wrap: nowrap;
    justify-content: stretch;
    gap: 0.375rem;
    width: 100%;
  }
  .horizontal-nav .nav-link {
    color: var(--color-sidebar-text);
    padding: 0.45rem 0.625rem;
    border-radius: 6px;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 0;
    white-space: nowrap;
    text-align: center;
    text-decoration: none;
    transition: all 0.18s ease;
    position: relative;
  }
  .horizontal-nav .nav-link i {
    font-size: 0.9rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    transition: color 0.18s ease;
  }
  .horizontal-nav .nav-link:hover {
    color: var(--color-sidebar-text-active);
    background-color: rgba(255, 255, 255, 0.06);
  }
  .horizontal-nav .nav-link:hover i {
    color: #60a5fa;
  }
  .horizontal-nav .nav-link.active {
    color: var(--color-sidebar-text-active);
    background: linear-gradient(
      135deg,
      rgba(37, 99, 235, 0.2),
      rgba(59, 130, 246, 0.12)
    );
    font-weight: 600;
    border-bottom-color: #2563eb;
  }
  .horizontal-nav .nav-link.active i {
    color: #60a5fa;
  }

  .app-wrapper {
    width: 100%;
  }
  .main-content {
    padding: 1.5rem;
  }
  .tab-section[hidden] {
    display: none !important;
  }
  .list-controls[hidden] {
    display: none !important;
  }
  .list-controls {
    position: sticky;
    top: 112px;
    z-index: 140;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    margin-bottom: 12px !important;
    box-shadow:
      0 -15px 0 0 #f3f4f6,
      0 15px 0 0 #f3f4f6;
  }

  .navbar {
    background: linear-gradient(
      135deg,
      var(--color-topbar-bg-start) 0%,
      var(--color-topbar-bg-end) 100%
    );
    box-shadow: var(--topbar-shadow);
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 200;
  }
  .navbar .navbar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #f1f5f9 !important;
    display: flex;
    align-items: center;
  }
  .navbar .navbar-brand i {
    color: #60a5fa;
    font-size: 1.15rem;
  }
  .navbar .badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.3em 0.7em;
    border-radius: 999px;
    letter-spacing: 0.03em;
    background-color: rgba(255, 255, 255, 0.12) !important;
    color: #cbd5e1 !important;
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(4px);
  }
  .card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  }
  .task-done {
    text-decoration: line-through;
    color: #94a3b8;
  }
  .btn-primary {
    background-color: #2563eb;
    border: none;
  }
  .btn-primary:hover {
    background-color: #1d4ed8;
  }

  /* Summary KPI Cards */
  #section-overview .row > .col-md {
    display: flex;
  }
  .kpi-card {
    background: #ffffff;
    width: 100%;
    border-radius: 10px;
    padding: 12px 16px;
    transition: transform 0.15s ease;
  }
  .kpi-card:hover {
    transform: translateY(-2px);
  }
  .kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
  }
  .quarter-chart-wrap {
    position: relative;
    width: 100%;
    height: 320px;
  }

  /* Overview Calendar */
  .overview-calendar-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  }
  .overview-calendar-toolbar {
    position: relative;
    min-height: 38px;
  }
  .overview-calendar-nav-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
  .overview-task-calendar {
    border: 1px solid #dbe3ef;
    border-radius: 12px;
    background: #ffffff;
    padding: 8px;
    min-height: 500px;
  }
  .overview-task-calendar .fc {
    height: 480px;
  }
  .overview-task-calendar .fc-timegrid-slot {
    height: 1.2rem;
  }
  .overview-task-calendar .fc-col-header-cell-cushion,
  .overview-task-calendar .fc-timegrid-axis-cushion {
    color: #334155;
    font-weight: 600;
    text-decoration: none;
  }
  .overview-task-calendar .fc-timegrid-slot-label-cushion {
    color: #64748b;
    font-size: 0.76rem;
  }
  .overview-task-calendar .fc-event {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 1px 3px;
    font-size: 0.74rem;
  }
  .overview-task-calendar .fc-event.calendar-completed {
    opacity: 0.55;
    filter: grayscale(60%);
  }
  .overview-task-calendar .fc-event.calendar-completed .fc-event-title {
    text-decoration: line-through;
  }
  .overview-task-calendar .calendar-extra-time {
    border-style: dashed !important;
    opacity: 0.9;
  }
  .overview-task-calendar .fc-event-main {
    font-weight: 600;
  }
  .overview-task-calendar .fc-daygrid-event {
    white-space: normal;
  }
  .overview-task-calendar .fc-day-today {
    background-color: rgba(37, 99, 235, 0.06) !important;
  }
  .overview-task-calendar .fc-now-indicator-line {
    border-color: #ef4444;
  }
  .overview-task-calendar .fc-now-indicator-arrow {
    border-color: #ef4444;
  }
  .overview-calendar-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 12px;
    align-items: start;
  }
  .overview-task-pool {
    border: 1px solid #dbe3ef;
    background: #ffffff;
    border-radius: 12px;
    padding: 10px;
    position: sticky;
    top: 120px;
    max-height: 860px;
    overflow: hidden;
  }
  .overview-task-pool.calendar-pool-drop-active {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
    background: #f0f9ff;
  }
  .overview-active-task-list {
    overflow-y: auto;
    max-height: 800px;
    padding-right: 4px;
  }
  .calendar-task-list-item {
    border: 1px solid #dbe3ef;
    border-left: 4px solid #2563eb;
    border-radius: 8px;
    background: #f8fafc;
    padding: 8px;
    margin-bottom: 8px;
    cursor: grab;
  }
  .calendar-task-list-item:active {
    cursor: grabbing;
  }
  .calendar-task-list-item .title {
    font-weight: 600;
    font-size: 0.82rem;
    color: #1e293b;
    line-height: 1.2;
  }
  .calendar-task-list-item .meta {
    color: #64748b;
    font-size: 0.72rem;
    margin-top: 3px;
  }

  @media (max-width: 768px) {
    .overview-calendar-toolbar {
      min-height: 0;
    }
    .overview-calendar-nav-center {
      position: static;
      left: auto;
      transform: none;
      width: 100%;
      justify-content: center;
      order: 3;
      margin-top: 0.25rem;
    }
    .overview-calendar-toolbar-actions {
      margin-left: auto;
    }
    .overview-calendar-layout {
      grid-template-columns: 1fr;
    }
    .overview-task-pool {
      position: static;
      max-height: none;
    }
    .overview-active-task-list {
      max-height: 220px;
    }
    .overview-task-calendar {
      min-height: 430px;
      padding: 4px;
    }
    .overview-task-calendar .fc {
      height: 410px;
    }
  }

  /* Priority Badges */
  .prio-Urgent {
    background-color: #dc2626;
    color: white;
  }
  .prio-High {
    background-color: #ea580c;
    color: white;
  }
  .prio-Medium {
    background-color: #ca8a04;
    color: white;
  }
  .prio-Low {
    background-color: #16a34a;
    color: white;
  }
  .prio-Idea {
    background-color: #0284c7;
    color: white;
  }

  /* Table Styles */
  .task-list-table {
    table-layout: fixed;
    width: 100%;
  }
  .task-list-table th {
    font-size: 0.75rem;
    white-space: nowrap;
    padding: 0.4rem 0.25rem;
    vertical-align: middle;
  }
  th.sortable {
    cursor: pointer;
    user-select: none;
  }
  th.sortable i {
    font-size: 0.7rem;
  }
  th.sortable:hover {
    background-color: #e2e8f0;
  }

  /* Drag & Drop Styling */
  .drag-handle {
    cursor: grab;
    color: #94a3b8;
    padding-right: 8px;
  }
  .drag-handle:active {
    cursor: grabbing;
    color: #2563eb;
  }
  tr.dragging {
    opacity: 0.4;
    background-color: #e2e8f0 !important;
  }
  tr.drag-over {
    border-top: 3px solid #2563eb !important;
  }
  .end-drop-zone {
    height: 18px;
  }
  .end-drop-zone td {
    border-top: 3px solid transparent;
    padding: 0;
  }
  .end-drop-zone.drag-over td {
    border-top-color: #2563eb;
  }

  /* Notes Box Styling */
  .notes-list {
    max-height: none;
    overflow: visible;
  }
  .note-card {
    background-color: #ffffff;
    border-left: 4px solid #2563eb;
    margin-bottom: 8px;
    border-radius: 4px;
    padding: 8px 12px;
  }
  .note-timestamp {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
  }
  .note-content ul {
    margin-bottom: 0;
    padding-left: 1.2rem;
  }
  .note-content p {
    margin-bottom: 0.25rem;
  }
  .compact-task-form {
    padding: 0.5rem 0.75rem;
  }
  .compact-task-form .form-label {
    margin-bottom: 0.15rem;
    font-size: 0.8rem;
  }
  .compact-task-form .form-control,
  .compact-task-form .form-select,
  .compact-task-form textarea {
    min-height: 30px;
    font-size: 0.9rem;
    padding: 0.25rem 0.45rem;
  }
  .compact-task-form .row {
    margin-bottom: 0.25rem !important;
  }
  .compact-task-form .mb-3 {
    margin-bottom: 0.35rem !important;
  }
  .compact-task-form textarea {
    min-height: 96px;
  }
  .compact-task-form #taskName {
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.3;
    min-height: 48px;
    padding: 0.45rem 0.7rem;
  }
  .compact-task-form #taskName::placeholder {
    color: #c5c9d1;
    font-weight: 400;
    opacity: 1;
  }
  .form-control::placeholder {
    color: #c5c9d1;
    font-weight: 400;
    opacity: 1;
  }
  .compact-task-form .btn {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    font-size: 0.75rem;
  }
  .due-date-cell {
    min-width: 80px;
    white-space: nowrap;
  }
  .task-list-table th[style*="min-width"],
  .task-list-table td[style*="min-width"] {
    min-width: 100px !important;
  }
  .task-list-table th[style*="min-width: 180px"],
  .task-list-table td:last-child {
    min-width: 180px !important;
  }
  .task-list-table th[style*="width: 40px"],
  .task-list-table td:nth-child(2) {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
  }
  .task-list-table th[style*="width: 30px"],
  .task-list-table td:first-child {
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
  }

  .task-list-table td:nth-child(3),
  .task-list-table th:nth-child(3) {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
  }

  .task-list-table td:nth-child(4),
  .task-list-table th:nth-child(4) {
    width: auto !important;
    min-width: 200px !important;
    max-width: none !important;
  }

  .task-list-table td:nth-child(n + 5),
  .task-list-table th:nth-child(n + 5) {
    width: 100px !important;
    min-width: 100px !important;
    max-width: 100px !important;
  }
  .task-list-table td:first-child .drag-handle {
    padding-right: 0 !important;
  }
  .task-list-table td:nth-child(2) input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
  }
  .due-date-status {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
  }
  .due-today {
    color: #a16207;
  }
  .past-due {
    color: #b91c1c;
  }
  .task-list-table th,
  .task-list-table td {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  .task-list-table td {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: anywhere;
  }
  .task-list-table td.cell-expand {
    min-width: auto;
    overflow: visible;
  }
  .issue-tracker-btn:hover,
  .issue-tracker-btn:focus-visible {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #ffffff !important;
  }
  .task-project-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
    color: #dc3545;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-decoration: none;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.2);
    transition: all 0.18s ease;
    cursor: pointer;
  }
  .task-project-link:hover,
  .task-project-link:focus-visible {
    color: #ffffff;
    background-color: #dc3545;
    border-color: #dc3545;
    text-decoration: none;
  }
  .issue-row {
    background-color: #fff5f5;
    border-left: 4px solid #dc3545;
  }
  .issue-row:hover {
    background-color: #ffe3e3;
  }
  .goal-row {
    background-color: #eff6ff;
    border-left: 4px solid #0d6efd;
  }
  .goal-row:hover {
    background-color: #dbeafe;
  }
  .task-name-clickable.task-goal {
    color: #000;
    font-weight: 700;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    letter-spacing: 0.01em;
    background: rgba(13, 110, 253, 0.08);
    border: 1px solid rgba(13, 110, 253, 0.2);
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.18s ease;
  }
  .task-name-clickable.task-goal:hover {
    color: #ffffff;
    background-color: #0d6efd;
    border-color: #0d6efd;
    font-weight: 700;
  }
  .task-name-clickable.task-regular {
    color: #000;
    font-weight: 700;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    letter-spacing: 0.01em;
    background: rgba(100, 116, 139, 0.08);
    border: 1px solid rgba(100, 116, 139, 0.2);
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.18s ease;
  }
  .task-name-clickable.task-regular:hover {
    color: #ffffff;
    background-color: #64748b;
    border-color: #64748b;
    font-weight: 700;
  }

  .title-row-offset {
    position: relative;
  }
  .title-row-offset .btn {
    position: absolute;
    left: 170px;
    top: 50%;
    transform: translateY(-50%);
  }

  /* Search & Controls */
  .input-group .form-control {
    border-width: 1px;
    border-right-width: 0;
    border-color: #ced4da;
    box-shadow: none;
    border-radius: 0.35rem 0 0 0.35rem;
  }
  .input-group .form-control:focus {
    box-shadow: none;
    border-color: #86b7ff;
  }
  .input-group .btn-outline-secondary {
    border-width: 1px;
    border-left-width: 0;
    border-color: #ced4da;
    box-shadow: none;
    background-color: #fff;
    border-radius: 0 0.35rem 0.35rem 0;
    padding: 0.375rem 0.5rem;
  }
  .input-group .btn-outline-secondary:focus,
  .input-group .btn-outline-secondary:active {
    box-shadow: none;
    border-color: #ced4da;
  }
  .input-group .btn-outline-secondary:hover,
  .input-group .btn-outline-secondary:focus-visible {
    background-color: #e9ecef;
    color: #495057;
  }
  .input-group .btn-outline-secondary:hover i,
  .input-group .btn-outline-secondary:focus-visible i {
    color: inherit;
  }

  @media (min-width: 1301px) {
    .task-list-table th,
    .task-list-table td {
      white-space: normal;
      word-wrap: break-word;
      overflow-wrap: anywhere;
    }
  }

  @media (max-width: 1300px) {
    .task-list-table thead {
      display: none;
    }

    .task-list-table tbody tr {
      display: block;
      width: 100%;
      margin-bottom: 0.75rem;
      border-radius: 8px;
      border: 1px solid #e2e8f0;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .task-list-table tbody tr td {
      display: flex;
      align-items: center;
      width: 100%;
      text-align: left;
      padding: 0.35rem 0.25rem;
      border-top: 1px solid #f1f5f9;
    }

    .task-list-table tbody tr td:first-child {
      border-top: none;
    }

    .task-list-table tbody tr td.text-end {
      text-align: left;
    }

    .task-list-table tbody tr td::before {
      content: attr(data-label);
      font-weight: 600;
      color: #475569;
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.03em;
      min-width: 90px;
      margin-right: 0.5rem;
    }

    .task-list-table .btn-group {
      display: flex;
      flex-wrap: wrap;
      gap: 0.25rem;
      align-items: center;
    }

    .task-list-table .btn {
      font-size: 0.7rem;
      padding: 0.2rem 0.4rem;
    }

    .due-date-cell {
      min-width: auto;
    }

    .compact-task-form .row {
      flex-direction: column;
      gap: 0.35rem;
    }

    .compact-task-form .col-md-2,
    .compact-task-form .col-md-1 {
      width: 100%;
    }

    .list-controls .d-flex.align-items-center.gap-2 {
      flex-wrap: wrap;
    }

    #taskSearchInput,
    #categoryFilter {
      width: 100% !important;
    }

    /* Hide the urgency-order empty cell and drag handle on mobile */
    .task-list-table tbody tr td.drag-handle-cell {
      display: none;
    }

    /* Reduce horizontal padding on mobile for more content space */
    .main-content {
      padding: 0.75rem;
    }

    .card.p-4 {
      padding: 1rem !important;
    }

    #section-overview .row > .col-md {
      flex: 0 0 100%;
      max-width: 100%;
      margin-bottom: 0.5rem;
    }
    #section-overview .row > .col-md:last-child {
      margin-bottom: 0;
    }
  }

  /* Quill Editor Styles for Notes Modal */
  #descriptionEditor,
  #resolutionEditor {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background: #fff;
  }

  /* Truncated text styles for description/resolution */
  .text-truncated-container {
    position: relative;
  }
  .truncate-toggle {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #0d6efd;
    cursor: pointer;
    user-select: none;
    background: none;
    border: none;
    padding: 0;
  }
  .truncate-toggle:hover {
    text-decoration: underline;
  }
  #descriptionEditor .ql-container,
  #resolutionEditor .ql-container {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.9rem;
    min-height: 100px;
  }
  #descriptionEditor .ql-editor,
  #resolutionEditor .ql-editor {
    min-height: 100px;
    padding: 0.5rem;
  }
  /* Quill 1.x renders each toolbar as the sibling immediately BEFORE its
     editor container, so `#descriptionEditor .ql-toolbar` can never match.
     Scripts.html tags the description/resolution toolbars with
     .ql-section-toolbar and drives their visibility directly, so style them
     by class instead of by ancestor. */
  .ql-section-toolbar {
    border-top: none;
    border-left: none;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 0.375rem 0.375rem 0 0;
    background: #f8f9fa;
    padding: 0.375rem 0.5rem;
  }
  .ql-section-toolbar button {
    padding: 0.125rem 0.375rem;
  }
  .ql-section-toolbar .ql-stroke {
    stroke: #475569;
  }
  .ql-section-toolbar .ql-fill {
    fill: #475569;
  }
  .ql-section-toolbar .ql-picker-label,
  .ql-section-toolbar .ql-picker-options {
    border-color: #ced4da;
  }

  /* Read-only Quill output: host HTML inside a .ql-editor element so the
     quill.snow.css content rules (headers, lists, blockquotes, code, links)
     apply during display. .ql-reader neutralizes editor-only layout props
     (padding/height/overflow) so it behaves purely as styled content. */
  .ql-reader {
    padding: 0.5rem 0.75rem;
    height: auto;
    min-height: 0;
    overflow: visible;
  }
