/* ==========================================================================
   Admin panel stylesheet - light staff dashboard of the NPI exam portal:
   white sticky top bar, slate-100 canvas, white rounded-2xl panels, teal
   actions, rose logout. Builds on the tokens defined in app.css.
   ========================================================================== */

.admin-body {
    background: var(--bg);
    color: var(--ink);
}

/* ---------------------------------------------------------------- top bar */

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 68px;
    padding: .6rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.admin-topbar__toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 42px;
    height: 42px;
    padding: 0 10px;
    background: var(--line-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.admin-topbar__toggle span {
    display: block;
    height: 2px;
    background: var(--label);
    border-radius: 2px;
}

.admin-topbar__brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-width: 0;
    flex: 1 1 auto;
    color: var(--heading);
    text-decoration: none;
}

.admin-topbar__brand:hover { color: var(--heading); }

.admin-topbar__logo { width: 38px; height: 38px; object-fit: contain; }
.admin-topbar__mark { font-size: 1.6rem; line-height: 1; }
.admin-topbar__text { min-width: 0; }
.admin-topbar__bn {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-topbar__en {
    display: block;
    font-size: .75rem;
    line-height: 1.3;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-topbar__user {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.admin-topbar__user form { margin: 0; }

/* chips, as used for the user badge on the portal's HoD dashboard */
.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .35rem .75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--line-soft);
    color: var(--body);
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
}

.chip--teal { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-700); }
.chip--indigo { background: var(--indigo-bg); border-color: var(--indigo-line); color: #4338ca; }

.badge-role {
    display: inline-block;
    padding: .15rem .55rem;
    border: 1px solid var(--indigo-line);
    border-radius: var(--radius-sm);
    background: var(--indigo-bg);
    color: #4338ca;
    font-size: .76rem;
    font-weight: 700;
    white-space: nowrap;
}

/* -------------------------------------------------------------- side bar */

.admin-shell {
    display: flex;
    align-items: flex-start;
    flex: 1 0 auto;
}

.admin-sidebar {
    position: sticky;
    top: 68px;
    width: 248px;
    flex: 0 0 248px;
    height: calc(100vh - 68px);
    overflow-y: auto;
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 1rem .75rem;
}

.admin-sidebar__label {
    margin: .25rem .75rem .5rem;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--faint);
}

.admin-sidebar__link {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .6rem .8rem;
    margin-bottom: .2rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--label);
    font: inherit;
    font-size: .92rem;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.admin-sidebar__link:hover { background: var(--line-soft); color: var(--ink); }

/* Active entry = the portal's selected tab pill */
.admin-sidebar__link.is-active {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.admin-sidebar__icon { width: 1.4em; text-align: center; flex: 0 0 auto; }

/* Icon holders collapse when the "show emoji" setting removes their emoji */
.admin-sidebar__icon:empty,
.admin-topbar__mark:empty,
.status-banner__icon:empty { display: none; }

.admin-sidebar__link--danger { color: var(--red); }
.admin-sidebar__link--danger:hover { background: var(--red-bg); color: var(--red); }
.admin-sidebar__logout { margin-top: .75rem; border-top: 1px solid var(--line-soft); padding-top: .75rem; }
.admin-sidebar__logout form { margin: 0; }

.admin-content {
    flex: 1 1 auto;
    min-width: 0;
    padding: 1.5rem;
}

.admin-content > .alert { margin-bottom: 1rem; }

.admin-footer {
    background: #fff;
    border-top: 1px solid var(--line);
    padding: 1rem;
    text-align: center;
    font-size: .78rem;
    font-weight: 500;
    color: var(--faint);
}

@media (max-width: 1023.98px) {
    .admin-topbar__toggle { display: inline-flex; }
    .admin-sidebar {
        position: fixed;
        top: 68px;
        left: 0;
        bottom: 0;
        height: auto;
        z-index: 35;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 4px 0 18px rgb(15 23 42 / .15);
    }
    .admin-sidebar.is-open { transform: translateX(0); }
    .admin-content { padding: 1rem .75rem; }
}

@media (max-width: 767.98px) {
    .admin-topbar { padding: .55rem .75rem; }
    .admin-topbar__en,
    .admin-topbar__user { display: none; }
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgb(15 23 42 / .45);
    z-index: 30;
}

.sidebar-backdrop[hidden] { display: none; }

/* ------------------------------------------------------- panels and pages */

.admin-content .card {
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* Panel headings: white with a hairline, bold slate-900 title */
.admin-content .card__head {
    background: #fff;
    color: var(--heading);
    border-bottom: 1px solid var(--line-soft);
    padding: 1rem 1.25rem;
}

.admin-content .card__head .text-muted-2,
.admin-content .card__head .small { color: var(--muted); }

.admin-content .card__title { font-size: 1rem; color: var(--heading); }

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.page-title { margin: 0; font-size: 1.4rem; color: var(--heading); }
.page-sub { margin: .2rem 0 0; font-size: .86rem; color: var(--muted); }

.page-head__actions {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}

.switch-label {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .84rem;
    font-weight: 600;
    color: var(--label);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: .4rem .8rem;
    cursor: pointer;
}

.switch-label input { accent-color: var(--brand-600); }

/* ------------------------------------------------------------------- stats */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
    .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
    .stat-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

/* KPI tile: small uppercase label over a large mono number */
.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-top: 3px solid var(--brand-600);
    border-radius: var(--radius);
    padding: .9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    box-shadow: var(--shadow-sm);
}

.stat-card__label {
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--faint);
}

.stat-card__value {
    font-family: var(--mono);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--brand-700);
    line-height: 1.2;
}

.stat--gold { border-top-color: #6366f1; }
.stat--gold .stat-card__value { color: var(--indigo); }
.stat--green { border-top-color: var(--accent-600); }
.stat--green .stat-card__value { color: var(--accent-600); }
.stat--amber { border-top-color: #f59e0b; }
.stat--amber .stat-card__value { color: #d97706; }
.stat--red { border-top-color: #f43f5e; }
.stat--red .stat-card__value { color: var(--red); }

.split {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

.split > .card { margin-bottom: 0; }

@media (min-width: 1100px) {
    .split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.progress-row {
    display: grid;
    grid-template-columns: 96px 1fr 44px;
    align-items: center;
    gap: .6rem;
    font-size: .86rem;
    margin-bottom: .5rem;
}

.progress-row__label { color: var(--label); font-weight: 600; }

.progress-row__track {
    height: 10px;
    background: var(--line-soft);
    border-radius: 999px;
    overflow: hidden;
}

.progress-row__bar {
    display: block;
    height: 100%;
    background: var(--brand-600);
    border-radius: 999px;
    transition: width .4s ease;
}

.progress-row__bar.badge-submitted { background: #6366f1; border: 0; }
.progress-row__bar.badge-verified { background: #f59e0b; border: 0; }
.progress-row__bar.badge-admitted { background: var(--accent-600); border: 0; }
.progress-row__bar.badge-rejected { background: #f43f5e; border: 0; }

.progress-row__value { text-align: right; font-family: var(--mono); font-weight: 700; color: var(--ink); }

.mini-bar {
    display: block;
    height: 8px;
    background: var(--line-soft);
    border-radius: 999px;
    overflow: hidden;
}

.mini-bar span {
    display: block;
    height: 100%;
    background: var(--brand-600);
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: .45rem;
    height: 180px;
    padding-top: 1.2rem;
}

.bar-chart__item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
}

.bar-chart__value { font-family: var(--mono); font-size: .74rem; font-weight: 700; color: var(--muted); }

.bar-chart__bar {
    width: 100%;
    max-width: 36px;
    background: linear-gradient(180deg, var(--brand-500), var(--accent-600));
    border-radius: 6px 6px 0 0;
    min-height: 3px;
}

.bar-chart__label { font-size: .7rem; color: var(--faint); margin-top: .25rem; }

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

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: .88rem;
}

table.table th,
table.table td {
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--line-soft);
    text-align: left;
    vertical-align: middle;
}

table.table th {
    background: #fff;
    color: var(--faint);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 1;
}

table.table tbody tr { transition: background .1s ease; }
table.table tbody tr:hover { background: rgb(236 253 245 / .5); }   /* emerald-50/50 */
table.table tbody tr.is-deleted { background: var(--red-bg); color: var(--muted); }
table.table .text-end { text-align: right; }
table.table .col-check { width: 34px; text-align: center; }

/* Application IDs read like the portal's roll numbers: bold indigo mono */
table a[href*="application.php?id="] {
    font-family: var(--mono);
    font-weight: 700;
    color: var(--indigo);
    white-space: nowrap;
    text-decoration: none;
}

table a[href*="application.php?id="]:hover { text-decoration: underline; }
table.table .col-actions { width: 1%; white-space: nowrap; }

table.table-sm { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.table-sm th,
table.table-sm td { padding: .5rem .6rem; border-bottom: 1px solid var(--line-soft); text-align: left; }
table.table-sm th {
    color: var(--faint);
    font-size: .74rem;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}
table.table-sm td.text-end, table.table-sm th.text-end { text-align: right; }
table.table-sm td.text-center, table.table-sm th.text-center { text-align: center; }
.table-hover tbody tr:hover { background: rgb(236 253 245 / .5); }

.table-scroll {
    max-height: 70vh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

input[type="checkbox"].row-check {
    width: 18px;
    height: 18px;
    accent-color: var(--brand-600);
}

/* ------------------------------------------------------------------ filters */

.filter-bar {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
}

@media (min-width: 768px) {
    .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
    .filter-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.filter-bar .form-control { min-height: 40px; font-size: .9rem; border-radius: var(--radius-sm); }
.filter-bar .field__label { font-size: .8rem; }
.filter-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; }

/* -------------------------------------------------------------- pagination */

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin-top: 1rem;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 .6rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--label);
    font-size: .86rem;
    font-weight: 600;
    text-decoration: none;
}

.pagination a:hover { background: var(--line-soft); }

.pagination .is-current {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
    font-weight: 700;
}

.pagination .is-disabled { opacity: .45; pointer-events: none; }

/* --------------------------------------------- login (portal login page) */

.admin-body--login { background: var(--surface-2); }

.login-main {
    flex: 1 0 auto;
    width: 100%;
    max-width: 448px;   /* max-w-md */
    margin: 0 auto;
    padding: 3rem 1rem;
}

.login-card {
    background: #fff;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
}

.login-card__head {
    padding: 1.5rem;
    text-align: center;
    background: var(--grad-card);
    color: #fff;
}

.login-logo {
    max-height: 56px;
    margin: 0 auto .6rem;
    background: #fff;
    border-radius: var(--radius-md);
    padding: 4px;
}

.login-card__title { margin: 0; font-size: 1.25rem; font-weight: 700; color: #fff; }
.login-card__sub { margin: .25rem 0 0; font-size: .78rem; color: var(--brand-100); }
.login-card__body { padding: 1.5rem; }
.login-card__body .form-control { font-family: var(--mono); }
.login-card__foot {
    padding: .75rem 1.5rem;
    background: var(--surface-2);
    border-top: 1px solid var(--line-soft);
    text-align: center;
    font-size: .8rem;
    color: var(--faint);
}

/* ------------------------------------------------------------- misc admin */

.kv-admin {
    display: grid;
    grid-template-columns: minmax(140px, 34%) 1fr;
    gap: .35rem .8rem;
    font-size: .92rem;
}

.kv-admin dt { color: var(--muted); font-weight: 600; }
.kv-admin dd { margin: 0; word-break: break-word; color: var(--ink); }

.section-title-admin {
    padding: .6rem .9rem;
    background: var(--brand-50);
    color: var(--brand-800);
    border: 1px solid var(--brand-100);
    border-bottom: 0;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-weight: 700;
    font-size: .95rem;
}

.section-body-admin {
    border: 1px solid var(--line);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    padding: .85rem .9rem;
    background: #fff;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 1100px) {
    .profile-grid { grid-template-columns: 270px 1fr; align-items: start; }
}

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

.doc-check-list li {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .2rem;
    border-bottom: 1px solid var(--line-soft);
}

.doc-check-list li:last-child { border-bottom: 0; }
.doc-check-list input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent-600); }

.timeline { list-style: none; margin: 0; padding: 0; font-size: .86rem; }
.timeline li { padding: .45rem 0; border-bottom: 1px solid var(--line-soft); }
.timeline li:last-child { border-bottom: 0; }

.toast-stack {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.toast {
    background: var(--ink);
    color: #fff;
    padding: .7rem 1rem;
    border-radius: var(--radius-md);
    font-size: .86rem;
    font-weight: 600;
    box-shadow: var(--shadow-xl);
    max-width: 340px;
}

.toast--error { background: var(--red); }
.toast--success { background: var(--accent-600); }

/* Modal dialogs: the views give them an inline display:flex overlay */
.modal > div,
.modal > .card {
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
}

/* Modals carry an inline display:flex; keep the hidden attribute authoritative */
.modal[hidden] { display: none !important; }

/* ----------------------------------------------------------- export page */

.export-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .export-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
    .export-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.export-grid .export-card { margin-bottom: 0; }
.export-card .card__body { display: flex; flex-direction: column; height: 100%; }
.export-card__title { margin: 0 0 .4rem; font-size: 1.05rem; color: var(--heading); }
.export-card__text { flex: 1 1 auto; font-size: .9rem; color: var(--muted); }

/* --------------------------------------------------------- settings page */

.settings-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.25rem;
}

.settings-nav a {
    padding: .45rem .9rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    color: var(--label);
    font-size: .88rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.settings-nav a:hover { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-800); }

.status-banner {
    display: flex;
    align-items: flex-start;
    gap: .9rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    border: 1px solid;
    border-radius: var(--radius);
}

.status-banner__icon { font-size: 1.75rem; line-height: 1.1; }
.status-banner__title { margin: 0; font-size: 1.05rem; font-weight: 700; }
.status-banner__text { margin: .2rem 0 0; font-size: .9rem; }
.status-banner--open { background: var(--green-bg); border-color: var(--green-line); color: #065f46; }
.status-banner--waiting { background: var(--amber-bg); border-color: var(--amber-line); color: #92400e; }
.status-banner--closed { background: var(--red-bg); border-color: var(--red-line); color: #9f1239; }

.settings-section { scroll-margin-top: 84px; }
.settings-section__intro { margin: .2rem 0 0; font-size: .86rem; font-weight: 400; color: var(--muted); }

.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.4rem 1.75rem;
}

@media (min-width: 900px) {
    .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .settings-grid .is-wide { grid-column: 1 / -1; }
}

.setting { min-width: 0; }
.setting .optional { font-weight: 400; font-size: .78rem; color: var(--faint); }
.setting__help { display: block; margin-top: .4rem; font-size: .82rem; line-height: 1.6; color: var(--muted); }
.setting__warning { display: block; margin-top: .4rem; font-size: .84rem; font-weight: 600; color: #92400e; }

.setting__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .4rem .75rem;
    margin-top: .45rem;
}

.setting__where {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .12rem .6rem;
    background: var(--brand-50);
    border: 1px solid var(--brand-100);
    border-radius: 999px;
    font-size: .76rem;
    color: var(--brand-800);
}

.setting__actions { display: inline-flex; align-items: center; gap: .75rem; margin-left: auto; }
.char-count { font-family: var(--mono); font-size: .75rem; color: var(--faint); }

.setting--warning {
    padding: 1rem;
    background: var(--amber-bg);
    border: 1px dashed #f59e0b;
    border-radius: var(--radius-md);
}

.link-btn {
    padding: 0;
    background: none;
    border: 0;
    color: var(--brand-700);
    font: inherit;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
}

.link-btn:hover { text-decoration: underline; }

.date-row { display: flex; gap: .5rem; align-items: stretch; }
.date-row .form-control { flex: 1 1 auto; }
.date-row .btn { flex: 0 0 auto; min-height: 48px; }

/* On/off switch */
.toggle {
    position: relative;
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .9rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.toggle input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; }

.toggle__track {
    position: relative;
    flex: 0 0 auto;
    width: 58px;
    height: 32px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background .2s ease;
}

.toggle__track::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease;
}

.toggle input:checked + .toggle__track { background: var(--accent-600); }
.toggle input:checked + .toggle__track::after { transform: translateX(26px); }
.toggle input:focus-visible + .toggle__track { box-shadow: 0 0 0 3px rgb(20 184 166 / .35); }
.toggle__text { font-weight: 700; font-size: .98rem; }
.toggle__on { display: none; color: var(--accent-700); }
.toggle__off { color: var(--red); }
.toggle input:checked ~ .toggle__text .toggle__on { display: inline; }
.toggle input:checked ~ .toggle__text .toggle__off { display: none; }

/* Admission form: required / optional field switches */
.field-rules__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .75rem;
}

.field-rules__bulk { display: inline-flex; flex-wrap: wrap; gap: .5rem; }

.field-rules {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 900px) {
    .field-rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.field-rules__step {
    min-width: 0;
    margin: 0;
    padding: .5rem 1rem .6rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.field-rules__step legend { padding: 0 .35rem; font-size: .9rem; font-weight: 700; color: var(--ink); }

.field-rule {
    position: relative;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem 0;
    border-bottom: 1px dashed var(--line);
    cursor: pointer;
}

.field-rule:last-child { border-bottom: 0; }
.field-rule input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; }

.field-rule__switch {
    position: relative;
    flex: 0 0 auto;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background .2s ease;
}

.field-rule__switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease;
}

.field-rule input:checked + .field-rule__switch { background: var(--accent-600); }
.field-rule input:checked + .field-rule__switch::after { transform: translateX(18px); }
.field-rule input:focus-visible + .field-rule__switch { box-shadow: 0 0 0 3px rgb(20 184 166 / .35); }
.field-rule__name { flex: 1 1 auto; min-width: 0; font-size: .92rem; }
.field-rule__state { flex: 0 0 auto; font-size: .78rem; font-weight: 600; }
.field-rule__on { display: none; color: var(--accent-700); }
.field-rule__off { color: var(--muted); }
.field-rule input:checked ~ .field-rule__state .field-rule__on { display: inline; }
.field-rule input:checked ~ .field-rule__state .field-rule__off { display: none; }
.field-rule.is-locked { cursor: default; }
.field-rule.is-locked .field-rule__switch { opacity: .5; }
.field-rule__lock { color: var(--faint); font-weight: 500; }

/* Logo */
.logo-field { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1rem; }
.logo-field__controls { flex: 1 1 260px; min-width: 0; }

.logo-preview {
    width: 104px;
    height: 104px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: #fff;
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    overflow: hidden;
    font-size: .75rem;
    color: var(--faint);
    text-align: center;
}

.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Save bar stays in view while scrolling the long form */
.save-bar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin: 0 -1.5rem -1.5rem;
    padding: .85rem 1.5rem;
    background: rgb(255 255 255 / .97);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 14px rgb(15 23 42 / .07);
}

.save-bar__state { font-size: .9rem; font-weight: 600; color: var(--muted); }
.save-bar.is-dirty { background: #fffbeb; }
.save-bar.is-dirty .save-bar__state { color: #b45309; }

@media (max-width: 1023.98px) {
    .save-bar { margin: 0 -.75rem -1rem; padding: .75rem; }
    .save-bar .btn-row { width: 100%; }
    .save-bar .btn { flex: 1 1 auto; }
}

@media print {
    .admin-topbar,
    .admin-sidebar,
    .admin-footer,
    .no-print,
    .sidebar-backdrop { display: none !important; }
    .admin-content { padding: 0; }
    body, .admin-body { background: #fff; }
    .card, .stat-card { box-shadow: none; }
    table.table th { position: static; }
}
