/* Temail design system — layered over Bootstrap 5.3 */
:root, [data-bs-theme="light"] {
    --mf-lagoon: #0E6B66;
    --mf-lagoon-dark: #0A5450;
    --mf-lagoon-soft: #DDEFEC;
    --mf-harbour: #14303A;
    --mf-harbour-2: #1C3F4B;
    --mf-signal: #E9A23B;
    --mf-signal-soft: #FBEFD9;
    --mf-bg: #F2F5F5;
    --mf-surface: #FFFFFF;
    --mf-line: #DCE3E4;
    --mf-ink: #1B2B32;
    --mf-muted: #5C6E75;
    --mf-sidebar-w: 248px;
    --mf-radius: 10px;
    --mf-font-head: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;

    --bs-body-font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-body-font-size: .94rem;
    --bs-body-bg: var(--mf-bg);
    --bs-body-color: var(--mf-ink);
    --bs-secondary-color: var(--mf-muted);
    --bs-border-color: var(--mf-line);
    --bs-primary: var(--mf-lagoon);
    --bs-primary-rgb: 14, 107, 102;
    --bs-link-color: var(--mf-lagoon);
    --bs-link-color-rgb: 14, 107, 102;
    --bs-link-hover-color: var(--mf-lagoon-dark);
    --bs-border-radius: 8px;
    --bs-border-radius-lg: var(--mf-radius);
    --bs-focus-ring-color: rgba(14, 107, 102, .35);
}
[data-bs-theme="dark"] {
    --mf-lagoon: #4FB8B0;
    --mf-lagoon-dark: #7AD0C9;
    --mf-lagoon-soft: #173A3B;
    --mf-harbour: #0E1F26;
    --mf-harbour-2: #16303A;
    --mf-signal-soft: #3A2E17;
    --mf-bg: #0F1A1F;
    --mf-surface: #16252C;
    --mf-line: #28393F;
    --mf-ink: #E4ECEE;
    --mf-muted: #93A6AD;
    --bs-body-bg: var(--mf-bg);
    --bs-body-color: var(--mf-ink);
    --bs-primary-rgb: 79, 184, 176;
    --bs-link-color-rgb: 79, 184, 176;
    --bs-border-color: var(--mf-line);
    --bs-secondary-bg: #1D2F36;
    --bs-tertiary-bg: #1D2F36;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-bs-theme="light"]) { color-scheme: dark; }
}

body { background: var(--mf-bg); color: var(--mf-ink); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 { font-family: var(--mf-font-head); font-weight: 600; letter-spacing: -.01em; }
h1, .h1 { font-size: 1.65rem; } .h4 { font-size: 1.35rem; }
a { text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--mf-lagoon); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: -999px; top: .5rem; z-index: 2000; background: var(--mf-surface); padding: .5rem 1rem; border-radius: 6px; }
.skip-link:focus { left: .5rem; }

/* ---------- buttons ---------- */
.btn { font-weight: 500; border-radius: 8px; }
.btn-primary { --bs-btn-bg: var(--mf-lagoon); --bs-btn-border-color: var(--mf-lagoon); --bs-btn-hover-bg: var(--mf-lagoon-dark); --bs-btn-hover-border-color: var(--mf-lagoon-dark); --bs-btn-active-bg: var(--mf-lagoon-dark); --bs-btn-active-border-color: var(--mf-lagoon-dark); --bs-btn-disabled-bg: var(--mf-lagoon); --bs-btn-disabled-border-color: var(--mf-lagoon); --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; }
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0B1A1D; --bs-btn-hover-color: #0B1A1D; --bs-btn-active-color: #0B1A1D; }
.btn-outline-primary { --bs-btn-color: var(--mf-lagoon); --bs-btn-border-color: var(--mf-lagoon); --bs-btn-hover-bg: var(--mf-lagoon); --bs-btn-hover-border-color: var(--mf-lagoon); --bs-btn-active-bg: var(--mf-lagoon); --bs-btn-active-border-color: var(--mf-lagoon); --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; }
.btn-outline-secondary { --bs-btn-color: var(--mf-ink); --bs-btn-border-color: var(--mf-line); --bs-btn-hover-bg: var(--bs-secondary-bg); --bs-btn-hover-color: var(--mf-ink); --bs-btn-hover-border-color: var(--mf-muted); --bs-btn-active-bg: var(--bs-secondary-bg); --bs-btn-active-color: var(--mf-ink); }
.btn-warning { --bs-btn-bg: var(--mf-signal); --bs-btn-border-color: var(--mf-signal); --bs-btn-color: #2A1D05; }

/* ---------- forms ---------- */
.form-control, .form-select { background-color: var(--mf-surface); border-color: var(--mf-line); padding: .5rem .75rem; }
.form-control:focus, .form-select:focus { border-color: var(--mf-lagoon); box-shadow: 0 0 0 .2rem rgba(14, 107, 102, .18); background-color: var(--mf-surface); }
.form-label { font-weight: 500; font-size: .88rem; margin-bottom: .3rem; }
.form-text { color: var(--mf-muted); }
.form-check-input:checked { background-color: var(--mf-lagoon); border-color: var(--mf-lagoon); }

/* ---------- panels (replace stock cards) ---------- */
.card { background: var(--mf-surface); border: 1px solid var(--mf-line); border-radius: var(--mf-radius); box-shadow: none; }
.card-header, .card-footer { background: transparent; border-color: var(--mf-line); font-weight: 600; }
.panel { background: var(--mf-surface); border: 1px solid var(--mf-line); border-radius: var(--mf-radius); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--mf-line); }
.panel-head h2 { font-size: 1rem; margin: 0; }
.panel-body { padding: 1.1rem; }
.panel-link { font-size: .85rem; font-weight: 500; text-decoration: none; }
.panel-link:hover { text-decoration: underline; }

/* ---------- tables ---------- */
.table { --bs-table-bg: transparent; --bs-table-border-color: var(--mf-line); --bs-table-hover-bg: var(--mf-lagoon-soft); }
.table > thead > tr > th { font-size: .8rem; font-weight: 600; color: var(--mf-muted); border-bottom-width: 1px; white-space: nowrap; background: transparent; }
.table > :not(caption) > * > * { padding: .7rem .85rem; }
.card > .table, .card > .table-responsive > .table { margin-bottom: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--mf-lagoon-soft); }

/* ---------- badges: soft tint + dot, not solid blocks ---------- */
.badge { font-weight: 500; font-size: .76rem; padding: .32em .65em; border-radius: 999px; }
.badge.text-bg-secondary { background: var(--bs-secondary-bg) !important; color: var(--mf-muted) !important; }
.badge.text-bg-success { background: #DDF1E4 !important; color: #17603A !important; }
.badge.text-bg-danger { background: #FBE1E0 !important; color: #9B2222 !important; }
.badge.text-bg-warning { background: var(--mf-signal-soft) !important; color: #7A4B05 !important; }
.badge.text-bg-info { background: #DCEBF7 !important; color: #1B4F7A !important; }
.badge.text-bg-primary { background: var(--mf-lagoon-soft) !important; color: var(--mf-lagoon-dark) !important; }
.badge.text-bg-dark { background: #E3E7E8 !important; color: #33434A !important; }
[data-bs-theme="dark"] .badge.text-bg-success { background: #173B27 !important; color: #8FDDB0 !important; }
[data-bs-theme="dark"] .badge.text-bg-danger { background: #43201F !important; color: #F2A3A1 !important; }
[data-bs-theme="dark"] .badge.text-bg-warning { color: #F2C67E !important; }
[data-bs-theme="dark"] .badge.text-bg-info { background: #1B3347 !important; color: #9CCBF0 !important; }
[data-bs-theme="dark"] .badge.text-bg-dark { background: #26363C !important; color: #B9C8CD !important; }

/* ---------- alerts, dropdowns, tabs ---------- */
.alert { border-radius: var(--mf-radius); border-width: 1px; }
.dropdown-menu { border-color: var(--mf-line); border-radius: var(--mf-radius); box-shadow: 0 8px 24px rgba(10, 30, 36, .12); padding: .35rem; }
.dropdown-item { border-radius: 6px; }
.dropdown-menu form { margin: 0; }
.dropdown-menu .dropdown-item { cursor: pointer; }
.nav-tabs { border-bottom-color: var(--mf-line); }

/* settings sub-navigation */
.subnav { display: flex; gap: .25rem; overflow-x: auto; padding-bottom: .25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--mf-line); scrollbar-width: thin; }
.subnav a { padding: .55rem .85rem; color: var(--mf-muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.subnav a:hover { color: var(--mf-ink); }
.subnav a.active { color: var(--mf-lagoon); border-bottom-color: var(--mf-lagoon); }

/* ---------- app shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--mf-sidebar-w); flex: 0 0 var(--mf-sidebar-w);
    background: var(--mf-harbour); color: #C9D8DC;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    display: none; flex-direction: column; padding: 1.1rem .8rem;
}
@media (min-width: 992px) { .sidebar { display: flex; } .mf-offcanvas { display: none !important; } }
.sidebar-brand, .sidebar-brand:hover { color: #fff; }
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .6rem 1.1rem; color: #fff; text-decoration: none; font-family: var(--mf-font-head); font-weight: 600; font-size: 1.15rem; }
.sidebar-brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--mf-signal); color: #2A1D05; display: grid; place-items: center; font-size: 1rem; }
.snav-group { font-size: .78rem; color: #7E959C; margin: 1.1rem .7rem .35rem; font-weight: 500; }
.snav { display: flex; flex-direction: column; gap: 2px; }
.snav a { display: flex; align-items: center; gap: .65rem; padding: .5rem .7rem; border-radius: 8px; color: #C9D8DC; text-decoration: none; font-weight: 500; position: relative; }
.snav a i { font-size: 1.05rem; opacity: .85; width: 1.2rem; text-align: center; }
.snav a:hover { background: var(--mf-harbour-2); color: #fff; }
.snav a.active { background: var(--mf-harbour-2); color: #fff; }
.snav a.active::before { content: ""; position: absolute; left: -.5rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--mf-signal); }
.snav a.disabled { opacity: .5; pointer-events: none; }
.snav .count { margin-left: auto; background: var(--mf-signal); color: #2A1D05; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; }
.snav .soon { margin-left: auto; font-size: .72rem; color: #7E959C; }
.sidebar-foot { margin-top: auto; padding-top: 1rem; }
.sidebar-user { display: flex; align-items: center; gap: .6rem; padding: .6rem; border-radius: 10px; background: var(--mf-harbour-2); color: #fff; width: 100%; }
.sidebar-user-links { display: flex; gap: .25rem; margin-top: .4rem; }
.sidebar-user-links form { margin: 0; flex: 1; }
.sidebar-user-links a, .sidebar-user-links button { display: block; width: 100%; flex: 1; background: none; border: 0; color: #9DB2B8; text-align: center; padding: .4rem; border-radius: 8px; font-size: .84rem; text-decoration: none; }
.sidebar-user-links a { flex: 1; }
.sidebar-user-links a:hover, .sidebar-user-links button:hover { background: var(--mf-harbour-2); color: #fff; }
.sidebar-user .who { min-width: 0; line-height: 1.2; }
.sidebar-user .who b { display: block; font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who span { font-size: .76rem; color: #9DB2B8; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; background: var(--mf-lagoon); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: .88rem; }
.offcanvas.offcanvas-start { background: var(--mf-harbour); width: var(--mf-sidebar-w); }
.offcanvas .btn-close { filter: invert(1); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.75rem; border-bottom: 1px solid var(--mf-line); background: var(--mf-surface); position: sticky; top: 0; z-index: 100; min-height: 58px; }
.topbar .page-title { font-family: var(--mf-font-head); font-weight: 600; font-size: 1.05rem; margin: 0; margin-right: auto; }
.content { flex: 1; min-width: 0; padding: 1.75rem; max-width: 1280px; width: 100%; }
@media (max-width: 991.98px) { .content { padding: 1rem; } .topbar { padding: .6rem 1rem; } }

pre { white-space: pre-wrap; word-break: break-all; }
form[data-confirm] { margin: 0; }
.preview-shell { background: var(--bs-secondary-bg); border: 1px solid var(--mf-line); border-radius: 8px; padding: .5rem; display: flex; justify-content: center; }
.preview-frame { width: 100%; height: 520px; border: 0; background: #fff; border-radius: 4px; transition: width .2s; }
textarea[data-editor-html] { font-size: .8rem; }

/* legacy .stat tiles used elsewhere */
.stat { background: var(--mf-surface); border: 1px solid var(--mf-line); border-radius: var(--mf-radius); padding: 1rem 1.1rem; height: 100%; }
.stat-n { font-family: var(--mf-font-head); font-size: 1.6rem; font-weight: 600; line-height: 1.2; }
.stat-l { font-size: .85rem; color: var(--mf-muted); }

/* ---------- empty states ---------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--mf-muted); }
.empty i { font-size: 2rem; color: var(--mf-lagoon); display: block; margin-bottom: .5rem; }
.empty h3 { font-size: 1.05rem; color: var(--mf-ink); }

/* ---------- auth ---------- */
.auth-body { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); background: var(--mf-surface); }
.auth-side { background: var(--mf-harbour); color: #E3EEF0; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side .sidebar-brand { padding: 0; }
.auth-side h2 { font-size: 2rem; line-height: 1.15; max-width: 16ch; color: #fff; }
.auth-side p { color: #A9BEC4; max-width: 38ch; }
.auth-route { position: absolute; right: -40px; bottom: 40px; width: 360px; opacity: .9; pointer-events: none; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-wide { max-width: 640px; }
.auth-mobile-brand { display: none; }
.auth-plain { grid-template-columns: 1fr; background: var(--mf-bg); }
.auth-plain .auth-wrap { background: var(--mf-surface); border: 1px solid var(--mf-line); border-radius: 14px; padding: 2rem; }
.auth-always { display: flex !important; color: var(--mf-ink); margin-bottom: 1.25rem; }
@media (max-width: 899.98px) {
    .auth-body { grid-template-columns: 1fr; }
    .auth-side { display: none; }
    .auth-mobile-brand { display: flex; color: var(--mf-ink); margin-bottom: 1.5rem; }
}

/* ---------- dashboard ---------- */
.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.dash-head h1 { margin: 0; }
.dash-head p { margin: .2rem 0 0; color: var(--mf-muted); }
.dash-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* the delivery flow: the one bold element */
.flow { background: var(--mf-harbour); color: #E3EEF0; border-radius: 14px; padding: 1.4rem 1.5rem 1.2rem; margin-bottom: 1.5rem; }
.flow-top { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.1rem; }
.flow-top h2 { font-size: 1.05rem; margin: 0; color: #fff; }
.flow-top span { font-size: .85rem; color: #9DB2B8; }
.flow-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.flow-step { padding-right: 1rem; position: relative; }
.flow-step .n { font-family: var(--mf-font-head); font-size: 2rem; font-weight: 600; line-height: 1.1; color: #fff; }
.flow-step .l { font-size: .88rem; color: #A9BEC4; }
.flow-step .pct { font-size: .82rem; color: var(--mf-signal); font-weight: 600; }
.flow-bars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-top: 1rem; align-items: end; height: 46px; }
.flow-bar { background: var(--mf-lagoon); border-radius: 4px; min-width: 4px; transition: width .6s ease; height: 100%; }
.flow-bar-wrap { background: rgba(255, 255, 255, .08); border-radius: 4px; height: 100%; display: flex; }
.flow-bar-wrap:nth-child(2) .flow-bar { background: #2E9C94; }
.flow-bar-wrap:nth-child(3) .flow-bar { background: #6CC7BE; }
.flow-bar-wrap:nth-child(4) .flow-bar { background: var(--mf-signal); }
.flow-empty { color: #A9BEC4; margin: 0; }
@media (max-width: 575.98px) { .flow-steps, .flow-bars { grid-template-columns: repeat(2, minmax(0, 1fr)); } .flow-bars { height: auto; } .flow-bar-wrap { height: 14px; } .flow-step { margin-bottom: .75rem; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { background: var(--mf-surface); border: 1px solid var(--mf-line); border-radius: var(--mf-radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; text-decoration: none; color: inherit; }
a.kpi:hover { border-color: var(--mf-lagoon); }
.kpi .v { font-family: var(--mf-font-head); font-size: 1.55rem; font-weight: 600; line-height: 1.2; }
.kpi .k { font-size: .85rem; color: var(--mf-muted); }
.kpi .sub { font-size: .8rem; color: var(--mf-muted); }
.kpi.attn { border-color: var(--mf-signal); background: var(--mf-signal-soft); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
@media (max-width: 1099.98px) { .dash-grid { grid-template-columns: 1fr; } }

.spark { width: 100%; height: 150px; display: block; }
.spark .bar { fill: var(--mf-lagoon); }
.spark .bar:hover { fill: var(--mf-signal); }
.spark .axis { fill: var(--mf-muted); font-size: 10px; }
.spark .grid { stroke: var(--mf-line); stroke-width: 1; }

.meter { height: 8px; border-radius: 999px; background: var(--bs-secondary-bg); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--mf-lagoon); border-radius: 999px; }
.meter.warn > span { background: var(--mf-signal); }
.meter.full > span { background: #C0392B; }
.meter-row + .meter-row { margin-top: 1rem; }
.meter-row .top { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: .35rem; }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.1rem; border-bottom: 1px solid var(--mf-line); }
.list-plain li:last-child { border-bottom: 0; }
.list-plain .grow { flex: 1; min-width: 0; }
.list-plain .grow a { font-weight: 500; text-decoration: none; color: var(--mf-ink); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-plain .grow a:hover { color: var(--mf-lagoon); }
.list-plain .grow small { color: var(--mf-muted); }

.checklist li { align-items: flex-start; }
.checklist .tick { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%; border: 2px solid var(--mf-line); display: grid; place-items: center; font-size: .8rem; color: #fff; margin-top: 1px; }
.checklist li.done .tick { background: var(--mf-lagoon); border-color: var(--mf-lagoon); }
.checklist li.done .grow a { color: var(--mf-muted); text-decoration: line-through; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
