/* ==========================================================================
   Shared UI primitives — cards, forms, chips, lists, pagination.
   Loaded by the storefront, the control panel and the auth screens alike.
   Depends on the design tokens defined in g4g.css.
   ========================================================================== */

:root { --p-gap: clamp(16px, 2.2vw, 26px); }

.p-card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden;
}

.p-card__head {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
}

.p-card__head h2 { font-family: var(--font-display); font-size: 1.02rem; letter-spacing: -.02em; font-weight: 600; }

.p-card__head .p-spacer { margin-left: auto; }

.p-card__body { padding: 20px; }

.p-card__body--flush { padding: 0; }

.p-grid { display: grid; gap: var(--p-gap); }

.p-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.p-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.p-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.p-grid--sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }

@media (max-width: 1180px) {
    .p-grid--4 { grid-template-columns: repeat(2, 1fr); }
    .p-grid--sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .p-grid--3, .p-grid--2 { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .p-grid--4 { grid-template-columns: 1fr; }
}

.p-thumb {
    width: 52px; height: 42px; border-radius: 9px; flex: none; overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--line);
    display: grid; place-items: center;
}

.p-thumb img { width: 100%; height: 100%; object-fit: cover; }

.p-thumb svg { width: 80%; }

.p-prod { display: flex; align-items: center; gap: 12px; min-width: 0; }

.p-prod b { display: block; font-family: var(--font-body); font-size: .9rem; font-weight: 600; letter-spacing: 0; }

:where(.p-prod) :where(span) { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }

.p-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    font-family: var(--font-mono); font-size: 10px; font-weight: 600;
    letter-spacing: .08em; text-transform: uppercase;
    border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
    white-space: nowrap;
}

.p-chip--live   { background: rgba(22, 163, 74, .14); border-color: rgba(22, 163, 74, .35); color: #16a34a; }

.p-chip--draft  { background: var(--brand-tint); border-color: var(--brand-line); color: var(--brand); }

.p-chip--arch   { background: var(--surface-3); }

.p-chip--low    { background: var(--brand-tint); border-color: var(--brand-line); color: var(--brand); }

.p-chip--out    { background: rgba(220, 38, 38, .14); border-color: rgba(220, 38, 38, .35); color: #ef4444; }

.p-chip--admin  { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; color: var(--on-brand); }

.p-chip--manager{ background: var(--brand-tint); border-color: var(--brand-line); color: var(--brand); }

.p-chip--star   { color: var(--brand); border-color: var(--brand-line); }

.p-chip--star svg { width: 11px; height: 11px; fill: currentColor; }

.p-field { display: grid; gap: 7px; }

.p-field > label, .p-label {
    font-family: var(--font-mono); font-size: 10px; font-weight: 700;
    letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}

.p-input, .p-select, .p-textarea {
    /* the global reset makes inputs inherit fonts, so pin the face explicitly */
    font-family: var(--font-body);
    width: 100%; padding: 11px 14px; border-radius: 11px;
    background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
    font-size: .93rem;
    transition: border-color .25s var(--ease), background .25s var(--ease), box-shadow .25s var(--ease);
}

.p-input:focus, .p-select:focus, .p-textarea:focus {
    outline: none; border-color: var(--brand); background: var(--surface);
    box-shadow: 0 0 0 4px var(--brand-tint);
}

.p-textarea { min-height: 112px; resize: vertical; line-height: 1.6; }

.p-select { appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8b9c' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
    padding-right: 36px;
}

.p-input--money { font-family: var(--font-mono); }

.p-hint { font-size: .78rem; color: var(--muted); }

.p-error { font-size: .8rem; color: #ef4444; }

.p-input.is-bad, .p-select.is-bad { border-color: #ef4444; }

.p-row { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.p-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 720px) {
    .p-row, .p-row--3 { grid-template-columns: 1fr; }
}

.p-switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }

.p-switch input { position: absolute; opacity: 0; pointer-events: none; }

.p-switch__track {
    width: 44px; height: 26px; border-radius: 999px; flex: none;
    background: var(--surface-3); border: 1px solid var(--line); position: relative;
    transition: background .3s var(--ease), border-color .3s var(--ease);
}

.p-switch__track::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
    background: var(--muted); transition: transform .32s var(--ease-bump), background .3s var(--ease);
}

.p-switch input:checked + .p-switch__track { background: var(--brand); border-color: transparent; }

.p-switch input:checked + .p-switch__track::after { transform: translateX(18px); background: #fff; }

.p-switch input:focus-visible + .p-switch__track { box-shadow: 0 0 0 4px var(--brand-tint); }

.p-switch__text b { display: block; font-size: .9rem; font-weight: 600; }

.p-switch__text span { font-size: .78rem; color: var(--muted); }

.p-bulk .p-spacer { margin-left: auto; }

.p-pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; padding: 16px; }

.p-pager a, .p-pager span {
    min-width: 34px; height: 34px; padding: 0 10px; border-radius: 10px;
    display: inline-grid; place-items: center;
    font-family: var(--font-mono); font-size: .8rem;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
    transition: all .25s var(--ease);
}

.p-pager a:hover { border-color: var(--brand-line); color: var(--brand); }

.p-pager .is-on { background: var(--brand); border-color: transparent; color: var(--on-brand); font-weight: 700; }

.p-pager .is-off { opacity: .4; }

.p-list { display: grid; gap: 2px; }

.p-listrow {
    display: flex; align-items: center; gap: 12px; padding: 11px 20px;
    border-bottom: 1px solid var(--line); transition: background .2s var(--ease);
}

.p-listrow:last-child { border-bottom: 0; }

.p-listrow:hover { background: var(--surface-2); }

.p-listrow b { display: block; font-family: var(--font-body); font-size: .88rem; font-weight: 600; letter-spacing: 0; }

:where(.p-listrow) :where(span) { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }

.p-listrow .p-spacer { margin-left: auto; }

/*
   --p-top is the control panel's fixed top bar and only exists in panel.css.
   The storefront loads neither, so without a fallback the calc() was invalid
   and every sticky sidebar out there silently stopped sticking.
*/
.p-sticky { position: sticky; top: calc(var(--p-top, var(--header-h, 0px)) + var(--p-gap)); }


/* ---------- Fulfilment tracker + stage chips (panel and storefront) ---------- */

.stage {
    display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
    padding: 5px 11px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface-2);
    font-family: var(--font-mono); font-size: 10px; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}

.stage i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.stage--received      { color: var(--ink-2); }

.stage--confirmed     { background: var(--brand-tint); border-color: var(--brand-line); color: var(--brand); }

.stage--packing       { background: rgba(168, 85, 247, .14); border-color: rgba(168, 85, 247, .35); color: #a855f7; }

.stage--ready_to_ship { background: rgba(14, 165, 233, .14); border-color: rgba(14, 165, 233, .35); color: #0ea5e9; }

.stage--shipped       { background: rgba(234, 179, 8, .14); border-color: rgba(234, 179, 8, .35); color: #eab308; }

.stage--delivered     { background: rgba(22, 163, 74, .14); border-color: rgba(22, 163, 74, .35); color: #16a34a; }

.stage--cancelled     { background: rgba(220, 38, 38, .12); border-color: rgba(220, 38, 38, .35); color: #ef4444; }

.stage--received i    { animation: pulseSoft 2s var(--ease) infinite; }

.track { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }

.track__line {
    position: absolute; top: 21px; left: 8%; right: 8%; height: 3px;
    border-radius: 999px; background: var(--surface-3); overflow: hidden;
}

.track__line i {
    display: block; height: 100%; width: var(--progress, 0%);
    background: linear-gradient(90deg, var(--brand), var(--brand-2));
    transition: width .8s var(--ease-out);
}

.track__step { position: relative; text-align: center; display: grid; gap: 5px; justify-items: center; }

.track__dot {
    width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
    background: var(--surface-2); border: 2px solid var(--line); color: var(--muted);
    transition: all .4s var(--ease-bump);
}

.track__dot svg { width: 18px; height: 18px; }

.track__step.is-done .track__dot { background: var(--brand); border-color: transparent; color: var(--on-brand); }

.track__step.is-now .track__dot {
    background: var(--surface); border-color: var(--brand); color: var(--brand);
    box-shadow: 0 0 0 5px var(--brand-tint);
    animation: bump .6s var(--ease-bump);
}

.track__step b { font-size: .84rem; font-weight: 600; }

.track__step em { font-style: normal; font-size: .74rem; color: var(--muted); line-height: 1.45; max-width: 20ch; }

.track__step .mono { font-size: 10px; color: var(--muted); }

.track__step.is-off b, .track__step.is-off em { opacity: .55; }

@media (max-width: 900px) {
    .track { grid-template-columns: 1fr; gap: 18px; }
    .track__line { display: none; }
    .track__step { grid-template-columns: 44px 1fr; text-align: left; justify-items: start; align-items: center; }
    .track__step b, .track__step em, .track__step .mono { grid-column: 2; }
    .track__dot { grid-row: span 3; }
}

/* ---------------------------------------------------------------------------
   Auth: password guidance, code entry, prefixed fields
   ------------------------------------------------------------------------ */

.p-field__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.p-field__aside { font-size: .8rem; font-weight: 600; color: var(--brand); }

.p-field__aside:hover { text-decoration: underline; }

/* A country code welded to the left of the input. */
.p-prefixed { display: flex; align-items: stretch; }

.p-prefixed__tag {
    display: grid;
    place-items: center;
    padding: 0 12px;
    font-family: var(--font-mono);
    font-size: .86rem;
    color: var(--muted);
    background: rgba(127, 127, 127, .08);
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: 12px 0 0 12px;
}

.p-prefixed .p-input { border-radius: 0 12px 12px 0; flex: 1; min-width: 0; }

/* Six digits, spaced out so they can be read back off a text message. */
.p-input--code {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    letter-spacing: .5em;
    text-align: center;
    padding-left: .5em;
}

/* A form body that fills its card, so buttons line up across a row of cards. */
.p-form { display: flex; flex-direction: column; gap: 16px; }

.p-form__foot { margin-top: auto; display: grid; gap: 12px; justify-items: start; }

/* Rules and meta blocks in a footer still want the full column width. */
.p-form__foot > dl, .p-form__foot > hr { justify-self: stretch; }

/* The strength meter and its checklist. */
.pwm { display: grid; gap: 8px; margin-top: 4px; }

.pwm__bar {
    height: 4px;
    border-radius: 999px;
    background: rgba(127, 127, 127, .18);
    overflow: hidden;
}

.pwm__bar span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--muted);
    transition: width .25s ease, background-color .25s ease;
}

.pwm__verdict { font-size: .78rem; color: var(--muted); }

.pwm.is-weak   .pwm__bar span { background: #ef4444; }
.pwm.is-fair   .pwm__bar span { background: #f59e0b; }
.pwm.is-good   .pwm__bar span { background: #22c55e; }
.pwm.is-strong .pwm__bar span { background: #16a34a; }

.pwm.is-weak   .pwm__verdict { color: #ef4444; }
.pwm.is-fair   .pwm__verdict { color: #f59e0b; }
.pwm.is-good   .pwm__verdict,
.pwm.is-strong .pwm__verdict { color: #16a34a; }

.pwm__list {
    display: grid;
    gap: 5px;
    margin: 2px 0 0;
    padding: 0;
    list-style: none;
}

/*
   In a wide card the checklist flows into columns rather than stacking into
   one tall wall; in a narrow one auto-fit collapses it back to a single file.
*/
.pwm--split .pwm__list { grid-template-columns: repeat(auto-fit, minmax(228px, 1fr)); gap: 6px 18px; }

.pwm__list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .78rem;
    color: var(--muted);
    transition: color .2s ease;
}

.pwm__tick {
    width: 14px;
    height: 14px;
    flex: none;
    border-radius: 50%;
    border: 1.5px solid currentColor;
    opacity: .5;
    position: relative;
    transition: opacity .2s ease, background-color .2s ease, border-color .2s ease;
}

.pwm__list li.is-ok { color: #16a34a; }

.pwm__list li.is-ok .pwm__tick {
    opacity: 1;
    background: #16a34a;
    border-color: #16a34a;
}

/* The tick itself, drawn rather than fetched. */
.pwm__list li.is-ok .pwm__tick::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 3px;
    height: 6px;
    border: solid #fff;
    border-width: 0 1.6px 1.6px 0;
    transform: translateY(-1px) rotate(45deg);
}

/* Someone tried to submit before the list was satisfied. */
.pwm.is-nagging .pwm__list li:not(.is-ok) { color: #ef4444; }

.pwm.is-nagging .pwm__verdict::after {
    content: ' Please finish the list below.';
    color: #ef4444;
}

/* The email fallback on the forgotten-password page, folded away by default. */
.a-detail { text-align: left; }

.a-detail > summary {
    cursor: pointer;
    font-size: .86rem;
    font-weight: 600;
    color: var(--brand);
    list-style: none;
    padding: 6px 0;
}

.a-detail > summary::-webkit-details-marker { display: none; }

.a-detail > summary::before { content: '＋ '; font-weight: 400; }

.a-detail[open] > summary::before { content: '－ '; }

.a-detail > form { display: grid; gap: 14px; margin-top: 12px; }

/* Firebase drops an invisible challenge in here; it only takes room if used. */
#otp-recaptcha:empty { display: none; }

[data-otp-status].is-bad { color: #ef4444; }

/* ---------------- Continue with Google ---------------- */

/*
   Sits above the email-and-password form on the auth pages. The rule is that
   the fastest way in goes first; the divider below it stops the two reading as
   one form.
*/
.p-social { display: grid; gap: 12px; }

/* The Google mark carries its own fills, so the button's hover colour changes
   the label without touching the artwork. */
.p-social__btn { gap: 10px; font-weight: 600; }

.p-social__btn[disabled] { opacity: .6; pointer-events: none; transform: none; }

.p-social__error {
    margin: 0;
    font-size: .82rem;
    line-height: 1.5;
    color: #ef4444;
}

/* A hairline with a word in it. */
.p-or {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
    font-size: .78rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.p-or::before,
.p-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* ---------------- Two ways back into an account ---------------- */

/*
   The forgotten-password page offers email and mobile as peers rather than
   burying one in a disclosure — an account opened with Google has no mobile
   number and no password, so the email door is the only one it has.
*/
.p-way { display: grid; gap: 14px; }

.p-way__title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.p-way__title svg { width: 17px; height: 17px; flex: none; color: var(--brand); }

.p-way__lead { margin: -6px 0 0; font-size: .86rem; line-height: 1.55; color: var(--muted); }

.p-way form { display: grid; gap: 14px; }

/* ---------------------------------------------------------------------------
   Account page
   ------------------------------------------------------------------------ */

.acct { display: grid; gap: var(--p-gap); }

/* ---------- Identity header ---------- */

.acct-hero {
    position: relative;
    display: flex; flex-wrap: wrap; align-items: center;
    gap: clamp(16px, 2.4vw, 28px);
    padding: clamp(22px, 2.8vw, 32px);
}

.acct-hero::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(680px 240px at 0% 0%, var(--brand-tint), transparent 70%);
}

.acct-hero > * { position: relative; }

.acct-hero__avatar {
    width: 68px; height: 68px; border-radius: 20px;
    font-size: 1.35rem; box-shadow: var(--shadow-brand);
}

.acct-hero__id { display: grid; gap: 8px; min-width: 0; }

.acct-hero__id h1 {
    font-family: var(--font-display); font-weight: 700;
    font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.1; letter-spacing: -.03em;
}

.acct-hero__mail {
    font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em;
    color: var(--muted); overflow-wrap: anywhere;
}

.acct-hero__side { margin-left: auto; display: grid; gap: 14px; justify-items: end; }

.acct-hero__chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.acct-hero__actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

@media (max-width: 720px) {
    .acct-hero__side { margin-left: 0; justify-items: start; width: 100%; }
    .acct-hero__chips, .acct-hero__actions { justify-content: flex-start; }
}

/* ---------- Quick actions ---------- */

/* Always four, so the row never leaves one tile stranded on its own line. */
.acct-quick { display: grid; gap: var(--p-gap); grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1000px) { .acct-quick { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (max-width: 560px)  { .acct-quick { grid-template-columns: 1fr; } }

.acct-quick__item {
    display: flex; align-items: center; gap: 12px; min-width: 0;
    padding: 15px 17px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--line);
    transition: transform .3s var(--ease-bump), border-color .25s var(--ease), box-shadow .3s var(--ease);
}

.acct-quick__item:hover {
    transform: translateY(-3px);
    border-color: var(--brand-line);
    box-shadow: var(--shadow-sm);
}

.acct-quick__ico {
    width: 38px; height: 38px; flex: none; border-radius: 12px;
    display: grid; place-items: center;
    background: var(--brand-tint); color: var(--brand);
}

.acct-quick__ico svg { width: 18px; height: 18px; }

.acct-quick__txt { min-width: 0; }

.acct-quick__txt b { display: block; font-size: .92rem; font-weight: 600; letter-spacing: -.01em; }

.acct-quick__txt span { display: block; font-size: .78rem; color: var(--muted); }

/* ---------- Orders ---------- */

.acct-count { color: var(--muted); }

.acct-empty { padding: 48px 24px; }

/* ---------- Settings ---------- */

/* Flex cards so each form can push its button to a shared baseline. */
.acct-settings > .p-card { display: flex; flex-direction: column; }

.acct-settings .p-form { flex: 1; }

.acct-meta {
    display: grid; gap: 9px; margin: 0 0 4px;
    padding-top: 14px; border-top: 1px dashed var(--line);
}

.acct-meta > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.acct-meta dt {
    font-family: var(--font-mono); font-size: 10px; font-weight: 700;
    letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}

.acct-meta dd { margin: 0; font-size: .88rem; font-weight: 600; }

.acct-note {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border-radius: var(--radius-sm);
    background: var(--brand-tint); border: 1px solid var(--brand-line);
    font-size: .82rem; line-height: 1.55; color: var(--ink-2);
}

.acct-note__ico { flex: none; color: var(--brand); }

.acct-note__ico svg { display: block; width: 16px; height: 16px; }

/* ---------------------------------------------------------------------------
   EMI — the checkout option, the tenure table, and the panel editor
   ------------------------------------------------------------------------ */

/* A payment row that is advertised but cannot be picked yet. */
.pay--soon .pay__box { opacity: .72; cursor: not-allowed; }

.pay--soon:hover .pay__box { border-color: var(--line); }

.pay__soon {
    margin-left: auto; flex: none;
    padding: 4px 10px; border-radius: 999px;
    background: var(--brand-tint); border: 1px solid var(--brand-line); color: var(--brand);
    font-family: var(--font-mono); font-size: 9.5px; font-weight: 700;
    letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
}

.pay__flag {
    font-family: var(--font-mono); font-size: 10px; font-weight: 700;
    letter-spacing: .06em; color: var(--brand);
}

/* The fold-down that lists cards and tenures. */
.emi-peek { margin-top: 2px; }

.emi-peek > summary {
    cursor: pointer; list-style: none; padding: 6px 0;
    font-size: .84rem; font-weight: 600; color: var(--brand);
}

.emi-peek > summary::-webkit-details-marker { display: none; }

.emi-peek > summary::before { content: '＋ '; font-weight: 400; }

.emi-peek[open] > summary::before { content: '－ '; }

.emi-peek__grid {
    display: grid; gap: 12px; margin: 10px 0 12px;
    grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
}

.emi-peek__card {
    padding: 13px 15px; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--line);
}

.emi-peek__card > b {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: .89rem; font-weight: 600;
}

.emi-peek__card > .mono { display: block; margin: 3px 0 9px; font-size: 10px; color: var(--muted); }

.emi-peek__card ul { display: grid; gap: 5px; margin: 0; }

.emi-peek__card li {
    display: flex; align-items: baseline; gap: 8px;
    font-size: .8rem; color: var(--ink-2);
}

.emi-peek__card li.is-off { opacity: .45; }

.emi-peek__card li em { font-style: normal; font-size: .74rem; color: var(--muted); }

.emi-peek__card li b { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--brand); }

/* ---------- Panel: status strip ---------- */

.emi-state__grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.emi-stat { display: grid; gap: 3px; min-width: 0; }

.emi-stat > span {
    font-family: var(--font-mono); font-size: 10px; font-weight: 700;
    letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}

.emi-stat > b { font-size: 1.02rem; font-weight: 600; letter-spacing: -.01em; }

.emi-stat > em { font-style: normal; font-size: .78rem; color: var(--muted); line-height: 1.45; }

.emi-missing {
    border-top: 1px solid var(--line);
    background: var(--brand-tint);
    display: grid; gap: 8px;
}

.emi-missing p { font-size: .84rem; color: var(--ink-2); line-height: 1.55; max-width: 68ch; }

.emi-missing__list { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0; }

.emi-missing__list li {
    padding: 4px 9px; border-radius: 7px;
    background: var(--surface); border: 1px solid var(--brand-line);
}

.emi-missing code, .emi-missing__list code {
    font-family: var(--font-mono); font-size: 11px; color: var(--brand);
}

/* ---------- Panel: one card and its tenures ---------- */

.emi-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

.emi-card.is-off { opacity: .6; }

.emi-card__head {
    display: flex; flex-wrap: wrap; align-items: center; gap: 9px;
    padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line);
}

.emi-card__head .p-input, .emi-card__head .p-select { width: auto; padding: 8px 11px; font-size: .86rem; }

.emi-card__name { min-width: 170px; flex: 1 1 170px; font-weight: 600; }

.emi-card__sort { width: 72px; }

.emi-plans { display: grid; gap: 8px; padding: 12px 14px; }

/* A fixed grid, not flex-wrap: every row then lines its columns up with the
   one above whether or not it carries a "no cost" chip. */
.emi-plan {
    display: grid; align-items: center; gap: 8px;
    grid-template-columns: 104px 104px 96px 96px 82px 62px 1fr auto auto;
}

.emi-plan .p-input { width: 100%; padding: 8px 11px; font-size: .86rem; }

.emi-plan__months, .emi-plan__rate { display: inline-flex; align-items: center; gap: 5px; }

.emi-plan__flag { display: flex; justify-content: flex-start; min-width: 0; }

.emi-plan__flag .p-chip { padding: 3px 7px; font-size: 9px; }

/* The add row has no delete button, so its submit takes the last two slots. */
.emi-plan__add { grid-column: -3 / -1; }

.emi-plan__months em, .emi-plan__rate em {
    font-style: normal; font-family: var(--font-mono); font-size: 11px; color: var(--muted);
}

.emi-plan--new { padding-top: 10px; border-top: 1px dashed var(--line); }

@media (max-width: 900px) {
    .emi-plan { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .emi-plan__add, .emi-plan .p-spacer { grid-column: auto; }
    .emi-plan .p-spacer { display: none; }
}

@media (max-width: 720px) {
    .emi-card__head { gap: 7px; }
    .emi-card__name { flex-basis: 100%; }
    .emi-plan { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* A button that has to look like a link, because the action it performs needs a
   form behind it (CSRF) but reads as a quiet way out, not a call to action. */
.p-linkish {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--brand);
    font-weight: 600;
    cursor: pointer;
}

.p-linkish:hover { text-decoration: underline; }

/* ---------- Closing an account ------------------------------------------- */
/* The one destructive control on the account page. It is allowed to look
   different from everything around it — that is the whole point of it.
   #ef4444 rather than a token because that is the red the rest of this
   stylesheet already uses for a bad field. */
.acct-danger { border-color: color-mix(in srgb, #ef4444 34%, var(--line)); }
.acct-danger .p-card__head h2 { color: #ef4444; }

.p-chip--bad {
    color: #ef4444;
    background: color-mix(in srgb, #ef4444 12%, transparent);
    border-color: color-mix(in srgb, #ef4444 30%, transparent);
}

/* Folded away so it cannot be hit while reaching for the password form. */
.acct-danger__reveal { margin-top: 16px; }
.acct-danger__reveal > summary {
    cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px;
    font-size: .88rem; font-weight: 600; color: #ef4444;
    padding: 9px 14px; border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, #ef4444 30%, transparent);
    background: color-mix(in srgb, #ef4444 8%, transparent);
    transition: background .25s var(--ease);
}
.acct-danger__reveal > summary::-webkit-details-marker { display: none; }
.acct-danger__reveal > summary:hover { background: color-mix(in srgb, #ef4444 14%, transparent); }
.acct-danger__reveal[open] > summary { margin-bottom: 18px; }

.btn--bad { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn--bad:hover { filter: brightness(1.08); }

/* ---------- "This account has been deleted" ------------------------------ */
/* Shown on the sign-in form to someone a deletion has locked out. Two ways to
   reach a person, because the reader who needs this most is the one who did not
   delete the account and has no idea why they cannot get in. */
.acct-gone { align-items: flex-start; gap: 12px; }
.acct-gone__ico { flex: none; margin-top: 2px; }
.acct-gone__body { display: grid; gap: 8px; line-height: 1.6; }
.acct-gone__body b { font-size: .95rem; }

.acct-gone__contact { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.acct-gone__contact a {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 13px; border-radius: var(--radius-sm);
    background: color-mix(in srgb, #ef4444 10%, transparent);
    border: 1px solid color-mix(in srgb, #ef4444 26%, transparent);
    font-size: .85rem; font-weight: 600; color: inherit;
    transition: background .25s var(--ease);
}
.acct-gone__contact a:hover { background: color-mix(in srgb, #ef4444 18%, transparent); }
.acct-gone__contact svg { width: 15px; height: 15px; flex: none; }

.acct-gone__hours { font-size: .8rem; opacity: .8; }
