/* ==========================================================================
   Selcom — shared UI theme
   Brand red: #e80032
   ========================================================================== */

:root {
    --brand:          #e80032;  /* matches the logo mark exactly */
    --brand-600:      #d4002d;
    --brand-700:      #bd0028;
    --brand-800:      #a30023;
    --brand-900:      #7d001b;  /* deepest — headings on light backgrounds */
    --brand-50:       #fff0f3;
    --brand-100:      #ffdbe3;
    --brand-rgb:      232, 0, 50;

    --ink:            #2f2b3a;
    --ink-soft:       #56526b;
    --muted:          #8a86a0;
    --line:           #e9e8f0;
    --line-soft:      #f2f1f7;
    --surface:        #ffffff;
    --bg:             #f4f4f8;

    --ok:             #28c76f;
    --warn:           #ff9f43;
    --info:           #00cfe8;
    --danger:         #ea5455;

    --radius:         14px;
    --radius-sm:      10px;
    --shadow-sm:      0 2px 6px rgba(47, 43, 58, .06);
    --shadow:         0 6px 20px rgba(47, 43, 58, .10);
    --shadow-lg:      0 18px 48px rgba(47, 43, 58, .16);

    --sidebar-w:      272px;
    --sidebar-w-mini: 82px;
    --topbar-h:       74px;

    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-700); }

::selection { background: var(--brand-100); color: var(--brand-900); }

/* Default size for the inline icons, so one that lands in an unstyled
   container degrades to a sensible glyph rather than a 300x150 block. */
svg[focusable="false"] { width: 18px; height: 18px; }

.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;
}

/* --------------------------------------------------------------------------
   Brand mark
   -------------------------------------------------------------------------- */

.logo {
    display: block;
    width: auto;
    height: 52px;
    flex: none;
    transition: height .22s ease;
}
.logo--white { height: 40px; }

/* Square "S" mark — only shown in the collapsed sidebar (see below). */
.logo-mark { display: none; height: 38px; border-radius: 8px; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .62rem 1.15rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s, transform .08s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn-primary {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 4px 14px rgba(var(--brand-rgb), .32);
}
.btn-primary:hover { background: var(--brand-600); color: #fff; box-shadow: 0 6px 18px rgba(var(--brand-rgb), .42); }

.btn-outline {
    background: transparent;
    color: var(--brand);
    border-color: var(--brand);
}
.btn-outline:hover { background: var(--brand-50); color: var(--brand-700); }

.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border-color: var(--line);
}
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--brand);
    font-weight: 600;
    cursor: pointer;
    font-size: .875rem;
}
.btn-link:hover { text-decoration: underline; }

.btn-block { width: 100%; }
.btn-lg { padding: .82rem 1.3rem; font-size: .95rem; }

.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.field { margin-bottom: 1.05rem; }

.field-label {
    display: block;
    margin-bottom: .4rem;
    font-size: .82rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: .68rem .9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: .92rem;
    transition: border-color .15s, box-shadow .15s;
}
.textarea { resize: vertical; min-height: 96px; }
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a86a0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .8rem center;
    padding-right: 2.4rem;
    cursor: pointer;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .14);
}

.input::placeholder, .textarea::placeholder { color: #b4b1c4; }

/* Searchable select (select[data-searchable], built by selcom.js) */
.combo { position: relative; }
.combo-native {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}
.combo-trigger {
    display: block;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.combo-trigger.is-placeholder { color: #b4b1c4; }
.combo-trigger:disabled { background-color: var(--line-soft); cursor: not-allowed; }
.combo.is-open .combo-trigger {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .14);
}
.combo-panel {
    position: absolute;
    z-index: 30;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    padding: .5rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}
.combo-search { padding: .55rem .8rem; font-size: .88rem; }
.combo-list {
    list-style: none;
    margin: .4rem 0 0;
    padding: 0;
    max-height: 240px;
    overflow-y: auto;
}
.combo-option {
    padding: .5rem .7rem;
    border-radius: 8px;
    font-size: .9rem;
    color: var(--ink);
    cursor: pointer;
}
.combo-option:hover,
.combo-option.is-active { background: var(--brand-50); color: var(--brand-800); }
.combo-empty { padding: .6rem .7rem; font-size: .86rem; color: var(--muted); }
/* Cards clip their content for the rounded corners; let an open list out. */
.card:has(.combo.is-open) { overflow: visible; }

.input-group { position: relative; }
.input-group .input { padding-left: 2.7rem; }
.input-group > svg {
    position: absolute;
    left: .92rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--muted);
    pointer-events: none;
}

.input-group .toggle-pass {
    position: absolute;
    right: .35rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--muted);
    cursor: pointer;
}
.input-group .toggle-pass:hover { background: var(--line-soft); color: var(--ink); }
.input-group .toggle-pass svg { width: 18px; height: 18px; display: block; }
.input-group .toggle-pass span { display: inline-flex; }
.input-group .input.has-toggle { padding-right: 2.9rem; }

.field-hint { margin: .4rem 0 0; font-size: .77rem; color: var(--muted); }
.field-error { margin: .4rem 0 0; font-size: .79rem; color: var(--danger); font-weight: 500; }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--danger); }

.field-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
}

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .72rem .9rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    margin-bottom: 1.1rem;
    border: 1px solid transparent;
}
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-success { background: #e9f9f0; color: #14794a; border-color: #c7efd9; }
.alert-danger  { background: #fdecec; color: #b42a2b; border-color: #f8d4d4; }
.alert-info    { background: var(--brand-50); color: var(--brand-800); border-color: var(--brand-100); }

/* --------------------------------------------------------------------------
   Auth screens — single centred card
   -------------------------------------------------------------------------- */

.auth-body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.1rem;
    background:
        radial-gradient(900px 480px at 8% -8%, rgba(var(--brand-rgb), .16), transparent 60%),
        radial-gradient(760px 420px at 104% 108%, rgba(var(--brand-rgb), .12), transparent 62%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 452px;
    background: var(--surface);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    padding: 2.6rem 2.4rem 2.2rem;
    position: relative;
    overflow: hidden;
    animation: card-in .45s cubic-bezier(.22, 1, .36, 1) both;
}
.auth-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: linear-gradient(90deg, var(--brand) 0%, var(--brand-700) 55%, var(--brand-900) 100%);
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(14px) scale(.985); }
    to   { opacity: 1; transform: none; }
}

.auth-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.auth-head { text-align: center; margin-bottom: 1.7rem; }
.success-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: .9rem;
    border-radius: 50%;
    background: var(--brand-50);
    color: var(--brand);
    box-shadow: 0 0 0 6px rgba(var(--brand-rgb), .08);
    flex: none;
}
.success-mark svg { width: 25px; height: 25px; stroke-width: 2.2; }
.auth-head h1 {
    margin: 0 0 .35rem;
    font-size: 1.32rem;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--ink);
}
.auth-head p {
    margin: 0;
    font-size: .875rem;
    color: var(--muted);
    line-height: 1.5;
}
.auth-head strong { color: var(--ink-soft); }

.auth-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    margin-bottom: 1.6rem;
}
.auth-steps .step {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    font-size: .74rem;
    font-weight: 600;
    color: var(--muted);
}
.auth-steps .step i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--line-soft);
    color: var(--muted);
    font-style: normal;
    font-size: .7rem;
}
.auth-steps .step.is-active i { background: var(--brand); color: #fff; box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .15); }
.auth-steps .step.is-active { color: var(--brand-800); }
.auth-steps .step.is-done i { background: var(--brand-100); color: var(--brand-800); }
.auth-steps .step.is-done svg { width: 12px; height: 12px; }
.auth-steps .bar { width: 34px; height: 2px; border-radius: 2px; background: var(--line); }
.auth-steps .bar.is-filled { background: var(--brand-100); }

.auth-foot {
    margin-top: 1.5rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--line-soft);
    text-align: center;
    font-size: .8rem;
    color: var(--muted);
}
.auth-foot a { font-weight: 600; }
.auth-foot svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: .1rem; color: var(--brand); }

.auth-legal {
    margin-top: 1.4rem;
    text-align: center;
    font-size: .75rem;
    color: #a6a3b8;
}

/* OTP boxes */

.otp-inputs {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: .5rem;
    margin-bottom: .3rem;
}
.otp-inputs input {
    width: 100%;
    min-height: 54px;
    text-align: center;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ink);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: #fff;
    transition: border-color .15s, box-shadow .15s, transform .12s;
    padding: 0;
    font-family: inherit;
}
.otp-inputs input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .15);
    transform: translateY(-1px);
}
.otp-inputs input.is-filled { border-color: var(--brand-100); background: var(--brand-50); }

.otp-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin: 1rem 0 .2rem;
    font-size: .8rem;
    color: var(--muted);
    flex-wrap: wrap;
}
.otp-meta .countdown { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-soft); }
.otp-meta > span { display: inline-flex; align-items: center; gap: .32rem; }
.otp-meta svg { width: 14px; height: 14px; flex: none; }

/* --------------------------------------------------------------------------
   App shell — sidebar + topbar
   -------------------------------------------------------------------------- */

.app { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(178deg, var(--brand) 0%, var(--brand-600) 52%, var(--brand-700) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: width .22s ease, transform .22s ease;
}

.sidebar-head {
    display: flex;
    align-items: center;
    gap: .6rem;
    height: var(--topbar-h);
    padding: 0 1.25rem;
    flex: none;
    position: relative;
}


.sidebar-collapse {
    position: absolute;
    right: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 4px solid var(--bg);
    background: #fff;
    color: var(--brand);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    padding: 0;
}
.sidebar-collapse svg { width: 15px; height: 15px; transition: transform .22s ease; }
.sidebar-collapse:hover { background: var(--brand-50); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .35rem .85rem 1.6rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .35) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .3); border-radius: 6px; }

.nav-item { position: relative; }

.nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .62rem .75rem;
    margin-bottom: .18rem;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, .94);
    font-size: .9rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color .15s, color .15s, box-shadow .15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    position: relative;
}
.nav-link:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.nav-link > svg:first-child { width: 20px; height: 20px; flex: none; }
.nav-link .nav-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.nav-link.is-active {
    background: #fff;
    color: var(--brand);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}
.nav-link.is-active::before {
    content: '';
    position: absolute;
    left: -.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    border-radius: 0 4px 4px 0;
    background: #fff;
}

.sidebar-foot {
    flex: none;
    padding: .9rem .85rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, .22);
}
.sidebar-foot .nav-link:hover { background: rgba(255, 255, 255, .2); }

/* Collapsed (mini) sidebar — desktop only */

@media (min-width: 993px) {
    .app.is-collapsed .sidebar { width: var(--sidebar-w-mini); }
    .app.is-collapsed .sidebar .nav-text { display: none; }
    .app.is-collapsed .sidebar .logo-full { display: none; }
    .app.is-collapsed .sidebar .logo-mark { display: block; }
    .app.is-collapsed .sidebar-head { justify-content: center; padding: 0 .6rem; }
    .app.is-collapsed .nav-link { justify-content: center; padding: .68rem 0; }
    .app.is-collapsed .sidebar-collapse svg { transform: rotate(180deg); }
    .app.is-collapsed .main { margin-left: var(--sidebar-w-mini); }
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(47, 43, 58, .45);
    z-index: 55;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s, visibility .2s;
}

/* Topbar */

.main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-left .22s ease;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.4rem;
    margin: .8rem 1.4rem 0;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.topbar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--ink-soft);
    cursor: pointer;
    flex: none;
}
.topbar-toggle svg { width: 22px; height: 22px; }
.topbar-toggle:hover { background: var(--line-soft); }

.topbar-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: .65rem;
    min-width: 0;
}
.topbar-search svg { width: 20px; height: 20px; color: var(--ink-soft); flex: none; }
.topbar-search input {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: .93rem;
    color: var(--ink);
    padding: .4rem 0;
}
.topbar-search input:focus { outline: none; }
.topbar-search input::placeholder { color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: .15rem; flex: none; }

.icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--line-soft); color: var(--brand); }
.icon-btn svg { width: 20px; height: 20px; }
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand-50);
    color: var(--brand-700);
    font-weight: 700;
    font-size: .82rem;
    letter-spacing: .02em;
    flex: none;
    text-transform: uppercase;
}
.avatar-wrap { position: relative; display: inline-flex; }
.avatar-wrap .status {
    position: absolute;
    right: 0;
    bottom: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ok);
    border: 2px solid #fff;
}

.user-menu { position: relative; margin-left: .35rem; }
.user-menu > button { border: none; background: none; padding: 0; cursor: pointer; }

.dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + .6rem);
    min-width: 240px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--line-soft);
    padding: .45rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .16s, transform .16s, visibility .16s;
    z-index: 50;
}
.user-menu.is-open .dropdown { opacity: 1; visibility: visible; transform: none; }

.dropdown-head {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem .7rem .7rem;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: .35rem;
}
.dropdown-head .name { font-weight: 600; font-size: .88rem; line-height: 1.25; }
.dropdown-head .meta { font-size: .76rem; color: var(--muted); word-break: break-all; }

.dropdown a,
.dropdown button.item {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .55rem .7rem;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--ink-soft);
    font: inherit;
    font-size: .865rem;
    text-align: left;
    cursor: pointer;
}
.dropdown a:hover,
.dropdown button.item:hover { background: var(--brand-50); color: var(--brand-700); }
.dropdown svg { width: 17px; height: 17px; flex: none; }
.dropdown .item-danger:hover { background: #fdecec; color: var(--danger); }

/* Content */

.content { flex: 1; padding: 1.5rem 1.4rem 2.2rem; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.35rem;
}
.page-head h1 {
    margin: 0;
    font-size: 1.32rem;
    font-weight: 700;
    letter-spacing: -.01em;
}
.breadcrumbs {
    margin: .2rem 0 0;
    font-size: .82rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--brand); }
.breadcrumbs .sep { opacity: .5; }

/* --------------------------------------------------------------------------
   Cards, stats, tables
   -------------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.35rem;
    overflow: hidden;
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.1rem 1.35rem;
    border-bottom: 1px solid var(--line-soft);
}
.card-head h2, .card-head h3 {
    margin: 0;
    font-size: .98rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.card-head h2 > svg, .card-head h3 > svg { width: 18px; height: 18px; color: var(--brand); flex: none; }
.card-head .sub { margin: .15rem 0 0; font-size: .8rem; color: var(--muted); font-weight: 400; }
.card-body { padding: 1.35rem; }
.card-narrow { max-width: 560px; }
.card-tools { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1.05rem;
    margin-bottom: 1.35rem;
}
.stat {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.15rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .95rem;
    transition: transform .16s, box-shadow .16s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat .stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--brand-50);
    color: var(--brand);
    flex: none;
}
.stat .stat-icon svg { width: 22px; height: 22px; }
.stat .stat-value { display: block; font-size: 1.5rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat .stat-label { display: block; font-size: .8rem; color: var(--muted); }
.stat-icon.tone-warn { background: #fff4e6; color: var(--warn); }
.stat-icon.tone-ok   { background: #e9f9f0; color: #17a96a; }
.stat-icon.tone-info { background: #e6fbfd; color: #0bb6cc; }

.filter-chips { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .38rem .85rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-soft);
    font-size: .8rem;
    font-weight: 500;
    transition: background-color .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.is-active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(var(--brand-rgb), .3);
}
.chip .count {
    padding: 0 .35rem;
    border-radius: 999px;
    background: var(--line-soft);
    font-size: .72rem;
    font-weight: 700;
    color: var(--ink-soft);
}
.chip.is-active .count { background: rgba(255, 255, 255, .26); color: #fff; }

.table-wrap { width: 100%; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }
.table th {
    padding: .85rem 1.35rem;
    text-align: left;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .055em;
    text-transform: uppercase;
    color: var(--muted);
    background: #fbfbfd;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td {
    padding: .92rem 1.35rem;
    font-size: .875rem;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
.table tbody tr { transition: background-color .13s; }
.table tbody tr:hover { background: #fcfbfd; }
.table tbody tr:last-child td { border-bottom: none; }
.table .t-strong { font-weight: 600; color: var(--ink); }
.table .t-muted { color: var(--muted); }
.table a.t-strong:hover { color: var(--brand); }
.table .t-right { text-align: right; }

.cell-stack { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.cell-user { display: flex; align-items: center; gap: .7rem; }
.cell-user .avatar { width: 34px; height: 34px; font-size: .72rem; }
.cell-user .meta { min-width: 0; }
.cell-user .meta .name { display: block; font-weight: 600; font-size: .875rem; line-height: 1.25; }
.cell-user .meta .sub { display: block; font-size: .76rem; color: var(--muted); word-break: break-word; }

.row-actions { display: inline-flex; gap: .3rem; justify-content: flex-end; }
.row-actions .icon-btn { width: 32px; height: 32px; }
.row-actions .icon-btn svg { width: 17px; height: 17px; }

.empty-state { padding: 3.2rem 1.35rem; text-align: center; color: var(--muted); }
.empty-state svg { width: 46px; height: 46px; color: #d5d3e0; margin-bottom: .7rem; }
.empty-state p { margin: 0 0 .25rem; font-weight: 600; color: var(--ink-soft); }
.empty-state span { font-size: .85rem; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .24rem .68rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-submitted { background: #eef1ff; color: #4b5bd6; }
.badge-in_review { background: #fff4e6; color: #c9791a; }
.badge-approved  { background: #e9f9f0; color: #17a96a; }
.badge-live      { background: var(--brand-50); color: var(--brand-700); }
.badge-rejected  { background: #fdecec; color: #cf3f40; }
.badge-neutral   { background: var(--line-soft); color: var(--ink-soft); }

.table-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: .9rem 1.35rem;
    border-top: 1px solid var(--line-soft);
    font-size: .82rem;
    color: var(--muted);
}

.pager { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.pager a, .pager span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 .5rem;
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--ink-soft);
}
.pager a:hover { background: var(--brand-50); color: var(--brand); }
.pager .is-current { background: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(var(--brand-rgb), .3); }
.pager .is-disabled { color: #c8c5d4; }
.pager svg { width: 15px; height: 15px; }

/* Detail pages */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.1rem 1.6rem;
}
.detail-grid .item .label {
    display: block;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: .18rem;
}
.detail-grid .item .value { display: block; font-size: .9rem; color: var(--ink); word-break: break-word; }

.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.35rem; align-items: start; }
@media (min-width: 1100px) {
    .split { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .app.is-mobile-open .sidebar { transform: none; }
    .app.is-mobile-open .sidebar-overlay { opacity: 1; visibility: visible; }
    .sidebar-collapse { display: none; }
    .main { margin-left: 0; }
    .topbar-toggle { display: inline-flex; }
    .topbar { margin: .7rem .9rem 0; padding: 0 1rem; }
    .content { padding: 1.2rem .9rem 2rem; }
}

@media (max-width: 640px) {
    body { font-size: 14.5px; }
    :root { --topbar-h: 64px; }

    .auth-card { padding: 2rem 1.35rem 1.7rem; border-radius: 18px; }
    .otp-inputs { gap: .35rem; }
    .otp-inputs input { font-size: 1.1rem; min-height: 48px; }

    .topbar-search input { font-size: .88rem; }

    .card-head { padding: 1rem; }
    .card-body { padding: 1rem; }
    .page-head h1 { font-size: 1.15rem; }

    /* Stacked table rows */
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
    .table tr:last-child { border-bottom: none; }
    .table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: .45rem 1rem;
        border: none;
        text-align: right;
    }
    .table td::before {
        content: attr(data-label);
        font-size: .7rem;
        font-weight: 700;
        letter-spacing: .05em;
        text-transform: uppercase;
        color: var(--muted);
        text-align: left;
        flex: none;
    }
    .cell-user { justify-content: flex-end; }
    .cell-stack { align-items: flex-end; }
    .table-foot { padding: .9rem 1rem; }
}

@media print {
    .sidebar, .topbar, .sidebar-overlay, .card-tools, .pager { display: none !important; }
    .main { margin-left: 0; }
    body { background: #fff; }
}

/* --------------------------------------------------------------------------
   Onboarding wizard
   -------------------------------------------------------------------------- */

.wizard { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.35rem; align-items: start; }
@media (min-width: 1000px) {
    .wizard { grid-template-columns: 250px minmax(0, 1fr); }
}

.stepper { list-style: none; margin: 0; padding: 0; }

.stepper-item > a,
.stepper-item > span {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .7rem;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    position: relative;
    transition: background-color .15s;
}
.stepper-item > a:hover { background: var(--surface); color: var(--ink); }

.stepper-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 50%;
    background: var(--line-soft);
    color: var(--muted);
    font-size: .74rem;
    font-weight: 700;
}
.stepper-dot svg { width: 16px; height: 16px; stroke-width: 2.4; }

.stepper-text { min-width: 0; }
.stepper-title { display: block; font-size: .875rem; font-weight: 600; line-height: 1.25; }
.stepper-sub { display: block; font-size: .74rem; color: var(--muted); }

.stepper-item.is-done .stepper-dot { background: #e9f9f0; color: #17a96a; }
.stepper-item.is-current > a,
.stepper-item.is-current > span { background: var(--surface); box-shadow: var(--shadow-sm); }
.stepper-item.is-current .stepper-dot { background: var(--brand); color: #fff; }
.stepper-item.is-current .stepper-title { color: var(--brand-800); }

/* Horizontal variant used on the partner dashboard */
.stepper--flat { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .3rem; margin-top: 1.2rem; }
.stepper--flat .stepper-item > a,
.stepper--flat .stepper-item > span { padding: .5rem .55rem; }

.progress-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.25rem 1.15rem;
    margin-bottom: 1.35rem;
}
.progress-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    font-size: .84rem;
    color: var(--muted);
    margin-bottom: .55rem;
}
.progress-head strong { color: var(--ink); }

.progress-track {
    display: block;
    height: 9px;
    border-radius: 999px;
    background: var(--line-soft);
    overflow: hidden;
}
.progress-track--sm { height: 6px; }
.progress-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand) 0%, var(--brand-700) 100%);
    transition: width .3s ease;
}

.wizard-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    margin-top: 1.1rem;
}
.wizard-actions-right { display: flex; gap: .6rem; flex-wrap: wrap; }

.save-state {
    font-size: .8rem;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 20px;
}
.save-state.is-saving { color: var(--muted); }
.save-state.is-saved { color: #17a96a; }
.save-state.is-error { color: var(--danger); }

/* Form layout inside the wizard */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 1.1rem; }

.req { color: var(--brand); margin-left: .15rem; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .5rem; }

.check-card {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem .8rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: .875rem;
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}
.check-card:hover { border-color: var(--brand); }
.check-card input { accent-color: var(--brand); width: 17px; height: 17px; flex: none; margin: 0; }
.check-card:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.check-card--wide { align-items: flex-start; line-height: 1.5; }
.check-card--wide input { margin-top: .15rem; }

.contact-block { padding-bottom: .5rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line-soft); }
.contact-block:last-child { border-bottom: none; margin-bottom: 0; }
.contact-head { margin-bottom: .6rem; }
.contact-head h3 { margin: 0; font-size: .92rem; font-weight: 600; }
.contact-head p { margin: .1rem 0 0; font-size: .78rem; color: var(--muted); }

/* Sortable table headers */

.th-sort {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    color: inherit;
    font: inherit;
}
.th-sort:hover { color: var(--brand); }
.th-sort svg { width: 13px; height: 13px; opacity: .55; }

.code-block {
    margin: 0;
    padding: .7rem .9rem;
    background: #2f2b3a;
    color: #f1eff5;
    border-radius: var(--radius-sm);
    font-size: .8rem;
    overflow-x: auto;
}
code {
    background: var(--line-soft);
    padding: .1rem .35rem;
    border-radius: 5px;
    font-size: .85em;
}

/* --------------------------------------------------------------------------
   Button loading state
   -------------------------------------------------------------------------- */

@keyframes spin { to { transform: rotate(360deg); } }

.btn-spinner {
    display: inline-block;
    flex: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-right-color: transparent;
    animation: spin .6s linear infinite;
    opacity: .9;
}

/* Buttons keep their label so nothing jumps; only the icon is swapped out. */
.is-loading {
    pointer-events: none;
    cursor: progress;
}
.btn.is-loading { opacity: .9; }
.btn.is-loading svg { display: none; }

.icon-btn.is-loading .btn-spinner,
.nav-link.is-loading .btn-spinner { width: 15px; height: 15px; }
.icon-btn.is-loading svg,
.nav-link.is-loading svg { display: none; }

.btn-lg .btn-spinner { width: 17px; height: 17px; }

/* Anything else on the page is inert while a submit is in flight. */
.is-submitting .btn:not(.is-loading),
.is-submitting .icon-btn:not(.is-loading) { opacity: .6; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
    .btn-spinner { animation-duration: 1.6s; }
}

/* Controls with no icon to swap: spinner sits over the label, width pinned. */
.is-loading-solo { position: relative; color: transparent !important; }
.is-loading-solo .btn-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
}

/* ======================================================================
   Due-diligence questionnaire
   Yes/no answers, repeating tables, document slots and the section
   notices the printed KYC form carries.
   ====================================================================== */

[hidden] { display: none !important; }

.tail-forms { display: none; }

hr.rule {
    border: 0;
    border-top: 1px solid var(--line-soft);
    margin: 1.7rem 0 1.4rem;
}

.subhead {
    margin: 0 0 .9rem;
    font-size: .93rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -.01em;
}

.btn-sm { padding: .42rem .8rem; font-size: .8rem; border-radius: 8px; }
.btn-sm svg { width: 15px; height: 15px; }

/* ---- Yes / no ------------------------------------------------------- */

.field-yesno {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.2rem;
    padding: .85rem 0;
    border-bottom: 1px dashed var(--line-soft);
    margin-bottom: 0;
}
.field-yesno:last-child { border-bottom: 0; }
.field-yesno .yn-question { flex: 1 1 auto; min-width: 0; }
.field-yesno .field-label { display: block; margin-bottom: 0; line-height: 1.45; }
.field-yesno .field-hint { margin-top: .25rem; }
.field-yesno.has-error .field-label { color: var(--danger); }

.yn-group { display: flex; gap: .45rem; flex: none; padding-top: .1rem; }

.yn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .42rem .85rem;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    font-size: .84rem;
    font-weight: 500;
    color: var(--ink-soft);
    cursor: pointer;
    transition: border-color .13s, background-color .13s, color .13s;
}
.yn:hover { border-color: var(--brand); }
.yn input { accent-color: var(--brand); width: 15px; height: 15px; margin: 0; flex: none; }
.yn:has(input:checked) {
    border-color: var(--brand);
    background: var(--brand-50);
    color: var(--brand-700);
}

/* A run of yes/no questions reads as one block, like the paper table. */
.yn-stack {
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    padding: .2rem 1rem;
    margin-bottom: 1.05rem;
}

/* A block that only applies to one answer. Visible by default so the form
   still works with JavaScript off; the script hides what does not apply. */
.reveal {
    border-left: 3px solid var(--brand-100);
    padding-left: 1rem;
    margin: 0 0 1.05rem;
}

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

.repeater { margin-bottom: 1.3rem; }
.repeater-head { margin-bottom: .6rem; }
.repeater-head .field-label { display: block; margin-bottom: 0; }
.repeater-head .field-hint { margin-top: .2rem; }

.repeater-table { width: 100%; border-collapse: separate; border-spacing: 0 .35rem; }
.repeater-table th {
    text-align: left;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 .3rem .1rem;
    white-space: nowrap;
}
.repeater-table td { padding: 0 .3rem; vertical-align: top; }
.repeater-table td:first-child { padding-left: 0; }

/* The people tables are six columns wide and scroll sideways on a laptop.
   Pinning the remove button keeps it reachable without scrolling back. */
.repeater-tools {
    width: 38px;
    text-align: right;
    vertical-align: middle;
    position: sticky;
    right: 0;
    background: #fff;
}
.repeater-tools .icon-btn { width: 32px; height: 32px; color: var(--muted); }
.repeater-tools .icon-btn svg { width: 16px; height: 16px; }
.repeater-tools .icon-btn:hover { color: var(--danger); background: #fdecec; }

.input-sm, .select-sm {
    padding: .48rem .6rem;
    font-size: .84rem;
    border-radius: 8px;
    width: 100%;
    min-width: 6.4rem;
}
/* A date box has its own picker glyph and clips below this. */
.input-sm[type="date"] { min-width: 8.2rem; }
.select-sm { padding-right: 1.9rem; background-position: right .55rem center; }

/* ---- Attached documents --------------------------------------------- */

.doc-slot {
    border: 1px dashed var(--line);
    border-radius: 11px;
    padding: .85rem 1rem;
    margin-bottom: 1.05rem;
    background: #fdfdff;
}
.doc-slot-head .field-label { display: block; margin-bottom: 0; }
.doc-slot-head .field-hint { margin-top: .15rem; }

.doc-list { list-style: none; margin: .6rem 0 0; padding: 0; }

.doc-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .38rem .55rem;
    border-radius: 8px;
    background: var(--brand-50);
    font-size: .84rem;
    margin-bottom: .3rem;
}
.doc-item svg { width: 15px; height: 15px; color: var(--brand); flex: none; }
.doc-item a { color: var(--ink); font-weight: 500; text-decoration: none; word-break: break-word; }
.doc-item a:hover { color: var(--brand); text-decoration: underline; }
.doc-size { color: var(--muted); font-size: .76rem; margin-left: auto; flex: none; }
.doc-item .icon-btn { width: 28px; height: 28px; flex: none; color: var(--muted); }
.doc-item .icon-btn svg { width: 14px; height: 14px; }
.doc-item .icon-btn:hover { color: var(--danger); background: #fdecec; }

.doc-empty { color: var(--muted); font-size: .8rem; padding: .15rem 0 .1rem; }

.doc-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.doc-actions .btn { cursor: pointer; }
.doc-status { font-size: .78rem; color: var(--muted); }
.doc-status.is-error { color: var(--danger); }
.doc-status.is-ok { color: #17a96a; }
.doc-warning {
    display: flex;
    align-items: flex-start;
    gap: .4rem;
    margin: .5rem 0 0;
    padding: .4rem .6rem;
    border-radius: 8px;
    background: #fff5eb;
    border: 1px solid #ffe0bf;
    color: #a4570f;
    font-size: .78rem;
}
.doc-warning svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.doc-expiry { color: #a4570f; font-size: .76rem; font-weight: 500; flex: none; }
.doc-expiry.is-expired { color: var(--danger); }
.doc-item a.doc-view { color: var(--muted); }
.doc-item a.doc-view:hover { color: var(--brand); background: var(--brand-50); text-decoration: none; }
.doc-expiry-field {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    flex: none;
    font-size: .8rem;
    font-weight: 500;
    color: var(--ink-soft);
}
/* The label keeps to one line; the date box sizes to its content. */
.doc-expiry-field > span { white-space: nowrap; }
.doc-expiry-field .input-sm { width: auto; }
.doc-warning span { min-width: 0; overflow-wrap: anywhere; }
.doc-slot .doc-warning { width: fit-content; max-width: 100%; }

/* ---- Section 12 checklist ------------------------------------------- */

.doc-checklist { list-style: none; margin: 0; padding: 0; }

.doc-check {
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    padding: .9rem 1rem;
    margin-bottom: .7rem;
    transition: border-color .13s, background-color .13s;
}
.doc-check:has(.doc-check-tick input:checked) {
    border-color: var(--brand-100);
    background: #fffafb;
}

.doc-check-tick {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    font-size: .875rem;
    line-height: 1.5;
    color: var(--ink);
    cursor: pointer;
}
.doc-check-tick input {
    accent-color: var(--brand);
    width: 17px;
    height: 17px;
    flex: none;
    margin: .1rem 0 0;
}

.doc-note {
    display: inline-block;
    margin-left: .35rem;
    font-size: .74rem;
    font-style: normal;
    color: var(--muted);
    background: var(--line-soft);
    border-radius: 5px;
    padding: .05rem .38rem;
}

.doc-check .doc-slot {
    border: 0;
    background: none;
    padding: .45rem 0 0 2.2rem;
    margin: 0;
}
.doc-check .doc-slot-head { display: none; }
.doc-check.has-error { border-color: var(--danger); }
.doc-check-error { padding-left: 2.2rem; }
@media (max-width: 640px) { .doc-check-error { padding-left: 0; } }
.doc-check .doc-formats { display: none; }
.doc-check .doc-list:not(:has(.doc-item)) { display: none; }

/* ---- Declaration notices -------------------------------------------- */

.notice {
    border-left: 3px solid var(--brand);
    background: var(--brand-50);
    border-radius: 0 10px 10px 0;
    padding: .85rem 1.05rem;
    margin: 0 0 .85rem;
}
.notice h4 {
    margin: 0 0 .3rem;
    font-size: .82rem;
    font-weight: 700;
    color: var(--brand-800);
}
.notice p { margin: 0; font-size: .84rem; line-height: 1.6; color: var(--ink-soft); }

/* A section Selcom sent back: no tick, and it says why at a glance. */
.stepper-item.needs-changes .stepper-dot {
    background: #fdecec;
    color: var(--danger);
}
.stepper-item.needs-changes .stepper-sub { color: var(--danger); font-weight: 600; }
.stepper-item.needs-changes.is-current .stepper-dot { background: var(--danger); color: #fff; }

/* Picking the sections to send back. */
.step-picker { list-style: none; margin: 0; padding: 0; }
.step-picker li + li { margin-top: .12rem; }
.step-picker label {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .3rem .45rem;
    border-radius: 7px;
    font-size: .83rem;
    color: var(--ink-soft);
    cursor: pointer;
}
.step-picker label:hover { background: var(--line-soft); }
.step-picker input {
    accent-color: var(--brand);
    width: 15px;
    height: 15px;
    flex: none;
    margin: 0;
}
.step-picker label:has(input:checked) { background: var(--brand-50); color: var(--brand-800); font-weight: 600; }


/* A tracking field the current role may look at but not change. */
.static-value { margin: 0; font-size: .88rem; color: var(--ink); }


/* The back-office reviewer's tick, in each section header. */
.review-tick {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin-left: auto;
    padding: .28rem .6rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: .76rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    cursor: pointer;
    transition: border-color .13s, background-color .13s, color .13s;
}
.review-tick:hover { border-color: var(--brand); color: var(--brand-700); }
.review-tick input { accent-color: #17a96a; width: 15px; height: 15px; margin: 0; flex: none; }
.review-tick:has(input:checked) { border-color: #c7efd9; background: #e9f9f0; color: #14794a; }

.review-tick.is-done {
    border-color: #c7efd9;
    background: #e9f9f0;
    color: #14794a;
    cursor: default;
}
.review-tick.is-done svg { width: 14px; height: 14px; }

/* The collapse chevron is appended after it, so it no longer needs the push. */
.card-head .review-tick ~ .card-toggle { margin-left: .35rem; }


/* Role badges on the users list. */
.badge-role-admin      { background: #eef1ff; color: #4b5bd6; }
.badge-role-backoffice { background: #fff4e6; color: #c9791a; }
.badge-role-partner    { background: var(--brand-50); color: var(--brand-700); }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
    margin-top: 1.4rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--line-soft);
}
.check-card--wide:has(input:disabled) { opacity: .5; cursor: not-allowed; }


/* ---- Collapsible section cards ---------------------------------------
   Long review pages and long form steps fold away section by section.
   Everything starts open, so the page still reads top to bottom with
   JavaScript switched off; the script is what adds the toggle at all. */

.card-head.is-toggle { cursor: pointer; user-select: none; }

.card-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: none;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background-color .13s, color .13s;
}
.card-toggle:hover { background: var(--line-soft); color: var(--brand); }
.card-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform .18s ease;
}
/* Open: the chevron points up. Closed: it points down, inviting a click. */
.card-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

.card.is-collapsed > *:not(.card-head) { display: none; }
.card.is-collapsed .card-head { border-bottom: 0; }

.cards-toggle-all { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
    .card-toggle svg { transition: none; }
}


/* ---- Review screen --------------------------------------------------- */

.detail-grid .item-wide { grid-column: 1 / -1; }

.answer-table { margin-top: 1.2rem; }
.answer-table:first-child { margin-top: 0; }
.answer-table .table { font-size: .84rem; }

.doc-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin: 0 .7rem .25rem 0;
    color: var(--ink);
    font-weight: 500;
    text-decoration: none;
    word-break: break-word;
}
.doc-link svg { width: 14px; height: 14px; color: var(--brand); flex: none; }
.doc-link:hover { color: var(--brand); text-decoration: underline; }

@media (max-width: 640px) {
    .field-yesno { flex-direction: column; gap: .55rem; }
    .yn-group { width: 100%; }
    .yn { flex: 1 1 0; justify-content: center; }

    .repeater-table, .repeater-table tbody, .repeater-table tr, .repeater-table td { display: block; width: 100%; }
    .repeater-table thead { display: none; }
    .repeater-table tr {
        border: 1px solid var(--line-soft);
        border-radius: 11px;
        padding: .7rem .8rem;
        margin-bottom: .6rem;
    }
    .repeater-table td { padding: 0 0 .55rem; }
    .repeater-table td::before {
        content: attr(data-label);
        display: block;
        font-size: .7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--muted);
        margin-bottom: .2rem;
    }
    .repeater-table .repeater-tools { text-align: left; padding-bottom: 0; }
    .repeater-table .repeater-tools::before { content: none; }
    .input-sm, .select-sm { min-width: 0; }

    .doc-check .doc-slot { padding-left: 0; }

    /* Expiry date takes its own row, the file buttons share the next. */
    .doc-expiry-field { flex: 1 1 100%; }
    .doc-expiry-field .input-sm { flex: 1; min-width: 0; }
    .doc-actions .btn { flex: 1 1 auto; justify-content: center; }
    .doc-status { flex-basis: 100%; }
}

/* ---- Document expiry (partners table + pop-up) ---------------------- */

.expiry-cell {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    padding: .35rem .5rem;
    margin: -.35rem -.5rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}
.expiry-cell:hover,
.expiry-cell:focus-visible { border-color: var(--line); background: var(--line-soft); outline: none; }
.expiry-cell .cell-stack { align-items: flex-start; }
.expiry-cell-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: var(--ink-soft);
    flex: none;
}
.expiry-cell-icon svg { width: 17px; height: 17px; }
.expiry-cell:hover .expiry-cell-icon { color: var(--brand); background: var(--surface); }

.dialog {
    width: min(680px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    padding: 0;
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    color: var(--ink);
    background: var(--surface);
}
.dialog[open] { display: flex; flex-direction: column; }
.dialog::backdrop { background: rgba(47, 43, 58, .45); }
.dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem .9rem;
    border-bottom: 1px solid var(--line-soft);
}
.dialog-head h3 { margin: 0; font-size: 1.05rem; }
.dialog-head p { margin: .15rem 0 0; color: var(--muted); font-size: .82rem; }
.dialog-foot {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: .85rem 1.25rem;
    border-top: 1px solid var(--line-soft);
}

.expiry-list { list-style: none; margin: 0; padding: .6rem 1.25rem 1rem; overflow-y: auto; }
.expiry-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: .75rem;
    padding: .7rem .1rem;
    border-bottom: 1px solid var(--line-soft);
}
.expiry-item:last-child { border-bottom: none; }
.expiry-item-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--brand-50);
    color: var(--brand);
}
.expiry-item-icon svg { width: 18px; height: 18px; }
.expiry-item.is-expired .expiry-item-icon { background: #fdecec; color: var(--danger); }
.expiry-item.is-soon .expiry-item-icon { background: #fff4e6; color: #c9791a; }
.expiry-item.is-empty .expiry-item-icon { background: var(--line-soft); color: var(--muted); }
.expiry-item-main { display: flex; flex-direction: column; min-width: 0; }
.expiry-item-label { font-weight: 600; font-size: .88rem; }
.expiry-item-file { color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expiry-item-date { display: flex; flex-direction: column; align-items: flex-end; font-size: .84rem; white-space: nowrap; }
.expiry-item-date span { color: var(--muted); font-size: .74rem; }
.expiry-item.is-expired .expiry-item-date strong { color: var(--danger); }
.expiry-item.is-empty { grid-template-columns: auto minmax(0, 1fr); }

@media (max-width: 640px) {
    .expiry-item { grid-template-columns: auto minmax(0, 1fr); row-gap: .45rem; }
    .expiry-item-date { grid-column: 2; flex-direction: row; gap: .4rem; align-items: baseline; }
    .expiry-item .badge,
    .expiry-item .btn { grid-column: 2; justify-self: start; }
    .dialog-foot { flex-direction: column-reverse; }
    .dialog-foot .btn { width: 100%; justify-content: center; }
}


/* ---- Settings: expiry documents grouped by wizard step ---------------- */

.slot-group { border: 0; padding: 0; margin: 0 0 1.1rem; min-width: 0; }
.slot-group + .slot-group { padding-top: 1.1rem; border-top: 1px solid var(--line-soft); }
.slot-group-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 0;
    margin: 0 0 .6rem;
    font-size: .86rem;
    font-weight: 600;
    color: var(--ink-soft);
}
.slot-group-step {
    padding: .12rem .45rem;
    border-radius: 6px;
    background: var(--brand-50);
    color: var(--brand-700);
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Settings: deadline and scheduler cards side by side under the expiry card. */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
    gap: 1.35rem;
    align-items: start;
}
.settings-grid > .card { margin-bottom: 0; }

/* ---------------------------------------------------------------------------
   Sign-in extras: "Forgot password?" and back links
   --------------------------------------------------------------------------- */
.auth-forgot { margin: .5rem 0 0; text-align: right; font-size: .82rem; }
.auth-forgot a,
.auth-alt a { font-weight: 600; color: var(--brand-700); text-decoration: none; }
.auth-forgot a:hover,
.auth-alt a:hover { text-decoration: underline; }
.auth-alt { margin: 1.1rem 0 0; text-align: center; font-size: .86rem; }

/* ---------------------------------------------------------------------------
   Session guard: idle warning bar and the one-tab-at-a-time cover
   --------------------------------------------------------------------------- */
.session-warning {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: calc(100% - 2rem);
    padding: .85rem 1rem .85rem 1.2rem;
    background: var(--ink);
    color: #fff;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: .9rem;
}
.session-warning[hidden] { display: none; }
.session-warning .btn { flex: none; }

.tab-lock {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: rgba(47, 43, 58, .72);
    backdrop-filter: blur(4px);
}
.tab-lock-card {
    max-width: 440px;
    padding: 1.75rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.tab-lock-card h2 { margin: 0 0 .6rem; font-size: 1.15rem; color: var(--ink); }
.tab-lock-card p { margin: 0 0 1.25rem; color: var(--ink-soft); line-height: 1.55; }
