/**
 * Safetech admin design system (safetechsafety.com tokens).
 * Premium SaaS shell — yellow/black brand, restrained status accents.
 */
:root {
    --st-primary: #ffc700;
    --st-primary-hover: #e5b300;
    --st-accent: #000000;
    --st-text: #3f3f46;
    --st-text-light: #71717a;
    --st-highlight: #c70a33;
    --st-surface: #ffffff;
    --st-muted: #f4f4f5;
    --st-border: #e4e4e7;
    --st-navy: #000000;
    --st-navy-mid: #18181b;
    --st-orange: #ffc700;
    --st-orange-deep: #e5b300;
    --st-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .05);
    --st-radius: .75rem;
}

body {
    background: var(--st-muted);
    color: var(--st-text);
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.st-skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    background: var(--st-primary);
    color: #000;
    padding: .5rem 1rem;
    z-index: 2000;
    font-weight: 700;
}
.st-skip-link:focus { left: .5rem; top: .5rem; }

.nav-role-badge {
    display: inline-block;
    margin-left: .35rem;
    padding: .15rem .5rem;
    border: 1px solid transparent;
    color: #000;
    background: var(--st-primary);
    border-radius: 999px;
    font-size: .65rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    font-weight: 800;
    vertical-align: middle;
}

.safetech-footer {
    background: transparent;
    border-top: 1px solid var(--st-border);
}

/* Login (unchanged behaviour, refined) */
.login-page-body { background: var(--st-muted); }
.login-brand-mark { font-weight: 800; letter-spacing: .16em; font-size: 1.1rem; }
.login-brand-mark--dark { color: var(--st-accent); }
.login-brand-panel {
    background: var(--st-accent) !important;
    min-height: 460px;
}
.login-brand-panel::before {
    background:
        linear-gradient(180deg, transparent 70%, rgba(255, 199, 0, .18)),
        radial-gradient(circle at 20% 80%, rgba(255, 199, 0, .25) 0%, transparent 45%) !important;
}
.login-split-card {
    border-radius: var(--st-radius);
    box-shadow: var(--st-shadow);
    background: #fff;
    max-width: 900px;
    border-top: 4px solid var(--st-primary);
}
.login-btn {
    background: var(--st-primary) !important;
    color: #000 !important;
    border: none;
    font-weight: 800;
}
.login-btn:hover {
    background: var(--st-primary-hover) !important;
    color: #000 !important;
}

.btn-safetech {
    background: var(--st-primary);
    border-color: var(--st-primary);
    color: #000;
    font-weight: 800;
}
.btn-safetech:hover,
.btn-safetech:focus {
    background: var(--st-primary-hover);
    border-color: var(--st-primary-hover);
    color: #000;
}
.btn-safetech:focus-visible,
.btn-outline-dark:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 3px solid #000;
    outline-offset: 2px;
}

.admin-panel-block {
    background: var(--st-surface);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius);
    padding: 1.25rem 1.35rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
}

/* Page headers */
.st-page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.35rem;
}
.st-page-kicker {
    font-size: .72rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--st-text-light);
}
.st-page-title {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--st-accent);
    letter-spacing: -.02em;
    margin: 0;
    line-height: 1.25;
}
.st-page-subtitle {
    color: var(--st-text-light);
    font-size: .95rem;
    margin-top: .35rem;
    max-width: 40rem;
}
.st-page-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}
.st-greeting {
    font-weight: 700;
    color: var(--st-accent);
}
.st-role-chip,
.st-count-chip {
    display: inline-flex;
    align-items: center;
    padding: .28rem .65rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    background: #fff;
    border: 1px solid var(--st-border);
    color: var(--st-text);
}
.st-count-chip {
    background: #fffbeb;
    border-color: #fde68a;
    color: #713f12;
}

/* KPI cards */
.kpi-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: .85rem;
    height: 100%;
    background: var(--st-surface);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius);
    padding: 1rem 1.05rem;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
    border-top: 3px solid var(--st-border);
    transition: transform .15s ease, box-shadow .15s ease;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--st-shadow);
    color: inherit;
}
.kpi-card:focus-visible {
    outline: 3px solid #000;
    outline-offset: 2px;
}
.kpi-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
}
.kpi-icon {
    width: 1.35rem;
    height: 1.35rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: .7;
}
.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    color: var(--st-accent);
    letter-spacing: -.03em;
}
.kpi-label {
    font-size: .8rem;
    font-weight: 700;
    color: var(--st-text-light);
    line-height: 1.3;
}
.kpi-total { border-top-color: #a1a1aa; }
.kpi-pending { border-top-color: var(--st-primary); }
.kpi-pending .kpi-icon { color: #a16207; }
.kpi-progress { border-top-color: #22c55e; }
.kpi-progress .kpi-icon { color: #166534; }
.kpi-paused { border-top-color: #f59e0b; }
.kpi-paused .kpi-icon { color: #9a3412; }
.kpi-completed { border-top-color: #16a34a; }
.kpi-completed .kpi-icon { color: #027a48; }
.kpi-cancelled { border-top-color: #ef4444; }
.kpi-cancelled .kpi-icon { color: #b42318; }

.attention-card {
    border-left: 4px solid var(--st-primary);
}
.attention-card--warn {
    border-left-color: #f59e0b;
}
.attention-count {
    min-width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .65rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    font-weight: 800;
    color: #713f12;
    font-size: 1.1rem;
}
.attention-card--warn .attention-count {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

/* Tables */
.st-table-wrap {
    border-radius: var(--st-radius);
    border: 1px solid var(--st-border);
    background: #fff;
    -webkit-overflow-scrolling: touch;
}
.admin-panel-block.st-table-wrap,
.admin-panel-block .st-table-wrap {
    border: 0;
    box-shadow: none;
}
.st-table {
    margin: 0;
    --bs-table-bg: transparent;
}
.st-table thead th {
    background: #fafafa;
    color: var(--st-text-light);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 800;
    border-bottom-width: 1px;
    white-space: nowrap;
    padding: .85rem 1rem;
}
.st-table tbody td {
    padding: .9rem 1rem;
    vertical-align: middle;
    border-color: var(--st-border);
}
.st-table tbody tr:hover {
    background: #fafafa;
}
.enquiry-index .table th,
.enquiry-index .table td {
    white-space: nowrap;
}
.enquiry-index .table td:nth-child(2),
.enquiry-index .table th:nth-child(2),
.enquiry-index .table td:nth-child(3),
.enquiry-index .table th:nth-child(3) {
    white-space: normal;
    min-width: 8rem;
}

.link-portal {
    color: var(--st-accent);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: var(--st-primary);
    text-underline-offset: 3px;
}
.link-portal:hover { color: var(--st-accent); }

.enquiry-row-pending {
    background: rgba(255, 199, 0, .10) !important;
}

.status-pill {
    display: inline-block;
    padding: .22rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .01em;
}
.status-new, .status-pill.status-new,
.status-pending, .status-pill.status-pending { background: #fff6cc; color: #5c4a00; }
.status-review, .status-pill.status-under-review, .status-pill.status-review { background: #e8e8e8; color: #222; }
.status-progress, .status-pill.status-in-progress, .status-pill.status-progress { background: #e8f7ef; color: #166534; }
.status-paused, .status-pill.status-paused { background: #fff4e5; color: #9a3412; }
.status-completed, .status-pill.status-completed { background: #ecfdf3; color: #027a48; }
.status-cancelled, .status-pill.status-cancelled { background: #fee4e2; color: #b42318; }
.status-closed, .status-pill.status-closed { background: #f2f4f7; color: #344054; }

.st-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--st-text-light);
}
.st-pagination .page-link {
    color: var(--st-accent);
    border-color: var(--st-border);
}
.st-pagination .page-item.active .page-link {
    background: var(--st-primary);
    border-color: var(--st-primary);
    color: #000;
    font-weight: 800;
}

.filter-panel .form-label {
    font-size: .78rem;
    font-weight: 700;
    color: var(--st-accent);
}
.enquiry-filters .form-control,
.enquiry-filters .form-select {
    min-height: 2.45rem;
}

/* Detail sections */
.section-title {
    font-size: .95rem;
    font-weight: 800;
    color: var(--st-accent);
    margin-bottom: 1rem;
}
.st-dl {
    display: grid;
    gap: .85rem;
    margin: 0;
}
.st-dl > div {
    display: grid;
    grid-template-columns: minmax(7rem, 34%) 1fr;
    gap: .75rem;
}
.st-dl dt {
    margin: 0;
    color: var(--st-text-light);
    font-weight: 600;
    font-size: .85rem;
}
.st-dl dd {
    margin: 0;
    font-weight: 600;
    color: var(--st-accent);
}
.complaint-body {
    white-space: pre-wrap;
    line-height: 1.55;
    color: var(--st-text);
}
.attachment-list { margin: 0; }
.attachment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--st-border);
}
.attachment-item:last-child { border-bottom: 0; padding-bottom: 0; }
.attachment-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    flex-shrink: 0;
}
.st-attachment-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(17, 24, 39, .72);
}
.st-attachment-lightbox[hidden] { display: none !important; }
.st-attachment-lightbox__dialog {
    position: relative;
    width: min(960px, 100%);
    max-height: min(90vh, 900px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: .75rem;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .28);
    overflow: hidden;
}
.st-attachment-lightbox__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--st-border);
}
.st-attachment-lightbox__title {
    margin: 0;
    font-size: .95rem;
    font-weight: 700;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.st-attachment-lightbox__close {
    flex-shrink: 0;
}
.st-attachment-lightbox__body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .75rem;
    background: #111827;
}
.st-attachment-lightbox__image {
    display: block;
    max-width: 100%;
    max-height: min(78vh, 780px);
    width: auto;
    height: auto;
    object-fit: contain;
}
.staff-card {
    padding: .85rem 1rem;
    border-radius: .65rem;
    background: #fafafa;
    border: 1px solid var(--st-border);
}
.status-timeline-item {
    position: relative;
    padding-left: 1.1rem;
    margin-bottom: 1rem;
}
.status-timeline-item:last-child { margin-bottom: 0; }
.status-timeline-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: .4rem;
    width: .55rem;
    height: .55rem;
    border-radius: 50%;
    background: var(--st-primary);
    box-shadow: 0 0 0 3px rgba(255, 199, 0, .25);
}
.st-form-card { max-width: 720px; }

/* Admin shell — viewport-locked; only .st-main scrolls */
html.h-100:has(body.st-admin),
html:has(body.st-admin) {
    height: 100%;
    overflow: hidden;
}
body.st-admin {
    background: var(--st-muted);
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}
.st-shell {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    width: 100%;
    overflow: hidden;
    align-items: stretch;
}
.st-sidebar {
    width: 248px;
    flex: 0 0 248px;
    background: var(--st-accent);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-self: stretch;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
    position: relative;
    border-right: 3px solid var(--st-primary);
    z-index: 1040;
}
.st-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.15rem 1.1rem 1rem;
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    letter-spacing: .14em;
    flex: 0 0 auto;
}
.st-brand:hover { color: var(--st-primary); }
.st-brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: .5rem;
    padding: .25rem .4rem;
    flex: 0 0 auto;
}
.st-brand-logo img { height: 34px; width: auto; display: block; }
.st-topbar-brand .st-brand-logo img { height: 28px; }
.st-nav {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    padding: .5rem .75rem 1rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.st-nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: rgba(255, 255, 255, .9);
    text-decoration: none;
    border-radius: .55rem;
    font-weight: 700;
    padding: .72rem .8rem;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
}
.st-nav-link:hover,
.st-nav-link:focus-visible {
    color: var(--st-primary);
    background: rgba(255, 255, 255, .07);
}
.st-nav-link.active {
    background: var(--st-primary);
    color: #000;
}
.st-nav-icon {
    width: 1.2rem;
    height: 1.2rem;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.st-logout-form {
    margin-top: auto;
    flex: 0 0 auto;
    padding: .75rem .75rem 1.1rem;
}
.st-logout { cursor: pointer; }
.st-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--st-muted);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.st-topbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem 1.35rem;
    background: #fff;
    border-bottom: 1px solid var(--st-border);
    position: sticky;
    top: 0;
    z-index: 1020;
    flex: 0 0 auto;
}
.st-topbar-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.st-topbar-kicker {
    font-size: .68rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--st-text-light);
}
.st-topbar-page {
    font-weight: 800;
    color: var(--st-accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.st-nav-toggle {
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--st-border);
    background: #fff;
    border-radius: .5rem;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: .28rem;
    padding: 0;
}
.st-nav-toggle:focus-visible { outline: 3px solid #000; outline-offset: 2px; }
.st-nav-toggle-bar {
    display: block;
    width: 1rem;
    height: 2px;
    background: #000;
}
.st-userchip {
    display: flex;
    align-items: center;
    gap: .45rem;
    min-width: 0;
}
.st-userchip-name {
    font-weight: 800;
    color: var(--st-accent);
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.st-topbar .nav-role-badge { margin-left: 0; }
.st-content { min-width: 0; }
.st-page { padding: 1.35rem 1.5rem 2rem; }
.st-loading { height: 3px; overflow: hidden; background: #fff4c2; }
.st-loading[hidden] { display: none !important; }
.st-loading-bar {
    display: block;
    height: 3px;
    width: 35%;
    background: var(--st-primary);
    animation: st-load 1s ease-in-out infinite;
}
@keyframes st-load {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
}
.st-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 1030;
}
.st-backdrop[hidden] { display: none !important; }

/* Legacy aliases used by older partials */
.stat-card { /* replaced by kpi-card */ }
.dashboard-banner { display: none !important; }

@media (min-width: 992px) {
    html.st-sidebar-collapsed .st-sidebar {
        width: 78px;
        flex-basis: 78px;
    }
    html.st-sidebar-collapsed .st-brand-text,
    html.st-sidebar-collapsed .st-nav-label {
        display: none;
    }
    html.st-sidebar-collapsed .st-brand,
    html.st-sidebar-collapsed .st-nav-link {
        justify-content: center;
    }
}

@media (max-width: 991.98px) {
    .st-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100%;
        max-height: 100dvh;
        transform: translateX(-105%);
        transition: transform .2s ease;
        width: min(280px, 86vw);
        flex-basis: auto;
    }
    html.st-nav-open .st-sidebar { transform: translateX(0); }
    .st-page { padding: 1rem .9rem 1.5rem; }
    .st-topbar { padding: .65rem .9rem; }
    .st-userchip-name { max-width: 6.5rem; }
    .st-page-title { font-size: 1.4rem; }
}

@media (max-width: 767.98px) {
    .kpi-value { font-size: 1.4rem; }
    .login-split-card { margin: .75rem; }
    .st-dl > div {
        grid-template-columns: 1fr;
        gap: .15rem;
    }
    .attachment-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .st-attachment-lightbox {
        padding: .5rem;
    }
    .st-attachment-lightbox__image {
        max-height: min(72vh, 640px);
    }
}

/* Password show/hide toggle
   Leave room on the far right for Bootstrap is-valid / is-invalid feedback icons. */
.st-password-field {
    position: relative;
}
.st-password-field .form-control {
    padding-right: 4.75rem !important;
    background-position: right .75rem center !important;
    background-size: 1rem 1rem !important;
}
.st-password-field .form-control-lg {
    padding-right: 5.1rem !important;
    background-position: right .85rem center !important;
    background-size: 1.1rem 1.1rem !important;
}
.st-password-toggle {
    position: absolute;
    top: 50%;
    /* Sit left of the validation feedback icon slot (~2.1–2.4rem). */
    right: 2.15rem;
    transform: translateY(-50%);
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: .4rem;
    background: transparent;
    color: #52525b;
    cursor: pointer;
    line-height: 0;
    box-shadow: none;
}
.st-password-field .form-control-lg ~ .st-password-toggle {
    right: 2.4rem;
    width: 2.15rem;
    height: 2.15rem;
}
.st-password-toggle:hover,
.st-password-toggle:focus-visible {
    color: #111;
    background: rgba(255, 199, 0, .3);
    outline: none;
}
.st-password-toggle:focus-visible {
    box-shadow: 0 0 0 2px #000;
}
.st-password-toggle svg {
    width: 1.2rem;
    height: 1.2rem;
    display: block;
    flex-shrink: 0;
    pointer-events: none;
}
@media (max-width: 575.98px) {
    .st-password-field .form-control {
        padding-right: 4.6rem !important;
    }
    .st-password-toggle {
        right: 2rem;
        width: 2.1rem;
        height: 2.1rem;
    }
}
