/* =====================================================
   NPI Console — bespoke admin skin
   =====================================================

   This is not a restyle of django-unfold; it replaces Unfold's shell markup
   (see templates/unfold/layouts/base_simple.html and the nav/header partials)
   and styles our own classes. Django still renders forms, permissions,
   actions and every custom flow — only the interface is ours.

   Hand-authored CSS. Unfold ships a PREBUILT Tailwind bundle, so any utility
   it was not compiled with silently does nothing; none of the classes here
   depend on it.

   Namespace: .npi-*  — deliberately distinct from Unfold's classes so the two
   never collide.
   ===================================================== */

/* ── TOKENS ─────────────────────────────────────────── */
:root {
  /* A green-biased neutral ramp: this is a pet marketplace, not a generic
     SaaS, and the greys should belong to the brand rather than be inherited. */
  --npi-canvas:      #F5F7F6;
  --npi-surface:     #FFFFFF;
  --npi-surface-2:   #FAFBFA;
  --npi-border:      #E2E7E4;
  --npi-border-firm: #D2DAD5;

  --npi-ink:         #101B17;   /* 17.4:1 on surface */
  --npi-ink-2:       #55625C;   /*  6.4:1 */
  --npi-ink-3:       #7C8A83;   /*  4.0:1 — non-text only */

  --npi-accent:      #067A55;   /*  5.35:1, and white on it is 5.35:1 */
  --npi-accent-deep: #05563C;
  --npi-accent-soft: #E7F5EF;

  /* Lifecycle states. An order here moves through irreversible physical
     steps, so these are pipeline stages, not decoration. */
  --npi-state-new:   #2E5AAC;
  --npi-state-pay:   #9A5C00;
  --npi-state-go:    #067A55;
  --npi-state-stop:  #C0392B;
  --npi-state-done:  #55625C;

  --npi-new-soft:    #E9EFF9;
  --npi-pay-soft:    #FDF3E3;
  --npi-go-soft:     #E7F5EF;
  --npi-stop-soft:   #FBEBE9;
  --npi-done-soft:   #EFF1F0;

  --npi-r:           10px;
  --npi-r-sm:        6px;
  --npi-r-pill:      999px;

  /* Stripe-grade elevation: barely there, but it separates card from canvas. */
  --npi-shadow:      0 1px 2px rgba(16, 27, 23, .05);
  --npi-shadow-pop:  0 4px 12px -2px rgba(16, 27, 23, .10), 0 2px 4px -2px rgba(16, 27, 23, .06);

  --npi-sidebar-w:   248px;
  --npi-topbar-h:    56px;

  --npi-sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --npi-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

html.dark {
  --npi-canvas:      #0F1512;
  --npi-surface:     #161D1A;
  --npi-surface-2:   #121917;
  --npi-border:      #253029;
  --npi-border-firm: #33413A;
  --npi-ink:         #E8EDEA;
  --npi-ink-2:       #9BA8A2;
  --npi-ink-3:       #74827B;
  --npi-accent:      #34D399;
  --npi-accent-deep: #6EE7B7;
  --npi-accent-soft: #10261C;
  --npi-state-new:   #7BA4E8;
  --npi-state-pay:   #E0A93B;
  --npi-state-go:    #34D399;
  --npi-state-stop:  #F0645B;
  --npi-state-done:  #9BA8A2;
  --npi-new-soft:    #14203A;
  --npi-pay-soft:    #241C0F;
  --npi-go-soft:     #10261C;
  --npi-stop-soft:   #291514;
  --npi-done-soft:   #1B2320;
  --npi-shadow:      0 1px 2px rgba(0, 0, 0, .4);
  --npi-shadow-pop:  0 4px 12px -2px rgba(0, 0, 0, .5), 0 2px 4px -2px rgba(0, 0, 0, .4);
}

/* ── SHELL ──────────────────────────────────────────── */
body.npi {
  margin: 0;
  background: var(--npi-canvas);
  color: var(--npi-ink);
  font-family: var(--npi-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.npi-shell { display: flex; min-height: 100vh; }

/* Sidebar ------------------------------------------------ */
.npi-side {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--npi-sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--npi-surface);
  border-right: 1px solid var(--npi-border);
  z-index: 40;
}
.npi-side__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--npi-topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--npi-border);
  flex: 0 0 auto;
}
.npi-side__mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--npi-accent);
  display: grid; place-items: center;
  color: #fff; font-size: 13px; font-weight: 700;
  flex: 0 0 auto;
}
.npi-side__name {
  font-size: 14px; font-weight: 650; letter-spacing: -.01em;
  color: var(--npi-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.npi-side__scroll { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.npi-side__scroll::-webkit-scrollbar { width: 8px; }
.npi-side__scroll::-webkit-scrollbar-thumb { background: var(--npi-border); border-radius: 4px; }

.npi-navgroup + .npi-navgroup { margin-top: 18px; }
.npi-navgroup__label {
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--npi-ink-3); padding: 0 10px 7px;
}
.npi-nav {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin-bottom: 1px;
  border-radius: var(--npi-r-sm);
  color: var(--npi-ink-2);
  font-size: 13.5px; font-weight: 500;
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
}
.npi-nav:hover { background: var(--npi-surface-2); color: var(--npi-ink); }
.npi-nav.is-active {
  background: var(--npi-accent-soft);
  color: var(--npi-accent);
  font-weight: 600;
}
/* A 2px indicator rather than a filled block: the active row stays quiet. */
.npi-nav.is-active::before {
  content: "";
  position: absolute; left: -12px; top: 6px; bottom: 6px;
  width: 2px; border-radius: 0 2px 2px 0;
  background: var(--npi-accent);
}
.npi-nav__icon {
  width: 16px; text-align: center; flex: 0 0 auto;
  font-size: 16px; line-height: 1; opacity: .85;
}
.npi-nav__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.npi-nav__count {
  margin-left: auto; font-family: var(--npi-mono);
  font-size: 11px; color: var(--npi-ink-3); font-variant-numeric: tabular-nums;
}

.npi-side__foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--npi-border);
  padding: 10px 12px;
}
.npi-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--npi-r-sm); text-decoration: none; }
.npi-user:hover { background: var(--npi-surface-2); }
.npi-user__av {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--npi-accent-soft); color: var(--npi-accent);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: 0 0 auto;
}
.npi-user__who { min-width: 0; }
.npi-user__name { font-size: 13px; font-weight: 600; color: var(--npi-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.npi-user__mail { font-size: 11.5px; color: var(--npi-ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main column -------------------------------------------- */
.npi-main {
  flex: 1; min-width: 0;
  margin-left: var(--npi-sidebar-w);
  display: flex; flex-direction: column;
}

.npi-topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--npi-topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--npi-surface) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--npi-border);
}
.npi-crumb { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--npi-ink-3); min-width: 0; }
.npi-crumb a { color: var(--npi-ink-2); text-decoration: none; white-space: nowrap; }
.npi-crumb a:hover { color: var(--npi-accent); }
.npi-crumb__sep { opacity: .5; }
.npi-crumb__now { color: var(--npi-ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.npi-topbar__spacer { flex: 1; }
.npi-topbar__actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.npi-burger {
  display: none;
  width: 34px; height: 34px; border-radius: var(--npi-r-sm);
  border: 1px solid var(--npi-border); background: var(--npi-surface);
  color: var(--npi-ink-2); cursor: pointer;
  align-items: center; justify-content: center;
}

.npi-page { padding: 28px; max-width: 1440px; width: 100%; }

/* Page header -------------------------------------------- */
.npi-head { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.npi-head__text { min-width: 0; flex: 1; }
.npi-head h1 {
  margin: 0 0 4px;
  font-size: 24px; font-weight: 680; letter-spacing: -.022em; line-height: 1.2;
  color: var(--npi-ink);
}
.npi-head__sub { margin: 0; font-size: 13.5px; color: var(--npi-ink-2); }
.npi-head__actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* ── BUTTONS ────────────────────────────────────────── */
.npi-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--npi-r-sm);
  font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.35;
  border: 1px solid var(--npi-border-firm);
  background: var(--npi-surface); color: var(--npi-ink);
  box-shadow: var(--npi-shadow);
  text-decoration: none; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.npi-btn:hover { background: var(--npi-surface-2); border-color: var(--npi-ink-3); }
.npi-btn--primary {
  background: var(--npi-accent); border-color: var(--npi-accent); color: #fff;
}
.npi-btn--primary:hover { background: var(--npi-accent-deep); border-color: var(--npi-accent-deep); }
.npi-btn--danger { color: var(--npi-state-stop); border-color: var(--npi-border-firm); }
.npi-btn--danger:hover { background: var(--npi-stop-soft); border-color: var(--npi-state-stop); }
.npi-btn--sm { padding: 5px 10px; font-size: 12px; }

/* ── CARDS ──────────────────────────────────────────── */
.npi-card {
  background: var(--npi-surface);
  border: 1px solid var(--npi-border);
  border-radius: var(--npi-r);
  box-shadow: var(--npi-shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.npi-card__head {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--npi-border);
}
.npi-card__title { margin: 0; font-size: 14px; font-weight: 650; color: var(--npi-ink); letter-spacing: -.01em; }
.npi-card__sub { margin: 2px 0 0; font-size: 12.5px; color: var(--npi-ink-2); }
.npi-card__tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.npi-card__body { padding: 18px; }
.npi-card__body--flush { padding: 0; }

/* ── STAT TILES ─────────────────────────────────────── */
.npi-stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 18px; }
.npi-stat {
  background: var(--npi-surface); border: 1px solid var(--npi-border);
  border-radius: var(--npi-r); box-shadow: var(--npi-shadow); padding: 16px 18px;
}
.npi-stat__k { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--npi-ink-3); margin-bottom: 7px; }
.npi-stat__v { display: block; font-size: 25px; font-weight: 680; letter-spacing: -.025em; line-height: 1.1; color: var(--npi-ink); font-variant-numeric: tabular-nums; }
.npi-stat__d { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--npi-state-go); }
.npi-stat__d--down { color: var(--npi-state-stop); }

/* ── BADGES ─────────────────────────────────────────── */
.npi-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--npi-r-pill);
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--npi-done-soft); color: var(--npi-state-done);
}
.npi-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.npi-badge--new  { background: var(--npi-new-soft);  color: var(--npi-state-new); }
.npi-badge--pay  { background: var(--npi-pay-soft);  color: var(--npi-state-pay); }
.npi-badge--go   { background: var(--npi-go-soft);   color: var(--npi-state-go); }
.npi-badge--stop { background: var(--npi-stop-soft); color: var(--npi-state-stop); }

/* ── MONO DATA ──────────────────────────────────────── */
.npi-mono, .npi-amount {
  font-family: var(--npi-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}
.npi-amount { font-weight: 600; }

/* ── FOCUS / MOTION FLOOR ───────────────────────────── */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--npi-accent);
  outline-offset: 2px;
  border-radius: 3px;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 1024px) {
  .npi-side {
    transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: var(--npi-shadow-pop);
  }
  body.npi.is-nav-open .npi-side { transform: none; }
  .npi-main { margin-left: 0; }
  .npi-burger { display: inline-flex; }
  .npi-scrim {
    position: fixed; inset: 0; z-index: 35;
    background: rgba(16, 27, 23, .45);
    opacity: 0; pointer-events: none; transition: opacity .18s ease;
  }
  body.npi.is-nav-open .npi-scrim { opacity: 1; pointer-events: auto; }
}
@media (max-width: 640px) {
  .npi-page { padding: 18px 14px; }
  .npi-topbar { padding: 0 14px; }
  .npi-head { flex-direction: column; gap: 12px; }
  .npi-head__actions { width: 100%; }
  .npi-head h1 { font-size: 20px; }
}

/* ── DATA TABLE ─────────────────────────────────────── */
.npi-table-wrap {
  background: var(--npi-surface);
  border: 1px solid var(--npi-border);
  border-radius: var(--npi-r);
  box-shadow: var(--npi-shadow);
  overflow-x: auto;
}
.npi-table { width: 100%; border-collapse: collapse; }

.npi-table thead th {
  /* Not sticky: .npi-table-wrap is an overflow-x container, and a sticky
     thead inside one collapses onto the first data row. */
  background: var(--npi-surface-2);
  padding: 9px 14px;
  text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--npi-ink-3);
  border-bottom: 1px solid var(--npi-border);
}
.npi-th__sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; }
.npi-th__sort:hover { color: var(--npi-ink); }
.npi-th__dir { font-size: 14px; line-height: 1; }

.npi-table tbody td {
  padding: 0 14px;
  height: 48px;
  border-bottom: 1px solid var(--npi-border);
  color: var(--npi-ink);
  font-size: 13.5px;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.npi-table tbody tr:last-child td { border-bottom: 0; }
.npi-table tbody tr:hover td { background: var(--npi-surface-2); }

/* Keep identity on one line — order numbers used to wrap to three. */
.npi-table tbody td:first-child,
.npi-table tbody th:first-child { white-space: nowrap; }
.npi-table tbody td a { color: var(--npi-ink); text-decoration: none; font-weight: 550; }
.npi-table tbody td a:hover { color: var(--npi-accent); text-decoration: underline; }

/* The lifecycle rail. Django emits status as plain text in a cell, so the
   colour is set by a small script that reads the row's status column. */
.npi-row { position: relative; }
.npi-row td:first-child { position: relative; padding-left: 18px; }
.npi-row td:first-child::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: transparent;
}
.npi-row[data-state="new"]  td:first-child::before { background: var(--npi-state-new); }
.npi-row[data-state="pay"]  td:first-child::before { background: var(--npi-state-pay); }
.npi-row[data-state="go"]   td:first-child::before { background: var(--npi-state-go); }
.npi-row[data-state="stop"] td:first-child::before { background: var(--npi-state-stop); }
.npi-row[data-state="done"] td:first-child::before { background: var(--npi-state-done); }

/* Django renders booleans as icons; keep them from bloating a row. */
.npi-table img { max-height: 16px; vertical-align: middle; }

/* ── EMPTY STATE ────────────────────────────────────── */
.npi-empty {
  background: var(--npi-surface); border: 1px solid var(--npi-border);
  border-radius: var(--npi-r); box-shadow: var(--npi-shadow);
  padding: 56px 24px; text-align: center;
}
.npi-empty__icon { font-size: 34px; color: var(--npi-ink-3); }
.npi-empty__title { margin: 10px 0 4px; font-size: 15px; font-weight: 650; color: var(--npi-ink); }
.npi-empty__sub { margin: 0 0 16px; font-size: 13px; color: var(--npi-ink-2); }

@media (max-width: 640px) {
  .npi-table thead { display: none; }
  .npi-table, .npi-table tbody, .npi-table tr, .npi-table td { display: block; width: 100%; }
  .npi-table-wrap { border: 0; background: transparent; box-shadow: none; overflow: visible; }
  .npi-row {
    background: var(--npi-surface); border: 1px solid var(--npi-border);
    border-left-width: 3px; border-radius: var(--npi-r);
    margin-bottom: 10px; padding: 10px 12px; box-shadow: var(--npi-shadow);
  }
  .npi-row[data-state="new"]  { border-left-color: var(--npi-state-new); }
  .npi-row[data-state="pay"]  { border-left-color: var(--npi-state-pay); }
  .npi-row[data-state="go"]   { border-left-color: var(--npi-state-go); }
  .npi-row[data-state="stop"] { border-left-color: var(--npi-state-stop); }
  .npi-row[data-state="done"] { border-left-color: var(--npi-state-done); }
  .npi-table tbody td { height: auto; padding: 3px 0; border-bottom: 0; }
  .npi-row td:first-child { padding-left: 0; font-weight: 700; font-size: 15px; }
  .npi-row td:first-child::before { display: none; }
}

/* ── OBJECT TOOLS (Add / Export / custom buttons) ───── */
/* Django renders these as <ul class="object-tools"><li><a>. They land in the
   page header, so give them button shape without touching the markup. */
.npi-head__actions ul.object-tools,
.npi-head__actions ul {
  display: flex; align-items: center; gap: 8px;
  list-style: none; margin: 0; padding: 0;
}
.npi-head__actions li { margin: 0; }
.npi-head__actions a,
.npi-head__actions .addlink,
.npi-head__actions button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--npi-r-sm);
  font-size: 13px; font-weight: 600; line-height: 1.35;
  border: 1px solid var(--npi-border-firm);
  background: var(--npi-surface); color: var(--npi-ink);
  box-shadow: var(--npi-shadow); text-decoration: none; white-space: nowrap;
}
.npi-head__actions a:hover { background: var(--npi-surface-2); border-color: var(--npi-ink-3); }
/* The first tool is the primary action — Django always emits Add first. */
.npi-head__actions ul li:first-child > a,
.npi-head__actions a.addlink {
  background: var(--npi-accent); border-color: var(--npi-accent); color: #fff;
}
.npi-head__actions ul li:first-child > a:hover,
.npi-head__actions a.addlink:hover { background: var(--npi-accent-deep); border-color: var(--npi-accent-deep); }
/* Unfold ships a floating round + button; the page header owns that job now. */
.npi-head__actions svg { display: none; }

/* ── DATE HIERARCHY ─────────────────────────────────── */
.npi-page .xfull, #changelist .xfull { margin: 0 0 14px; }
#toolbar, .npi-page #changelist-search { margin: 0; }

/* Dense rows: no cell wraps, the table scrolls sideways instead. Order
   numbers were breaking across three lines, which made every row 80px tall. */
.npi-table td, .npi-table th { white-space: nowrap; }
.npi-table td.npi-wrap { white-space: normal; }
/* The action checkbox column is the rail's home; keep it tight. */
.npi-table td.action-checkbox, .npi-table th.action-checkbox { width: 34px; padding-left: 14px; }

/* ── FORMS ──────────────────────────────────────────── */
.npi-fieldset {
  background: var(--npi-surface);
  border: 1px solid var(--npi-border);
  border-radius: var(--npi-r);
  box-shadow: var(--npi-shadow);
  margin: 0 0 16px;
  padding: 0;
  overflow: hidden;
}
.npi-fieldset__head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--npi-border);
  background: var(--npi-surface);
}
.npi-fieldset__title {
  margin: 0; font-size: 14px; font-weight: 650;
  letter-spacing: -.01em; color: var(--npi-ink);
}
.npi-fieldset__chev { margin-left: auto; color: var(--npi-ink-3); font-size: 18px; }
.npi-fieldset__collapse[open] .npi-fieldset__chev { transform: rotate(180deg); }
.npi-fieldset__collapse > summary { list-style: none; cursor: pointer; }
.npi-fieldset__collapse > summary::-webkit-details-marker { display: none; }
.npi-fieldset__body { padding: 4px 18px 14px; }
.npi-fieldset__desc {
  margin: 12px 0 4px; font-size: 13px; line-height: 1.55; color: var(--npi-ink-2);
  max-width: 72ch;
}

/* Field rows: label left, control right, hairline between. */
.npi-fieldrows .form-row,
.npi-fieldrows > div {
  border-bottom: 1px solid var(--npi-border);
  padding: 13px 0;
}
.npi-fieldrows > div:last-child, .npi-fieldrows .form-row:last-child { border-bottom: 0; }

.npi-fieldset label {
  font-size: 13px; font-weight: 600; color: var(--npi-ink);
}
.npi-fieldset .help, .npi-fieldset .helptext {
  display: block; margin-top: 5px;
  font-size: 12.5px; line-height: 1.5; color: var(--npi-ink-2); max-width: 70ch;
}

/* Inputs: one consistent control across every widget Django emits. */
.npi-page input[type="text"], .npi-page input[type="email"], .npi-page input[type="url"],
.npi-page input[type="number"], .npi-page input[type="password"], .npi-page input[type="date"],
.npi-page input[type="time"], .npi-page input[type="datetime-local"], .npi-page input[type="search"],
.npi-page select, .npi-page textarea {
  font-family: inherit; font-size: 13.5px; color: var(--npi-ink);
  background: var(--npi-surface);
  border: 1px solid var(--npi-border-firm);
  border-radius: var(--npi-r-sm);
  padding: 8px 11px;
  max-width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.npi-page textarea { line-height: 1.55; }
.npi-page input:focus, .npi-page select:focus, .npi-page textarea:focus {
  outline: none;
  border-color: var(--npi-accent);
  box-shadow: 0 0 0 3px var(--npi-accent-soft);
}
.npi-page input::placeholder, .npi-page textarea::placeholder { color: var(--npi-ink-3); }
.npi-page input[disabled], .npi-page select[disabled], .npi-page textarea[disabled] {
  background: var(--npi-surface-2); color: var(--npi-ink-3); cursor: not-allowed;
}

/* Errors. No required marker here: Unfold's field template already emits
   one, and adding ours produced "Coupon code* *" on every required field. */
.npi-page .errorlist {
  list-style: none; margin: 6px 0 0; padding: 0;
  font-size: 12.5px; color: var(--npi-state-stop); font-weight: 500;
}
.npi-page .errors input, .npi-page .errors select, .npi-page .errors textarea {
  border-color: var(--npi-state-stop);
}

/* filter_horizontal: Django's dual listbox, given our surface. */
.npi-page .selector { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.npi-page .selector select { min-height: 160px; padding: 4px; }
.npi-page .selector h2 {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--npi-ink-3); background: transparent; margin: 0 0 6px; padding: 0;
}
.npi-page .selector-chosen h2 { color: var(--npi-accent); }
.npi-page .selector-clearall, .npi-page .selector-clear { color: var(--npi-state-stop); font-size: 12px; }

/* ── SUBMIT BAR ─────────────────────────────────────── */
.npi-submit {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  margin: 18px -28px -28px;
  padding: 12px 28px;
  background: color-mix(in srgb, var(--npi-surface) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--npi-border);
}
.npi-submit__left { display: flex; gap: 8px; }
.npi-submit__right { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.npi-submit input[type="submit"] { cursor: pointer; }

@media (max-width: 640px) {
  .npi-submit { margin: 14px -14px -18px; padding: 10px 14px; }
  .npi-submit__right { width: 100%; }
  .npi-fieldset__body { padding: 4px 14px 12px; }
}

/* Unfold ships the Add link as a floating round button that positions itself
   against the viewport. In our shell it lives in the page header, so pin it
   back into normal flow — free-floating it pushed the page 7px wide on a
   390px screen, and the scrim then inherited that width. */
.npi-head__actions a.addlink,
.npi-head__actions .addlink {
  position: static;
  width: auto; height: auto;
  border-radius: var(--npi-r-sm);
}
.npi-scrim { max-width: 100%; }

@media (max-width: 640px) {
  /* Header actions wrap onto as many lines as they need. Pinning the Add
     link into flow gave it its full label width, which then would not fit
     beside Export/POS on one row. */
  .npi-head__actions, .npi-head__actions ul { flex-wrap: wrap; }
  .npi-head__actions a, .npi-head__actions button { max-width: 100%; }
}

/* ── SIGN IN ────────────────────────────────────────── */
/* The login templates use Tailwind classes Unfold's prebuilt bundle never
   compiled, so they resolve to nothing. Style the elements directly instead
   of rewriting that markup. */
body.npi-auth-body { background: var(--npi-canvas); }

.npi-auth {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 32px 18px;
}
.npi-auth__card {
  width: 100%; max-width: 400px;
  background: var(--npi-surface);
  border: 1px solid var(--npi-border);
  border-radius: 14px;
  box-shadow: var(--npi-shadow-pop);
  overflow: hidden;
}
.npi-auth__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--npi-border);
}
.npi-auth__mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--npi-accent); color: #fff;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.npi-auth__name { font-size: 14px; font-weight: 650; color: var(--npi-ink); letter-spacing: -.01em; }
.npi-auth__body { padding: 26px 22px 24px; }
.npi-auth__foot { margin: 0; font-size: 12.5px; color: var(--npi-ink-3); }

/* Headings inside the card */
.npi-auth h1 {
  margin: 0 0 4px; font-size: 19px; font-weight: 680;
  letter-spacing: -.02em; color: var(--npi-ink); text-align: center;
}
.npi-auth h1 + p, .npi-auth .text-center p {
  margin: 0 0 4px; font-size: 13px; color: var(--npi-ink-2); text-align: center;
}

/* Forms */
.npi-auth form { display: flex; flex-direction: column; gap: 14px; }
.npi-auth label {
  display: block; margin-bottom: 5px;
  font-size: 13px; font-weight: 600; color: var(--npi-ink);
}
.npi-auth input[type="text"], .npi-auth input[type="password"],
.npi-auth input[type="email"], .npi-auth input[type="number"],
.npi-auth input[type="tel"], .npi-auth input:not([type]) {
  width: 100%;
  font-family: inherit; font-size: 14px; color: var(--npi-ink);
  background: var(--npi-surface);
  border: 1px solid var(--npi-border-firm);
  border-radius: var(--npi-r-sm);
  padding: 10px 12px;
}
.npi-auth input:focus {
  outline: none; border-color: var(--npi-accent);
  box-shadow: 0 0 0 3px var(--npi-accent-soft);
}
.npi-auth button, .npi-auth input[type="submit"] {
  width: 100%;
  font-family: inherit; font-size: 14px; font-weight: 650;
  padding: 10px 16px; border-radius: var(--npi-r-sm);
  background: var(--npi-accent); border: 1px solid var(--npi-accent); color: #fff;
  cursor: pointer;
}
.npi-auth button:hover, .npi-auth input[type="submit"]:hover {
  background: var(--npi-accent-deep); border-color: var(--npi-accent-deep);
}
.npi-auth a { color: var(--npi-accent); font-size: 13px; text-decoration: none; }
.npi-auth a:hover { text-decoration: underline; }

/* The templates mark errors with Tailwind's bg-red-50 / border-red-300, which
   do not exist in the bundle. Match on those class names directly. */
.npi-auth [class*="bg-red"], .npi-auth .errornote, .npi-auth .errorlist {
  background: var(--npi-stop-soft);
  border: 1px solid var(--npi-state-stop);
  color: var(--npi-state-stop);
  border-radius: var(--npi-r-sm);
  padding: 10px 12px; font-size: 13px; font-weight: 500;
  list-style: none; margin: 0;
}
.npi-auth [class*="text-gray-5"], .npi-auth [class*="text-sm"] { color: var(--npi-ink-2); }

/* OTP entry: give the code field room and let it read as a code. */
.npi-auth input[name*="otp"], .npi-auth input[name*="code"] {
  font-family: var(--npi-mono); font-size: 20px; letter-spacing: .3em;
  text-align: center; font-variant-numeric: tabular-nums;
}

/* The login template puts its own text-colour class on the submit button's
   label, which won over the button's colour and left "Continue" dark on
   green. Force the label to inherit. */
.npi-auth button, .npi-auth input[type="submit"],
.npi-auth button *, .npi-auth input[type="submit"] * { color: #fff !important; }

/* ── CONTAINMENT ────────────────────────────────────── */
/* The console skin must be self-sufficient: on nearpetshop these rules also
   exist in admin_unfold.css, but a brand that only gets admin_console.css
   was left with 59 overflowing pages at 390px. Generic, no brand content. */

/* Flex and grid children default to min-width:auto and refuse to shrink below
   their content, which is how one wide table drags a whole page sideways. */
.npi-page .grow,
.npi-page [class*="px-4"],
.npi-page .module,
.npi-page fieldset.module,
.npi-page fieldset.module .form-rows { min-width: 0; max-width: 100%; }
.npi-page fieldset.module,
.npi-page fieldset.module .form-rows { overflow-x: auto; }

@media (max-width: 640px) {
  /* App index cards and any Django module scroll inside themselves. */
  .npi-page div[class*="app-"].module,
  .npi-page .module { max-width: 100%; overflow-x: auto; }

  /* Wide tables scroll in their own box rather than the page.
     #result_list is excluded — it card-stacks instead. */
  .npi-page table:not(#result_list) {
    display: block; max-width: 100%; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Labels above controls instead of a forced two-column grid. */
  .npi-page .form-row { display: block; }
  .npi-page .form-row label { display: block; margin-bottom: 4px; }

  /* Anything that lays out in a row may wrap. */
  .npi-page .flex, .npi-page form .flex { flex-wrap: wrap; }
  .npi-page button, .npi-page .button, .npi-page input[type="submit"] { max-width: 100%; }
}
