/* ══════════════════════════════════════════════════════════════════════════════
   Meshit theme — the brand layer over Bootstrap.

   Loaded after bootstrap.min.css and site.css. It retokens Bootstrap through its
   CSS variables rather than restyling components one by one, so every page —
   including ones written before this file — picks up the look without edits.

   The accent is the violet at the heart of the Meshit logo; the logo's own
   blue → violet → magenta sweep is kept for brand moments only (the sign-in
   panel, the active nav marker), never for data or status.
   ══════════════════════════════════════════════════════════════════════════════ */

:root {
  --brand: #6d4bff;
  --brand-600: #5a38f0;
  --brand-700: #4a2bd6;
  --brand-50: #f3f0ff;
  --brand-100: #e8e2ff;
  --brand-gradient: linear-gradient(135deg, #1fa2ff 0%, #6d4bff 48%, #e026b5 100%);

  --ink: #161a2c;
  --ink-2: #4a5068;
  --ink-3: #7c8299;
  --line: #e7e8f0;
  --line-2: #f0f1f6;
  --canvas: #f6f7fb;
  --surface: #ffffff;

  --radius: .75rem;
  --radius-sm: .5rem;
  --shadow-sm: 0 1px 2px rgba(22, 26, 44, .04), 0 1px 3px rgba(22, 26, 44, .06);
  --shadow: 0 1px 2px rgba(22, 26, 44, .04), 0 6px 18px -6px rgba(22, 26, 44, .10);

  /* Bootstrap, retokened. */
  --bs-primary: var(--brand);
  --bs-primary-rgb: 109, 75, 255;
  --bs-link-color: var(--brand-600);
  --bs-link-color-rgb: 90, 56, 240;
  --bs-link-hover-color: var(--brand-700);
  --bs-link-hover-color-rgb: 74, 43, 214;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--canvas);
  --bs-secondary-color: var(--ink-3);
  --bs-border-color: var(--line);
  --bs-border-radius: var(--radius-sm);
  --bs-border-radius-lg: var(--radius);
  --bs-body-font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: .9375rem;
  --bs-focus-ring-color: rgba(109, 75, 255, .25);
}

body {
  background-color: var(--canvas);
  color: var(--ink);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

/* Numbers line up in columns, which is most of what this app shows. */
.table, .kpi-value, .text-end { font-variant-numeric: tabular-nums; }

h1, .h1, h2, .h2, h3, .h3, h4, .h4 { color: var(--ink); font-weight: 650; letter-spacing: -.015em; }
.app-main h1.h3, .app-main > h1, .app-main .h3.mb-0, .app-main .h3.mb-1 { font-size: 1.5rem; }

.text-body-secondary, .text-muted { color: var(--ink-3) !important; }
a { text-underline-offset: .15em; }

/* ── Focus ─────────────────────────────────────────────────────────────────── */

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-select:focus, .form-check-input:focus {
  box-shadow: 0 0 0 3px var(--bs-focus-ring-color);
  border-color: var(--brand);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn { border-radius: var(--radius-sm); font-weight: 550; padding: .45rem .95rem; }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; }

.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-600);
  --bs-btn-hover-border-color: var(--brand-600);
  --bs-btn-active-bg: var(--brand-700);
  --bs-btn-active-border-color: var(--brand-700);
  --bs-btn-disabled-bg: var(--brand);
  --bs-btn-disabled-border-color: var(--brand);
  box-shadow: 0 1px 2px rgba(74, 43, 214, .25), inset 0 1px 0 rgba(255, 255, 255, .12);
}

.btn-outline-primary {
  --bs-btn-color: var(--brand-600);
  --bs-btn-border-color: var(--brand-100);
  --bs-btn-bg: var(--brand-50);
  --bs-btn-hover-bg: var(--brand);
  --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand-600);
  --bs-btn-active-border-color: var(--brand-600);
}

.btn-outline-secondary {
  --bs-btn-color: var(--ink-2);
  --bs-btn-border-color: var(--line);
  --bs-btn-bg: var(--surface);
  --bs-btn-hover-bg: var(--line-2);
  --bs-btn-hover-color: var(--ink);
  --bs-btn-hover-border-color: #d9dbe6;
  --bs-btn-active-bg: #e9eaf2;
  --bs-btn-active-color: var(--ink);
  --bs-btn-active-border-color: #d9dbe6;
}

.btn-link { --bs-btn-color: var(--brand-600); --bs-btn-hover-color: var(--brand-700); font-weight: 500; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */

.card {
  --bs-card-border-color: var(--line);
  --bs-card-border-radius: var(--radius);
  --bs-card-inner-border-radius: calc(var(--radius) - 1px);
  --bs-card-cap-bg: transparent;
  box-shadow: var(--shadow-sm);
}

.card-header {
  font-weight: 600;
  color: var(--ink);
  padding: .85rem 1.1rem;
  border-bottom-color: var(--line-2);
}

.card-body { padding: 1.1rem; }
.card.card-body { padding: 1rem 1.1rem; }

/* ── Tables ────────────────────────────────────────────────────────────────── */

.table {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--line-2);
  --bs-table-hover-bg: #faf9ff;
  --bs-table-striped-bg: #fafbfd;
  color: var(--ink);
  margin-bottom: 0;
}

.table > thead > tr > th,
.table > thead th {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-3);
  background: #fafbfd;
  border-bottom: 1px solid var(--line);
  padding-top: .65rem;
  padding-bottom: .65rem;
  white-space: nowrap;
}

.table > :not(caption) > * > * { padding: .7rem .8rem; }
.table-sm > :not(caption) > * > * { padding: .5rem .65rem; }

.table tfoot td, .table tfoot th { border-top: 1px solid var(--line); }
.table-light { --bs-table-bg: #f7f5ff; --bs-table-color: var(--ink); }

/* A table that stands on its own on the page gets a card's surface, so lists read as
   panels rather than lines floating on the canvas. One inside a card is left alone. */
.app-main > .table-responsive,
.app-main > div > .table-responsive:only-child {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.app-main > .table-responsive > .table > thead > tr > th:first-child { border-top-left-radius: var(--radius); }
.app-main > .table-responsive > .table > thead > tr > th:last-child { border-top-right-radius: var(--radius); }
.app-main > .table-responsive > .table > tbody > tr:last-child > * { border-bottom: 0; }

/* ── Badges: soft, readable, never neon ────────────────────────────────────── */

.badge { font-weight: 600; letter-spacing: .01em; border-radius: 999px; padding: .32em .7em; }

.badge.text-bg-success { background: #e3f6ec !important; color: #13744a !important; }
.badge.text-bg-primary { background: var(--brand-50) !important; color: var(--brand-700) !important; }
.badge.text-bg-info { background: #e3f3fd !important; color: #0b6a9e !important; }
.badge.text-bg-warning { background: #fff3d6 !important; color: #8a5a00 !important; }
.badge.text-bg-danger { background: #fde7ea !important; color: #b4233a !important; }
.badge.text-bg-secondary { background: #eef0f5 !important; color: #4a5068 !important; }
.badge.text-bg-light { background: #f4f5f9 !important; color: #5b6178 !important; border: 1px solid var(--line); }
.badge.text-bg-dark { background: #2b2f45 !important; color: #fff !important; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */

.alert { border-radius: var(--radius); border-width: 1px; padding: .85rem 1.05rem; }
.alert-info { --bs-alert-bg: #f3f0ff; --bs-alert-border-color: #e1d9ff; --bs-alert-color: #3b2a9c; }
.alert-success { --bs-alert-bg: #eefaf3; --bs-alert-border-color: #cdeedb; --bs-alert-color: #13603e; }
.alert-warning { --bs-alert-bg: #fff8e8; --bs-alert-border-color: #f6e2b0; --bs-alert-color: #7a5000; }
.alert-danger { --bs-alert-bg: #fff1f2; --bs-alert-border-color: #f8cdd3; --bs-alert-color: #9b1c30; }
.alert-light { --bs-alert-bg: var(--surface); --bs-alert-border-color: var(--line); --bs-alert-color: var(--ink-2); }

/* ── Forms ─────────────────────────────────────────────────────────────────── */

.form-label { font-weight: 550; font-size: .85rem; color: var(--ink-2); margin-bottom: .35rem; }
.form-control, .form-select {
  border-color: #dfe1ea;
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  background-color: var(--surface);
}
.form-control-sm, .form-select-sm { padding: .3rem .6rem; }
.form-control:disabled, .form-select:disabled { background-color: #f4f5f9; color: var(--ink-2); }
.form-text { color: var(--ink-3); font-size: .8rem; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

/* ── The shell ─────────────────────────────────────────────────────────────── */

.app-sidebar { background: var(--surface); border-right: 1px solid var(--line); }
/* Bootstrap zeroes an offcanvas-lg body's padding at lg; this has to out-rank it. */
.app-sidebar .offcanvas-body.app-sidebar-body { padding: 1.35rem .85rem 1rem; }

.app-brand {
  display: flex !important;
  align-items: center;
  gap: .65rem;
  padding: .25rem .5rem 1.1rem;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -.01em;
}
.app-brand:hover { color: var(--ink); }
.app-brand img { width: 36px; height: 36px; }
.app-brand-sub { display: block; font-size: .7rem; font-weight: 500; color: var(--ink-3); letter-spacing: .02em; }

.app-org {
  margin: 0 0 .9rem;
  padding: .65rem .75rem;
  background: var(--canvas);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
}
.app-org-label { font-size: .64rem; letter-spacing: .08em; color: var(--ink-3); }
.app-org-name { font-size: .88rem; }

.app-nav-section {
  font-size: .66rem;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: .9rem .75rem .35rem;
  list-style: none;
}

.app-nav-link {
  display: flex !important;
  align-items: center;
  gap: .65rem;
  color: var(--ink-2);
  font-weight: 500;
  font-size: .9rem;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  position: relative;
}
.app-nav-link .app-icon { color: var(--ink-3); flex: 0 0 auto; transition: color .12s; }

.app-nav-link:hover, .app-nav-link:focus { background: var(--line-2); color: var(--ink); }
.app-nav-link:hover .app-icon { color: var(--ink-2); }

.app-nav-link.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.app-nav-link.active .app-icon { color: var(--brand); }
.app-nav-link.active::before {
  content: "";
  position: absolute;
  left: -.85rem;
  top: .4rem;
  bottom: .4rem;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand-gradient);
}

.app-nav-divider { display: none; }

.app-sidebar-footer { border-top: 1px solid var(--line-2); padding-top: .75rem; }

.app-user { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem .6rem; }
.app-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  flex: 0 0 auto;
}
.app-user-name { color: var(--ink); font-weight: 600; font-size: .85rem; line-height: 1.2; }
.app-user-role { display: block; color: var(--ink-3); font-size: .72rem; font-weight: 500; }

.app-topbar { background: var(--surface); border-bottom-color: var(--line); }
.app-topbar-brand { display: inline-flex; align-items: center; gap: .5rem; color: var(--ink); }
.app-topbar-brand img { width: 28px; height: 28px; }

.app-main { padding: 1.5rem 1rem 2.5rem; }
.app-footer { border-top-color: var(--line); color: var(--ink-3) !important; background: transparent; }

@media (min-width: 992px) {
  .app-sidebar { flex: 0 0 256px; width: 256px; }
  .app-main { padding: 2rem 2.25rem 3rem; max-width: 1480px; width: 100%; }
}

/* The flash message under the page title. */
.app-main > .alert[role="status"] { box-shadow: var(--shadow-sm); }

/* ── Dashboard ─────────────────────────────────────────────────────────────── */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-eyebrow { font-size: .78rem; font-weight: 600; color: var(--brand-600); letter-spacing: .02em; margin-bottom: .2rem; }
.page-head h1 { margin: 0; font-size: 1.75rem; }
.page-sub { color: var(--ink-3); margin: .25rem 0 0; }

.kpi {
  position: relative;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.05rem 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  overflow: hidden;
}
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.kpi-label { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.kpi-icon {
  width: 34px; height: 34px;
  border-radius: .6rem;
  display: grid; place-items: center;
  background: var(--brand-50);
  color: var(--brand);
}
.kpi-icon.is-danger { background: #fde7ea; color: #c02a43; }
.kpi-icon.is-success { background: #e3f6ec; color: #13744a; }
.kpi-icon.is-info { background: #e3f3fd; color: #0b6a9e; }
.kpi-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: .35rem; color: var(--ink); }
.kpi-value .kpi-unit { font-size: .85rem; font-weight: 600; color: var(--ink-3); margin-right: .15rem; }
.kpi-value.is-danger { color: #c02a43; }
.kpi-foot { font-size: .8rem; color: var(--ink-3); }
.kpi-foot a { font-weight: 600; }

/* The billed trend: one series, so no legend — the tile names it. */
.spark { display: block; width: 100%; height: 56px; margin-top: .5rem; overflow: visible; }
.spark rect { fill: var(--brand-100); transition: fill .12s; }
.spark rect.is-current { fill: var(--brand); }
.spark g:hover rect { fill: var(--brand-600); }
.spark .spark-hit { fill: transparent; }
.spark-axis { display: flex; justify-content: space-between; font-size: .68rem; color: var(--ink-3); margin-top: .25rem; }

.attention {
  display: flex;
  gap: .85rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid #f6e2b0;
  border-left: 4px solid #e9a800;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: .9rem 1.1rem;
  margin-bottom: 1.5rem;
}
.attention.is-clear { border-color: #cdeedb; border-left-color: #1f9d63; }
.attention-icon { color: #b27a00; margin-top: .1rem; }
.attention.is-clear .attention-icon { color: #1f9d63; }
.attention-title { font-weight: 650; margin-bottom: .2rem; }
.attention ul { margin: 0; padding-left: 1.1rem; color: var(--ink-2); font-size: .9rem; }

.stat-list { display: grid; gap: .1rem; margin: 0 0 1rem; }
.stat-list > div { display: flex; justify-content: space-between; padding: .5rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.stat-list > div:last-child { border-bottom: 0; }
.stat-list dt { font-weight: 500; color: var(--ink-2); }
.stat-list dd { margin: 0; font-weight: 700; }

/* ── Sign-in ───────────────────────────────────────────────────────────────── */

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--canvas); }
.auth-brand { display: none; }
.auth-panel { display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 2rem 2rem 1.75rem;
}
.auth-logo { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.5rem; font-weight: 700; font-size: 1.1rem; }
.auth-logo img { width: 44px; height: 44px; }

@media (min-width: 992px) {
  .auth-shell { grid-template-columns: minmax(420px, 46%) 1fr; }
  .auth-brand {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem 3.25rem;
    color: #fff;
    background:
      radial-gradient(circle at 15% 20%, rgba(255, 255, 255, .18), transparent 45%),
      radial-gradient(circle at 85% 90%, rgba(255, 255, 255, .12), transparent 40%),
      var(--brand-gradient);
    position: relative;
    overflow: hidden;
  }
  .auth-brand::after {
    content: "";
    position: absolute;
    width: 520px; height: 520px;
    right: -180px; bottom: -200px;
    border-radius: 50%;
    border: 70px solid rgba(255, 255, 255, .08);
  }
  .auth-brand-top { display: flex; align-items: center; gap: .75rem; font-weight: 700; font-size: 1.15rem; }
  .auth-brand-top img { width: 48px; height: 48px; background: #fff; border-radius: 50%; padding: 4px; }
  .auth-brand h2 { color: #fff; font-size: 2.1rem; line-height: 1.2; font-weight: 700; max-width: 26rem; }
  .auth-brand p { color: rgba(255, 255, 255, .85); max-width: 26rem; font-size: 1rem; }
  .auth-points { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .6rem; }
  .auth-points li { display: flex; gap: .6rem; align-items: center; color: rgba(255, 255, 255, .95); }
  .auth-points .app-icon { flex: 0 0 auto; }
  .auth-brand-foot { font-size: .8rem; color: rgba(255, 255, 255, .75); position: relative; z-index: 1; }
  .auth-logo { display: none; }
}

/* ── Phone ─────────────────────────────────────────────────────────────────── */

@media (max-width: 575.98px) {
  .page-head h1 { font-size: 1.4rem; }
  .kpi-value { font-size: 1.35rem; }
  .auth-card { padding: 1.5rem 1.25rem; border-radius: var(--radius); }
}

/* ── Print: the canvas and chrome are noise on paper ───────────────────────── */

@media print {
  .app-sidebar, .app-topbar, .app-footer { display: none !important; }
  body { background: #fff; }
  .card, .kpi, .app-main > .table-responsive { box-shadow: none; }
}

/* ── Public pages ──────────────────────────────────────────────────────────── */

body.public { background: var(--surface); }

.public-header {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line-2);
}

.public-brand { display: flex; align-items: center; gap: .6rem; color: var(--ink); font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.public-brand:hover { color: var(--ink); }
.public-brand img { width: 38px; height: 38px; }

.public-hero {
  background:
    radial-gradient(60rem 30rem at 85% -10%, rgba(224, 38, 181, .10), transparent 60%),
    radial-gradient(50rem 30rem at -10% 10%, rgba(31, 162, 255, .12), transparent 60%),
    linear-gradient(180deg, #faf9ff 0%, #fff 100%);
  border-bottom: 1px solid var(--line-2);
}

.public-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .8rem; font-weight: 600;
  color: var(--brand-700);
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-radius: 999px;
  padding: .3rem .75rem;
  margin-bottom: 1.1rem;
}

.public-title { font-size: clamp(2.2rem, 4.5vw, 3.4rem); font-weight: 800; letter-spacing: -.035em; line-height: 1.08; margin-bottom: 1.1rem; }
.public-gradient-text { background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.public-lead { font-size: 1.1rem; color: var(--ink-2); margin-bottom: 1.75rem; max-width: 34rem; }

.public-preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 30px 60px -25px rgba(74, 43, 214, .35), 0 12px 24px -12px rgba(22, 26, 44, .12);
  overflow: hidden;
  transform: perspective(1400px) rotateY(-6deg) rotateX(2deg);
}
.public-preview-bar { display: flex; gap: .35rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line-2); background: #fafbfd; }
.public-preview-bar span { width: 10px; height: 10px; border-radius: 50%; background: #e2e4ee; }
.public-preview-body { padding: 1.1rem; }
.pp-tile { border: 1px solid var(--line); border-radius: .6rem; padding: .6rem .7rem; }
.pp-tile small { display: block; color: var(--ink-3); font-size: .72rem; font-weight: 600; }
.pp-tile strong { font-size: 1.1rem; }
.pp-chart { display: flex; align-items: flex-end; gap: 8px; height: 90px; padding: .25rem .25rem 0; border-bottom: 1px solid var(--line); margin-bottom: .75rem; }
.pp-chart span { flex: 1; background: var(--brand-100); border-radius: 4px 4px 0 0; }
.pp-chart span:last-child { background: var(--brand); }
.pp-rows > div { display: grid; grid-template-columns: 1.3fr 1fr auto; gap: .5rem; align-items: center; font-size: .8rem; padding: .45rem .1rem; border-bottom: 1px solid var(--line-2); }
.pp-rows > div:last-child { border-bottom: 0; }
.pp-rows span:first-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.pp-rows span:nth-child(2) { color: var(--ink-3); }

@media (max-width: 991.98px) { .public-preview { transform: none; } }

.public-feature {
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.public-feature:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand-100); }
.public-feature-icon {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: .75rem;
  background: var(--brand-50);
  color: var(--brand);
  margin-bottom: .9rem;
}

.public-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
  padding: 2rem 2.25rem;
  border-radius: 1.1rem;
  color: #fff;
  background:
    radial-gradient(circle at 90% 10%, rgba(255, 255, 255, .18), transparent 45%),
    var(--brand-gradient);
}
.public-cta h2 { color: #fff; }
.public-cta p { color: rgba(255, 255, 255, .88); }

.public-footer { border-top: 1px solid var(--line-2); background: #fafbfd; }
