/* ==========================================================================
   Devwebs ERP — theme layer on top of Bootstrap 5.
   Bootstrap handles the grid, components and responsiveness; this file gives
   the product an identity and fixes the two things stock Bootstrap gets wrong
   for dense admin work: data legibility and vertical rhythm.
   ========================================================================== */

:root {
    /* Palette — ink and steel, with a single amber signal colour that is used
       ONLY to mark "you are here" and keyboard focus. Nothing else is amber. */
    --dw-ink:        #101828;
    --dw-sidebar:    #131c2e;
    --dw-sidebar-2:  #1b2740;
    --dw-primary:    #2b5bd7;
    --dw-primary-d:  #1f45a8;
    --dw-accent:     #f5b301;
    --dw-surface:    #f5f7fb;
    --dw-card:       #ffffff;
    --dw-line:       #e4e8f0;
    --dw-muted:      #667085;

    --dw-radius:     10px;
    --dw-sidebar-w:  254px;
    --dw-topbar-h:   60px;

    --bs-primary:    var(--dw-primary);
    --bs-body-color: var(--dw-ink);
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body {
    background: var(--dw-surface);
    font-family: var(--bs-body-font-family);
    font-size: .9rem;
    color: var(--dw-ink);
    -webkit-font-smoothing: antialiased;
}

/* Identifiers, counts, IPs and timestamps are set in mono. In an ERP these are
   scanned column-wise, and tabular figures make that possible. */
.dw-mono,
.table td .dw-mono,
code {
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
}

/* ---------------------------------------------------------------- Sidebar */
.dw-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--dw-sidebar-w);
    background: var(--dw-sidebar);
    color: #aeb8cc;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .2s ease;
}

.dw-brand {
    height: var(--dw-topbar-h);
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: 0 1.125rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    color: #fff;
    text-decoration: none;
    flex: 0 0 auto;
    justify-content:center;
}

.dw-brand__mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--dw-primary), #4d7cff);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .8rem;
    color: #fff;
}

.dw-brand__name { font-weight: 650; font-size: .95rem; letter-spacing: -.01em; }
.dw-brand__sub  { font-size: .65rem; color: #7d8aa5; letter-spacing: .08em; text-transform: uppercase; }

.dw-nav { flex: 1 1 auto; overflow-y: auto; padding: .75rem 0 2rem; }

/* Eyebrow labels group the 24 modules the same way the org actually splits
   the work — this encodes real structure, it is not decoration. */
.dw-nav__group {
    font-size: .62rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #5f6b83;
    padding: 1rem 1.125rem .4rem;
    font-weight: 600;
}

.dw-nav__link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .5rem 1.125rem;
    color: #aeb8cc;
    text-decoration: none;
    font-size: .855rem;
    border-left: 3px solid transparent;
    transition: background .12s, color .12s;
}

.dw-nav__link:hover { background: var(--dw-sidebar-2); color: #fff; }

/* The signature: a single amber rail marks the current location. */
.dw-nav__link.active {
    background: var(--dw-sidebar-2);
    color: #fff;
    border-left-color: var(--dw-accent);
    font-weight: 550;
}

.dw-nav__link i { font-size: 1rem; width: 1.1rem; text-align: center; }
.dw-nav__badge { margin-left: auto; font-size: .65rem; }

/* ----------------------------------------------------------------- Shell */
.dw-main { margin-left: var(--dw-sidebar-w); min-height: 100vh; }

.dw-topbar {
    height: var(--dw-topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--dw-line);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.dw-search { max-width: 340px; flex: 1 1 auto; }
.dw-search .form-control { background: var(--dw-surface); border-color: transparent; }
.dw-search .form-control:focus { background: #fff; }

.dw-content { padding: 1.25rem; }

/* ------------------------------------------------------------ Page header */
.dw-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1.1rem;
}

.dw-page-head h1 { font-size: 1.3rem; font-weight: 650; margin: 0; letter-spacing: -.02em; }
.dw-page-head p  { margin: .2rem 0 0; color: var(--dw-muted); font-size: .82rem; }

/* ----------------------------------------------------------------- Cards */
.card {
    border: 1px solid var(--dw-line);
    border-radius: var(--dw-radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--dw-line);
    padding: .8rem 1rem;
    font-weight: 600;
    font-size: .875rem;
}

.dw-stat { display: flex; align-items: center; gap: .9rem; padding: 1rem; }
.dw-stat__icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-size: 1.15rem; }
.dw-stat__value { font-size: 1.5rem; font-weight: 650; line-height: 1.1; }
.dw-stat__label { font-size: .74rem; color: var(--dw-muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------------------------------------------------------------- Tables */
.table { --bs-table-bg: transparent; margin-bottom: 0; }

.table > thead th {
    background: #fbfcfe;
    border-bottom: 1px solid var(--dw-line);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--dw-muted);
    font-weight: 600;
    white-space: nowrap;
    padding: .6rem .75rem;
}

.table > tbody td { padding: .7rem .75rem; vertical-align: middle; border-color: var(--dw-line); }
.table > tbody tr:hover { background: #fafbfd; }

.dw-sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .25rem; }
.dw-sort:hover { color: var(--dw-primary); }
.dw-sort i { opacity: .35; font-size: .7rem; }
.dw-sort.is-active i { opacity: 1; color: var(--dw-primary); }

.dw-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }

/* ---------------------------------------------------- Permission matrix */
.dw-perm-module { border: 1px solid var(--dw-line); border-radius: var(--dw-radius); overflow: hidden; height: 100%; }
.dw-perm-module__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: .55rem .8rem; background: #fbfcfe; border-bottom: 1px solid var(--dw-line);
    font-weight: 600; font-size: .8rem; text-transform: capitalize;
}
.dw-perm-module__body { padding: .55rem .8rem; }
.dw-perm-module .form-check { margin-bottom: .3rem; }
.dw-perm-module .form-check-label { font-size: .82rem; }

/* --------------------------------------------------------------- Details */
.form-label { font-weight: 550; font-size: .8rem; margin-bottom: .3rem; }
.form-control, .form-select { border-color: var(--dw-line); font-size: .875rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--dw-primary);
    box-shadow: 0 0 0 3px rgba(43, 91, 215, .12);
}

.btn { font-size: .855rem; font-weight: 550; border-radius: 8px; }
.btn-primary { background: var(--dw-primary); border-color: var(--dw-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--dw-primary-d); border-color: var(--dw-primary-d); }

.badge { font-weight: 550; letter-spacing: .01em; }

.dw-empty { text-align: center; padding: 3rem 1rem; color: var(--dw-muted); }
.dw-empty i { font-size: 2rem; opacity: .35; display: block; margin-bottom: .6rem; }

/* Keyboard focus is amber everywhere, matching the "you are here" rail. */
:focus-visible { outline: 2px solid var(--dw-accent); outline-offset: 2px; }

/* --------------------------------------------------------------- Mobile */
@media (max-width: 991.98px) {
    .dw-sidebar { transform: translateX(-100%); }
    .dw-sidebar.is-open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
    .dw-main { margin-left: 0; }
    .dw-backdrop {
        position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 1035;
    }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   Module 3 — Employee Management
   ========================================================================== */

/* Department identity dot. The colour is data, so it arrives as a CSS variable
   set inline rather than as one class per department. */
.dw-dept-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dot, var(--dw-primary));
    margin-right: .35rem;
    vertical-align: middle;
}

/* ------------------------------------------------------ Department tree */
.dw-tree { list-style: none; margin: 0; padding-left: 1rem; border-left: 1px solid var(--dw-line); }
.dw-tree--root { padding-left: 0; border-left: 0; }
.dw-tree li { position: relative; padding: .2rem 0; }
.dw-tree__link { color: var(--dw-ink); text-decoration: none; font-size: .84rem; }
.dw-tree__link:hover { color: var(--dw-primary); }

/* ------------------------------------------------------------ Org chart */
.dw-org { overflow-x: auto; }
.dw-org__list { list-style: none; margin: 0; padding: 0 0 0 1.4rem; }
.dw-org > .dw-org__list { padding-left: 0; }

.dw-org__item { position: relative; padding: .3rem 0 .3rem 1.1rem; }
.dw-org > .dw-org__list > .dw-org__item { padding-left: 0; }

/* Connector lines: a vertical spine down the branch and a short elbow into
   each card. Drawn in CSS so the markup stays a plain nested list, which is
   what a screen reader should hear. */
.dw-org__item::before,
.dw-org__item::after {
    content: '';
    position: absolute;
    background: var(--dw-line);
}
.dw-org__item::before { left: 0; top: 0; bottom: 0; width: 1px; }
.dw-org__item:last-child::before { bottom: auto; height: 1.55rem; }
.dw-org__item::after { left: 0; top: 1.55rem; width: .8rem; height: 1px; }
.dw-org > .dw-org__list > .dw-org__item::before,
.dw-org > .dw-org__list > .dw-org__item::after { display: none; }

.dw-org__card {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem .7rem;
    border: 1px solid var(--dw-line);
    border-radius: var(--dw-radius);
    background: #fff;
    text-decoration: none;
    color: var(--dw-ink);
    min-width: 230px;
    transition: border-color .12s, box-shadow .12s;
}
.dw-org__card:hover { border-color: var(--dw-primary); box-shadow: 0 2px 8px rgba(43, 91, 215, .12); }

.dw-org__meta { display: flex; flex-direction: column; line-height: 1.25; margin-right: auto; }
.dw-org__name { font-weight: 600; font-size: .84rem; }
.dw-org__role { font-size: .74rem; color: var(--dw-muted); }
.dw-org__dept { font-size: .7rem; color: var(--dw-muted); }

/* --------------------------------------------------------- Profile tabs */
.nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--dw-muted);
    font-size: .84rem;
    font-weight: 550;
    padding: .6rem .85rem;
}
.nav-tabs .nav-link:hover { border-bottom-color: var(--dw-line); color: var(--dw-ink); }
.nav-tabs .nav-link.active { color: var(--dw-primary); border-bottom-color: var(--dw-primary); background: transparent; }

dl.row dt { font-weight: 400; }

/* ==========================================================================
   Module 24 — Settings
   ========================================================================== */

.dw-brand__logo { max-height: 45px; max-width: 170px; object-fit: contain; }

/* Vertical group nav. Eight groups is too many for a horizontal tab strip,
   and the labels are what the operator is scanning for. */
.dw-settings-nav .list-group-item {
    border: 0;
    border-left: 3px solid transparent;
    padding: .6rem .9rem;
    font-size: .855rem;
    color: var(--dw-ink);
}
.dw-settings-nav .list-group-item:hover { background: var(--dw-surface); }
.dw-settings-nav .list-group-item.active {
    background: var(--dw-surface);
    color: var(--dw-primary);
    border-left-color: var(--dw-accent);
    font-weight: 600;
}

.form-control-color { width: 3.2rem; padding: .25rem; }

/* ==========================================================================
   Module 10 — Notifications
   ========================================================================== */

/* ---------------------------------------------------------------- Bell */
.dw-bell__badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--dw-accent);
    color: #101828;
    font-size: .62rem;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
}

.dw-bell__menu { width: 360px; max-width: 92vw; padding: 0; overflow: hidden; }

.dw-bell__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .7rem .9rem;
    border-bottom: 1px solid var(--dw-line);
    font-size: .875rem;
}

.dw-bell__list { max-height: 380px; overflow-y: auto; }

.dw-bell__item {
    display: flex;
    gap: .6rem;
    padding: .65rem .9rem;
    border-bottom: 1px solid var(--dw-line);
    text-decoration: none;
    color: var(--dw-ink);
    transition: background .1s;
}
.dw-bell__item:hover { background: var(--dw-surface); }
.dw-bell__item--unread { background: #f0f5ff; }
.dw-bell__item--unread:hover { background: #e7efff; }

.dw-bell__icon {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--dw-surface);
    display: grid;
    place-items: center;
    color: var(--dw-primary);
}

.dw-bell__body { display: flex; flex-direction: column; min-width: 0; }
.dw-bell__title { font-weight: 600; font-size: .82rem; }
.dw-bell__text { font-size: .78rem; color: var(--dw-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-bell__time { font-size: .68rem; color: var(--dw-muted); margin-top: .1rem; }

.dw-bell__empty { text-align: center; padding: 2rem 1rem; color: var(--dw-muted); font-size: .82rem; }
.dw-bell__foot {
    display: block;
    text-align: center;
    padding: .6rem;
    border-top: 1px solid var(--dw-line);
    font-size: .8rem;
    font-weight: 550;
    text-decoration: none;
    color: var(--dw-primary);
}
.dw-bell__foot:hover { background: var(--dw-surface); }

/* --------------------------------------------------------- Inbox rows */
.dw-notif { display: flex; gap: .8rem; padding: .85rem 1rem; }
.dw-notif--unread { background: #f6f9ff; }
.dw-notif__icon {
    flex: 0 0 auto; width: 36px; height: 36px; border-radius: 9px;
    display: grid; place-items: center; font-size: 1rem;
}
.dw-notif__body { flex: 1 1 auto; min-width: 0; }
.dw-notif__title { font-weight: 600; font-size: .875rem; }
.dw-notif__time { font-size: .72rem; color: var(--dw-muted); white-space: nowrap; }
.dw-notif__text { font-size: .82rem; color: var(--dw-muted); margin: .15rem 0 .4rem; }
.dw-notif__actions { display: flex; gap: 1rem; align-items: center; }
.dw-notif__actions .btn-link { font-size: .78rem; text-decoration: none; }

/* --------------------------------------------------- Preference matrix */
.dw-pref-table th { font-weight: 600; }
.dw-pref-table td, .dw-pref-table th { border-color: var(--dw-line); }
.dw-token { font-family: 'IBM Plex Mono', monospace; font-size: .72rem; }

/* ==========================================================================
   Module 5 — Clients
   ========================================================================== */

/* Square avatar/monogram for a client, logo or initials. */
.dw-client-badge {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--dw-surface);
    color: var(--dw-primary);
    font-weight: 700;
    font-size: .78rem;
    overflow: hidden;
    flex: 0 0 auto;
}
.dw-client-badge img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.dw-client-badge--lg { width: 72px; height: 72px; border-radius: 12px; font-size: 1.4rem; }

/* Repeatable contact / address rows on the client form. */
.dw-repeat-row { background: #fff; }
.dw-repeat-row + .dw-repeat-row { border-top: 0; }

/* Client timeline. A single spine with an icon node per entry. */
.dw-timeline-item { display: flex; gap: .8rem; padding: .2rem 0 .9rem; position: relative; }
.dw-timeline-item::before {
    content: '';
    position: absolute;
    left: 16px; top: 34px; bottom: -6px;
    width: 1px;
    background: var(--dw-line);
}
.dw-timeline-item:last-child::before { display: none; }
.dw-timeline-item__icon {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: .9rem;
    z-index: 1;
}
.dw-timeline-item__body { flex: 1 1 auto; min-width: 0; }

/* ==========================================================================
   Module 4 — CRM / Leads
   ========================================================================== */

/* Stage chip: a coloured pill driven by the stage's own colour via --chip. */
.dw-stage-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    color: var(--chip, var(--dw-primary));
    background: color-mix(in srgb, var(--chip, #64748b) 14%, #fff);
    border: 1px solid color-mix(in srgb, var(--chip, #64748b) 30%, #fff);
}

/* ------------------------------------------------------------- Board */
.dw-board {
    display: flex;
    gap: .8rem;
    overflow-x: auto;
    padding-bottom: .5rem;
    align-items: flex-start;
}
.dw-board__col {
    flex: 0 0 270px;
    background: var(--dw-surface);
    border: 1px solid var(--dw-line);
    border-radius: var(--dw-radius);
}
.dw-board__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem .7rem;
    border-bottom: 1px solid var(--dw-line);
    border-top: 3px solid var(--chip, #64748b);
    border-radius: var(--dw-radius) var(--dw-radius) 0 0;
}
.dw-board__dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--chip, #64748b); margin-right: .4rem;
}
.dw-board__list { padding: .5rem; min-height: 60px; }
.dw-board__empty { text-align: center; padding: 1rem .5rem; }

.dw-board__card {
    background: #fff;
    border: 1px solid var(--dw-line);
    border-radius: 8px;
    padding: .55rem .65rem;
    margin-bottom: .5rem;
    cursor: grab;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.dw-board__card:active { cursor: grabbing; }
.dw-board__card--ghost { opacity: .4; }
.dw-board__card-title { display: block; font-weight: 600; font-size: .82rem; text-decoration: none; color: var(--dw-ink); }
.dw-board__card-sub { font-size: .74rem; color: var(--dw-muted); margin: .1rem 0 .35rem; }
.dw-board__card-meta { display: flex; align-items: center; gap: .4rem; }
.dw-board__card-owner {
    display: inline-grid; place-items: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--dw-surface); color: var(--dw-primary);
    font-size: .6rem; font-weight: 700;
}

/* ==========================================================================
   Module 17 — Quotations
   ========================================================================== */

/* The line-item editor keeps inputs compact so a row fits without wrapping. */
.dw-items-table td { vertical-align: middle; }
.dw-items-table input.form-control-sm,
.dw-items-table textarea.form-control-sm { font-size: .82rem; }
.dw-item-row textarea { resize: vertical; min-height: 31px; }
.dw-line-total { font-weight: 600; color: var(--dw-ink); white-space: nowrap; }

/* ==========================================================================
   Module 18 — Invoices & Payments
   ========================================================================== */

/* A slim progress bar showing how much of an invoice has been settled. */
.dw-paidbar {
    width: 120px; height: 8px; border-radius: 999px;
    background: var(--dw-line); overflow: hidden;
}
.dw-paidbar__fill {
    height: 100%; background: var(--bs-success, #22c55e);
    border-radius: 999px; transition: width .3s ease;
}

/* ==========================================================================
   Module 2 — Dashboard
   ========================================================================== */

/* A compact figure block used inside the domain widgets (sales, delivery...). */
.dw-mini { padding: .25rem 0; }
.dw-mini__value { font-size: 1.25rem; font-weight: 650; line-height: 1.15; }
.dw-mini__label { font-size: .72rem; color: var(--dw-muted); text-transform: uppercase; letter-spacing: .05em; }

/* Dependency-free bar sparkline for the collections trend. */
.dw-spark { display: flex; align-items: flex-end; gap: .35rem; height: 120px; }
.dw-spark__col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; height: 100%; }
.dw-spark__bar-wrap { flex: 1 1 auto; width: 100%; display: flex; align-items: flex-end; }
.dw-spark__bar {
    width: 100%; border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, var(--dw-primary), color-mix(in srgb, var(--dw-primary) 55%, #ffffff));
    transition: height .3s ease; min-height: 2px;
}
.dw-spark__col:hover .dw-spark__bar { background: var(--dw-accent, var(--dw-primary)); }
.dw-spark__label { font-size: .68rem; color: var(--dw-muted); margin-top: .25rem; }
