:root {
  --daj-navy: #10233f;
  --daj-blue: #0877ff;
  --daj-sky: #e9f3ff;
  --daj-gray: #f4f7fb;
}

body {
  background: var(--daj-gray);
  color: #1f2937;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--daj-navy), #0b5ed7);
}

.auth-card,
.panel-card,
.metric-card {
  background: #fff;
  border: 1px solid #dde6f2;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(16, 35, 63, 0.08);
}

.app-shell {
  padding-left: 0;
  padding-right: 0;
}

.app-row {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
}

.sidebar {
  min-height: 100vh;
  background: var(--daj-navy);
  flex: 0 0 280px;
}

.sidebar-collapsible {
  width: 72px;
  flex-basis: 72px;
  overflow-x: hidden;
  transition: width 0.18s ease, flex-basis 0.18s ease, box-shadow 0.18s ease;
  position: sticky;
  top: 0;
  align-self: flex-start;
  z-index: 20;
}

.sidebar-collapsible:hover,
.sidebar-collapsible:focus-within {
  width: 280px;
  flex-basis: 280px;
  box-shadow: 18px 0 28px rgba(16, 35, 63, 0.2);
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.78);
  border-radius: 6px;
  min-height: 40px;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  transition: background 0.18s ease, color 0.18s ease;
}

.sidebar .nav-link > i,
.sidebar .nav-link > span:first-child > i {
  width: 1.25rem;
  flex: 0 0 1.25rem;
  text-align: center;
}

.sidebar .nav-link > span:first-child {
  display: flex;
  align-items: center;
  min-width: 0;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
  color: #fff;
  background: rgba(8, 119, 255, 0.32);
}

.nav-badge {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #2f80ff;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.nav-badge.alt {
  background: #8b5cf6;
}

.sidebar-collapsible:not(:hover):not(:focus-within) .nav-link {
  justify-content: center !important;
  font-size: 0;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.sidebar-collapsible:not(:hover):not(:focus-within) .nav-link i {
  margin-right: 0 !important;
  font-size: 1.08rem;
}

.sidebar-collapsible:not(:hover):not(:focus-within) .nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 17px;
  height: 17px;
  padding: 0;
  font-size: 10px;
  line-height: 17px;
}

.sidebar-collapsible:not(:hover):not(:focus-within) .sidebar-logo {
  display: flex;
  justify-content: center;
}

.sidebar-logo a {
  display: block;
  width: 100%;
  color: inherit;
  text-decoration: none;
}

.sidebar-collapsible:not(:hover):not(:focus-within) .sidebar-logo a {
  width: 44px;
}

.sidebar-collapsible:not(:hover):not(:focus-within) .sidebar-logo img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  object-position: left center;
  border-radius: 8px;
}

.sidebar-company {
  color: #dbeafe;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 14px;
  font-size: 0.86rem;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin-top: 32px;
  padding: 18px 0 4px;
  border-top: 1px solid #dbe4f0;
  color: #64748b;
  font-size: 0.9rem;
}

.app-footer strong {
  color: var(--daj-navy);
}

.email-preview-link {
  color: var(--daj-navy);
  text-decoration: none;
}

.email-preview-link:hover {
  color: var(--daj-blue);
  text-decoration: underline;
}

.sidebar-company span,
.sidebar-company strong {
  display: block;
  margin-bottom: 8px;
}

.top-search {
  position: relative;
  width: min(360px, 100%);
}

.top-search i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
}

.top-search input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 10px 12px 10px 40px;
  outline: none;
}

.icon-alert {
  position: relative;
  color: var(--daj-navy);
}

.icon-alert-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  text-decoration: none;
  padding: 0;
}

.icon-alert-button:hover,
.icon-alert-button:focus {
  color: var(--daj-blue);
}

.icon-alert b {
  position: absolute;
  top: -10px;
  right: -11px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.alerts-menu {
  width: min(320px, 92vw);
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(16, 35, 63, 0.18);
  overflow: hidden;
}

.alerts-menu-header {
  padding: 14px 16px;
  background: var(--daj-navy);
  color: #fff;
}

.alerts-menu-header span {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.84rem;
  margin-top: 2px;
}

.alerts-menu-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  color: #1f2937;
  text-decoration: none;
  border-top: 1px solid #edf2f7;
}

.alerts-menu-item:hover {
  background: var(--daj-sky);
  color: var(--daj-navy);
}

.alerts-menu-item i {
  color: var(--daj-blue);
}

.alerts-menu-item b {
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--daj-sky);
  color: var(--daj-navy);
  text-align: center;
  font-size: 0.78rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--daj-blue);
  color: #fff;
  border-radius: 8px;
  font-weight: 800;
}

.sidebar-logo img {
  display: block;
  width: 100%;
  max-width: 230px;
  height: auto;
  transition: width 0.18s ease, height 0.18s ease;
}

.document-logo {
  width: auto;
  max-width: 42vw;
  height: 72px;
  object-fit: contain;
  object-position: left center;
}

.metric-card {
  padding: 18px;
}

.dashboard-metrics .metric-link {
  display: block;
  width: 100%;
  height: 100%;
  color: inherit !important;
  text-decoration: none !important;
}

.dashboard-metrics .metric-link *,
.dashboard-metrics .metric-link:hover,
.dashboard-metrics .metric-link:focus-visible {
  color: inherit !important;
  text-decoration: none !important;
  outline: none;
}

.dashboard-metrics .metric-link .metric-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  min-height: 118px;
  height: 100%;
  padding: 18px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.dashboard-metrics .metric-link:hover .metric-card,
.dashboard-metrics .metric-link:focus-visible .metric-card {
  border-color: var(--daj-blue);
  box-shadow: 0 14px 34px rgba(8, 119, 255, 0.16);
  transform: translateY(-2px);
}

.dashboard-metrics .metric-link:active .metric-card {
  transform: translateY(0);
}

.dashboard-metrics .metric-card .metric-label {
  display: block;
  color: #526070 !important;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none !important;
}

.dashboard-metrics .metric-card .number {
  color: var(--daj-navy);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.05;
  margin-top: 14px;
  display: block;
}

.badge-status {
  background: var(--daj-sky);
  color: var(--daj-navy);
}

.ticket-hero-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #65d6a8;
  color: #fff;
  font-size: 1.8rem;
}

.detail-list {
  display: grid;
  gap: 18px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-size: 0.94rem;
}

.activity-timeline {
  position: relative;
  display: grid;
  gap: 18px;
}

.activity-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
}

.activity-dot {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--daj-blue);
  color: #fff;
  font-size: 0.9rem;
}

.soft-tab {
  border-bottom: 2px solid transparent;
  padding: 12px 18px;
  color: #334155;
  text-decoration: none;
}

.soft-tab.active {
  border-color: var(--daj-blue);
  color: var(--daj-blue);
  font-weight: 700;
}

.mail-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mail-tab {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #334155;
  text-decoration: none;
}

.mail-tab.active,
.mail-tab:hover {
  background: var(--daj-blue);
  border-color: var(--daj-blue);
  color: #fff;
}

.mail-table td {
  vertical-align: top;
}

.rich-text-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem;
  background: #f8fafc;
  border: 1px solid #ced4da;
  border-bottom: 0;
  border-radius: 0.375rem 0.375rem 0 0;
}

.rich-text-editor {
  min-height: 240px;
  max-height: 420px;
  overflow-y: auto;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  white-space: normal;
}

.rich-text-editor:empty::before {
  color: #6c757d;
  content: attr(data-placeholder);
  pointer-events: none;
}

.rich-text-editor img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.75rem 0;
}

.rich-message-composer {
  min-height: 240px;
  max-height: 520px;
  overflow: auto;
  padding: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.rich-message-input {
  min-height: 190px;
  padding: 0.75rem;
  outline: 0;
}

.rich-message-input:empty::before {
  color: #6c757d;
  content: attr(data-placeholder);
  pointer-events: none;
}

.rich-message-input img,
.rich-signature-preview img {
  max-width: 100%;
  height: auto;
}

.rich-signature-preview {
  padding: 0.75rem;
  border-top: 1px solid #dee2e6;
  background: #fff;
  overflow-x: auto;
}

.mail-table tr.mail-row-unread > td {
  background-color: #dbeafe !important;
  border-color: #bfdbfe;
  color: #0f2745;
  font-weight: 600;
}

.mail-table tr.mail-row-unread:hover > td {
  background-color: #cfe2ff !important;
}

.mail-table tr.mail-row-unread .text-muted {
  color: #475569 !important;
}

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

@media (max-width: 767px) {
  .app-row {
    display: block;
  }
  .sidebar {
    min-height: auto;
  }
  .sidebar-collapsible,
  .sidebar-collapsible:hover,
  .sidebar-collapsible:focus-within {
    width: 100%;
    flex-basis: auto;
    position: static;
    box-shadow: none;
  }
  .sidebar-collapsible:not(:hover):not(:focus-within) .nav-link {
    font-size: 1rem;
    min-height: 48px;
  }
  .sidebar-collapsible:not(:hover):not(:focus-within) .nav-link i {
    margin-right: 0.5rem !important;
  }
  .sidebar-collapsible:not(:hover):not(:focus-within) .sidebar-logo {
    justify-content: flex-start;
  }
  .sidebar-collapsible:not(:hover):not(:focus-within) .sidebar-logo img {
    width: 100%;
    height: auto;
    max-width: 230px;
  }
  .extracted-grid {
    grid-template-columns: 1fr;
  }
}

.table > :not(caption) > * > * {
  vertical-align: middle;
}

.print-header {
  border-bottom: 4px solid var(--daj-blue);
}

.quote-document {
  color: #1f2937;
}

.quote-items-table th:nth-child(1),
.quote-items-table td:nth-child(1) {
  width: 56%;
}

.quote-items-table th:nth-child(n+2),
.quote-items-table td:nth-child(n+2) {
  white-space: nowrap;
}

@media print {
  @page {
    size: letter portrait;
    margin: 13mm;
  }

  .no-print {
    display: none !important;
  }

  html,
  body {
    background: #fff;
    width: 100%;
    min-width: 0;
  }

  body {
    color: #111827;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10.5pt;
    line-height: 1.35;
    font-synthesis: none;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    text-rendering: optimizeLegibility;
  }

  body.pdf-export .quote-document,
  body.pdf-export .quote-document * {
    -webkit-user-select: text !important;
    user-select: text !important;
    text-shadow: none !important;
    filter: none !important;
  }

  .app-shell,
  .app-row,
  .app-main {
    display: block;
    width: 100%;
    min-height: 0;
    padding: 0 !important;
    margin: 0 !important;
  }

  .panel-card {
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .quote-document {
    color: #111827;
    font-size: 10.5pt;
    letter-spacing: 0;
    word-spacing: normal;
  }

  .quote-document h2,
  .quote-document .h4,
  .quote-document .h5,
  .quote-document .fw-semibold,
  .quote-document strong,
  .quote-document th {
    color: #0f2745 !important;
    font-weight: 700;
  }

  .quote-document .text-muted {
    color: #374151 !important;
  }

  .quote-document .badge-status {
    background: #e8f1fb !important;
    color: #0f2745 !important;
    border: 1px solid #c7d7ea;
  }

  .document-logo {
    width: auto;
    max-width: 48mm;
    height: 22mm;
    object-fit: contain;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .table-responsive {
    overflow: visible;
  }

  table {
    width: 100% !important;
    border-collapse: collapse;
    table-layout: auto;
  }

  thead {
    display: table-header-group;
  }

  tr,
  .print-header {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .quote-document p,
  .quote-document td,
  .quote-document th {
    orphans: 3;
    widows: 3;
  }

  .table > :not(caption) > * > * {
    color: #111827;
    padding: 2mm 1.8mm;
    vertical-align: top;
    overflow-wrap: break-word;
    border-color: #d1d5db;
  }

  .quote-items-table th:nth-child(1),
  .quote-items-table td:nth-child(1) {
    width: 58%;
  }

  .quote-items-table th:nth-child(n+2),
  .quote-items-table td:nth-child(n+2) {
    width: 14%;
    text-align: right;
    white-space: nowrap;
  }

  p,
  .quote-document .row,
  .quote-document .d-flex {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
.email-rendered-content {
    line-height: 1.55;
    overflow-wrap: anywhere;
    max-width: 100%;
}

.email-rendered-content img {
    display: inline-block;
    max-width: 100%;
    height: auto;
}

.email-rendered-content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
}

.email-rendered-content a {
    word-break: break-word;
}

.email-attachments {
    border-top: 1px solid var(--bs-border-color);
    padding-top: 1rem;
}

.rich-text-editor img {
    cursor: pointer;
}

.rich-text-editor img.rich-image-selected {
    outline: 2px solid var(--daj-blue);
    outline-offset: 2px;
}

.rich-text-editor img.rich-image-selected:hover {
    cursor: nwse-resize;
}

.rich-text-editor img.rich-image-resizing {
    user-select: none;
    opacity: 0.92;
}

.rich-text-editor table {
    border-collapse: collapse;
    border-spacing: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: none;
}

.rich-text-editor td,
.rich-text-editor th {
    position: relative;
    vertical-align: top;
    margin: 0 !important;
    padding: 0 !important;
}

.rich-text-editor .rich-table-cell-selected {
    outline: 2px dashed var(--daj-blue);
    outline-offset: -2px;
}

.rich-text-editor .rich-table-cell-selected:hover {
    cursor: col-resize;
}

.rich-text-editor .rich-table-cell-resizing {
    background-color: rgba(8, 119, 255, 0.06);
    user-select: none;
}

.signature-modal-dialog {
    width: min(92vw, 1050px);
    max-width: min(92vw, 1050px);
}

.signature-modal-dialog .modal-content {
    width: 100%;
    min-width: min(560px, 92vw);
    min-height: 560px;
    max-width: 96vw;
    max-height: 94vh;
    resize: both;
    overflow: auto;
}

.signature-modal-dialog .modal-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: auto;
}

.signature-modal-dialog .rich-text-editor {
    flex: 1 1 380px;
    min-height: 380px;
    resize: none;
}

@media (max-width: 767.98px) {
    .signature-modal-dialog {
        width: calc(100vw - 1rem);
        max-width: calc(100vw - 1rem);
        margin: .5rem auto;
    }

    .signature-modal-dialog .modal-content {
        min-width: 0;
        min-height: 480px;
        resize: vertical;
    }
}
