/* Shared admin layout.  Kept as a small separately served stylesheet so the
   admin screens stay correct even when the optional Tailwind CLI is not
   installed on a development machine. */
.admin-shell {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem;
}

.admin-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.admin-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    min-width: 0;
    flex: 1 1 auto;
}

.admin-heading-copy {
    min-width: 0;
}

.admin-title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.admin-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.admin-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.admin-nav-link,
.admin-context-link {
    display: inline-flex;
    align-items: center;
    min-height: 2.25rem;
    padding: 0.35rem 0.6rem;
    border-radius: 0.375rem;
    color: #475467;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.admin-nav-link:hover,
.admin-context-link:hover {
    background: #f1f5f9;
    color: #1d4ed8;
}

.admin-nav-link.is-active {
    background: #dbeafe;
    color: #1e40af;
}

.admin-account {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.admin-logout-form {
    display: inline;
    margin: 0;
}

.admin-detail-meta {
    margin: 0.25rem 0 0;
    color: #667085;
    font-size: 0.875rem;
}

.admin-header-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.375rem;
}

.admin-detail-card {
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #fff;
}

.admin-shell .alert {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
}

.admin-shell .alert-success {
    border: 1px solid #bbf7d0;
    background: #dcfce7;
    color: #166534;
}

.admin-shell .alert-error {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.admin-name {
    font-size: 0.875rem;
    color: #6b7280;
}

.admin-section {
    margin-bottom: 2rem;
}

.admin-section .section-heading {
    margin-bottom: 0.75rem;
}

.admin-section .section-heading > div {
    min-width: 0;
}

/* The legacy dashboard selector targeted every span in a heading.  Keep the
   dashboard count style limited to its direct child and explicitly reset the
   detail-page badges. */
.section-heading > span {
    min-width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #e5e7eb;
    font-weight: 800;
}

/* Not every direct heading span is a dashboard count. */
.admin-shell .section-heading > .section-hint {
    min-width: 0;
    height: auto;
    display: inline-block;
    place-items: initial;
    border-radius: 0;
    background: transparent;
    font-weight: 400;
}

.admin-shell .section-heading > .status-pill {
    min-width: 0;
    height: auto;
    display: inline-flex;
    place-items: initial;
    border-radius: 999px;
    font-weight: 600;
}

.admin-shell .section-heading .count-badge {
    display: inline-block;
    min-width: 0;
    width: auto;
    height: auto;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: #eef2f6;
    color: #475467;
    font-size: 0.8rem;
    font-weight: 400;
    vertical-align: middle;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

/* The foreman editor has several controls in one row.  Keep its columns
   inside the admin shell instead of letting intrinsic input/button widths
   create a horizontal scrollbar. */
.foremen-table {
    table-layout: fixed;
}

.foremen-table th:nth-child(1) { width: 17%; }
.foremen-table th:nth-child(2) { width: 16%; }
.foremen-table th:nth-child(3) { width: 23%; }
.foremen-table th:nth-child(4) { width: 14%; }
.foremen-table th:nth-child(5) { width: 30%; }

.foremen-table td,
.foremen-table .table-actions,
.foremen-table .table-actions > form,
.foremen-table .send-code-form {
    min-width: 0;
}

.foremen-table .cell-input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.foremen-table .send-code-form {
    display: flex;
    flex: 1 1 10rem;
}

.foremen-table .send-code-form select {
    min-width: 0;
    max-width: 100%;
    flex: 1 1 6rem;
}

.admin-table th,
.admin-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    background: #f8fafc;
    color: #667085;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

.admin-table-wrap {
    max-width: 100%;
    overflow-x: auto;
}

/* ── Unified control scale ─────────────────────────────────────────────
   Every button-like control in the admin shell shares one geometry;
   variants differ only in color. Two sizes: standard and .btn-small
   (dense in-row controls). Pages must not redefine sizing — the old
   per-template button rules were removed when this was introduced. */
.admin-shell .btn-primary,
.admin-shell .btn-secondary,
.admin-shell .btn-secondary-outline,
.admin-shell .btn-danger,
.admin-shell .btn-danger-outline,
.admin-shell .compact-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    height: 34px;
    min-height: 34px;
    padding: 0 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.admin-shell .btn-small {
    height: 26px;
    min-height: 26px;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
}
.admin-shell .btn-primary { background: #1d4ed8; color: #fff; }
.admin-shell .btn-primary:hover { background: #1e40af; }
.admin-shell .btn-secondary,
.admin-shell .btn-secondary-outline,
.admin-shell .compact-button {
    background: #fff;
    color: #374151;
    border-color: #d1d5db;
}
.admin-shell .btn-secondary:hover,
.admin-shell .btn-secondary-outline:hover,
.admin-shell .compact-button:hover {
    background: #f9fafb;
}
.admin-shell .btn-danger { background: #dc2626; color: #fff; }
.admin-shell .btn-danger:hover { background: #b91c1c; }
.admin-shell .btn-danger-outline { background: #fff; color: #b91c1c; border-color: #fca5a5; }
.admin-shell .btn-danger-outline:hover { background: #fef2f2; }

/* Top bar: context link, nav, and account share one baseline. */
.admin-top-bar .admin-header-actions {
    align-items: center;
}

/* Wide data pages use the same 1200px column as the catalog. */
.admin-shell.package-detail {
    max-width: 1200px;
}

.admin-success-banner,
.admin-error-banner {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin: 1rem 0;
}

.admin-success-banner {
    background: #d4edda;
    color: #155724;
}

.admin-error-banner {
    background: #f8d7da;
    color: #721c24;
}

.program-back {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: #475467;
    text-decoration: none;
    white-space: nowrap;
}

.program-back:hover {
    color: #1d2939;
    text-decoration: underline;
}

.program-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.mute-form {
    display: inline-flex;
}

.mute-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
    cursor: pointer;
}

.mute-toggle input {
    accent-color: #2563eb;
}

.program-subnav a {
    color: #475467;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
}

.program-subnav a:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.report-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.report-toolbar .section-hint {
    margin-left: 0.5rem;
}

.program-actions,
.inline-form {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.program-delivery-card {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #fff;
}

.program-delivery-card h3 {
    margin: 0;
}

.program-delivery-card .admin-table {
    margin-top: 0.75rem;
}

.program-reschedule {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.8rem;
    padding-top: 0.7rem;
    border-top: 1px solid #e5e7eb;
}

.program-reschedule strong {
    margin-right: 0.25rem;
}

@media print {
    @page {
        margin: 14mm;
    }

    html,
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 10pt;
    }

    .admin-shell {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .admin-top-bar {
        display: block;
        margin-bottom: 1rem;
    }

    .admin-header-actions,
    .program-subnav,
    .admin-account,
    .admin-nav,
    .no-print,
    .calendar-feed-card,
    .report-toolbar,
    .program-print-controls {
        display: none !important;
    }

    .admin-table-wrap {
        overflow: visible;
    }

    .admin-table {
        color: #000;
    }

    .admin-table th,
    .admin-table td {
        border-color: #999;
    }

    .admin-table thead {
        display: table-header-group;
    }

    .admin-table tr {
        break-inside: avoid;
    }

    .program-delivery-card {
        border: 0;
        padding: 0;
        margin-bottom: 1.25rem;
        break-inside: auto;
    }

    .program-delivery-card h2,
    .program-delivery-card h3 {
        break-after: avoid;
    }

    .program-delivery-card + .program-delivery-card {
        break-before: page;
    }

    a {
        color: #000;
        text-decoration: none;
    }
}

@media (max-width: 720px) {
    .admin-top-bar {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-heading {
        width: 100%;
    }

    .admin-header-actions {
        justify-content: flex-start;
        width: 100%;
        align-items: flex-start;
    }

    .admin-nav {
        justify-content: flex-start;
    }

    .admin-table-wrap {
        margin-right: -1rem;
        margin-left: -1rem;
        padding: 0 1rem;
    }

    .foremen-table,
    .foremen-table tbody,
    .foremen-table tr,
    .foremen-table td {
        display: block;
        width: 100%;
    }

    .foremen-table thead {
        display: none;
    }

    .foremen-table tr {
        padding: 0.5rem 0;
        border-bottom: 1px solid #e0e0e0;
    }

    .foremen-table td {
        display: grid;
        grid-template-columns: minmax(5.5rem, 7rem) minmax(0, 1fr);
        align-items: center;
        gap: 0.75rem;
        padding: 0.4rem 0;
        border-bottom: 0;
    }

    .foremen-table td::before {
        content: attr(data-label);
        color: #667085;
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .foremen-table .table-actions {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .foremen-table .table-actions > button,
    .foremen-table .table-actions > form {
        width: auto;
        flex: 0 1 auto;
    }

    .foremen-table .send-code-form {
        flex: 1 1 13rem;
    }
}
