/* Typeface: Inter, self-hosted so every page renders the same files (no third-party font requests). */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/Inter-400.ttf') format('truetype'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/Inter-500.ttf') format('truetype'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/Inter-600.ttf') format('truetype'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/Inter-700.ttf') format('truetype'); }

/* Small overrides on top of Tailwind. Brand: navy #0b3d5c, teal #0e7c86, sand #f5efe6 */
:root { --dk-navy: #0b3d5c; --dk-teal: #0e7c86; }
html, body, input, select, textarea, button { font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }
html { font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11'; -webkit-font-smoothing: antialiased; }

/* Portal data tables scroll inside their own box (both directions) with a sticky header,
   so the page header, filters and pagination stay put. */
.dk-table {
  max-height: calc(100vh - 15rem);
  min-height: 12rem;
  overflow: auto;
  overscroll-behavior: contain;
}
.dk-table--short { max-height: 24rem; }
.dk-table table { border-collapse: separate; border-spacing: 0; }
.dk-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  box-shadow: inset 0 -1px 0 #e2e8f0;
}
@media (max-width: 767px) { .dk-table { max-height: calc(100vh - 14rem); } }

/* Pipeline board: columns scroll horizontally, cards scroll inside each column. */
.dk-board { max-height: calc(100vh - 14rem); }
.dk-board > .dk-column { display: flex; flex-direction: column; max-height: 100%; }
.dk-board .dk-column-body { overflow-y: auto; overscroll-behavior: contain; }

/* Portal type scale: 14px body text everywhere in the content area (headings keep their explicit sizes). */
.portal-main { overflow-x: clip; font-size: 0.875rem; line-height: 1.5; }
.portal-main input, .portal-main select, .portal-main textarea, .portal-main button { font-size: 0.875rem; }
.portal-main .dk-select { font-size: 0.875rem; }
.portal-main select, .portal-main input, .portal-main textarea { max-width: 100%; min-width: 0; }
.portal-main .grid > * { min-width: 0; }

/* Portal sidebar: collapsible icon rail on desktop (state class lives on <html>). */
.sb-icon-expand { display: none; }
@media (min-width: 768px) {
  .sidebar-collapsed .portal-sidebar { width: 4.5rem; }
  .sidebar-collapsed .portal-shell { padding-left: 4.5rem; }
  .sidebar-collapsed .sb-label, .sidebar-collapsed .sb-group { display: none; }
  .sidebar-collapsed .sb-only-collapsed { display: flex; }
  .sidebar-collapsed .sb-item { justify-content: center; padding-left: 0; padding-right: 0; }
  .sidebar-collapsed .sb-item > span:first-child { left: -0.75rem; }
  .sidebar-collapsed .sb-collapse { margin-left: 0; }
  .sidebar-collapsed .portal-sidebar > div:first-child { flex-direction: column; height: auto; padding: 0.75rem 0; gap: 0.5rem; }
  .sidebar-collapsed .portal-sidebar .border-t > div { justify-content: center; padding: 0; }
  .sidebar-collapsed .sb-icon-collapse { display: none; }
  .sidebar-collapsed .sb-icon-expand { display: inline; }
}


/* ---- Data tables: quiet header, roomy rows, soft dividers (portal standard) */
.dk-table { background: #fff; }
.dk-table table { width: 100%; }
.dk-table thead th {
  text-transform: none; letter-spacing: 0; font-size: 0.8rem; font-weight: 500; color: #64748b;
  background: #f8fafc; padding: 0.8rem 1rem; box-shadow: inset 0 -1px 0 #e2e8f0; white-space: nowrap;
}
.dk-table thead th a { color: inherit; display: inline-flex; align-items: center; gap: 0.25rem; }
.dk-table thead th a:hover { color: #0b3d5c; }
.dk-table thead th .sort-ico { color: #cbd5e1; } .dk-table thead th.sorted .sort-ico { color: #0e7c86; }
.dk-table tbody td { padding: 0.95rem 1rem; font-size: 0.875rem; color: #334155; vertical-align: middle; border-bottom: 1px solid #f1f5f9; }
.dk-table tbody tr:last-child td { border-bottom: 0; }
.dk-table tbody tr:hover td { background: #fafafa; }
.dk-table tbody tr.is-selected td { background: #f0fdfa; }
.dk-table td.num, .dk-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dk-table .row-actions { display: inline-flex; gap: 0.25rem; justify-content: flex-end; }
.dk-table .row-actions a, .dk-table .row-actions button { display: inline-flex; height: 1.9rem; width: 1.9rem; align-items: center; justify-content: center; border-radius: 0.375rem; color: #94a3b8; }
.dk-table .row-actions a:hover { background: #f1f5f9; color: #0b3d5c; }
.dk-table .row-actions a.danger:hover { background: #fef2f2; color: #dc2626; }
.dk-check { height: 1rem; width: 1rem; border-radius: 0.25rem; border: 1.5px solid #cbd5e1; accent-color: #0e7c86; cursor: pointer; }

/* status filter tabs above tables */
.dk-tabs { display: flex; gap: 0.25rem; overflow-x: auto; border-bottom: 1px solid #e2e8f0; margin-bottom: 1rem; }
.dk-tabs a { white-space: nowrap; padding: 0.6rem 0.9rem; font-size: 0.875rem; color: #64748b; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.dk-tabs a:hover { color: #0b3d5c; }
.dk-tabs a.on { color: #0b3d5c; font-weight: 600; border-color: #0b3d5c; }
.dk-tabs a .n { margin-left: 0.35rem; border-radius: 999px; background: #f1f5f9; padding: 0.05rem 0.45rem; font-size: 0.72rem; color: #475569; }
.dk-tabs a.on .n { background: #0b3d5c; color: #fff; }

/* floating bulk-selection bar */
#bulk-bar { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); z-index: 35; display: none; align-items: center; gap: 0.5rem;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 0.75rem; box-shadow: 0 10px 30px rgba(15, 23, 42, .15); padding: 0.5rem 0.75rem; font-size: 0.875rem; }
#bulk-bar.on { display: flex; }
#bulk-bar button { display: inline-flex; align-items: center; gap: 0.35rem; border: 1px solid #e2e8f0; border-radius: 0.5rem; padding: 0.4rem 0.7rem; }
#bulk-bar button:hover { background: #f8fafc; }

/* Portal forms: fill the page with up to three columns; long controls span the whole row. */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem 1.5rem; align-items: start; }
@media (min-width: 768px)  { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.form-grid > div:has(textarea), .form-grid > div:has(input[type="file"]), .form-grid > div:has(.grid),
.form-grid > .span-all, .form-grid > p { grid-column: 1 / -1; }
.form-grid > div:has(input[type="checkbox"]:only-of-type):not(:has(.grid)) { align-self: end; padding-bottom: .55rem; }
.form-grid textarea { min-height: 7rem; }
.form-card { background: #fff; border: 1px solid #e2e8f0; border-radius: .75rem; padding: 1.5rem; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid #f1f5f9; }

/* ---- dk-select: custom searchable dropdowns (native select stays in the DOM, visually hidden) */
select.dk-select__native { position: absolute !important; width: 1px; height: 1px; opacity: 0; pointer-events: none; margin: 0; }
.dk-select { position: relative; width: 100%; font-size: 0.9rem; }
.dk-select__control { display: flex; width: 100%; min-height: 2.6rem; align-items: center; gap: 0.5rem; border: 1px solid #cbd5e1; border-radius: 0.5rem; background: #fff; padding: 0.35rem 0.75rem; text-align: left; color: #1e293b; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); transition: border-color .15s, box-shadow .15s; }
.dk-select__control:hover { border-color: #94a3b8; }
.dk-select.is-open .dk-select__control, .dk-select__control:focus-visible { outline: none; border-color: #0e7c86; box-shadow: 0 0 0 3px rgba(14, 124, 134, .15); }
.dk-select.is-disabled .dk-select__control { background: #f8fafc; color: #94a3b8; cursor: not-allowed; }
.dk-select__value { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; overflow: hidden; }
.dk-select:not(.dk-select--multi) .dk-select__value { display: block; white-space: nowrap; text-overflow: ellipsis; }
.dk-select__placeholder { color: #94a3b8; }
.dk-select__chevron { color: #64748b; display: inline-flex; transition: transform .15s; }
.dk-select.is-open .dk-select__chevron { transform: rotate(180deg); }
.dk-select__pop { position: absolute; z-index: 60; left: 0; right: 0; margin-top: 0.35rem; background: #fff; border: 1px solid #e2e8f0; border-radius: 0.75rem; box-shadow: 0 16px 40px rgba(15, 23, 42, .14); padding: 0.4rem; }
.dk-select__pop--up { bottom: calc(100% + 0.35rem); margin-top: 0; }
.dk-select__search { width: 100%; border: 1px solid #e2e8f0; border-radius: 0.5rem; padding: 0.45rem 0.7rem; font-size: 0.875rem; margin-bottom: 0.35rem; }
.dk-select__search:focus { outline: none; border-color: #0e7c86; box-shadow: 0 0 0 3px rgba(14, 124, 134, .12); }
.dk-select__list { max-height: 16rem; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.dk-select__option { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0.75rem; border-radius: 0.5rem; cursor: pointer; color: #1e293b; }
.dk-select__option.is-active { background: #f1f5f9; }
.dk-select__option.is-selected { background: #ecfeff; color: #0b3d5c; font-weight: 500; }
.dk-select__option.is-selected.is-active { background: #cffafe; }
.dk-select__option.is-disabled { color: #cbd5e1; cursor: not-allowed; }
.dk-select__option.is-placeholder { color: #94a3b8; }
.dk-select__check { color: #0e7c86; display: inline-flex; }
.dk-select__empty { padding: 0.75rem; text-align: center; color: #94a3b8; font-size: 0.85rem; }
.dk-select__chip { display: inline-flex; align-items: center; gap: 0.3rem; border-radius: 999px; background: #ecfeff; color: #0b3d5c; padding: 0.15rem 0.35rem 0.15rem 0.6rem; font-size: 0.8rem; font-weight: 500; }
.dk-select__chip-x { display: inline-flex; align-items: center; justify-content: center; width: 1.1rem; height: 1.1rem; border-radius: 999px; color: #0e7c86; }
.dk-select__chip-x:hover { background: #0e7c86; color: #fff; }
.dk-table .dk-select__control, form.grid .dk-select__control { min-height: 2.5rem; }

/* ---- form design: sections with a sticky index, inline errors, radio cards */
.form-layout { display: grid; gap: 1.5rem; align-items: start; }
@media (min-width: 1280px) { .form-layout.has-index { grid-template-columns: 13rem minmax(0, 1fr); } }
.form-index { position: sticky; top: 5.25rem; display: none; }
@media (min-width: 1280px) { .form-layout.has-index .form-index { display: block; } }
.form-index a { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.8rem; border-radius: 0.5rem; font-size: 0.875rem; color: #64748b; }
.form-index a::before { content: ''; width: 0.4rem; height: 0.4rem; border-radius: 999px; background: #cbd5e1; }
.form-index a:hover { color: #0b3d5c; background: #f8fafc; }
.form-index a.on { background: #eef6fb; color: #0b3d5c; font-weight: 600; } .form-index a.on::before { background: #0e7c86; }
.form-section { padding: 1.5rem; }
.form-section + .form-section { border-top: 1px solid #f1f5f9; }
.form-section h2 { font-size: 1.05rem; font-weight: 600; color: #0f172a; }
.form-section .form-section__sub { margin-top: 0.15rem; font-size: 0.85rem; color: #64748b; }
.form-section .form-grid { margin-top: 1.1rem; }
.form-card { padding: 0; overflow: visible; }
.form-card > .form-grid, .form-card > .form-actions { padding-left: 1.5rem; padding-right: 1.5rem; }
.form-card > .form-grid { padding-top: 1.5rem; }
.form-card > .form-actions { padding-bottom: 1.5rem; margin-top: 0; padding-top: 1.25rem; border-top: 1px solid #f1f5f9; }
.form-section + .form-actions { margin-top: 0; }
.field label { font-size: 0.875rem; font-weight: 500; color: #334155; }
.field .help { font-size: 0.78rem; color: #64748b; margin-top: 0.35rem; line-height: 1.4; }
.field.has-error input, .field.has-error select, .field.has-error textarea, .field.has-error .dk-select__control { border-color: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .10); }
.field .error { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: #dc2626; margin-top: 0.35rem; }
.field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field textarea { box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.field input:focus, .field textarea:focus { border-color: #0e7c86; box-shadow: 0 0 0 3px rgba(14, 124, 134, .15); outline: none; }
.field input[type=file] { padding: 0.45rem; border: 1px dashed #cbd5e1; border-radius: 0.5rem; background: #f8fafc; font-size: 0.85rem; width: 100%; }
.field ul { display: grid; gap: 0.4rem; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); margin: 0; padding: 0; list-style: none; }
.field ul li label { display: flex; align-items: center; gap: 0.55rem; border: 1px solid #e2e8f0; border-radius: 0.5rem; padding: 0.5rem 0.75rem; font-weight: 400; cursor: pointer; }
.field ul li label:has(input:checked) { border-color: #0e7c86; background: #ecfeff; color: #0b3d5c; }

/* ---- mail */
.mail-row { display: grid; grid-template-columns: 2rem 10rem minmax(0, 1fr) 4rem; gap: 0.75rem; align-items: center; padding: 0.65rem 1.1rem; border-top: 1px solid #f1f5f9; color: #475569; font-size: 0.875rem; }
.mail-row:hover { background: #fafafa; }
.mail-row.is-unread { color: #0f172a; }
.mail-row.is-unread .mail-subject { font-weight: 600; }
.mail-avatar { display: inline-flex; height: 2rem; width: 2rem; flex: none; align-items: center; justify-content: center; border-radius: 999px; color: #fff; font-weight: 600; font-size: 0.8rem; }
.mail-from { display: flex; align-items: center; min-width: 0; font-weight: 500; }
.mail-main { min-width: 0; }
.mail-subject { color: inherit; }
.mail-snippet { color: #94a3b8; font-weight: 400; font-size: 0.85rem; }
.mail-dot { display: inline-block; height: 0.5rem; width: 0.5rem; flex: none; border-radius: 999px; background: #ef4444; }
.mail-meta { display: flex; align-items: center; justify-content: flex-end; gap: 0.35rem; font-size: 0.75rem; color: #64748b; white-space: nowrap; }
.mail-chip { display: inline-flex; align-items: center; gap: 0.3rem; border: 1px solid #e2e8f0; border-radius: 0.4rem; padding: 0.15rem 0.5rem; font-size: 0.72rem; color: #475569; background: #fff; }
.mail-chip--lead { border-color: #a5f3fc; background: #ecfeff; color: #0b3d5c; }
@media (max-width: 640px) { .mail-row { grid-template-columns: 2.25rem minmax(0, 1fr) 3.5rem; } .mail-from { display: none; } }
article.is-collapsed .mail-body { display: none; }
article:not(.is-collapsed) .mail-collapsed-preview { display: none; }
.mail-frame { border: 0; min-height: 5rem; background: #fff; }
.mail-header { font-size: 0.875rem; }
.mail-header .mail-avatar { height: 2.25rem; width: 2.25rem; }
.mail-attach { display: inline-flex; max-width: 18rem; align-items: center; gap: 0.6rem; border: 1px solid #e2e8f0; border-radius: 0.5rem; padding: 0.4rem 0.6rem; }
.mail-attach:hover { border-color: #0e7c86; background: #f8fafc; }

/* ---- rich text editor (Quill) */
.dk-editor .ql-toolbar.ql-snow { border: 1px solid #cbd5e1; border-bottom: 0; border-radius: 0.5rem 0.5rem 0 0; background: #f8fafc; padding: 0.35rem 0.5rem; }
.dk-editor .ql-container.ql-snow { border: 1px solid #cbd5e1; border-radius: 0 0 0.5rem 0.5rem; font-family: inherit; font-size: 0.9rem; min-height: 12rem; background: #fff; }
.dk-editor .ql-editor { min-height: 12rem; line-height: 1.6; color: #1e293b; }
.dk-editor .ql-editor.ql-blank::before { color: #94a3b8; font-style: normal; }
.dk-editor:focus-within .ql-toolbar.ql-snow, .dk-editor:focus-within .ql-container.ql-snow { border-color: #0e7c86; }
.dk-editor .ql-snow .ql-stroke { stroke: #475569; } .dk-editor .ql-snow .ql-fill { fill: #475569; }
.mail-quote details { border: 1px solid #e2e8f0; border-radius: 0.5rem; background: #f8fafc; }
.mail-quote summary { cursor: pointer; padding: 0.6rem 0.9rem; font-size: 0.85rem; color: #475569; list-style: none; display: flex; align-items: center; gap: 0.5rem; }
.mail-quote summary::-webkit-details-marker { display: none; }
.mail-quote .quoted { padding: 0 1rem 1rem; border-left: 3px solid #cbd5e1; margin: 0 1rem 1rem; color: #64748b; font-size: 0.85rem; white-space: pre-wrap; max-height: 20rem; overflow: auto; }
.reply-row { display: grid; grid-template-columns: 3.5rem minmax(0, 1fr); align-items: center; gap: 0.5rem; border-bottom: 1px solid #f1f5f9; padding: 0.35rem 0; }
.reply-row label { font-size: 0.8rem; color: #64748b; }
.reply-row input { border: 0 !important; box-shadow: none !important; padding-left: 0 !important; background: transparent; }
.reply-row input:focus { outline: none; box-shadow: none !important; }
