/* ================================================================
   PRIME SMS — COMPONENTS
   Every reusable surface, control and indicator. Pages compose
   these; pages do not invent their own.
================================================================ */

/* ================================================================
   BUTTONS
================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    height: var(--control-h);
    padding: 0 var(--sp-4);
    border-radius: var(--r-md);
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    line-height: 1;
    white-space: nowrap;
    vertical-align: middle;
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.btn i { font-size: 0.875em; }
.btn:focus-visible { box-shadow: var(--ring); }
.btn:disabled, .btn.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: var(--sh-xs);
}
.btn-primary:hover  { background: var(--primary-hover);  border-color: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); border-color: var(--primary-active); }

.btn-secondary {
    background: var(--surface);
    color: var(--tx-2);
    border-color: var(--border);
    box-shadow: var(--sh-xs);
}
.btn-secondary:hover {
    background: var(--surface-hover);
    color: var(--tx-1);
    border-color: var(--border-strong);
}

.btn-ghost { background: transparent; color: var(--tx-2); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-hover); color: var(--tx-1); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-text); border-color: var(--danger-text); }

.btn-sm  { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }

/* Square icon-only button. Used for secondary row actions, where four
   labelled buttons would overflow the table. Always pair with a title
   attribute and aria-label so the action stays discoverable. */
.btn-icon {
    padding: 0;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}
.btn-icon i { font-size: var(--fs-sm); }
.btn-lg  { height: 44px; padding: 0 var(--sp-5); font-size: var(--fs-body); }
.btn-block { width: 100%; }

/* Async submit state — used by the report download buttons. */
.btn.is-loading { pointer-events: none; opacity: 0.7; }
.btn.is-loading i { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   CARD
================================================================ */
.card {
    background: var(--surface);
    border-radius: var(--r-xl);
    border: 1px solid var(--border);
    box-shadow: var(--sh-sm);
    /* Grid/flex children default to min-width:auto, which lets a wide
       table push the whole page sideways. Zero it so .table-wrap does
       the scrolling instead. */
    min-width: 0;
}
.card-body    { padding: var(--card-pad); }
.card-padded  { padding: var(--card-pad); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-3) var(--card-pad);
    min-height: 48px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-sunk);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.card-header h2 { font-size: var(--fs-h3); font-weight: var(--fw-bold); }
.card-header p  { font-size: var(--fs-sm); color: var(--tx-3); margin-top: 1px; }

.card-footer {
    padding: var(--sp-3) var(--card-pad);
    border-top: 1px solid var(--border);
    background: var(--surface-sunk);
    border-radius: 0 0 var(--r-xl) var(--r-xl);
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2);
}

/* ================================================================
   TOOLBAR
   The strip above a data table: what you're looking at, how many
   there are, and what you can do to it.
================================================================ */
/* Title and count sit together on the left; anything in .toolbar-actions
   is pushed right by its own auto margin. space-between would strand the
   count against the far edge, away from the label it belongs to. */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--card-pad);
    border-bottom: 1px solid var(--border);
    background: var(--surface-sunk);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    flex-wrap: wrap;
}
.toolbar-title {
    font-family: var(--font-display);
    font-size: var(--fs-h3);
    font-weight: var(--fw-bold);
    color: var(--tx-1);
}
/* Result count. Reads as part of the title, not as a badge. */
.toolbar-count {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--tx-3);
    font-variant-numeric: tabular-nums;
    padding: 1px var(--sp-2);
    background: var(--slate-100);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
}
.toolbar-actions { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }

/* Cards that only wrap a table need no inner padding — the table
   supplies its own via cell padding. */
.card-flush { padding: 0; overflow: hidden; }

/* Interactive card (dashboard quick actions) */
.card-link {
    transition: box-shadow var(--dur) var(--ease),
                transform var(--dur) var(--ease),
                border-color var(--dur) var(--ease);
}
.card-link:hover {
    box-shadow: var(--sh-md);
    transform: translateY(-2px);
    border-color: var(--border-strong);
}

/* ================================================================
   STAT TILE
================================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-4);
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--sp-5);
    box-shadow: var(--sh-sm);
}
.stat-label {
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    color: var(--tx-3);
    text-transform: uppercase;
    letter-spacing: var(--ls-caps);
    margin-bottom: var(--sp-2);
}
.stat-value {
    font-family: var(--font-display);
    font-size: 1.8125rem;
    font-weight: var(--fw-black);
    color: var(--tx-1);
    letter-spacing: var(--ls-h1);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-meta { font-size: var(--fs-sm); color: var(--tx-3); margin-top: var(--sp-2); }

/* ================================================================
   ICON CHIP  (dashboard action cards, empty states)
================================================================ */
.icon-chip {
    width: 40px; height: 40px;
    border-radius: var(--r-lg);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    background: var(--brand-50);
    color: var(--primary);
}
.icon-chip-success { background: var(--success-bg); color: var(--success); }
.icon-chip-warning { background: var(--warning-bg); color: var(--warning); }
.icon-chip-danger  { background: var(--danger-bg);  color: var(--danger); }
.icon-chip-neutral { background: var(--slate-100);  color: var(--tx-2); }

/* ================================================================
   TABLE
================================================================ */
/* Scroll container. max-height + sticky header means long result sets
   scroll under a header that stays readable — the single biggest thing
   that separates a data grid from an HTML table on a web page. */
.table-wrap {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 68vh;
}

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-body); }

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: var(--head-py) var(--row-px);
    text-align: left;
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    color: var(--tx-3);
    text-transform: uppercase;
    letter-spacing: var(--ls-caps);
    background: var(--surface-sunk);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: var(--row-py) var(--row-px);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--tx-2);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--dur-fast) var(--ease); }
tbody tr:hover td { background: var(--brand-50); }

/* Primary identifier in a row — the thing you scan for. */
.cell-primary { font-weight: var(--fw-medium); color: var(--tx-1); }
/* Secondary line inside a cell (size under a filename, time under a date) */
.cell-sub { display: block; font-size: var(--fs-sm); color: var(--tx-3); margin-top: 2px; }
.cell-meta { color: var(--tx-3); font-size: var(--fs-sm); white-space: nowrap; }

/* Numeric columns: right-aligned, aligned digits, tighter than text. */
th.num, td.num {
    text-align: right;
    padding-left: var(--sp-2);
    padding-right: var(--sp-2);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
th.num { letter-spacing: 0.03em; }

/* Columns that should hug their content rather than share width. */
th.col-tight, td.col-tight { width: 1%; white-space: nowrap; }
th.col-action, td.col-action { width: 1%; white-space: nowrap; text-align: right; }

/* Row action cluster. Deliberately does NOT wrap — wrapping stacks the
   buttons vertically and triples the row height. The table scrolls
   horizontally instead, which is the correct trade for a data grid. */
.row-actions {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: nowrap;
    justify-content: flex-end;
}

/* Entity cell: avatar + name */
.cell-entity { display: flex; align-items: center; gap: var(--sp-3); }

/* ================================================================
   BADGE
================================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 2px var(--sp-2);
    border-radius: var(--r-sm);
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.6;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: var(--danger-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.badge-info    { background: var(--info-bg);    color: var(--info-text);    border-color: var(--info-border); }
.badge-gray    { background: var(--slate-100);  color: var(--tx-2);         border-color: var(--border); }

/* Status dot inside a badge */
.badge .dot {
    width: 5px; height: 5px;
    border-radius: var(--r-full);
    background: currentColor;
    flex-shrink: 0;
}

/* Credits chip — the recurring "N credits" indicator. */
.chip-credits {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 2px var(--sp-2);
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    font-variant-numeric: tabular-nums;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--warning-text);
    white-space: nowrap;
}
.chip-credits i { font-size: 10px; color: var(--warning); }

/* Delta values in credit ledgers */
.delta-up   { color: var(--success-text); font-weight: var(--fw-semibold); }
.delta-down { color: var(--danger-text);  font-weight: var(--fw-semibold); }

/* ================================================================
   DELIVERY METRICS
   These four classes must stay in step with the donut palette in
   dashboard/home.html — a table cell and a chart slice describing the
   same stage should never disagree on colour.
================================================================ */
.m-total     { color: var(--tx-1); font-weight: var(--fw-semibold); }
.m-sent      { color: var(--tx-2); }
.m-delivered { color: var(--warning-text); font-weight: var(--fw-medium); }
.m-read      { color: var(--success-text); font-weight: var(--fw-medium); }
.m-failed    { color: var(--danger-text);  font-weight: var(--fw-medium); }
.m-none      { color: var(--tx-4); }

/* ================================================================
   CREDIT LEDGER
   Shared by all four credit-history tables.
================================================================ */

/* Date over time, in one cell. */
.cell-when { white-space: nowrap; }
.cell-when strong {
    display: block;
    font-weight: var(--fw-medium);
    color: var(--tx-1);
}
.cell-when span { font-size: var(--fs-sm); color: var(--tx-3); }

/* Signed amount. Colour carries the direction, so the sign is not the
   only cue — but it is still printed for anyone who can't see hue. */
.ledger-amount {
    font-family: var(--font-display);
    font-size: var(--fs-h3);
    font-weight: var(--fw-black);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.ledger-amount.is-add    { color: var(--success-text); }
.ledger-amount.is-deduct { color: var(--warning-text); }
.ledger-amount.is-set    { color: var(--primary-text); }

/* before → after */
.bal-arrow {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.bal-arrow .bal-before { color: var(--tx-3); }
.bal-arrow .bal-sep    { font-size: 9px; color: var(--tx-4); }
.bal-arrow .bal-after  { color: var(--tx-1); font-weight: var(--fw-semibold); }

/* ================================================================
   FORMS
================================================================ */
.form-row { margin-bottom: var(--sp-5); }
.form-row:last-child { margin-bottom: 0; }

.form-row label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    color: var(--tx-1);
    margin-bottom: var(--sp-2);
}
.form-req { color: var(--danger); margin-left: 2px; }

.form-hint  { font-size: var(--fs-sm); color: var(--tx-3); margin-top: var(--sp-2); }
.form-error {
    font-size: var(--fs-sm);
    color: var(--danger-text);
    margin-top: var(--sp-2);
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

/* Submit row at the foot of a form. */
.form-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-top: var(--sp-6);
    padding-top: var(--sp-5);
    border-top: 1px solid var(--border-subtle);
}

/* Two-up field row that collapses on narrow screens. */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-5);
}

input[type=text],
input[type=email],
input[type=password],
input[type=date],
input[type=month],
input[type=number],
input[type=tel],
input[type=url],
input[type=search],
input[type=file],
select,
textarea {
    width: 100%;
    max-width: 100%;
    height: var(--control-h);
    padding: 0 var(--sp-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    font-size: var(--fs-body);
    font-family: inherit;
    color: var(--tx-1);
    background: var(--surface);
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
    outline: none;
}
/* Multi-line controls set their own height. */
textarea { height: auto; padding: var(--sp-2) var(--sp-3); }
input[type=file] { height: auto; }
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) {
    border-color: var(--slate-400);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--tx-4); }
input:disabled, select:disabled, textarea:disabled {
    background: var(--surface-sunk);
    color: var(--tx-3);
    cursor: not-allowed;
}

/* Invalid state, set by Django's error rendering. */
.form-row.has-error input,
.form-row.has-error select,
.form-row.has-error textarea { border-color: var(--danger); }
.form-row.has-error input:focus,
.form-row.has-error select:focus,
.form-row.has-error textarea:focus { box-shadow: var(--ring-danger); }

select {
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--sp-3) center;
    padding-right: var(--sp-8);
    cursor: pointer;
}

input[type=file] {
    padding: var(--sp-2);
    color: var(--tx-3);
    background: var(--surface-sunk);
    border-style: dashed;
    border-color: var(--border-strong);
    cursor: pointer;
}
input[type=file]::-webkit-file-upload-button {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    padding: var(--sp-1) var(--sp-3);
    font-size: var(--fs-sm);
    font-family: inherit;
    font-weight: var(--fw-medium);
    color: var(--tx-2);
    cursor: pointer;
    margin-right: var(--sp-3);
}
textarea { resize: vertical; min-height: 96px; line-height: var(--lh-body); }
textarea.is-mono { font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.7; }

/* Input with a leading icon (login, search). */
.input-group { position: relative; display: flex; }
.input-prefix {
    position: absolute;
    left: var(--sp-3); top: 50%;
    transform: translateY(-50%);
    color: var(--tx-3);
    font-size: var(--fs-body);
    pointer-events: none;
    z-index: 1;
}
.input-group input { padding-left: var(--sp-10); }

/* ================================================================
   ALERTS
================================================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    font-size: var(--fs-body);
    font-weight: var(--fw-medium);
    margin-bottom: var(--sp-5);
    border: 1px solid transparent;
    line-height: var(--lh-snug);
}
.alert i { font-size: var(--fs-body); flex-shrink: 0; margin-top: 2px; }
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.alert-error   { background: var(--danger-bg);  color: var(--danger-text);  border-color: var(--danger-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.alert-info    { background: var(--info-bg);    color: var(--info-text);    border-color: var(--info-border); }

/* ================================================================
   TABS
================================================================ */
.tabs {
    display: inline-flex;
    gap: var(--sp-1);
    padding: var(--sp-1);
    background: var(--slate-100);
    border-radius: var(--r-lg);
    margin-bottom: var(--sp-6);
}
.tab {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--r-md);
    font-size: var(--fs-body);
    font-weight: var(--fw-medium);
    color: var(--tx-2);
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--tx-1); }
.tab.active {
    background: var(--surface);
    color: var(--primary-text);
    font-weight: var(--fw-semibold);
    box-shadow: var(--sh-xs);
}
.tab i { font-size: 0.875em; }

/* Segmented switch (Add / Deduct / Set) — same shape as .tabs. */
.seg {
    display: flex;
    background: var(--slate-100);
    border-radius: var(--r-lg);
    padding: var(--sp-1);
    gap: var(--sp-1);
    margin-bottom: var(--sp-4);
}
.seg-btn {
    flex: 1;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--sp-2);
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--tx-2);
    transition: background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
}
.seg-btn:hover { color: var(--tx-1); }
.seg-btn.active {
    background: var(--surface);
    color: var(--tx-1);
    font-weight: var(--fw-semibold);
    box-shadow: var(--sh-xs);
}

/* ================================================================
   EMPTY STATE
================================================================ */
.empty-state {
    text-align: center;
    padding: var(--sp-16) var(--sp-6);
    color: var(--tx-3);
}
.empty-state i {
    font-size: 30px;
    color: var(--tx-4);
    margin-bottom: var(--sp-4);
    display: block;
}
.empty-state p {
    font-size: var(--fs-body);
    color: var(--tx-2);
    margin-bottom: var(--sp-5);
}

/* ================================================================
   MODAL
================================================================ */
.modal-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
}
.modal-backdrop.show { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--r-xl);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--sh-xl);
    animation: modal-in var(--dur) var(--ease-out);
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-5) var(--sp-5) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}
.modal-head h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); }
.modal-head p  { font-size: var(--fs-sm); color: var(--tx-3); margin-top: 2px; }
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--tx-3);
    font-size: var(--fs-h3);
    line-height: 1;
    padding: var(--sp-1);
    border-radius: var(--r-sm);
    flex-shrink: 0;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.modal-close:hover { color: var(--tx-1); background: var(--surface-hover); }

.modal-body { padding: var(--sp-5); }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-5) var(--sp-5);
}

/* ================================================================
   CODE / CREDENTIAL DISPLAY
================================================================ */
.code-inline {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    background: var(--slate-100);
    border: 1px solid var(--border);
    color: var(--tx-1);
    padding: 1px var(--sp-2);
    border-radius: var(--r-xs);
    white-space: nowrap;
}
.code-block {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    background: var(--slate-100);
    border: 1px solid var(--border);
    color: var(--tx-1);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    line-height: 1.7;
    word-break: break-all;
    overflow-x: auto;
}

/* ================================================================
   ENTITY BANNER
   "You are acting on <customer>" context strip above a form.
================================================================ */
.entity-banner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--sp-4) var(--sp-5);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
    box-shadow: var(--sh-sm);
}
.entity-banner .avatar { width: 40px; height: 40px; font-size: var(--fs-h3); }
.entity-banner-text { flex: 1; min-width: 0; }
.entity-banner-text strong {
    display: block;
    font-size: var(--fs-h3);
    font-weight: var(--fw-semibold);
    color: var(--tx-1);
}
.entity-banner-text span { font-size: var(--fs-sm); color: var(--tx-3); }

/* Template variable token, e.g. {{order_id}} */
.var-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    background: var(--brand-50);
    color: var(--primary-text);
    border: 1px solid var(--brand-200);
    border-radius: var(--r-sm);
    padding: 2px var(--sp-2);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    margin: 0 var(--sp-1) var(--sp-1) 0;
}
.var-pill i { font-size: 9px; opacity: 0.7; }

/* ================================================================
   KEY / VALUE LIST
   Credential panels and read-only detail blocks.
================================================================ */
.kv-list { display: flex; flex-direction: column; }
.kv-row {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--border-subtle);
}
.kv-row:first-child { padding-top: 0; }
.kv-row:last-child  { border-bottom: none; padding-bottom: 0; }
.kv-key {
    font-size: var(--fs-sm);
    color: var(--tx-3);
    width: 92px;
    flex-shrink: 0;
    padding-top: 1px;
}
.kv-val {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    color: var(--tx-1);
    word-break: break-all;
    min-width: 0;
}
.kv-val.is-missing { font-family: var(--font-sans); color: var(--warning-text); }

/* ================================================================
   HINT LIST
   Icon + title + explanation, stacked. Used for "rules" panels.
================================================================ */
.hint-list { display: flex; flex-direction: column; gap: var(--sp-4); }
.hint-item { display: flex; gap: var(--sp-3); align-items: flex-start; }
.hint-item .icon-chip {
    width: 28px; height: 28px;
    border-radius: var(--r-sm);
    font-size: 12px;
}
.hint-item strong {
    display: block;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--tx-1);
}
.hint-item span { font-size: var(--fs-sm); color: var(--tx-3); }

/* ================================================================
   FIELDSET PANEL
   A sunken group of related inputs inside a form.
================================================================ */
.panel {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--sp-4);
    background: var(--surface-sunk);
    margin-bottom: var(--sp-5);
}
.panel-title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--tx-3);
    text-transform: uppercase;
    letter-spacing: var(--ls-caps);
    margin-bottom: var(--sp-4);
}
.panel-title i { color: var(--primary); }

/* Counter under a textarea (recipient count). */
.field-count {
    font-size: var(--fs-sm);
    color: var(--tx-3);
    margin-top: var(--sp-2);
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.field-count strong { color: var(--tx-1); font-weight: var(--fw-semibold); }
.field-count.is-over, .field-count.is-over strong { color: var(--danger); }

/* ================================================================
   UTILITIES  — layout only, never colour or type
================================================================ */
.stack     { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm  { display: flex; flex-direction: column; gap: var(--sp-2); }
.row       { display: flex; align-items: center; gap: var(--sp-3); }
.row-wrap  { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.spacer    { margin-left: auto; }
.narrow    { max-width: 560px; margin-inline: auto; }
.narrow-lg { max-width: 760px; margin-inline: auto; }
