/* ==========================================================================
   9Dot Admin Panel — theme
   Bootstrap 5.3 is loaded first; everything here layers on top of it.
   ========================================================================== */

:root {
    --nd-sidebar-w: 264px;
    --nd-sidebar-w-collapsed: 74px;
    --nd-topbar-h: 62px;

    --nd-body: #f1f4f9;
    --nd-surface: #ffffff;
    --nd-border: #e4e9f2;
    --nd-ink: #1f2a44;
    --nd-ink-soft: #6b7a99;

    --nd-sidebar-bg: #14203c;
    --nd-sidebar-bg-2: #1c2c50;
    --nd-sidebar-ink: #b8c4dd;
    --nd-sidebar-ink-active: #ffffff;

    --bs-primary: #2f6fed;
    --bs-primary-rgb: 47, 111, 237;

    --nd-purple: #7c4dff;
    --nd-teal: #0ea5a5;
    --nd-orange: #f97316;

    --nd-radius: 12px;
    --nd-shadow: 0 1px 2px rgba(20, 32, 60, .05), 0 8px 24px -18px rgba(20, 32, 60, .35);
}

/* ---------- base ---------- */
body {
    background: var(--nd-body);
    color: var(--nd-ink);
    font-family: "Segoe UI", Inter, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: .9rem;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }
a:hover { text-decoration: none; }

.text-muted-2 { color: var(--nd-ink-soft) !important; }
.fw-600 { font-weight: 600; }
.fs-13 { font-size: .8125rem; }
.fs-12 { font-size: .75rem; }
.fs-11 { font-size: .6875rem; }
.letter-wide { letter-spacing: .04em; }
.mono { font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace; }

.btn { --bs-btn-font-size: .85rem; border-radius: 9px; font-weight: 500; }
.btn-sm { --bs-btn-font-size: .78rem; border-radius: 8px; }
.btn-primary { background: var(--bs-primary); border-color: var(--bs-primary); }
.btn-primary:hover { background: #2560d4; border-color: #2560d4; }

.form-control, .form-select { border-radius: 9px; border-color: var(--nd-border); font-size: .85rem; }
.form-control:focus, .form-select:focus {
    border-color: #a8c2f8;
    box-shadow: 0 0 0 .18rem rgba(47, 111, 237, .13);
}
.form-control-sm, .form-select-sm { font-size: .8rem; border-radius: 8px; }
.form-label { font-size: .78rem; font-weight: 600; color: #3d4a66; margin-bottom: .3rem; }
.form-label .req { color: #dc3545; }
.form-text { font-size: .72rem; }
textarea.form-control { min-height: 84px; }

.card {
    background: var(--nd-surface);
    border: 1px solid var(--nd-border);
    border-radius: var(--nd-radius);
    box-shadow: var(--nd-shadow);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--nd-border);
    padding: .85rem 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.card-body { padding: 1.1rem; }

/* ---------- soft badges (driven by master-value colours) ---------- */
.badge {
    font-weight: 600;
    font-size: .72rem;
    padding: .34em .62em;
    border-radius: 7px;
}
.badge-soft-primary   { background: rgba(47, 111, 237, .12); color: #1e4fbd; }
.badge-soft-secondary { background: rgba(107, 122, 153, .14); color: #55637f; }
.badge-soft-success   { background: rgba(25, 160, 96, .14);  color: #12794a; }
.badge-soft-danger    { background: rgba(220, 53, 69, .13);  color: #b02330; }
.badge-soft-warning   { background: rgba(240, 173, 20, .18); color: #96660a; }
.badge-soft-info      { background: rgba(14, 165, 233, .14); color: #0b7ba8; }
.badge-soft-dark      { background: rgba(31, 42, 68, .12);   color: #1f2a44; }
.badge-soft-purple    { background: rgba(124, 77, 255, .13); color: #5b32c9; }
.badge-soft-teal      { background: rgba(14, 165, 165, .14); color: #0a7d7d; }
.badge-soft-orange    { background: rgba(249, 115, 22, .15); color: #c1580d; }

/* Bootstrap has no purple/teal/orange text utilities; the panel uses them. */
.text-purple { color: var(--nd-purple) !important; }
.text-teal { color: var(--nd-teal) !important; }
.text-orange { color: var(--nd-orange) !important; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-primary { background: #2f6fed; } .dot-secondary { background: #6b7a99; }
.dot-success { background: #19a060; } .dot-danger { background: #dc3545; }
.dot-warning { background: #f0ad14; } .dot-info { background: #0ea5e9; }
.dot-dark { background: #1f2a44; }    .dot-purple { background: #7c4dff; }
.dot-teal { background: #0ea5a5; }    .dot-orange { background: #f97316; }

/* ---------- layout ---------- */
.nd-shell { display: flex; min-height: 100vh; }

.nd-sidebar {
    width: var(--nd-sidebar-w);
    flex: 0 0 var(--nd-sidebar-w);
    background: linear-gradient(178deg, var(--nd-sidebar-bg) 0%, var(--nd-sidebar-bg-2) 100%);
    color: var(--nd-sidebar-ink);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .22s ease;
}
.nd-brand {
    height: var(--nd-topbar-h);
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    flex: 0 0 auto;
}
.nd-brand-mark {
    width: 34px; height: 34px; border-radius: 9px;
    background: linear-gradient(135deg, #2f6fed, #7c4dff);
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: .95rem;
    flex: 0 0 auto;
}
.nd-brand-text { color: #fff; font-weight: 700; font-size: .98rem; line-height: 1.1; }
.nd-brand-text small { display: block; font-weight: 400; font-size: .66rem; color: #8fa2c8; letter-spacing: .06em; text-transform: uppercase; }

.nd-nav { flex: 1 1 auto; overflow-y: auto; padding: .8rem .6rem 1.5rem; }
.nd-nav::-webkit-scrollbar { width: 6px; }
.nd-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 3px; }

.nd-nav-label {
    font-size: .64rem; text-transform: uppercase; letter-spacing: .12em;
    color: #6d7fa5; padding: .9rem .75rem .35rem; font-weight: 700;
}
.nd-link {
    display: flex; align-items: center; gap: .68rem;
    padding: .56rem .75rem; margin-bottom: 2px;
    border-radius: 9px; color: var(--nd-sidebar-ink);
    font-size: .845rem; font-weight: 500;
    transition: background .15s, color .15s;
}
.nd-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nd-link i:first-child { font-size: 1.02rem; width: 18px; text-align: center; flex: 0 0 auto; }
.nd-link.active { background: rgba(47, 111, 237, .22); color: var(--nd-sidebar-ink-active); box-shadow: inset 2px 0 0 #4f8bff; }
.nd-link .nd-count {
    margin-left: auto; background: rgba(255, 255, 255, .12); color: #dce5f7;
    font-size: .66rem; font-weight: 700; border-radius: 20px; padding: .1rem .42rem;
}
.nd-link .nd-count.is-alert { background: rgba(220, 53, 69, .85); color: #fff; }
.nd-link .nd-count.is-new { background: rgba(25, 135, 84, .9); color: #fff; }
/* When a menu carries more than one badge, keep them (and the chevron) apart. */
.nd-link .nd-count + .nd-count { margin-left: .3rem; }
.nd-link .nd-count + .bi-chevron-down { margin-left: .3rem; }
.nd-sub { padding-left: .55rem; margin: 0 0 .3rem; }
.nd-sub .nd-link { font-size: .8rem; padding: .42rem .7rem; color: #9daac7; }
.nd-sub .nd-link.active { background: rgba(255, 255, 255, .08); box-shadow: none; color: #fff; }
.nd-link[data-bs-toggle] .bi-chevron-down { margin-left: auto; font-size: .7rem; transition: transform .18s; }
.nd-link[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }

.nd-main { flex: 1 1 auto; margin-left: var(--nd-sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.nd-topbar {
    height: var(--nd-topbar-h);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--nd-border);
    display: flex; align-items: center; gap: .8rem;
    padding: 0 1.1rem;
    position: sticky; top: 0; z-index: 1030;
}
.nd-content { padding: 1.15rem 1.15rem 3rem; flex: 1 1 auto; }

.nd-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, #2f6fed, #7c4dff);
    color: #fff; display: grid; place-items: center; font-size: .78rem; font-weight: 700;
}

.nd-backdrop { display: none; }

@media (max-width: 991.98px) {
    .nd-sidebar { transform: translateX(-100%); }
    body.nd-sidebar-open .nd-sidebar { transform: translateX(0); }
    .nd-main { margin-left: 0; }
    body.nd-sidebar-open .nd-backdrop {
        display: block; position: fixed; inset: 0;
        background: rgba(15, 23, 42, .45); z-index: 1035;
    }
}

/* ---------- page header ---------- */
.nd-page-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .75rem; margin-bottom: 1rem; }
.nd-page-head h1 { font-size: 1.22rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.nd-page-head .subtitle { font-size: .8rem; color: var(--nd-ink-soft); margin-top: .15rem; }
.breadcrumb { --bs-breadcrumb-divider: '›'; font-size: .75rem; margin: 0 0 .25rem; }
.breadcrumb a { color: var(--nd-ink-soft); }
.breadcrumb-item.active { color: var(--nd-ink); font-weight: 600; }

/* ---------- stat cards ---------- */
.nd-stat {
    background: var(--nd-surface); border: 1px solid var(--nd-border);
    border-radius: var(--nd-radius); padding: .95rem 1rem;
    box-shadow: var(--nd-shadow); height: 100%;
    display: flex; flex-direction: column; gap: .35rem;
    position: relative; overflow: hidden;
    transition: transform .16s ease, box-shadow .16s ease;
}
a.nd-stat:hover { transform: translateY(-2px); box-shadow: 0 10px 26px -16px rgba(20, 32, 60, .45); }
.nd-stat .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--nd-ink-soft); font-weight: 700; }
.nd-stat .value { font-size: 1.42rem; font-weight: 700; line-height: 1.1; color: var(--nd-ink); }
.nd-stat .hint { font-size: .72rem; color: var(--nd-ink-soft); }
.nd-stat .icon {
    position: absolute; top: .8rem; right: .85rem;
    width: 36px; height: 36px; border-radius: 10px;
    display: grid; place-items: center; font-size: 1.05rem;
}

/* ---------- auto-fill grids ----------
   Cards flow to fill whatever width is available and wrap when they run out,
   so no breakpoint leaves a half-empty row. --min sets the narrowest a tile is
   allowed to get before the grid drops a column. */
.nd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--min, 250px), 1fr));
    gap: .7rem;
}
.nd-grid.tight { gap: .55rem; }

/* Compact KPI strip — denser than .nd-stat, made to sit above a card grid. */
.nd-stats { --min: 150px; display: grid; grid-template-columns: repeat(auto-fit, minmax(var(--min), 1fr)); gap: .6rem; }
.nd-stats .nd-stat { padding: .6rem .7rem; gap: .15rem; }
.nd-stats .nd-stat .value { font-size: 1.18rem; }
.nd-stats .nd-stat .icon { width: 26px; height: 26px; font-size: .8rem; top: .55rem; right: .55rem; border-radius: 8px; }
.nd-stats .nd-stat .label { font-size: .64rem; padding-right: 30px; }
.nd-stats .nd-stat .hint { font-size: .68rem; }

/* ---------- compact tile ----------
   The card used across App Setting: a coloured status rail, a tight header,
   and rows of label/value that stay legible down to a phone. */
.nd-tile {
    background: var(--nd-surface);
    border: 1px solid var(--nd-border);
    border-radius: var(--nd-radius);
    box-shadow: var(--nd-shadow);
    display: flex; flex-direction: column;
    overflow: hidden; position: relative;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.nd-tile:hover { border-color: #cfd9ea; box-shadow: 0 10px 26px -18px rgba(20, 32, 60, .5); }

/* Status rail down the left edge — colour carries the state at a glance. */
.nd-tile::before {
    content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
    background: var(--rail, transparent);
}
.nd-tile.rail-success { --rail: #16a34a; }
.nd-tile.rail-danger  { --rail: #dc2626; }
.nd-tile.rail-warning { --rail: #f59e0b; }
.nd-tile.rail-info    { --rail: #0ea5e9; }
.nd-tile.rail-secondary { --rail: #94a3b8; }

.nd-tile-head {
    display: flex; align-items: flex-start; gap: .5rem;
    padding: .6rem .75rem .5rem .85rem;
    border-bottom: 1px solid var(--nd-border);
}
.nd-tile-head .t { min-width: 0; flex: 1; }
.nd-tile-head .name {
    font-size: .84rem; font-weight: 700; color: var(--nd-ink);
    text-decoration: none; display: block;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nd-tile-head .name:hover { color: var(--bs-primary); }
.nd-tile-head .sub {
    font-size: .7rem; color: var(--nd-ink-soft); margin-top: .1rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nd-tile-body { padding: .55rem .75rem .6rem .85rem; flex: 1; }
.nd-tile-foot {
    padding: .45rem .75rem .5rem .85rem;
    border-top: 1px solid var(--nd-border);
    background: #fbfcfe;
    display: flex; align-items: center; gap: .35rem; flex-wrap: wrap;
}

/* Two-column label/value rows inside a tile — the dense alternative to a table. */
.nd-tile-rows { display: grid; grid-template-columns: auto 1fr; gap: .18rem .6rem; font-size: .76rem; }
.nd-tile-rows dt { color: var(--nd-ink-soft); font-weight: 500; white-space: nowrap; }
.nd-tile-rows dd { margin: 0; font-weight: 600; text-align: right; word-break: break-word; }

/* Chip row for endpoints, platforms, flags. */
.nd-chips { display: flex; flex-wrap: wrap; gap: .25rem; }
.nd-chip {
    display: inline-flex; align-items: center; gap: .25rem;
    font-size: .69rem; font-weight: 600; line-height: 1.5;
    padding: .1rem .4rem; border-radius: 6px;
    background: #eef2f8; color: var(--nd-ink-soft); text-decoration: none;
}
a.nd-chip:hover { background: #e2e9f5; color: var(--nd-ink); }
.nd-chip.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nd-chip.on  { background: rgba(22, 163, 74, .12); color: #15803d; }
.nd-chip.off { background: rgba(220, 38, 38, .1); color: #b91c1c; }

/* One endpoint line inside a client's server card. */
.nd-endpoint {
    display: flex; align-items: center; gap: .45rem;
    padding: .3rem 0; font-size: .77rem;
    border-top: 1px dashed var(--nd-border);
}
.nd-endpoint:first-child { border-top: 0; padding-top: 0; }
.nd-endpoint .ep { min-width: 0; flex: 1; }
.nd-endpoint .ep .mono { display: block; font-weight: 600; }
.nd-endpoint .ep .lbl {
    display: block; font-size: .69rem; color: var(--nd-ink-soft);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nd-endpoint .flags { display: flex; gap: .25rem; font-size: .72rem; }
.nd-endpoint.is-off { opacity: .55; }
/* "view all" affordance under a client's first few endpoints. */
.nd-endpoint-more {
    display: flex; align-items: center; gap: .4rem; width: 100%;
    margin-top: .45rem; padding: .34rem .55rem;
    font-size: .74rem; font-weight: 600; text-align: left;
    color: var(--bs-primary);
    background: rgba(47, 111, 237, .06);
    border: 1px dashed rgba(47, 111, 237, .35); border-radius: 8px;
    cursor: pointer; transition: background .15s, border-color .15s;
}
.nd-endpoint-more:hover { background: rgba(47, 111, 237, .12); border-color: rgba(47, 111, 237, .55); }

/* A social media platform's icon, on App Setting → Social Media. */
.nd-social-icon {
    display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 1px;
    border-radius: 8px; font-size: 1.05rem;
    background: rgba(47, 111, 237, .1); color: var(--bs-primary);
}

/* A small square logo, shown wherever a company's branding is relevant. */
.nd-logo-thumb {
    width: 40px; height: 40px; flex: 0 0 auto;
    border: 1px solid var(--nd-border); border-radius: 9px;
    display: grid; place-items: center; overflow: hidden; background: #fff;
}
.nd-logo-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Inline empty state — a single line instead of a full-height panel. */
.nd-empty-inline {
    display: flex; align-items: center; gap: .4rem;
    font-size: .78rem; color: var(--nd-ink-soft);
    background: #f7f9fc; border: 1px dashed var(--nd-border);
    border-radius: 10px; padding: .5rem .7rem;
}

/* A card in the onboarding funnel — one submission, at a glance. */
.nd-funnel-card {
    display: block; text-decoration: none;
    border: 1px solid var(--nd-border); border-radius: 10px;
    padding: .45rem .55rem; margin-bottom: .4rem;
    background: #fbfcfe; transition: border-color .15s ease, background .15s ease;
}
.nd-funnel-card:hover { border-color: #cfd9ea; background: #fff; }
.nd-funnel-card .co {
    display: block; font-size: .8rem; font-weight: 700; color: var(--nd-ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nd-funnel-card .meta {
    display: block; font-size: .69rem; color: var(--nd-ink-soft);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nd-funnel-card .nd-chips, .nd-funnel-card .nd-chip { margin-top: .25rem; }

/* Section heading above a grid, with the count on the right. */
.nd-grid-head {
    display: flex; align-items: center; gap: .5rem;
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    color: var(--nd-ink-soft); margin: 0 0 .5rem;
}
.nd-grid-head .line { flex: 1; height: 1px; background: var(--nd-border); }

/* Inline switch that submits its row — used by Access Control. */
.nd-tile-switch { display: flex; align-items: center; gap: .4rem; font-size: .74rem; font-weight: 600; }
.nd-tile-switch .form-check { margin: 0; min-height: auto; }
.nd-tile-switch .form-check-input { margin-top: 0; }

@media (max-width: 575.98px) {
    /* Tiles go full width, but KPIs stay two-up — six stacked numbers is all
       scrolling and no information. */
    .nd-grid { --min: 100%; }
    .nd-stats { --min: 140px; gap: .45rem; }
    .nd-stats .nd-stat { padding: .5rem .55rem; }
    .nd-stats .nd-stat .value { font-size: 1.05rem; }
    .nd-tile-rows { font-size: .74rem; }
}

/* ---------- filter bar ---------- */
.nd-filters { padding: .85rem 1rem; border-bottom: 1px solid var(--nd-border); }
.nd-filters .filter-col { min-width: 0; }
.nd-filters label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--nd-ink-soft); font-weight: 700; margin-bottom: .22rem; display: block;
}
.nd-active-chip {
    display: inline-flex; align-items: center; gap: .3rem;
    background: rgba(47, 111, 237, .1); color: #1e4fbd;
    font-size: .72rem; font-weight: 600;
    padding: .2rem .5rem; border-radius: 20px;
}

/* ---------- tables ---------- */
.nd-table-wrap { overflow-x: auto; }
.table { --bs-table-bg: transparent; margin: 0; font-size: .845rem; }
.table > thead > tr > th {
    background: #f7f9fd; border-bottom: 1px solid var(--nd-border);
    font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
    color: #64748b; font-weight: 700; white-space: nowrap; padding: .6rem .8rem;
}
.table > tbody > tr > td { padding: .62rem .8rem; vertical-align: middle; border-color: #eef2f8; }
.table > tbody > tr:hover > td { background: #f8fafd; }
.table th a { color: inherit; display: inline-flex; align-items: center; gap: .3rem; }
.table-fixed-actions { width: 1%; white-space: nowrap; }

.nd-actions { display: inline-flex; gap: .25rem; }
.nd-act {
    width: 29px; height: 29px; border-radius: 8px;
    display: grid; place-items: center; font-size: .84rem;
    border: 1px solid var(--nd-border); background: #fff; color: #55637f;
    transition: all .14s;
}
.nd-act:hover { color: #fff; }
.nd-act.view:hover { background: #2f6fed; border-color: #2f6fed; }
.nd-act.doc:hover { background: #0ea5a5; border-color: #0ea5a5; }
.nd-act.edit:hover { background: #f0ad14; border-color: #f0ad14; }
.nd-act.pdf:hover { background: #7c4dff; border-color: #7c4dff; }
.nd-act.pay:hover { background: #19a060; border-color: #19a060; }
.nd-act.del:hover { background: #dc3545; border-color: #dc3545; }

.nd-cell-primary { font-weight: 600; color: var(--nd-ink); }
.nd-cell-sub { font-size: .74rem; color: var(--nd-ink-soft); }

/* ---------- empty state ---------- */
.nd-empty { padding: 3rem 1rem; text-align: center; color: var(--nd-ink-soft); }
.nd-empty i { font-size: 2.4rem; opacity: .35; display: block; margin-bottom: .6rem; }

/* ---------- forms ---------- */
.nd-form-section { border-bottom: 1px solid var(--nd-border); padding: 1.05rem 1.15rem; }
.nd-form-section:last-child { border-bottom: 0; }
.nd-form-section > .head { display: flex; align-items: center; gap: .5rem; margin-bottom: .9rem; }
.nd-form-section > .head .n {
    width: 24px; height: 24px; border-radius: 7px; flex: 0 0 auto;
    background: rgba(47, 111, 237, .12); color: #1e4fbd;
    display: grid; place-items: center; font-size: .72rem; font-weight: 700;
}
.nd-form-section > .head h6 { margin: 0; font-size: .88rem; font-weight: 700; }
.nd-form-section > .head .desc { font-size: .72rem; color: var(--nd-ink-soft); }

.nd-sticky-actions {
    position: sticky; bottom: 0; z-index: 5;
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(6px);
    border-top: 1px solid var(--nd-border);
    padding: .75rem 1.15rem; display: flex; gap: .5rem; justify-content: flex-end;
    border-radius: 0 0 var(--nd-radius) var(--nd-radius);
}

.nd-check-grid { display: flex; flex-wrap: wrap; gap: .4rem; }
.nd-check-grid .form-check {
    margin: 0; border: 1px solid var(--nd-border); border-radius: 8px;
    padding: .35rem .6rem .35rem 2rem; background: #fff; font-size: .82rem;
}
.nd-check-grid .form-check:has(input:checked) { border-color: #a8c2f8; background: rgba(47, 111, 237, .06); }

/* repeatable rows (documents, invoice items) */
.nd-repeat-row { border: 1px dashed var(--nd-border); border-radius: 10px; padding: .7rem; margin-bottom: .6rem; background: #fbfcfe; }

/* ---------- detail / show pages ---------- */
.nd-dl { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: .1rem .8rem; font-size: .84rem; }
.nd-dl dt { color: var(--nd-ink-soft); font-weight: 500; padding: .3rem 0; }
.nd-dl dd { margin: 0; padding: .3rem 0; font-weight: 600; word-break: break-word; }

.nd-timeline { position: relative; padding-left: 1.5rem; }
.nd-timeline::before { content: ''; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--nd-border); }
.nd-timeline-item { position: relative; padding-bottom: 1rem; }
.nd-timeline-item::before {
    content: ''; position: absolute; left: -1.5rem; top: 4px;
    width: 14px; height: 14px; border-radius: 50%;
    background: #fff; border: 3px solid #2f6fed;
}
.nd-timeline-item .when { font-size: .72rem; color: var(--nd-ink-soft); }

.nd-tabs { border-bottom: 1px solid var(--nd-border); padding: 0 1rem; display: flex; gap: .2rem; overflow-x: auto; }
.nd-tabs a {
    padding: .65rem .85rem; font-size: .83rem; font-weight: 600; color: var(--nd-ink-soft);
    border-bottom: 2px solid transparent; white-space: nowrap;
}
.nd-tabs a:hover { color: var(--nd-ink); }
.nd-tabs a.active { color: #1e4fbd; border-bottom-color: #2f6fed; }
.nd-tabs .count { font-size: .68rem; background: #eef2f8; border-radius: 20px; padding: .05rem .38rem; margin-left: .25rem; }

/* ---------- kanban (lead funnel) ---------- */
.nd-board { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .75rem; align-items: flex-start; }
.nd-board-col { flex: 0 0 274px; background: #e9eef7; border-radius: 12px; padding: .6rem; }
.nd-board-col > h6 {
    font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    display: flex; align-items: center; gap: .4rem; margin: .15rem .25rem .55rem;
}
.nd-board-col > h6 .n { margin-left: auto; background: #fff; border-radius: 20px; padding: .05rem .42rem; font-size: .7rem; }
.nd-board-card {
    background: #fff; border: 1px solid var(--nd-border); border-radius: 10px;
    padding: .6rem .7rem; margin-bottom: .5rem; display: block; color: inherit;
    box-shadow: 0 1px 2px rgba(20, 32, 60, .05);
}
.nd-board-card:hover { border-color: #a8c2f8; box-shadow: 0 6px 16px -10px rgba(20, 32, 60, .4); }
.nd-board-card .t { font-weight: 600; font-size: .82rem; }
.nd-board-card .m { font-size: .72rem; color: var(--nd-ink-soft); }

/* ---------- funnel bars ---------- */
.nd-funnel-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .45rem; font-size: .8rem; }
.nd-funnel-row .name { flex: 0 0 34%; color: var(--nd-ink-soft); }
.nd-funnel-row .bar { flex: 1 1 auto; height: 20px; background: #eef2f8; border-radius: 6px; overflow: hidden; }
.nd-funnel-row .bar > span { display: block; height: 100%; border-radius: 6px; }
.nd-funnel-row .n { flex: 0 0 42px; text-align: right; font-weight: 700; }

/* ---------- letterhead / document preview ---------- */
.nd-preview-frame {
    background: #eef2f8; border-radius: 10px; padding: 1rem;
    max-height: 74vh; overflow: auto;
}
.nd-preview-page {
    background: #fff; width: 100%; max-width: 720px; margin: 0 auto;
    box-shadow: 0 4px 18px rgba(20, 32, 60, .16); padding: 26px 30px;
    font-size: 12px; color: #111; line-height: 1.55;
}
.nd-preview-page table { width: 100%; border-collapse: collapse; }
.nd-preview-page .lh-header { border-bottom: 2px solid #2563eb; padding-bottom: 8px; margin-bottom: 16px; }
.nd-preview-page .lh-footer { border-top: 1px solid #cbd5e1; padding-top: 6px; margin-top: 18px; font-size: 10px; color: #64748b; }
.nd-preview-page img { max-width: 100%; }

/* ---------- print (invoice/document view in browser) ---------- */
@media print {
    .nd-sidebar, .nd-topbar, .nd-no-print, .nd-sticky-actions { display: none !important; }
    .nd-main { margin-left: 0 !important; }
    .nd-content { padding: 0 !important; }
    .card { border: 0 !important; box-shadow: none !important; }
    body { background: #fff; }
}

/* ---------- misc ---------- */
.alert { border-radius: 10px; border: 0; font-size: .85rem; }
.alert-success { background: rgba(25, 160, 96, .12); color: #12794a; }
.alert-danger { background: rgba(220, 53, 69, .12); color: #b02330; }
.alert-warning { background: rgba(240, 173, 20, .16); color: #96660a; }
.alert-info { background: rgba(14, 165, 233, .12); color: #0b7ba8; }

.dropdown-menu { border-radius: 11px; border-color: var(--nd-border); box-shadow: 0 12px 30px -14px rgba(20, 32, 60, .4); font-size: .85rem; }
.dropdown-item { border-radius: 7px; padding: .4rem .6rem; }
.dropdown-menu { padding: .35rem; }

.page-link { border-radius: 8px !important; margin: 0 2px; border-color: var(--nd-border); font-size: .82rem; color: #3d4a66; }
.page-item.active .page-link { background: var(--bs-primary); border-color: var(--bs-primary); }

.progress { height: 7px; border-radius: 20px; background: #eef2f8; }

.nd-scroll-sm { max-height: 340px; overflow-y: auto; }

.ck-editor__editable_inline { min-height: 320px; }
.ck.ck-editor { border-radius: 9px; overflow: hidden; }

/* ---------- letterhead designer ---------- */
.lhd-wrap { position: relative; }
.lhd-wrap.is-busy { opacity: .6; pointer-events: none; }

.lhd-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
    padding: .5rem .6rem; border: 1px solid var(--nd-border);
    border-radius: 9px 9px 0 0; background: #f7f9fd;
}
.lhd-bar .form-control-sm, .lhd-bar .form-select-sm { width: auto; }
.lhd-bar .lhd-sep { width: 1px; align-self: stretch; background: var(--nd-border); margin: 0 .15rem; }

.lhd-canvas {
    position: relative;
    border: 1px solid var(--nd-border);
    border-top: 0;
    border-radius: 0 0 9px 9px;
    background: #fff;
    background-image:
        linear-gradient(90deg, rgba(47,111,237,.05) 1px, transparent 1px),
        linear-gradient(rgba(47,111,237,.05) 1px, transparent 1px);
    background-size: 10% 25%;
    overflow: hidden;
    user-select: none;
    touch-action: none;
}
.lhd-canvas.is-dropping { outline: 2px dashed #2f6fed; outline-offset: -4px; background-color: rgba(47,111,237,.05); }

.lhd-el {
    position: absolute;
    cursor: move;
    outline: 1px dashed transparent;
    outline-offset: 2px;
    min-height: 10px;
}
.lhd-el:hover { outline-color: #a8c2f8; }
.lhd-el.is-selected { outline: 1px solid #2f6fed; outline-offset: 2px; }
.lhd-el.is-dragging { opacity: .8; }
.lhd-el img { width: 100%; display: block; pointer-events: none; }
.lhd-text { line-height: 1.3; word-break: break-word; white-space: pre-wrap; }
.lhd-text[contenteditable="true"] { cursor: text; background: rgba(47,111,237,.07); outline: 1px solid #2f6fed; }

.lhd-handle {
    position: absolute; right: -5px; bottom: -5px;
    width: 11px; height: 11px; border-radius: 50%;
    background: #2f6fed; border: 2px solid #fff; cursor: ew-resize;
    display: none;
}
.lhd-remove {
    position: absolute; top: -9px; right: -9px;
    width: 18px; height: 18px; border-radius: 50%; line-height: 1;
    background: #dc3545; color: #fff; border: 2px solid #fff;
    font-size: .7rem; padding: 0; display: none;
}
.lhd-el.is-selected .lhd-handle,
.lhd-el.is-selected .lhd-remove { display: block; }

.lhd-hint { font-size: .72rem; color: var(--nd-ink-soft); margin-top: .4rem; }
.lhd-ruler {
    display: flex; justify-content: space-between;
    font-size: .65rem; color: var(--nd-ink-soft); padding: 0 .1rem .2rem;
}

/* ---------- document editor + paginated preview ----------
   The editor, the preview and the PDF must all lay text out identically or
   they disagree about where pages break, so they share one font: the very
   DejaVu Sans that dompdf renders with, served from public/fonts.
   Sizes come from config/panel.php document_typography.
   -------------------------------------------------------- */
@font-face {
    font-family: "DejaVu Sans";
    src: url("../fonts/DejaVuSans.ttf") format("truetype");
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "DejaVu Sans";
    src: url("../fonts/DejaVuSans-Bold.ttf") format("truetype");
    font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "DejaVu Sans";
    src: url("../fonts/DejaVuSans-Oblique.ttf") format("truetype");
    font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
    font-family: "DejaVu Sans";
    src: url("../fonts/DejaVuSans-BoldOblique.ttf") format("truetype");
    font-weight: 700; font-style: italic; font-display: swap;
}

.docp-frame { background: #e9eef7; border-radius: 10px; padding: 12px; overflow: auto; max-height: 76vh; }
.docp-scaler { position: relative; }
.docp-pages { display: flex; flex-direction: column; gap: 14px; }

.docp-page {
    position: relative;
    background: #fff;
    box-shadow: 0 4px 18px rgba(20, 32, 60, .18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 0 0 auto;
}
.docp-band { flex: 0 0 auto; overflow: hidden; position: relative; }
.docp-rule { position: absolute; pointer-events: none; }
.docp-header { display: flex; align-items: center; }
.docp-footer { display: flex; align-items: flex-end; padding-bottom: 4mm !important; }
.docp-body { flex: 0 0 auto; overflow: hidden; }

/* The shared document typography, applied to both the sheet and the editor. */
.docp-body,
.docp-band,
.ck-editor__editable.ck-content {
    font-family: var(--doc-font, "DejaVu Sans", Verdana, sans-serif);
    font-size: var(--doc-size, 11px);
    line-height: var(--doc-leading, 1.55);
    color: #16202f;
}
.docp-body > *:first-child,
.ck-editor__editable.ck-content > *:first-child { margin-top: 0; }
.docp-body h1, .docp-body h2, .docp-body h3,
.ck-editor__editable.ck-content h1,
.ck-editor__editable.ck-content h2,
.ck-editor__editable.ck-content h3 { line-height: var(--doc-heading-leading, 1.25); }
.docp-body img, .ck-editor__editable.ck-content img { max-width: 100%; }

.docp-body table,
.ck-editor__editable.ck-content table { width: 100%; border-collapse: collapse; }
.docp-body table td, .docp-body table th,
.ck-editor__editable.ck-content table td,
.ck-editor__editable.ck-content table th { border: 1px solid #cbd5e1; padding: 4px 6px; vertical-align: top; }

.docp-number {
    position: absolute; right: 6px; bottom: 4px;
    font-size: 9px; color: #94a3b8; letter-spacing: .04em;
}
.docp-legend { display: flex; align-items: center; gap: .5rem; font-size: .72rem; color: var(--nd-ink-soft); }

/* ---------- page guides inside the editor ---------- */
.docp-editor-wrap { position: relative; }

/* content-box so `width` is the text column itself: the editor then wraps at
   exactly the printable width and its page guides line up with the preview. */
.docp-editor-wrap .ck-editor__editable.ck-content {
    box-sizing: content-box;
    width: var(--doc-content-width, 180mm);
    max-width: none;
    padding-left: 6mm;
    padding-right: 6mm;
    background-image: none;
}
.docp-guides { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.docp-guide {
    position: absolute; left: 0; right: 0;
    border-top: 1px dashed #a8c2f8;
}
.docp-guide::after {
    content: attr(data-label);
    position: absolute; right: 4px; top: 2px;
    font-size: .62rem; color: #6b7a99;
    background: #fff; padding: 0 4px; border-radius: 3px;
}

/* Read-more clamp: long free text folds to a few lines with a More/Less toggle
   (any [data-clamp] block; the button is revealed by admin.js only on overflow). */
.nd-clamp-text {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.nd-clamp.is-open .nd-clamp-text {
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
}
.nd-clamp-btn {
    border: 0; background: none; padding: 0; cursor: pointer;
    font-weight: 600; font-size: .78rem; color: #2f6fed;
}
.nd-clamp-btn:hover { text-decoration: underline; }

/* ---------- Cold Mail ---------- */

/* The bar under the broker list once something is ticked; it follows the scroll. */
.cm-bulkbar {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
    padding: .6rem 1rem; background: #fff;
    border-top: 1px solid var(--nd-border);
    box-shadow: 0 -6px 16px rgba(15, 23, 42, .06);
    border-radius: 0 0 12px 12px;
}
.cm-bulkbar[hidden] { display: none; }

/* The preview's mail-client header: From, To, Subject. */
.cm-mail-head { padding: .75rem 1rem; border-bottom: 1px solid var(--nd-border); background: #fafbfd; font-size: .8rem; }
.cm-mail-line { display: flex; gap: .5rem; margin-bottom: .15rem; word-break: break-word; }
.cm-mail-line .k { width: 64px; flex: 0 0 auto; color: var(--nd-ink-soft); }
.cm-mail-subject { font-weight: 700; font-size: .95rem; margin-top: .35rem; color: var(--nd-ink); word-break: break-word; }
.cm-mail-frame { display: block; width: 100%; min-height: 420px; border: 0; background: #f3f5f9; }
.cm-mail-frame-sm { min-height: 240px; border: 1px solid var(--nd-border); border-radius: 8px; margin-top: .4rem; }
.cm-mail-files { display: flex; flex-wrap: wrap; gap: .35rem; padding: .6rem 1rem; border-top: 1px solid var(--nd-border); }
.cm-mail-files[hidden] { display: none; }

/* Files picked in the draft, and those a template brings. */
.cm-files { list-style: none; padding: 0; margin: 0; }
.cm-files li {
    display: flex; align-items: center; gap: .4rem;
    font-size: .8rem; padding: .3rem .5rem; margin-bottom: .3rem;
    border: 1px solid var(--nd-border); border-radius: 6px;
}
.cm-files li.off { opacity: .55; }
.cm-files li.off .text-break { text-decoration: line-through; }

.cm-header-thumb {
    display: block; max-width: 100%; max-height: 110px; margin-bottom: .4rem;
    border: 1px solid var(--nd-border); border-radius: 6px; object-fit: cover;
}
.cm-header-thumb[hidden] { display: none; }
.cm-to { max-height: 150px; overflow: auto; }
.cm-recipients { max-height: 440px; overflow: auto; }
[data-cm-compose] .ck-editor__editable_inline,
.cm-editor .ck-editor__editable_inline { min-height: 260px; max-height: 560px; }

/* A broker's addresses in a bulk send: tick each one in or out. */
.cm-addrs { display: flex; flex-direction: column; gap: .1rem; }
.cm-addr { display: flex; align-items: center; gap: .35rem; margin: 0; font-size: .78rem; cursor: pointer; }
.cm-addr .form-check-input { margin: 0; flex: 0 0 auto; }
.cm-addr-add { max-width: 300px; margin-top: .25rem; }
.cm-addr-add[hidden] { display: none; }
tr.cm-row-off > td { opacity: .5; }

/* The Emails box on the broker form, as removable chips. */
.cm-chips-input { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; height: auto; min-height: 38px; cursor: text; }
.cm-chip {
    display: inline-flex; align-items: center; gap: .2rem;
    padding: .1rem .2rem .1rem .5rem; border-radius: 6px;
    background: #eef2f8; color: var(--nd-ink); font-size: .78rem; word-break: break-all;
}
.cm-chip button { border: 0; background: none; padding: 0 .3rem; line-height: 1; font-size: 1rem; color: var(--nd-ink-soft); cursor: pointer; }
.cm-chip button:hover { color: #b91c1c; }
.cm-chips-field { border: 0; outline: 0; background: transparent; flex: 1 1 180px; min-width: 140px; font-size: .85rem; padding: .15rem 0; }

/* Emails and websites on the broker list: tap one to correct it where it is. */
.cm-contacts { display: flex; flex-direction: column; gap: .1rem; min-width: 150px; }
.cm-contact { display: flex; align-items: center; gap: .3rem; max-width: 260px; }
.cm-contact-text {
    border: 0; background: none; padding: 0; margin: 0; text-align: left; font: inherit; color: var(--nd-ink);
    max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    border-bottom: 1px dashed transparent; cursor: text;
}
.cm-contact-text.is-static { cursor: default; }
button.cm-contact-text:hover, button.cm-contact-text:focus { border-bottom-color: #9db1d4; outline: 0; }
.cm-contact-open { color: var(--nd-ink-soft); font-size: .72rem; line-height: 1; flex: 0 0 auto; }
.cm-contact-open:hover { color: #2f6fed; }
.cm-contact-tools { display: flex; gap: .25rem; margin-top: .15rem; }
.cm-contact-tools .nd-chip { cursor: pointer; }
.cm-contact-editor { flex: 1 1 auto; min-width: 200px; }
.cm-contact-input { font-size: .8rem; padding: .15rem .4rem; height: auto; }
.cm-contact-error { font-size: .72rem; color: #b91c1c; margin-top: .1rem; white-space: normal; }
.cm-contacts.is-busy { opacity: .6; }
.cm-contacts.is-saved .cm-contact-text { color: #15803d; transition: color .3s; }

/* Roles & Permissions: one block per module, the head tick taking the block with it. */
.nd-perm-module { border: 1px solid var(--nd-border); border-radius: 10px; padding: .6rem .8rem; height: 100%; background: #fff; }
.nd-perm-head { border-bottom: 1px solid var(--nd-border); padding-bottom: .35rem; margin-bottom: .45rem; }
.nd-perm-item { margin-bottom: .15rem; }
.nd-perm-item .form-check-label { color: var(--nd-ink); }
.nd-perm-item .form-check-input:disabled + .form-check-label, .nd-perm-head .form-check-input:disabled + .form-check-label { opacity: .75; }

/* Pictures in a row in the mail editor: a little space between, lined up on the middle. */
.ck-content .image-inline { vertical-align: middle; }
.ck-content .image-inline + .image-inline, .ck-content a + .image-inline, .ck-content .image-inline + a { margin-left: 8px; }

/* The badge and icon palette beside the mail editor. */
.cm-icon-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.cm-icon-pick {
    display: flex; align-items: center; gap: .5rem; min-width: 0;
    border: 1px solid var(--nd-border); border-radius: 8px; background: #fff;
    padding: .35rem .5rem; font-size: .78rem; color: var(--nd-ink); text-align: left; cursor: pointer;
}
.cm-icon-pick:hover { border-color: #2f6fed; background: #f3f7ff; }
.cm-icon-pick img { flex: 0 0 auto; }
.cm-icon-strip { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .4rem; }
.cm-icon-pick.is-compact { padding: .2rem .3rem; border-radius: 6px; }

/* The Send box's own video and poster, folded away until wanted. */
.cm-video-own > summary { cursor: pointer; color: #2f6fed; list-style: none; }
.cm-video-own > summary::before { content: "\25B8"; display: inline-block; width: 1em; }
.cm-video-own[open] > summary::before { content: "\25BE"; }

/* Text held to two lines in a list cell, with an ellipsis when there is more; the title carries the rest. */
.nd-two-lines {
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; white-space: normal; word-break: break-word; line-height: 1.35;
}
