/*
 * A Materialize-style look: Inter, a soft grey canvas, white cards with a
 * diffuse shadow, a fixed sidebar, and "tonal" badges and buttons (the colour
 * at low opacity behind text in the full colour). Written from scratch here —
 * no theme files, no framework — so the panel still needs no build step.
 *
 * Every colour is a token below. The per-screen rules further down use the
 * tonal tokens rather than literals, so the palette changes in one place.
 */
:root {
    --bg: #f7f7f9;
    --surface: #ffffff;
    --surface-alt: #f9f9fb;
    --border: #e6e6ea;
    --text: #4c4e64;
    --heading: #393b51;
    --muted: #8a8d9f;

    --primary: #666cff;
    --primary-dark: #5a5fe0;
    --primary-tonal: #ededff;
    --primary-line: #d3d4ff;

    --success: #3e9b16;
    --success-tonal: #ebf8e2;
    --success-line: #cbecb6;

    --danger: #e53935;
    --danger-tonal: #fdecec;
    --danger-line: #f6c7c6;

    --warning: #b7791f;
    --warning-bg: #fff4e0;
    --warning-line: #f6dcae;

    --purple: #7c4dff;
    --purple-tonal: #f1ecff;
    --purple-line: #ddd1ff;

    --neutral-tonal: #f0f0f4;

    --shadow: 0 2px 10px 0 rgba(76, 78, 100, .14);
    --shadow-lg: 0 6px 30px 0 rgba(76, 78, 100, .22);
    --radius: 10px;
    --radius-sm: 8px;
    --sidebar-width: 260px;
}

* { box-sizing: border-box; }

/**
 * The panel shows and hides views with the `hidden` attribute, and `[hidden]`
 * is only a user-agent rule — any author `display` beats it. Without this,
 * `.centered { display: grid }` keeps the sign-in view on screen after sign-in
 * and both views render at once.
 */
[hidden] { display: none !important; }

body {
    margin: 0;
    font: 15px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--heading); font-weight: 600; }
h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0; }

/* Material Symbols, by ligature: the element's text is the icon's name. */
.icon {
    font-family: "Material Symbols Rounded";
    font-weight: normal;
    font-style: normal;
    font-size: 22px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    direction: ltr;
    font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
    flex-shrink: 0;
}

/* ------------------------------------------------------------------ layout */

.layout { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 1.1rem .9rem;
    overflow-y: auto;
    z-index: 30;
    transition: transform .2s ease;
}

.brand { display: flex; align-items: center; gap: .6rem; padding: .2rem .6rem 1.2rem; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(102, 108, 255, .4);
}
.brand-name { font-size: 1.2rem; font-weight: 700; color: var(--heading); letter-spacing: -.01em; }
.brand-tag {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--primary);
    background: var(--primary-tonal);
    border-radius: 6px;
    padding: .05rem .4rem;
}

.menu { display: flex; flex-direction: column; gap: .2rem; }
.menu-header {
    margin: 1rem .8rem .35rem;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}
.menu-header:first-child { margin-top: 0; }

/* The nav entries: full-width rows, and the active one in a primary gradient,
   which is the most recognisable part of the look. */
.nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: .75rem;
    width: 100%;
    padding: .6rem .8rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text);
    font-weight: 500;
    text-align: left;
}
.nav .icon { font-size: 21px; color: var(--muted); }
.nav:hover:not(:disabled) { background: var(--neutral-tonal); }
.nav.active,
.nav.active:hover:not(:disabled) {
    background: linear-gradient(72.47deg, var(--primary) 22.16%, #8f93ff 76.47%);
    color: #fff;
    box-shadow: 0 2px 6px rgba(102, 108, 255, .45);
}
.nav.active .icon { color: #fff; }

.main { margin-left: var(--sidebar-width); min-height: 100vh; }

.topbar {
    position: sticky;
    top: .75rem;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: .75rem 1.5rem 0;
    padding: .55rem 1rem;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(6px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.page-title { font-size: 1.1rem; margin: 0; }
.spacer { flex: 1; }

.user-chip { display: flex; align-items: center; gap: .5rem; }
.avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-tonal);
    color: var(--primary);
    font-weight: 600;
    font-size: .9rem;
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--text);
}
.menu-toggle { display: none; }

/* Full width: the tables are the work here, and a centred 1240px column left
   them wrapping names and dates onto three lines beside empty margins. */
.content { padding: 1.5rem; }

/* Each section is one card on the canvas. */
.view { padding: 1.5rem; }
.content > .view {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.centered { min-height: 100vh; display: grid; place-items: center; }

/* Under 1100px the sidebar becomes a drawer, opened from the top bar. */
.scrim { position: fixed; inset: 0; background: rgba(38, 39, 55, .45); z-index: 25; }
@media (max-width: 1100px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-grid; }
    .topbar { margin: .5rem .75rem 0; top: .5rem; }
    .content { padding: 1rem .75rem; }
    .view { padding: 1.1rem; }
}
@media (max-width: 640px) {
    #current-user { display: none; }
    /* Stacked rows have the full width to themselves, so the actions wrap
       instead of running off the card. */
    td.actions { white-space: normal; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
    td.actions > * + * { margin-left: 0; }
}

/* ------------------------------------------------------------------- cards */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.4rem;
}
/* A card inside a section card stays flat, or it floats off a surface that is
   already floating. */
.view .card { box-shadow: none; border: 1px solid var(--border); }
.card.narrow { width: min(400px, 92vw); display: flex; flex-direction: column; gap: .4rem; }
.card.inline { margin-bottom: 1.25rem; }

.login-card { padding: 2rem 1.8rem; box-shadow: var(--shadow-lg); }
.login-brand { padding: 0 0 1rem; }
.login-card h1 { font-size: 1.3rem; margin: 0; }
.login-card h1 + .muted { margin: 0 0 .6rem; }

/* ------------------------------------------------------------------- forms */

label { font-weight: 500; font-size: .85rem; color: var(--heading); }

input, select {
    padding: .6rem .75rem;
    border: 1px solid #d8d8dd;
    border-radius: var(--radius-sm);
    font: inherit;
    background: var(--surface);
    color: inherit;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 108, 255, .16);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ----------------------------------------------------------------- buttons */

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, box-shadow .15s, color .15s;
}
button .icon { font-size: 20px; }
button:hover:not(:disabled) { background: var(--neutral-tonal); }
button:disabled { opacity: .55; cursor: progress; }

button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    margin-top: .6rem;
    box-shadow: 0 2px 6px rgba(102, 108, 255, .4);
}
button.primary:hover:not(:disabled) { background: var(--primary-dark); }

/* Row actions are tonal: coloured text on a tint, no border, so a table full
   of them reads as a quiet column rather than a wall of outlines. */
button.approve { color: var(--success); background: var(--success-tonal); border-color: transparent; }
button.approve:hover:not(:disabled) { background: var(--success-line); }
button.reject { color: var(--danger); background: var(--danger-tonal); border-color: transparent; }
button.reject:hover:not(:disabled) { background: var(--danger-line); }
button.link { background: none; border: none; color: var(--primary); padding: .3rem .4rem; }
button.link:hover:not(:disabled) { background: var(--primary-tonal); }

.row { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.row .spacer { flex: 1; }

/* ------------------------------------------------------------------ tables */

/**
 * Wide tables scroll inside their own box. Without this the page itself scrolls
 * horizontally at any width between the mobile breakpoint and desktop, which
 * pushes the top bar off screen.
 */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}
th, td { text-align: left; padding: .75rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--heading);
    background: var(--surface-alt);
    white-space: nowrap;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-alt); }
tbody tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; }
/* A name or a date broken over lines reads as several rows. Kept on one line
   and left to the table's own horizontal scroll if it ever runs out of room.
   Desktop only: the stacked phone layout gives each cell the full width. */
@media (min-width: 641px) {
    td[data-label="Nombre"], td[data-label="Alta"], td[data-label="Registro"],
    td[data-label="Fecha"], td[data-label="Teléfono"] { white-space: nowrap; }
}
td.actions > * + * { margin-left: .35rem; }

/* Row actions: round icon buttons, grey until hovered, as in the datatable
   pattern. The label lives in aria-label and the tooltip. */
.icon-action {
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--muted);
    font-size: 21px;
    vertical-align: middle;
}
.icon-action:hover:not(:disabled) { background: var(--neutral-tonal); color: var(--heading); }
.icon-action[aria-expanded="true"] { background: var(--neutral-tonal); color: var(--heading); }
.icon-action.tone-danger:hover:not(:disabled) { background: var(--danger-tonal); color: var(--danger); }
.icon-action.tone-success:hover:not(:disabled) { background: var(--success-tonal); color: var(--success); }
td.actions > .icon-action + .icon-action,
td.actions > .icon-action + .row-menu,
td.actions > .row-menu + .icon-action { margin-left: .1rem; }
.row-menu { display: inline-block; vertical-align: middle; }

/* The ⋮ menu. Fixed-positioned by app.js (see rowMenu) so the table's scroll
   box cannot clip it. */
.row-menu-list {
    position: fixed;
    z-index: 50;
    min-width: 190px;
    padding: .4rem 0;
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}
.row-menu-list .menu-item {
    justify-content: flex-start;
    width: 100%;
    padding: .55rem 1.1rem;
    border: none;
    border-radius: 0;
    background: none;
    color: var(--heading);
    font-weight: 400;
    text-align: left;
    white-space: nowrap;
}
.row-menu-list .menu-item:hover:not(:disabled),
.row-menu-list .menu-item:focus-visible { background: var(--neutral-tonal); outline: none; }
/* Decisions keep their meaning in the menu, as coloured text only. */
.row-menu-list .menu-item.approve { color: var(--success); }
.row-menu-list .menu-item.reject { color: var(--danger); }
td.change { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }

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

/* ------------------------------------------------------------------ badges */

.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 6px;
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--muted);
    background: var(--neutral-tonal);
}
.badge.IN_REVIEW, .badge.PENDING_INVITE { background: var(--warning-bg); color: var(--warning); }
.badge.APPROVED, .badge.ACCEPTED { background: var(--success-tonal); color: var(--success); }
.badge.REJECTED, .badge.REVOKED, .badge.EXPIRED { background: var(--danger-tonal); color: var(--danger); }
.badge.PENDING { background: var(--neutral-tonal); color: var(--muted); }
/* Disputes, by how they were opened. ACCOUNT_DELETED wears the danger colour
   alone: it is the one a reviewer cannot work by asking both sides, because one
   of them was anonymised and is gone. The other two are ordinary queue items. */
.badge.SUSPENDED { background: var(--danger-tonal); color: var(--danger); }
.badge.ACCOUNT_DELETED { background: var(--danger-tonal); color: var(--danger); }
.badge.CLIENT_RAISED { background: var(--warning-bg); color: var(--warning); }
.badge.ABANDONED_WITH_ESCROW { background: var(--neutral-tonal); color: var(--muted); }

/* Catalog: a category is offered, or retired but still resolvable. */
.badge.ACTIVA { background: var(--success-tonal); color: var(--success); border-color: var(--success-line); }
.badge.RETIRADA { background: var(--neutral-tonal); color: var(--muted); }

/* The job lifecycle, in the app's own colours so a support call about a green
   "Abierta" is looking at the same thing the caller is.

   Scoped to the table rather than written as bare `.badge.EXPIRED` and friends:
   EXPIRED already means something else here — an invitation nobody accepted,
   which wears the danger colour with REJECTED — and a job that simply ran its
   course is spent, not refused. One word, two vocabularies; the narrower
   selector keeps them apart instead of making one of them wrong.

   Both places a job status appears are listed: the table, and the chips in a
   job's timeline. A third place has to be added here too -- that is the cost
   of scoping, and it is cheaper than EXPIRED reading as "rejected". */
#jobs-table .badge.OPEN,
.timeline .badge.OPEN { background: var(--success-tonal); color: var(--success); border-color: var(--success-line); }
#jobs-table .badge.IN_PROGRESS,
.timeline .badge.IN_PROGRESS { background: var(--primary-tonal); color: var(--primary); border-color: var(--primary-line); }
/* Waiting on the client, and it has to be distinguishable at a glance from
   IN_PROGRESS, which is waiting on the professional. */
#jobs-table .badge.PENDING_APPROVAL,
.timeline .badge.PENDING_APPROVAL { background: var(--purple-tonal); color: var(--purple); border-color: var(--purple-line); }
/* Green like OPEN, as the app has it: done and accepted is the good ending,
   not just an ending. EXPIRED is the one that is merely spent. */
#jobs-table .badge.COMPLETED,
.timeline .badge.COMPLETED { background: var(--success-tonal); color: var(--success); border-color: var(--success-line); }
#jobs-table .badge.EXPIRED,
.timeline .badge.EXPIRED { background: var(--neutral-tonal); color: var(--muted); }
#jobs-table .badge.CANCELLED,
.timeline .badge.CANCELLED { background: var(--danger-tonal); color: var(--danger); border-color: var(--danger-line); }
#jobs-table .badge.DISPUTED,
.timeline .badge.DISPUTED { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-line); }

h3 { font-size: 1rem; margin: 0; }

/**
 * The category form. A grid rather than the stacked `.card.narrow` layout the
 * other forms use: six fields in one column is a form nobody reads to the end,
 * and two of them (what it includes, the synonyms) need the full width because
 * they hold sentences.
 */
.fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .9rem;
}
.field { display: flex; flex-direction: column; gap: .25rem; }
.field.wide { grid-column: 1 / -1; }
.field .muted { font-size: .8rem; margin: 0; }
.category-modes { border: 0; padding: 0; margin: 0; }
.category-modes legend { font-weight: 600; padding: 0; }
.category-modes label { display: flex; align-items: center; gap: .5rem; }
.category-modes input { width: auto; }

/**
 * A filter bar. Five controls, which is two more than fit in the `.row` the
 * other screens put a single `<select>` in — at that count they need labels,
 * and labels need a column each.
 *
 * `auto-fit` rather than a fixed count so the bar collapses to one column on a
 * phone without a breakpoint of its own; the minimum is what a date input wants
 * before its picker starts clipping.
 */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: .7rem .9rem;
    align-items: end;
    margin-bottom: 1rem;
}
/* The search box earns the full width: it holds a sentence, and the four
   controls beside it hold a word each. */
.filters .field.wide { grid-column: 1 / -1; }
/* Buttons sit on their own line, hard against the right, so "Filtrar" is never
   mistaken for the label of the field that happens to land beside it. */
.filters .filter-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    margin-bottom: 0;
}

/* Long prose in a table cell should wrap rather than stretch the row. */
td.prose { max-width: 22rem; white-space: normal; }
tr.retired td:not(.actions) { opacity: .6; }

.error { color: var(--danger); font-size: .88rem; }
.error.banner {
    margin: 0 0 1rem;
    padding: .75rem 1rem;
    background: var(--danger-tonal);
    border-left: 4px solid var(--danger);
    border-radius: var(--radius-sm);
}
.ok { color: var(--success); font-size: .88rem; }

.notice {
    background: var(--warning-bg);
    border-left: 4px solid #fdb528;
    color: var(--warning);
    padding: .7rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    margin: 0 0 1rem;
}

/* Rejection reason.
 *
 * `reject-modal`, not `reject`: the table's own action button is
 * `button.reject`, so a dialog sharing that class means every rule written for
 * one silently lands on the other. It did — the row's Rechazar button rendered
 * at the dialog's 560px width and padding. Qualifying the selectors would fix
 * the symptom; a name that cannot collide removes the trap. */
.reject-modal {
    width: min(560px, 92vw);
    padding: 1.4rem 1.5rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    color: var(--text);
}
.reject-modal::backdrop { background: rgba(38, 39, 55, .45); }
.reject-modal textarea {
    width: 100%;
    padding: .5rem .6rem;
    font: inherit;
    border: 1px solid #d8d8dd;
    border-radius: var(--radius-sm);
    resize: vertical;
}
.reject-modal .field { margin: .6rem 0; }
/* The destructive action carries the danger colour; nothing else in the dialog
   should, so a reviewer's eye lands on the one button that ends the review. */
.reject-submit {
    background: var(--danger);
    box-shadow: 0 2px 6px rgba(229, 57, 53, .35);
    border-color: var(--danger);
    color: #fff;
    font-weight: 600;
}

/* Approval: a transcription task, so the document sits beside the fields it is
   copied into rather than one dialog further back. Two columns, the evidence
   taking the larger share; stacked on narrow screens. */
.approve-modal {
    width: min(1120px, 96vw);
    max-height: 94vh;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    color: var(--text);
}
.approve-modal::backdrop { background: rgba(38, 39, 55, .55); }
.approve-modal form { display: flex; flex-direction: column; max-height: 94vh; }
.approve-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border);
}
.approve-header > div { flex: 1; min-width: 0; }
.approve-header h3 { margin: 0; }
.approve-header p { margin: .2rem 0 0; font-size: .85rem; }
.approve-body {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr);
    min-height: 0;
    overflow-y: auto;
}
.approve-evidence {
    display: flex;
    flex-direction: column;
    gap: .7rem;
    padding: 1.2rem 1.4rem;
    background: var(--surface-alt);
    border-right: 1px solid var(--border);
}
.approve-stage { height: min(60vh, 540px); }
.approve-tabs {
    display: flex;
    gap: .25rem;
    padding: .25rem;
    background: var(--neutral-tonal);
    border-radius: var(--radius-sm);
}
.approve-tabs button {
    flex: 1;
    justify-content: center;
    padding: .4rem .6rem;
    border: none;
    background: none;
    font-size: .85rem;
    font-weight: 600;
    color: var(--muted);
}
.approve-tabs button.active { background: var(--surface); color: var(--heading); box-shadow: var(--shadow); }
.approve-tabs button.missing { color: var(--danger); }

.approve-fields {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.2rem 1.4rem;
}
.approve-lede { margin: 0; font-size: .9rem; color: var(--text); }
.approve-fields fieldset { border: none; padding: 0; margin: 0; }
.approve-fields legend,
.approve-fields .field > label { font-size: .85rem; font-weight: 600; color: var(--heading); margin-bottom: .35rem; padding: 0; }
.approve-fields input[type="text"] {
    width: 100%;
    padding: .6rem .7rem;
    font: inherit;
    font-size: 1rem;
    border: 1px solid #d8d8dd;
    border-radius: var(--radius-sm);
}
.approve-fields input[type="text"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tonal); }
.approve-fields input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .03em; }

/* Three options, all visible: a select hid them behind a click and defaulted
   to "Selecciona…", the one value that is never right. */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
    display: block;
    padding: .55rem .4rem;
    text-align: center;
    font-size: .9rem;
    font-weight: 600;
    border: 1px solid #d8d8dd;
    border-radius: var(--radius-sm);
    color: var(--text);
}
.segmented input:checked + span { border-color: var(--primary); background: var(--primary-tonal); color: var(--primary); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.approve-check {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    padding: .7rem .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    cursor: pointer;
}
.approve-check input { margin-top: .15rem; accent-color: var(--success); }
.approve-check:has(input:checked) { border-color: var(--success-line); background: var(--success-tonal); }
.approve-note {
    display: flex;
    gap: .5rem;
    margin: 0;
    font-size: .8rem;
    color: var(--muted);
}
.approve-note .icon { font-size: 16px; }
.approve-fields .error { margin: 0; }

.approve-footer {
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
    padding: .9rem 1.4rem;
    border-top: 1px solid var(--border);
}

@media (max-width: 860px) {
    .approve-body { grid-template-columns: 1fr; }
    .approve-evidence { border-right: none; border-bottom: 1px solid var(--border); }
    .approve-stage { height: 42vh; }
}
.approve-submit {
    background: var(--success);
    box-shadow: 0 2px 6px rgba(62, 155, 22, .35);
    border-color: var(--success);
    color: #fff;
    font-weight: 600;
}

/* KYC document viewer */
dialog.documents {
    width: min(960px, 94vw);
    max-height: 94vh;
    padding: 1.4rem 1.5rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    overflow-y: auto;
}
dialog.documents::backdrop { background: rgba(38, 39, 55, .45); }

/* One document at a time on a dark stage, so a pale cédula photographed on a
   white table still has an edge, and the reviewer looks at the paper rather
   than at three thumbnails. */
.carousel { margin: .9rem 0 .6rem; }
.carousel-stage {
    position: relative;
    height: min(54vh, 520px);
    background: #1e1f2b;
    border-radius: var(--radius);
    overflow: hidden;
}
.carousel-track, .document { height: 100%; }
.document {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Identity papers are photographed in whatever aspect the phone was held
       at, so the image letterboxes inside the stage rather than cropping — a
       cropped corner is exactly the part a reviewer needs to read. */
    overflow: hidden;
}
.document img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    cursor: zoom-in;
    animation: slide-in .2s ease-out;
}
@keyframes slide-in { from { opacity: 0; } to { opacity: 1; } }
/* Clicked open: the image renders at well over the stage's size and the slide
   scrolls, starting centred on the click. Kept inside the dialog rather than
   opening the signed URL in a tab: that URL is a live credential and does not
   belong in browser history. */
.document.zoomed { display: block; overflow: auto; }
.document.zoomed img {
    max-width: none;
    max-height: none;
    width: 220%;
    cursor: zoom-out;
}
.document-note {
    margin: 0;
    font-size: .9rem;
    color: #b9bbcc;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 2.6rem;
    height: 2.6rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    color: var(--heading);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.carousel-nav:hover:not(:disabled) { background: #fff; }
.carousel-nav .icon { font-size: 26px; }
.carousel-nav.prev { left: .8rem; }
.carousel-nav.next { right: .8rem; }

.carousel-counter, .carousel-hint {
    position: absolute;
    bottom: .7rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: .78rem;
    font-weight: 500;
    pointer-events: none;
}
.carousel-counter { right: .8rem; font-variant-numeric: tabular-nums; }
.carousel-hint {
    left: .8rem;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
.carousel-hint .icon { font-size: 16px; }
/* Zoomed, the arrows and labels would sit on top of the very text being read. */
.carousel-stage.zoomed .carousel-nav,
.carousel-stage.zoomed .carousel-hint { display: none; }

.carousel-thumbs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .7rem;
    margin-top: .7rem;
}
.carousel-thumb {
    flex-direction: column;
    align-items: stretch;
    gap: .4rem;
    padding: .4rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    text-align: left;
}
.carousel-thumb:hover:not(:disabled) { background: var(--surface-alt); border-color: var(--primary-line); }
.carousel-thumb.active { border-color: var(--primary); background: var(--primary-tonal); }
.carousel-thumb-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 4rem;
    border-radius: 5px;
    background: var(--neutral-tonal);
    color: var(--muted);
    overflow: hidden;
}
.carousel-thumb-frame img { width: 100%; height: 100%; object-fit: cover; }
.carousel-thumb-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--heading);
}
.carousel-thumb.active .carousel-thumb-label { color: var(--primary); }
/* A missing side should catch the eye from the strip, not only once paged to. */
.carousel-thumb.missing .carousel-thumb-frame { background: var(--danger-tonal); color: var(--danger); }

.documents-status { display: inline-flex; align-items: center; font-size: .85rem; }

.documents-actions { margin-top: .4rem; }

@media (max-width: 640px) {
    table, thead, tbody, th, td, tr { display: block; }
    thead { display: none; }
    tr { border-bottom: 1px solid var(--border); padding: .4rem 0; }
    td { border: none; padding: .3rem .7rem; }
    td::before { content: attr(data-label) ": "; font-weight: 600; color: var(--muted); }
    /* Nothing scrolls sideways once the rows are stacked, so the pinned
       Historial cell has nothing to pin against -- and a sticky block would
       only put a stray shadow down the side of one line. */
    #jobs-table td.actions { position: static; box-shadow: none; }
}

/* ----------------------------------------------------------------- paging */

/* The count on the left, the numbered controls on the right — the datatable
   pattern. */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Tabular figures so "1–10 de 47" does not reflow into "11–20 de 47". */
.pager-status { font-variant-numeric: tabular-nums; }

.pager-controls, .pager-numbers { display: flex; align-items: center; gap: .4rem; }

/* Round grey buttons; the current page filled in the primary colour. */
.pager-button {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--neutral-tonal);
    color: var(--text);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.pager-button.icon { font-size: 22px; }
.pager-button:hover:not(:disabled) { background: var(--primary-line); color: var(--primary-dark); }
.pager-button.current,
.pager-button.current:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(102, 108, 255, .4);
    cursor: default;
}

/**
 * The global rule is `cursor: progress`, written for buttons disabled *while
 * an action runs*. The arrows spend most of their life disabled because there
 * is no page in that direction — nothing is in progress and the hourglass is
 * a lie, so they opt out of it.
 */
.pager button:disabled { cursor: default; opacity: .45; }

@media (max-width: 640px) {
    .pager { justify-content: center; }
    .pager-status { width: 100%; text-align: center; }
    .pager-button { width: 32px; height: 32px; }
    .pager-controls, .pager-numbers { gap: .25rem; }
}

/* Ten columns is wider than the 1100px this panel gives a view, so the jobs
 * table scrolls inside `.table-wrap` like every other wide table here. The
 * difference is what ends up off the edge: Historial is last, and it holds the
 * only control on the screen. Pinning it means the button is always reachable
 * and no column had to be dropped to get there.
 *
 * The shadow is a hairline standing in for the border the pinned cell scrolls
 * over -- without it the rows appear to slide under nothing. */
/* `separate` with zero spacing, which draws identically to the `collapse` every
   other table here uses -- the cells only ever set `border-bottom`, so there is
   nothing to merge. It is required: Chrome and Safari ignore `position: sticky`
   on a cell inside a collapsed table, silently, which is why the first attempt
   at this looked correct in the stylesheet and did nothing on screen. */
#jobs-table { border-collapse: separate; border-spacing: 0; overflow: visible; }

#jobs-table thead th:last-child,
#jobs-table td.actions {
    position: sticky;
    right: 0;
    background: var(--surface);
    box-shadow: -1px 0 0 var(--border);
}
#jobs-table thead th:last-child { background: var(--surface-alt); }

/* A job's timeline.
 *
 * `job-history`, not `history`, for the reason `.reject-modal` spells out a few
 * rules up: a name that cannot collide with a row's own button class. */
.job-history {
    width: min(640px, 92vw);
    max-height: 80vh;
    padding: 1.4rem 1.5rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    color: var(--text);
}
.job-history::backdrop { background: rgba(38, 39, 55, .45); }

/* Read as a story, oldest first -- which is how job-service returns it, and the
 * opposite of how Auditoría reads. The rule down the left is what makes a list
 * of transitions look like a sequence rather than five unrelated rows.
 *
 * Rule and dots are drawn INSIDE each entry rather than as a border on the list
 * with dots hung off it on negative offsets. The list scrolls, and a scroll
 * container clips its own padding box: every dot lost its outer half. Keeping
 * both within the entry's content box means there is nothing to clip. */
.timeline {
    list-style: none;
    margin: .6rem 0 0;
    padding: 0;
    overflow-y: auto;
    max-height: 60vh;
}
.timeline-entry { position: relative; padding: 0 0 1rem 1.1rem; }
.timeline-entry:last-child { padding-bottom: 0; }
.timeline-entry::before {
    content: "";
    position: absolute;
    left: 0;
    top: .35rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
}
/* The connecting rule, from under this entry's dot to the next one. Not drawn
   on the last entry: a line trailing past the final state suggests the job has
   somewhere left to go. */
.timeline-entry::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 1.1rem;
    bottom: 0;
    width: 2px;
    background: var(--border);
}
.timeline-entry:last-child::after { content: none; }
.timeline-move { display: flex; align-items: center; gap: .4rem; margin: 0 0 .2rem; flex-wrap: wrap; }
.timeline-arrow { color: var(--muted); }
.timeline-meta { margin: 0; }
/* The admin's ruling, or the rule that fired. Indented and quoted because it is
   somebody's words rather than the platform's. */
.timeline-reason {
    margin: .3rem 0 0;
    padding-left: .6rem;
    border-left: 2px solid var(--border);
    font-size: .9rem;
    white-space: pre-wrap;
}
.timeline-actor { margin: .2rem 0 0; font-size: .8rem; }

/* The client's report behind a dispute. Same dialog shell as the timeline. */
.dispute-reports { overflow-y: auto; max-height: 62vh; }
.case-body { display: flex; flex-direction: column; gap: 1rem; overflow-y: auto; max-height: 72vh; }
.case-body .dispute-reports { max-height: none; overflow: visible; }
.case-record { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.case-stat { background: var(--neutral-tonal); border-radius: 8px; padding: .7rem; display: flex; flex-direction: column; font-size: .85rem; }
.case-stat strong { font-size: 1.3rem; color: var(--heading); }
.case-decisions { border: 0; margin: 0 0 .8rem; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.case-decisions legend { font-weight: 600; color: var(--heading); margin-bottom: .4rem; }
.case-decisions label { display: flex; align-items: center; gap: .5rem; }
#case-form textarea { width: 100%; box-sizing: border-box; margin-bottom: .6rem; }
.dispute-report + .dispute-report { margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.dispute-report-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0 0 .3rem; }
.dispute-report-head .badge { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-line); }
.dispute-report-text {
    margin: .5rem 0 0;
    padding-left: .6rem;
    border-left: 2px solid var(--border);
    white-space: pre-wrap;
}
.dispute-report-wants { margin: .6rem 0 0; font-size: .9rem; }
.dispute-report-photos { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .7rem; }
.dispute-report-photos img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* Support queue.
 *
 * A chat app inside the card: the queue on the left, the open thread on the
 * right. A reviewer working this needs both at once — the answer to most
 * questions is sitting in another thread from last week, and a list that
 * navigates away hides it. */
.support-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    height: min(72vh, 760px);
    min-height: 460px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}
/* One column under a narrow window, where two would leave neither readable. */
@media (max-width: 760px) {
    /* minmax(0, …): a plain 1fr will not shrink below its widest no-wrap
       preview, which pushed the card past the edge of a phone. */
    .support-layout { grid-template-columns: minmax(0, 1fr); height: auto; }
    .chat-sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 50vh; }
    .chat-main { min-height: 420px; }
}

.chat-sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border);
}
.chat-search {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 1rem;
    padding: 0 .9rem;
    border: 1px solid #d8d8dd;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 400;
}
.chat-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(102, 108, 255, .16); }
.chat-search input {
    flex: 1;
    min-width: 0;
    border: none;
    padding: .6rem 0;
    background: none;
    box-shadow: none;
}
.chat-search input:focus { box-shadow: none; }
.chat-section-title {
    margin: .2rem 1.25rem .4rem;
    color: var(--primary);
    font-size: 1.05rem;
    font-weight: 600;
}
.chat-no-match { margin: .5rem 1.25rem; }

.support-threads {
    list-style: none;
    margin: 0;
    padding: 0 .6rem .6rem;
    overflow-y: auto;
    flex: 1;
}
.support-thread-item { margin: .1rem 0; }

.support-thread-button {
    display: flex;
    align-items: center;
    gap: .8rem;
    width: 100%;
    text-align: left;
    padding: .6rem .7rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    font: inherit;
    font-weight: 400;
}
.support-thread-button:hover:not(:disabled) { background: var(--neutral-tonal); }
.support-thread-item.active .support-thread-button {
    background: linear-gradient(72.47deg, var(--primary) 22.16%, #8f93ff 76.47%);
    box-shadow: 0 2px 6px rgba(102, 108, 255, .4);
}
.support-thread-item.active .support-thread-button * { color: #fff; }
.support-thread-item.active .avatar { background: rgba(255, 255, 255, .25); }
.support-thread-button:disabled { cursor: progress; }

.support-thread-text { display: grid; gap: .1rem; flex: 1; min-width: 0; }
.support-thread-top, .support-thread-bottom { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.support-thread-top strong {
    flex: 1;
    min-width: 0;
    color: var(--heading);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The preview is one line whatever the user wrote: a queue where one row is a
   paragraph pushes everything else off screen. */
.support-preview {
    flex: 1;
    min-width: 0;
    color: var(--text);
    font-size: .85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.support-when { color: var(--muted); font-size: .76rem; white-space: nowrap; }

.support-badge {
    flex-shrink: 0;
    min-width: 20px;
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    padding: 0 .4rem;
    font-size: .72rem;
    font-weight: 700;
    text-align: center;
}

.chat-main {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg);
}

/* Nothing open: the big tinted icon and one line, centred. */
.chat-empty {
    flex: 1;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 1rem;
    color: var(--text);
}
.chat-empty p { margin: 0; }
.chat-empty-icon {
    display: grid;
    place-items: center;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background: var(--primary-tonal);
    color: var(--primary);
    font-size: 48px;
}

.support-thread {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.chat-header {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .9rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.chat-header-text { display: grid; min-width: 0; }
.chat-header h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header .muted { font-size: .8rem; }

.support-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    overflow-y: auto;
    padding: 1.25rem;
}
.support-message {
    max-width: 72%;
    padding: .55rem .85rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(76, 78, 100, .12);
}
.support-message p { margin: .1rem 0; white-space: pre-wrap; word-break: break-word; }
.support-message-who { font-size: .74rem; font-weight: 600; color: var(--muted); }
.support-message .support-when { display: block; text-align: right; margin-top: .1rem; }
/* The platform's own replies on the right in the primary colour, the user's
   on the left in white — the same arrangement the user sees in the app. */
.support-message.mine {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.support-message.mine .support-message-who,
.support-message.mine .support-when { color: rgba(255, 255, 255, .8); }
.support-message.theirs {
    align-self: flex-start;
    background: var(--surface);
    border-bottom-left-radius: 3px;
}

.chat-main > .support-thread > .error { margin: 0 1.25rem .5rem; }

.support-reply {
    display: flex;
    gap: .6rem;
    align-items: flex-end;
    margin: 0 1.25rem 1.25rem;
    padding: .5rem .5rem .5rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.support-reply textarea {
    flex: 1;
    min-height: 40px;
    max-height: 160px;
    padding: .55rem 0;
    font: inherit;
    border: none;
    background: none;
    resize: none;
    box-shadow: none;
    overflow-y: hidden;
}
.support-reply textarea:focus { box-shadow: none; }
/* The icon is drawn by CSS rather than markup: withBusy() resets the button's
   text after sending, which would strip an icon element out of it. */
.send-button {
    flex-shrink: 0;
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(102, 108, 255, .4);
}
.send-button::after {
    content: "send";
    font-family: "Material Symbols Rounded";
    font-size: 19px;
    line-height: 1;
}
.send-button:hover:not(:disabled) { background: var(--primary-dark); }
/* On a phone the label costs the reply box half its width; the icon alone is
   the familiar send button, and the text stays as its accessible name. */
@media (max-width: 640px) {
    .send-button { font-size: 0; gap: 0; padding: .55rem .7rem; }
    .send-button::after { font-size: 20px; }
}

/* Reports queue.
 *
 * Only one rule of its own: a target reported repeatedly should be visible at a
 * glance. A single complaint and a fourth are different situations, and the
 * count is the one column a reviewer scans for. */
td.warn { color: var(--danger); font-weight: 600; }

/* ================================================================ catalog
 *
 * The Catálogo screen: a page header, a tab per thing the backoffice manages
 * (categories, Home groups, supply, licenses), lists first, and every
 * create/edit form in a side drawer over the list it changes.
 */

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mono, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
button.with-icon { padding-left: .8rem; }
button.dashed {
    border-style: dashed;
    border-color: var(--primary-line);
    color: var(--primary);
    background: transparent;
    align-self: flex-start;
}
button.dashed:hover:not(:disabled) { background: var(--primary-tonal); }

.page-head {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.1rem;
}
.page-head > div { flex: 1; min-width: 0; }
.page-sub { margin: .3rem 0 0; max-width: 62rem; }

/* Tabs: an underline strip, the selected one in the brand colour. */
.tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.tab {
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: none;
    padding: .65rem .9rem;
    color: var(--muted);
    white-space: nowrap;
    margin-bottom: -1px;
}
.tab .icon { font-size: 19px; }
.tab:hover:not(:disabled) { background: var(--surface-alt); color: var(--heading); }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tab[aria-selected="true"]:hover:not(:disabled) { background: var(--primary-tonal); color: var(--primary); }
.tab-count {
    min-width: 1.4rem;
    padding: 0 .4rem;
    border-radius: 999px;
    background: var(--neutral-tonal);
    color: var(--muted);
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.35rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.tab[aria-selected="true"] .tab-count { background: var(--primary-tonal); color: var(--primary); }

.panel-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: .9rem;
}
.panel-toolbar > p { flex: 1; margin: 0; max-width: 62rem; }
.tab-panel > [role=status]:not([hidden]) {
    display: block;
    padding: .55rem .85rem;
    margin: 0 0 .9rem;
    border-radius: var(--radius-sm);
    background: var(--success-tonal);
}
.tab-panel > [role=status].error { background: var(--danger-tonal); }

.empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin-top: .75rem;
}

details.help { margin: 0 0 .9rem; font-size: .88rem; }
details.help summary { cursor: pointer; color: var(--primary); width: fit-content; }
details.help dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: .3rem 1rem;
    margin: .6rem 0 0;
    padding: .75rem 1rem;
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
}
details.help dt { font-weight: 600; color: var(--heading); }
details.help dd { margin: 0; }

/* Cells */
td.num { font-variant-numeric: tabular-nums; color: var(--muted); }
td.identity { min-width: 11rem; }
td.identity strong { display: block; color: var(--heading); font-weight: 600; }
td.identity code { display: block; color: var(--muted); }
td.identity .muted { display: block; font-size: .8rem; }
#catalog-table tbody tr, #catalog-licenses-table tbody tr { cursor: default; }
#catalog-table td.prose, #catalog-licenses-table td.prose { font-size: .88rem; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
    padding: .1rem .55rem;
    border-radius: 999px;
    background: var(--neutral-tonal);
    font-size: .8rem;
    white-space: nowrap;
}
details.use-details summary { cursor: pointer; color: var(--primary); font-weight: 500; white-space: nowrap; }
details.use-details ul { margin: .4rem 0 0; padding-left: 1.1rem; font-size: .85rem; }

/* ----------------------------------------------------------------- drawer */

dialog.drawer {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(760px, 100vw);
    height: 100vh;
    max-height: 100vh;
    max-width: 100vw;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: var(--shadow-lg);
    color: var(--text);
    background: var(--surface);
    flex-direction: column;
}
dialog.drawer[open] { display: flex; animation: drawer-in .2s ease-out; }
dialog.drawer::backdrop { background: rgba(38, 39, 55, .45); }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog.drawer[open] { animation: none; } }

.drawer-head {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.drawer-head > div { flex: 1; min-width: 0; }
.drawer-head h3 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.eyebrow {
    margin: 0 0 .15rem;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}
.drawer-body { flex: 1; overflow-y: auto; padding: 0 1.5rem; }
.drawer-foot {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .85rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
}
.drawer-foot [role=status] { margin: 0; flex: 1; min-width: 0; }
.drawer-foot [role=status]:not([hidden]) + .spacer { display: none; }

.form-section { padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: none; }
.form-section h4 { margin: 0 0 .25rem; font-size: .95rem; color: var(--heading); font-weight: 600; }
.form-section > .muted { margin: 0 0 .9rem; }
.form-section > h4 + .fields, .form-section > h4 + .category-modes { margin-top: .75rem; }
.fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .fields.two { grid-template-columns: 1fr; } }
.optional { font-weight: 400; color: var(--muted); font-size: .78rem; margin-left: .25rem; }
.drawer textarea {
    padding: .6rem .75rem;
    border: 1px solid #d8d8dd;
    border-radius: var(--radius-sm);
    font: inherit;
    color: inherit;
    resize: vertical;
    min-height: 3.2rem;
}
.category-modes.stack { display: flex; flex-direction: column; gap: .45rem; margin-top: 1rem; }
.category-modes.stack label { font-weight: 400; }
.callout:empty { display: none; }
.callout {
    margin: 1rem 0 0;
    padding: .65rem .85rem;
    border-radius: var(--radius-sm);
    background: var(--primary-tonal);
    color: var(--primary-dark);
    font-size: .85rem;
}

/* Two big toggles rather than two small checkboxes: the choice is visual. */
.choice-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.choice-row .choice {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
}
.choice-row .choice .icon { font-size: 20px; color: var(--muted); }
.choice-row .choice:has(input:checked) { border-color: var(--primary); background: var(--primary-tonal); color: var(--primary); }
.choice-row .choice:has(input:checked) .icon { color: var(--primary); }

.inline-check { display: flex; align-items: center; gap: .4rem; font-weight: 400; margin-top: .35rem; }
.inline-check input { width: auto; }

.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: .4rem;
}
.check-grid label {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .45rem .65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 400;
    cursor: pointer;
}
.check-grid label:has(input:checked) { border-color: var(--primary); background: var(--primary-tonal); color: var(--primary-dark); }
.check-grid input { width: auto; }

.scope-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.scope-list:empty { display: none; }
.scope-row {
    padding: .6rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
}
.scope-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto auto auto;
    gap: .4rem;
    align-items: center;
}
.scope-fields label { display: flex; align-items: center; gap: .35rem; font-weight: 400; padding: 0 .3rem; }
.scope-fields label input { width: auto; }
.scope-usage { margin: .35rem 0 0; font-size: .8rem; }
@media (max-width: 640px) {
    .scope-fields { grid-template-columns: 1fr 1fr; }
    .scope-fields .scope-key, .scope-fields .scope-name { grid-column: 1 / -1; }
}

/* The services sub-form inside the category drawer. */
.subform {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-alt);
}
.subform h5 { margin: 0 0 .75rem; font-size: .88rem; color: var(--heading); }
.subform-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .9rem; }

@media (max-width: 640px) {
    .page-head { flex-direction: column; gap: .75rem; }
    .panel-toolbar { flex-direction: column; align-items: stretch; }
    .drawer-head, .drawer-foot { padding-left: 1rem; padding-right: 1rem; }
    .drawer-body { padding: 0 1rem; }
}
td.prose.clamp { max-width: 18rem; }
.clamp-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.chip.more { background: var(--primary-tonal); color: var(--primary); }

/* The same shell, centred: used where the form is short (the license editor). */
dialog.drawer.modal {
    inset: 0;
    margin: auto;
    width: min(720px, 94vw);
    height: auto;
    max-height: 90vh;
    border-radius: var(--radius);
    overflow: hidden;
}
dialog.drawer.modal[open] { animation: modal-in .18s ease-out; }
@keyframes modal-in { from { transform: translateY(8px) scale(.98); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog.drawer.modal[open] { animation: none; } }
@media (max-width: 640px) {
    dialog.drawer.modal { width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
}

/* ------------------------------------------------------- two-factor sign-in */

/* The second step, enrollment and the one-time recovery codes share the
   sign-in card; enrollment needs a little more room for the QR code. */
.login-card .link { align-self: center; margin-top: .2rem; }
.field-stack { display: flex; flex-direction: column; gap: .4rem; }

.enroll-card { width: min(480px, 92vw); display: flex; flex-direction: column; gap: .5rem; }
.enroll-steps { margin: .2rem 0 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .9rem; }
.enroll-steps li { padding-left: .2rem; }
.enroll-steps p { margin: 0 0 .5rem; }
.enroll-steps label { display: block; margin-bottom: .45rem; }
.enroll-steps input { width: 100%; box-sizing: border-box; }

/* Black on white in every theme: phone cameras read that most reliably. */
.qr-frame {
    width: 200px;
    height: 200px;
    margin: .2rem auto .6rem;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.qr-frame img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }

.key-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.secret-key, .recovery-codes {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: .04em;
}
.secret-key {
    padding: .35rem .55rem;
    background: var(--neutral-tonal);
    border-radius: var(--radius-sm);
    overflow-wrap: anywhere;
}

.otp-input { font-size: 1.15rem; letter-spacing: .18em; text-align: center; }

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .35rem 1.4rem;
    margin: .3rem 0 .4rem;
    padding: .8rem 1rem .8rem 2.2rem;
    background: var(--neutral-tonal);
    border-radius: var(--radius-sm);
    font-size: .95rem;
}
@media (max-width: 420px) {
    .recovery-codes { grid-template-columns: 1fr; }
}

.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; margin-top: .4rem; }

/* Mi cuenta */
.account-card { margin-bottom: 1.25rem; }
.account-card h3 { margin-bottom: .2rem; }
.account-card .field-stack { margin-top: .4rem; }
#regenerated-codes { margin-top: .8rem; display: flex; flex-direction: column; gap: .4rem; }

/* Administradores: the admin accounts under the invitations. */
.subsection-title { margin: 1.8rem 0 .3rem; font-size: 1.05rem; }
.badge.TWO_FACTOR_ON { background: var(--success-tonal); color: var(--success); border-color: var(--success-line); }
.badge.TWO_FACTOR_PENDING { background: var(--warning-bg); color: var(--warning); }
