﻿/* ============================================================================
   MOH Health Facility Management System - back-office portal
   MOH navy base with a gold sidebar accent, on the AdminLTE 3.2 shell with a single inner
   scroll region. The surface language follows the approved wireframe: a slate neutral scale,
   generously rounded cards, hairline borders in place of heavy chrome, and status carried by
   a tinted-and-bordered badge rather than a block of colour.
   ============================================================================ */

:root {
    /* MOH identity. Unchanged - the emblem, the navy and the gold are the ministry's. */
    --primary: #1A3564;
    --primary-light: #2d4a7c;
    --primary-dark: #0f2340;
    --sidebar-top: #0D2147;
    --sidebar-active: #1a2a3e;
    --accent-gold: #C9A227;
    --accent-gold-soft: #e8d89a;
    --accent-gold-bright: #f6d365;
    --accent-green: #2E7D4F;

    /* Neutrals. A slate scale rather than a plain grey: the slight blue cast sits under the
       navy without the muddiness a neutral grey picks up next to it. */
    --slate-50:  #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-700: #334155;
    --slate-900: #0f172a;

    --text-dark: var(--slate-900);
    --text-light: var(--slate-500);
    --border-color: var(--slate-200);
    --border-subtle: var(--slate-100);
    --bg-light: var(--slate-50);
    --white: #ffffff;

    --success: #059669;
    --danger: #e11d48;
    --warning: #d97706;
    --info: #0284c7;
    --muted: var(--slate-400);

    /* Corner radii, named by role rather than size, so a card and a control cannot drift
       apart when one of them is adjusted. */
    --radius-card: 16px;
    --radius-control: 12px;
    --radius-pill: 8px;
    --radius-badge: 6px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, .08);
}

/* ============================ Base ============================ */

* { box-sizing: border-box; }

html, body {
    height: 100%;
    overflow: hidden; /* the single scroll region is section.content */
}

/* Text grows on wide monitors. Every size in this sheet, and Bootstrap's own, is in rem, so the
   root is the one dial: the browser's 16px below 1600px - laptops read as they always have - then
   about 7% and 14% larger, where 13px Khmer was small at arm's length from a large screen. */
@media (min-width: 1600px) {
    html { font-size: 107%; }
}

@media (min-width: 1920px) {
    html { font-size: 114%; }
}

body {
    font-family: 'Inter', 'Kantumruy Pro', 'Nokora', Arial, sans-serif;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--text-dark);
    background: var(--bg-light);
}

/* Khmer and English mix freely in every label, so long words must wrap rather
   than force the page into a horizontal scroll. */
h1, h2, h3, h4, h5, p, td, th, label, .nav-link p {
    overflow-wrap: break-word;
    word-break: break-word;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); text-decoration: none; }

.wrapper {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ============================ Header ============================ */

.main-header.navbar {
    background-color: var(--white);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.1rem;
    min-height: 56px;
    box-shadow: var(--shadow-xs);
    flex-shrink: 0;
    align-items: center;
}

.navbar-page-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--slate-700);
    margin-left: .5rem;
}

/* Which province this account is confined to. Beside the menu button, because it qualifies
   everything in the rail below it rather than the page currently on screen. Quiet by design:
   it is a standing condition, not a notification. */
.navbar-scope {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-left: .35rem;
    padding: .25rem .65rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    background: var(--slate-50, #f8f9fa);
    color: var(--slate-700);
    font-size: 0.7812rem;
    font-weight: 600;
    white-space: nowrap;
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-scope i { color: var(--primary); font-size: 0.6875rem; }

.navbar-nav .nav-link {
    color: var(--slate-500) !important;
    padding: .45rem .6rem;
    border-radius: var(--radius-pill);
    transition: background-color .15s ease, color .15s ease;
}

.navbar-nav .nav-link:hover {
    color: var(--slate-900) !important;
    background-color: var(--slate-100);
}

/* ============================ Language toggle ============================ *
   One flag, showing the language the button switches to.

   Sized to the header rather than to the artwork: the flag files are 512px squares, so they
   are scaled down and cropped to a landscape aspect - a flag squeezed into a circle or a
   square stops looking like that country's flag.
 * ---------------------------------------------------------------- */

.language-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 24px;
    padding: 0;
    margin-right: .65rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-badge);
    background: var(--white);
    overflow: hidden;
    flex-shrink: 0;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.language-toggle:hover,
.language-toggle:focus-visible {
    border-color: var(--slate-300);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.language-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* The source images are square with the flag centred, so cover-cropping to the button's
   landscape box gives the flag its own proportions back. */
.language-flag {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (prefers-reduced-motion: reduce) {
    .language-toggle { transition: none; }
    .language-toggle:hover { transform: none; }
}

@media (max-width: 575.98px) {
    .language-toggle { margin-right: .35rem; }
}

.user-profile-section { display: flex; align-items: center; gap: .5rem; }

.user-info {
    display: flex;
    align-items: center;
    padding: .35rem .75rem;
    border-radius: 12px;
    transition: background .2s ease;
}

.user-info:hover { background: var(--bg-light); }

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-light), #f0f0f0);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: .7rem;
    flex-shrink: 0;
}

.user-avatar i { color: var(--primary); font-size: 1rem; }

.username { display: flex; flex-direction: column; gap: 2px; }
.username p { margin: 0; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 0.875rem; }

.user-account {
    font-size: 0.7812rem;
    color: var(--text-light);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================ Sidebar ============================ */

.main-sidebar {
    background: linear-gradient(180deg, var(--sidebar-top) 0%, var(--primary) 60%, var(--primary-dark) 100%);
    box-shadow: 2px 0 12px rgba(0, 0, 0, .28);
    border-right: 1px solid #15263d;
    display: flex;
    flex-direction: column;

    /* AdminLTE leaves this rail scrollable sideways. With the 1px border above, the content box
       is one pixel narrower than the border box, which is enough for "auto" to decide a
       horizontal scrollbar is needed - a scrollbar for one pixel nobody can scroll to. The rail
       is a fixed-width column of navigation; there is never anything to reach off to its right. */
    overflow-x: hidden;
}

.brand-link {
    background: linear-gradient(160deg, #091830 0%, var(--sidebar-top) 100%);
    border-bottom: 1px solid rgba(28, 46, 71, .6);
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.1rem .75rem .9rem;
    position: relative;
    overflow: hidden;
}

/* The gold hairline that opens the rail. Fades at both ends so it reads as a ribbon of
   trim rather than a rule drawn across the panel. */
.brand-link::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
}

/* The emblem, as the file draws it, and nothing added.

   The artwork already carries its own white ground behind the crest, so everything this rule
   used to do to give it one is now something done twice: a background the file supplies, a
   rounded corner the file's own edge already has, padding that inset the white inside more
   white, and a drop shadow around a rectangle that reads as a floating card rather than as a
   coat of arms.

   No object-fit and no cropping either. The width is set, the height follows the file's own
   proportions, and what appears on the rail is the image.

   AdminLTE ships its own .brand-image rules, which is why these carry !important. */
.brand-image {
    float: none !important;
    width: clamp(52px, 4.1vw, 72px) !important;
    height: auto !important;
    max-width: 72px !important;
    max-height: none !important;
    background: none;
    border-radius: 0;
    padding: 0;
    margin: 0 0 .55rem 0 !important;
    box-shadow: none;
    opacity: 1;
}

/* Both lines of the wordmark are gold. The ministry's name and the system's name belong to
   the same plate, and splitting them across two colours read as an accident. */
.brand-text {
    color: var(--accent-gold-soft) !important;
    font-size: 0.625rem;
    font-weight: 500;
    display: block;
    line-height: 1.4;
    text-align: center;
    letter-spacing: .01em;
    opacity: .9;
}

.brand-link .brand-text:first-of-type {
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: .02em;
    opacity: 1;
}

.sidebar {
    padding-top: .75rem;
    flex: 1 1 auto;
    overflow-y: auto;
}

.nav-sidebar .nav-header {
    color: var(--accent-gold);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    padding: 1rem .95rem .35rem;
    opacity: .8;
    line-height: 1.4;
}

/* ---------------------------------------------------------------------------
   The rail at full width

   The rail is 250px wide in two different situations, and they do not share a body class:

     - open normally                      body is NOT .sidebar-collapse
     - collapsed to icons, then hovered   body IS .sidebar-collapse, and AdminLTE widens
                                          .main-sidebar back to 250px on :hover / .sidebar-focused

   Everything below has to apply in both, so each rule lists all three selectors. Scoping any of
   it to :not(.sidebar-collapse) alone leaves the hover state running the unfixed geometry, which
   is exactly how the list came back broken when the rail was reopened by hovering.

   Collapsed and NOT hovered is deliberately excluded: there AdminLTE keeps the list at full width
   and clips it so a label can slide back out, and a 74px rail has no scrollbar to fix.
   --------------------------------------------------------------------------- */

/* The list is a column flex container whose items were resolving to a cross size 21px wider than
   the container - measurably: an empty list laid out at the rail's width, and adding any single
   item, even "Dashboard", pushed the flex line 21px past it. The list then overflowed its rail,
   where .sidebar's overflow-x: hidden silently clipped it and .main-sidebar's overflow-x: auto
   put a scrollbar under it.

   max-width caps each item at the width it is actually given, which is what stops the line
   growing. Because a percentage resolves against the container's content box, the 10px gutter has
   to move from the items' own horizontal margins onto the list's padding - a margin sits outside
   that cap and would put the overflow straight back. */
body:not(.sidebar-collapse) .nav-sidebar,
.sidebar-mini.sidebar-collapse .main-sidebar:not(.sidebar-no-expand):hover .nav-sidebar,
.sidebar-mini.sidebar-collapse .main-sidebar:not(.sidebar-no-expand).sidebar-focused .nav-sidebar {
    padding-left: 10px;
    padding-right: 10px;
}

/* Unscoped, because a row should never be wider than the rail holding it in any state. Collapsed,
   these two are what centre the icons: with a 10px side margin the row started 10px in and still
   stretched past the right edge, so its middle - and the icon justified to it - sat 15px right of
   the rail's centre, visibly out of line with the emblem above. Full width and no side margin put
   the row's centre on the rail's centre, which is where the emblem already is. */
.nav-sidebar > .nav-item,
.nav-sidebar > .nav-header,
.nav-sidebar .nav-link {
    max-width: 100%;
}

.nav-sidebar > .nav-item { margin: 3px 0; }

/* AdminLTE keeps section headers on one line, which is right while the rail is animating closed -
   wrapping text mid-collapse looks broken - but wrong once it is open at 250px: uppercase at .12em
   tracking makes the longest header, "Approval and licences", want 254px in a 233px list. The
   padding loses the 10px the list now carries, so the labels stay on the line they were on. */
body:not(.sidebar-collapse) .nav-sidebar > .nav-header,
.sidebar-mini.sidebar-collapse .main-sidebar:not(.sidebar-no-expand):hover .nav-sidebar > .nav-header,
.sidebar-mini.sidebar-collapse .main-sidebar:not(.sidebar-no-expand).sidebar-focused .nav-sidebar > .nav-header {
    padding-left: .35rem;
    padding-right: .35rem;
    white-space: normal;
    overflow-wrap: break-word;
}

/* Collapsing to icons sets the label to width: 0 and hides it. Reopening on hover makes it
   visible again but never restores the width - AdminLTE does not need to, because its own nav
   link is display: block, so a zero-width label simply paints its text over the space to its
   right.

   This portal's nav link is display: flex, so that same label is a flex item: at width 0 it
   occupies no space, and the text lands on top of whatever follows it. Giving the width back is
   what makes the labels reappear properly instead of collapsing into each other. */
.sidebar-mini.sidebar-collapse .main-sidebar:not(.sidebar-no-expand):hover .nav-sidebar .nav-link p,
.sidebar-mini.sidebar-collapse .main-sidebar:not(.sidebar-no-expand).sidebar-focused .nav-sidebar .nav-link p {
    width: auto;
    white-space: normal;
}

.nav-sidebar .nav-link {
    color: #cbd5e1 !important;
    border-radius: var(--radius-control);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background-color .18s ease, color .18s ease;
    border-left: 4px solid transparent;
}

.nav-sidebar .nav-link p { margin: 0; line-height: 1.35; }

.nav-sidebar .nav-link:hover {
    background-color: #16253b !important;
    color: #ffffff !important;
}

/* The active rail marker: a solid gold edge and a lifted panel, rather than a wash of
   colour. It survives against the gradient at every scroll position. */
.nav-sidebar .nav-link.active {
    background-color: var(--sidebar-active) !important;
    color: var(--accent-gold-bright) !important;
    font-weight: 700;
    border-left: 4px solid var(--accent-gold-bright);
    box-shadow: var(--shadow-xs);
}

.nav-sidebar .nav-link.active .nav-icon { color: var(--accent-gold-bright) !important; }

.nav-sidebar .nav-icon {
    width: 18px;
    margin-right: 11px;
    font-size: 0.8125rem;
    color: #94a3b8;
    flex-shrink: 0;
    transition: color .18s ease;
}

.nav-sidebar .nav-link:hover .nav-icon { color: var(--accent-gold-soft); }

/* The gold-green-gold rule that closes the rail, mirroring the one that opens it. Sits
   outside the scrolling list so it stays pinned to the bottom of the panel. */
.sidebar-footer-accent {
    height: 3px;
    flex-shrink: 0;
    background: linear-gradient(90deg, var(--accent-gold), var(--accent-green), var(--accent-gold));
}

/* Collapsed rail: the emblem shrinks to a mark. Height still follows the ratio rather than
   being pinned, so it does not squash into the narrower rail. */
.sidebar-mini.sidebar-collapse .brand-image {
    width: 38px !important;
    height: 38px !important;
    max-width: 38px !important;
    max-height: 38px !important;
    padding: 3px;
    margin: 0 !important;
}

.sidebar-mini.sidebar-collapse .brand-text { display: none !important; }

.sidebar-mini.sidebar-collapse .nav-sidebar .nav-link {
    justify-content: center;
    border-left-width: 0;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-mini.sidebar-collapse .nav-sidebar .nav-icon { margin-right: 0; }

/* AdminLTE pulls the hidden label back with margin-left: -10px while the rail is collapsed. In
   its own block layout that is invisible; here the label is a flex item, so those -10px count
   toward what justify-content centres and pushed every icon 5px right of the rail's axis - just
   enough to sit visibly out of line with the emblem above. Zeroing it leaves the icon alone on
   the line, centred on the rail exactly as the emblem is.

   Five classes deep to outrank AdminLTE's own selector; the hover rules are deeper still, so
   reopening the rail continues to win. */
.sidebar-mini.sidebar-collapse .sidebar .nav-sidebar .nav-link p { margin-left: 0; }

/* ...and undone the moment the collapsed rail is hovered back open. The centring above exists to
   put a lone icon in the middle of a 74px rail; at 250px with the label showing it pushes the
   whole row into the middle and closes the gap between icon and text. Restoring the open rail's
   own values is what makes a hovered rail read exactly like a pinned one. */
.sidebar-mini.sidebar-collapse .main-sidebar:not(.sidebar-no-expand):hover .nav-sidebar .nav-link,
.sidebar-mini.sidebar-collapse .main-sidebar:not(.sidebar-no-expand).sidebar-focused .nav-sidebar .nav-link {
    justify-content: flex-start;
    border-left-width: 4px;
    padding-left: 14px;
    padding-right: 14px;
}

.sidebar-mini.sidebar-collapse .main-sidebar:not(.sidebar-no-expand):hover .nav-sidebar .nav-icon,
.sidebar-mini.sidebar-collapse .main-sidebar:not(.sidebar-no-expand).sidebar-focused .nav-sidebar .nav-icon {
    margin-right: 11px;
}

/* A short viewport - a phone in landscape, or a laptop with browser chrome open - has
   little vertical room in the sidebar. The emblem gives some of it back. */
@media (max-height: 700px) {
    .brand-link { padding: .7rem .75rem .6rem; }

    .brand-image {
        width: clamp(44px, 3.4vw, 56px) !important;
        height: clamp(44px, 3.4vw, 56px) !important;
        max-height: 56px !important;
        padding: 4px;
        margin-bottom: .35rem !important;
    }
}

/* ============================ Content shell ============================ */

.content-wrapper {
    background: var(--bg-light);
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* The title alone, so the band it sits in is the height of one line rather than of a line, a
   subtitle and a breadcrumb. Both of those were removed from the layout; the bottom padding
   here is what stops the heading sitting flush against the content that follows it. */
.content-header {
    flex-shrink: 0;
    padding: 1rem 1.25rem .35rem;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-heading-text { min-width: 0; }

.page-heading h1 {
    color: var(--primary);
    font-weight: 600;
    font-size: 1.375rem;
    margin: 0;
}

.page-heading-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

section.content {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.25rem 0 2rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

section.content::-webkit-scrollbar { width: 6px; }
section.content::-webkit-scrollbar-track { background: transparent; }
section.content::-webkit-scrollbar-thumb { background-color: var(--border-color); border-radius: 3px; }
section.content::-webkit-scrollbar-thumb:hover { background-color: var(--text-light); }

/* ============================ Footer ============================ *
   A status strip rather than a band of text: copyright on one side, environment and version
   on the other, at the smallest size that stays legible so it never competes with the work.
 * ---------------------------------------------------------------- */

.main-footer {
    flex-shrink: 0;
    background: var(--white);
    border-top: 1px solid var(--border-color);
    padding: 0 1.1rem;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: var(--text-light);
    font-size: 0.6875rem;
    line-height: 1.4;
}

.main-footer .footer-copyright strong { color: var(--slate-700); font-weight: 600; }

.main-footer .footer-meta {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-shrink: 0;
}

.main-footer .footer-context {
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
}

/* A live dot beside the environment name. Small, but it is the one thing on the strip an
   operator actually looks for. */
.main-footer .footer-status {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-weight: 700;
    color: var(--success);
    font-family: 'JetBrains Mono', 'Nokora', monospace;
    font-size: 0.625rem;
}

.main-footer .footer-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

.main-footer .footer-version {
    font-family: 'JetBrains Mono', 'Nokora', monospace;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.625rem;
}

@media (max-width: 640px) {
    .main-footer .footer-context,
    .main-footer .footer-status { display: none; }
}

/* ============================ Cards ============================ *
   Generous corners and a hairline border, with almost no shadow. The page is a stack of
   panels on a tinted ground; separation comes from the ground showing through, not from
   each panel casting its own weight.
 * ---------------------------------------------------------------- */

.card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-xs);
    margin-bottom: 1.1rem;
    overflow: hidden;
}

.card-header {
    background: var(--white);
    border-bottom: 1px solid var(--border-subtle);
    padding: .85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
}

.card-header h2, .card-header h3 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--slate-900);
    margin: 0;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.card-header h2 i, .card-header h3 i { color: var(--slate-400); font-size: 0.8125rem; }

/* A heading inside a card body, set the same as the card's own title - the approval tab's
   "License scope selected by the MoH inspection" under "Workflow approval". */
.card-section-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--slate-900);
    margin: 0 0 .5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.card-section-title i { color: var(--slate-400); font-size: 0.8125rem; }

.card-header .card-subtitle,
.card-header .doc-viewer-meta {
    font-size: 0.75rem;
    color: var(--text-light);
    margin: .1rem 0 0;
    width: 100%;
}

/* A count belongs beside the title it counts, not on a line of its own beneath it. The default
   above gives the meta the full width, which pushes a two-word progress figure onto a second
   row and costs a whole line of a panel that is already scrolling. This keeps it on the header
   line and pushes it to the far edge. */
.card-header .doc-viewer-meta-inline {
    width: auto;
    margin: 0 0 0 auto;
    white-space: nowrap;
}

/* The header's own controls - the checklist's Pass all / Fail all pair. Sits after the count
   and stays on the same line as the title. */
.card-header-tools {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-left: .5rem;
}

.card-body { padding: 1.25rem; }
.card-body.tight { padding: 0; }

/* ============================ Buttons ============================ */

.btn {
    border-radius: 6px;
    padding: .45rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    transition: background .15s ease, box-shadow .15s ease;
}

.btn-primary { background-color: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background-color: var(--primary-light); border-color: var(--primary-light); color: #fff; }

.btn-success { background-color: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background-color: #218838; color: #fff; }

.btn-danger { background-color: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background-color: #c82333; color: #fff; }

.btn-warning { background-color: var(--warning); border-color: var(--warning); color: #1f2937; }
.btn-warning:hover { background-color: #d97706; color: #1f2937; }

.btn-light { background-color: #fff; border-color: var(--border-color); color: var(--text-dark); }
.btn-light:hover { background-color: var(--bg-light); border-color: #c0c0c0; }

.btn-sm { padding: .3rem .7rem; font-size: 0.8125rem; }

/* A disabled action must read as unavailable rather than merely unstyled. */
.btn:disabled, .btn.disabled, .btn[disabled] {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
}

/* Row action buttons inside grids */
.btn-row {
    border-radius: 6px;
    padding: 5px 9px;
    font-size: 0.7812rem;
    font-weight: 500;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    color: #fff;
}

.btn-row.btn-primary { background: var(--primary); }
.btn-row.btn-success { background: var(--success); }
.btn-row.btn-info { background: var(--info); }
.btn-row.btn-danger { background: var(--danger); }
.btn-row.btn-light { background: #fff; border: 1px solid var(--border-color); color: var(--text-dark); }

.action-container {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 4px;
    white-space: nowrap;
}

.action-bar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
    padding: .85rem 1.25rem;
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 8px 8px;
}

/* Pushed to the far end of the bar, away from the actions beside it - for the approval screen's
   Reject, which cannot be undone and should not sit a slip away from Approve or a return. */
.action-bar .action-bar-end {
    margin-left: auto;
}

/* Wrapped onto its own line on a narrow screen, it keeps the gap rather than sitting flush
   against the button above it. */
@media (max-width: 575.98px) {
    .action-bar .action-bar-end { margin-left: auto; margin-top: .25rem; }
}

/* An action in flight: the button reports it is working and refuses a second click. */
.btn.is-busy {
    position: relative;
    pointer-events: none;
    opacity: .75;
}

.btn.is-busy::after {
    content: '';
    width: 13px;
    height: 13px;
    margin-left: .45rem;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: portal-spin .7s linear infinite;
}

.btn-light.is-busy::after { border-color: rgba(0,0,0,.2); border-top-color: var(--primary); }

@keyframes portal-spin { to { transform: rotate(360deg); } }

/* ============================ Tables ============================ *
   Rows separated by a hairline rather than striped, with the header a quiet label row rather
   than a band of navy. On a long queue the navy band competed with the sidebar for the eye;
   the work is in the rows, so the rows are what carries weight.
 * ---------------------------------------------------------------- */

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.grid {
    border-collapse: collapse;
    width: 100%;
    background: #fff;
    font-size: 0.8125rem;
}

table.grid thead {
    background-color: var(--slate-50);
    color: var(--text-light);
}

table.grid th {
    font-weight: 700;
    font-size: 0.6875rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

table.grid th a { color: var(--text-light); }
table.grid th a:hover { color: var(--slate-900); }

table.grid tbody tr { transition: background-color .12s ease; }
table.grid tbody tr:hover { background-color: var(--slate-50); }

table.grid td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    color: var(--slate-700);
}

table.grid tbody tr:last-child td { border-bottom: none; }

/* The row a save just wrote. An administration list is ordered by name, not by when a row was
   made, so without this an operator who has just created an account has to hunt for it among
   the rest to confirm anything happened at all. Tinted rather than outlined so it reads as
   "this one" without looking like a warning, and it lasts one render. */
table.grid tbody tr.grid-row-saved,
table.grid tbody tr.grid-row-saved:hover {
    background-color: #ecfdf5;
    box-shadow: inset 3px 0 0 var(--success);
}

/* A row that belongs to the row above it - the individual rounds of a step that was worked more
   than once. Tinted and indented so the eye reads them as a breakdown of their parent rather
   than as more steps in the list, and separated by a hairline instead of the full rule so the
   group still reads as one block. */
table.grid tbody tr.grid-subrow { background-color: var(--slate-50); }
table.grid tbody tr.grid-subrow:hover { background-color: var(--slate-100, var(--slate-50)); }

table.grid tbody tr.grid-subrow td {
    padding-top: 8px;
    padding-bottom: 8px;
    border-bottom-color: var(--border-subtle);
    font-size: 0.8125rem;
}

table.grid td.grid-subrow-label {
    padding-left: 34px;
    position: relative;
    color: var(--text-light);
}

/* The elbow that ties the round to its step. */
table.grid td.grid-subrow-label::before {
    content: "";
    position: absolute;
    left: 18px;
    top: 50%;
    width: 8px;
    height: 1px;
    background: var(--border-color);
}

.grid-subrow-note {
    color: var(--text-light);
    font-size: 0.75rem;
}

table.grid td.numeric, table.grid th.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

table.grid td.nowrap, table.grid th.nowrap { white-space: nowrap; }

/* "Steps and cycles". The approval workspace gives it half the page, so the columns are fixed
   shares of whatever width there is and every cell wraps, rather than the table growing a
   scrollbar to fit a long date or comment on one line. */
table.grid.steps-grid { table-layout: fixed; }

table.grid.steps-grid th,
table.grid.steps-grid td {
    padding: 10px 10px;
    white-space: normal;
    overflow-wrap: anywhere;
    vertical-align: top;
}

table.grid.steps-grid td.grid-subrow-label { padding-left: 30px; }

/* A badge wraps inside its column instead of spilling into the next one. */
table.grid.steps-grid .badge {
    white-space: normal;
    text-align: left;
    max-width: 100%;
}

table.grid.steps-grid col.steps-col-seq     { width: 40px; }
table.grid.steps-grid col.steps-col-step    { width: 24%; }
table.grid.steps-grid col.steps-col-status  { width: 14%; }
table.grid.steps-grid col.steps-col-outcome { width: 12%; }
table.grid.steps-grid col.steps-col-date    { width: 15%; }
table.grid.steps-grid col.steps-col-by      { width: 13%; }
table.grid.steps-grid col.steps-col-comment { width: auto; }

table.grid.steps-grid td.steps-comment { white-space: pre-line; }

/* The first cell of a queue row is the thing being worked on. It gets the weight, with the
   supporting facts a step down beneath it. */
.cell-title {
    font-weight: 700;
    color: var(--slate-900);
    font-size: 0.8438rem;
    line-height: 1.4;
}

.cell-meta {
    font-size: 0.6875rem;
    color: var(--text-light);
    line-height: 1.45;
}

.cell-ref {
    font-family: 'JetBrains Mono', 'Nokora', monospace;
    font-size: 0.6875rem;
    color: var(--slate-700);
}


/* ==================== One workflow and its versions ==================== *
   The administration workflow list stacks a block per definition: what it is on the left, the
   actions on the right, and the version table beneath. The two halves of the head were laid out
   as plain divs with nothing to align them, so the buttons sat under the title on a wide screen
   and the code and service badge ran into them on a narrow one.

   Same shape as .card-header, because it is the same kind of thing - a heading with actions -
   and two headers in one page that align differently read as a fault rather than a choice.
 * ---------------------------------------------------------------------- */

/* The card body these sit in is .tight, which has no padding at all, so each block supplies its
   own. Vertical only: the version table underneath goes edge to edge like every other grid in
   the portal, and a block that inset the table would leave it hanging inside the card. */
.workflow-block {
    padding: .9rem 0;
}

.workflow-block + .workflow-block {
    border-top: 1px solid var(--border-subtle);
}

/* Inset by the grid's own cell padding rather than the card's, so the workflow name starts on
   the same vertical line as the Version column beneath it and the buttons end on the same line
   as the Actions column. Aligning it to the card header instead would put the name 6px to the
   right of its own table, which is the kind of near-miss that reads as a fault. */
.workflow-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    padding: 0 14px;
    margin-bottom: .6rem;
}

/* The identity half takes the slack; the buttons keep their own width. min-width:0 so a long
   workflow name wraps inside the column instead of pushing the actions off the row. */
.workflow-block-head > div:first-child {
    flex: 1 1 16rem;
    min-width: 0;
}

/* The actions carry .action-container, which is what spaces every other row of buttons in the
   portal; all this adds is that they keep their width while the identity half gives up its own. */
.workflow-block-head > .action-container {
    flex-shrink: 0;
}

/* The code and the service badge sit on one baseline rather than the badge riding high on it. */
.workflow-block-head .cell-meta {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
    margin-top: .2rem;
}

/* "No draft yet" stands in for the table, so it is inset to where the table's text would be
   rather than left flush against the card edge, and drops the margin the table has no need of. */
.workflow-block .page-message {
    margin: 0 14px;
}

/* Key/value table used on the detail tabs */
table.detail-table { width: 100%; font-size: 0.8125rem; }
table.detail-table th {
    width: 34%;
    font-weight: 500;
    color: var(--text-light);
    padding: 9px 12px 9px 0;
    vertical-align: top;
    text-align: left;
}
table.detail-table td { padding: 9px 0; vertical-align: top; color: var(--slate-900); }
table.detail-table tr + tr th, table.detail-table tr + tr td { border-top: 1px solid var(--border-subtle); }

/* ============================ Badges ============================ *
   Tint, text and a matching border at one step darker. The border is what lets a badge hold
   its shape on a white row and on a tinted one, which a flat pill does not.
 * ---------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: 3px 9px;
    border-radius: var(--radius-badge);
    border: 1px solid transparent;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: .01em;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-primary { background: #e0e7ff; color: #312e81; border-color: #c7d2fe; }
.badge-success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.badge-danger  { background: #ffe4e6; color: #9f1239; border-color: #fda4af; }
.badge-warning { background: #fef3c7; color: #78350f; border-color: #fcd34d; }
.badge-info    { background: #e0f2fe; color: #075985; border-color: #7dd3fc; }
.badge-muted   { background: var(--slate-100); color: var(--slate-700); border-color: var(--slate-200); }

/* Inspection files. Three badges, and the colours carry the distinction that matters rather
   than one hue per purpose code: sky for what the inspector observed, slate-indigo for what the
   office signed, violet for paperwork that arrived after the round had already closed. */
.badge-evidence { background: #e0f2fe; color: #075985; border-color: #7dd3fc; }
.badge-official { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.badge-postpass { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }

/* A reference, a licence number or a chat id. Monospace so digits line up down a column and
   a transposed character is visible. */
.badge-ref {
    background: var(--slate-100);
    color: var(--slate-700);
    border-color: var(--slate-200);
    font-family: 'JetBrains Mono', 'Nokora', monospace;
    font-size: 0.6562rem;
}

/* A live badge - work in progress, an SLA still running. The dot pulses; the badge does not. */
.badge-live::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
    animation: badge-pulse 1.8s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .35; }
}

@media (prefers-reduced-motion: reduce) {
    .badge-live::before { animation: none; }
}

/* ============================ Search and filters ============================ *
   The toolbar carries three things and no more: what you are looking for, how to narrow it,
   and what is currently narrowing it. Each is a distinct shape, so none is mistaken for
   another at a glance.
 * ---------------------------------------------------------------- */

.query-section {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.1rem;
    flex-wrap: wrap;
}

.form-group.has-search { position: relative; flex: 1; max-width: 480px; margin: 0; }

/* A note under a field, for the one or two places where the label alone does not say what the
   answer will do. Quiet enough not to compete with the label above it. */
.form-hint {
    display: block;
    margin-top: .3rem;
    font-size: 0.7188rem;
    line-height: 1.45;
    color: var(--text-light);
}

.form-control-feedback {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
    z-index: 2;
    font-size: 0.8125rem;
}

.inputSearch-control {
    padding-left: 38px !important;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-control);
    background: var(--white);
    font-size: 0.8438rem;
    width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.inputSearch-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 53, 100, .09);
}

.filter-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

.btn-filter {
    height: 40px;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    position: relative;
    white-space: nowrap;
    border-radius: var(--radius-control);
}

.filter-badge {
    position: absolute;
    top: -6px; right: -6px;
    background-color: var(--primary);
    color: #fff;
    border-radius: 10px;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6562rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', 'Nokora', monospace;
    padding: 0 6px;
    border: 2px solid var(--white);
}

/* ---- Advanced panel -------------------------------------------------------- */

.advanced-filters-panel {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    margin-bottom: 1.1rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    animation: slideDown .25s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .advanced-filters-panel { animation: none; }
}

.advanced-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .85rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    background-color: var(--slate-50);
}

.filter-panel-title {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--slate-900);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.filter-panel-title i { color: var(--slate-400); }

.advanced-filters-content { padding: 1.15rem 1.25rem; }

.filter-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.filter-row:last-child { margin-bottom: 0; }

.filter-group { flex: 1; min-width: 210px; display: flex; flex-direction: column; gap: .4rem; }

.filter-group-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: .04em;
    text-transform: uppercase;
    margin: 0;
}

.filter-group-controls { display: flex; align-items: center; gap: .5rem; }

.filter-separator { color: var(--muted); font-size: 0.75rem; flex-shrink: 0; }

.advanced-filters-footer {
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
    padding: .85rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
    background-color: var(--slate-50);
}

/* ---- Active filter chips --------------------------------------------------- */

.active-filters-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .65rem .9rem;
    background-color: var(--slate-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-control);
    margin-bottom: 1rem;
}

.active-filters-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .22rem .6rem;
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-badge);
    font-size: 0.7188rem;
    font-weight: 600;
    color: var(--slate-700);
    box-shadow: var(--shadow-xs);
}

.filter-chip a { color: var(--muted); display: inline-flex; }
.filter-chip a:hover { color: var(--danger); }

/* ============================ Operational list ============================ *
   A queue row is an operational summary of one file: what it is, who holds it, what is owed
   and by when. Three bands do that work - identity, supporting detail, state-specific facts -
   with ownership, deadline and the single next action pulled to the trailing edge where the
   eye finishes.

   Restraint is the rule. Most rows stay white and carry their state in one badge; the tinted
   backgrounds below are reserved for the few conditions worth interrupting a scan, because a
   list where every row is coloured has no emphasis at all.
 * ---------------------------------------------------------------- */

.portal-list { display: flex; flex-direction: column; }

.portal-list-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    border-left: 4px solid transparent;
    transition: background-color .12s ease;
}

.portal-list-row:last-child { border-bottom: none; }
.portal-list-row:hover { background-color: var(--slate-50); }

/* The four states worth marking. Each also carries a badge, so the colour is reinforcement
   rather than the only signal - the row still reads without colour vision. */
.portal-list-row.is-correction { background-color: rgba(217, 119, 6, .04); border-left-color: var(--warning); }
.portal-list-row.is-overdue    { background-color: rgba(225, 29, 72, .04); border-left-color: var(--danger); }
.portal-list-row.is-success    { background-color: rgba(5, 150, 105, .04); border-left-color: var(--success); }
.portal-list-row.is-rejected   { background-color: var(--slate-50); border-left-color: var(--slate-300); }

/* A file nobody can act on any more reads back a step, without becoming unreadable. */
.portal-list-row.is-readonly .portal-list-title { color: var(--slate-700); }

.portal-list-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: .3rem; }

.portal-list-headline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}

.portal-list-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--slate-900);
    line-height: 1.35;
}

.portal-list-meta,
.portal-list-facts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .3rem 1rem;
    font-size: 0.7188rem;
    color: var(--text-light);
    line-height: 1.5;
}

.portal-list-meta strong { color: var(--slate-700); font-weight: 600; }

/* ---- State-specific facts ------------------------------------------------- */

.portal-fact { display: inline-flex; align-items: baseline; gap: .3rem; }

.portal-fact-label {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}

.portal-fact-value {
    font-family: 'JetBrains Mono', 'Nokora', monospace;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--slate-900);
}

.portal-activity { font-size: 0.6875rem; color: var(--muted); font-style: italic; }

/* ---- Ownership, deadline, action ------------------------------------------ */

.portal-list-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .45rem;
    flex-shrink: 0;
    text-align: right;
}

.portal-incharge { display: flex; flex-direction: column; line-height: 1.35; }

.portal-incharge-label {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}

.portal-incharge-name { font-size: 0.7812rem; font-weight: 700; color: var(--slate-900); }
.portal-incharge-role { font-size: 0.6875rem; color: var(--text-light); }

.portal-list-actions { display: flex; align-items: center; gap: .4rem; margin-top: .15rem; }

/* ---- Status badges --------------------------------------------------------- *
   Styled by meaning rather than by business code, so a new status is a data change and one
   line in the resolver rather than a hunt through the screens for the switch that colours it.
 * ---------------------------------------------------------------- */

.portal-status {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: 3px 9px;
    border-radius: var(--radius-badge);
    border: 1px solid transparent;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
}

.portal-status-neutral    { background: var(--slate-100); color: var(--slate-700); border-color: var(--slate-200); }
.portal-status-info       { background: #e0f2fe; color: #075985; border-color: #7dd3fc; }
.portal-status-waiting    { background: #e0e7ff; color: #312e81; border-color: #c7d2fe; }
.portal-status-warning    { background: #fef3c7; color: #78350f; border-color: #fcd34d; }

/* Correction is amber-orange and deliberately not the danger red: an applicant asked to fix a
   document has a live application and a deadline, and colouring that as a refusal tells the
   officer scanning the queue the opposite of what is true. */
.portal-status-correction { background: #ffedd5; color: #7c2d12; border-color: #fdba74; }

.portal-status-success    { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.portal-status-approval   { background: #ede9fe; color: #4c1d95; border-color: #c4b5fd; }
.portal-status-danger     { background: #ffe4e6; color: #9f1239; border-color: #fda4af; }

/* ---- SLA ------------------------------------------------------------------- */

.portal-sla {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-family: 'JetBrains Mono', 'Nokora', monospace;
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-badge);
    border: 1px solid transparent;
    white-space: nowrap;
}

.portal-sla-ontrack { color: var(--text-light); background: var(--slate-100); border-color: var(--slate-200); }
.portal-sla-soon    { color: #78350f; background: #fef3c7; border-color: #fcd34d; }
.portal-sla-overdue { color: #9f1239; background: #ffe4e6; border-color: #fda4af; }

/* A paused clock is its own state, not a missing one: the ministry is not late while the file
   sits with the applicant, and showing nothing would read as "no deadline". */
.portal-sla-none    { color: var(--muted); background: transparent; border-color: var(--border-color); }

/* ---- Quick filter tabs ------------------------------------------------------ *
   Each tab is a real server-side filter across the whole dataset. A tab that only hid rows on
   the current page would show a count of two and then list nothing.
 * ---------------------------------------------------------------- */

.filter-tabs {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
    margin-bottom: 1.1rem;
}

.filter-tab {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .75rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--slate-200);
    background: var(--slate-100);
    color: var(--slate-500);
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1.6;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.filter-tab:hover { background: var(--slate-200); color: var(--slate-700); }

/* The selected tab goes near-black rather than brighter: it is the one that has stopped being
   a suggestion, and it must not compete with the status tints beside it. */
.filter-tab.is-active,
.filter-tab.is-active:hover {
    background: var(--slate-900);
    border-color: var(--slate-900);
    color: #fff;
    box-shadow: var(--shadow-xs);
}

.filter-tab-warning    { background: #fef3c7; color: #78350f; border-color: #fde68a; }
.filter-tab-correction { background: #ffedd5; color: #7c2d12; border-color: #fdba74; }
.filter-tab-info       { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.filter-tab-waiting    { background: #e0e7ff; color: #312e81; border-color: #c7d2fe; }
.filter-tab-success    { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.filter-tab-approval   { background: #ede9fe; color: #4c1d95; border-color: #ddd6fe; }
.filter-tab-danger     { background: #ffe4e6; color: #9f1239; border-color: #fecdd3; }

.filter-tab-count {
    font-family: 'JetBrains Mono', 'Nokora', monospace;
    font-size: 0.625rem;
    opacity: .75;
}

.filter-tab.is-active .filter-tab-count { opacity: .9; }

/* ---- Narrow screens --------------------------------------------------------- *
   The side block moves under the detail rather than being dropped. Who holds a file and when
   it is due are the two things an officer opened the queue to find out, so neither is hidden
   on a phone; only the alignment changes.
 * ---------------------------------------------------------------- */

@media (max-width: 900px) {
    .portal-list-row { flex-direction: column; gap: .75rem; }

    .portal-list-side {
        align-items: flex-start;
        text-align: left;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        border-top: 1px dashed var(--border-color);
        padding-top: .6rem;
    }

    .portal-list-actions { margin-top: 0; }
}

/* ============================ Forms ============================ */

.form-control {
    width: 100%;
    padding: .5rem .8rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 53, 100, .1);
}

.form-control:disabled, .form-control[readonly] {
    background-color: var(--bg-light);
    cursor: not-allowed;
}

input[type="text"].form-control,
input[type="date"].form-control,
select.form-control { height: 38px; }

textarea.form-control { min-height: 90px; resize: vertical; font-family: inherit; }

.control-label { font-weight: 500; color: #4a5568; font-size: 0.8438rem; display: block; margin-bottom: .3rem; }
.control-label .required { color: var(--danger); margin-left: .2rem; }

.field-error { color: var(--danger); font-size: 0.7812rem; margin-top: .3rem; display: block; }

.validation-summary {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid var(--danger);
    color: #991b1b;
    border-radius: 6px;
    padding: .8rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.8438rem;
}

.validation-summary ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* ============================ States ============================ */

.empty-data-container {
    text-align: center;
    padding: 52px 20px;
    background-color: var(--bg-light);
    border-radius: 8px;
    margin: 8px 0;
}

.empty-data-container i { font-size: 2.6rem; color: #adb5bd; margin-bottom: 16px; display: block; }
.empty-data-container h4 { color: #495057; font-weight: 600; margin-bottom: 8px; font-size: 1rem; }
.empty-data-container p { color: var(--text-light); font-size: 0.8438rem; margin: 0; }

.page-message {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left: 4px solid var(--info);
    color: #1e40af;
    border-radius: 6px;
    padding: .75rem 1rem;
    margin-bottom: 1.15rem;
    font-size: 0.8438rem;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
}

.read-only-banner {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid var(--warning);
    color: #92400e;
}

.results-info { font-size: 0.8125rem; margin: 14px 2px 0; color: var(--text-light); }
.results-info strong { color: #495057; font-weight: 600; }

/* ============================ Pager ============================ */

.pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 16px 0 4px;
}

.pager a, .pager span {
    display: inline-block;
    min-width: 36px;
    height: 36px;
    line-height: 34px;
    text-align: center;
    padding: 0 10px;
    border-radius: 6px;
    font-size: 0.8438rem;
    font-weight: 500;
    color: #495057;
    background-color: #fff;
    border: 1px solid var(--border-color);
}

.pager a:hover { background-color: #e9ecef; border-color: #adb5bd; color: #212529; }
.pager span.current { background-color: var(--primary); color: #fff; border-color: var(--primary); }
.pager span.disabled { opacity: .45; cursor: not-allowed; }

/* ============================ Dashboard ============================ *
   A metric card is a label, a number and a line of context, in that order of size. No icon
   and no coloured edge: on a row of four, the icons became the pattern and the numbers - the
   only part anyone reads - stopped being the loudest thing on the card.
 * ---------------------------------------------------------------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .9rem;
    margin-bottom: 1.25rem;
}

/* Five across on a desktop, which is what puts the dashboard's two groups on their own rows:
   the five stages of the process above, the three exceptions below. auto-fill alone decides
   the count from the available width and would split them wherever the window happened to be. */
@media (min-width: 1200px) {
    .stat-grid { grid-template-columns: repeat(5, 1fr); }
}

.stat-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-xs);
    padding: 1.1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    transition: box-shadow .15s ease, border-color .15s ease;
}

.stat-card:hover { box-shadow: var(--shadow-md); border-color: var(--slate-300); }

.stat-card .stat-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: .06em;
    text-transform: uppercase;
    line-height: 1.4;
    order: 1;
}

.stat-card .stat-value {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--slate-900);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    order: 2;
}

.stat-card .stat-hint {
    display: block;
    font-size: 0.7188rem;
    font-weight: 400;
    color: var(--muted);
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.45;
    order: 3;
}

/* Semantic colour lives on the number, which is the thing being judged. */
.card-accent-primary .stat-value { color: var(--primary); }
.card-accent-danger  .stat-value { color: var(--danger); }
.card-accent-warning .stat-value { color: var(--warning); }
.card-accent-success .stat-value { color: var(--success); }
.card-accent-info    .stat-value { color: var(--info); }

/* ============================ Detail header ============================ */

.detail-header {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.25rem;
}

/* Left column takes the room; the right column is only as wide as the portrait.
   align-items: start keeps the badges at the top rather than centring them against a
   facts grid that is far taller than they are. */
.detail-header-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 1rem 1.5rem;
}

.detail-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .6rem;
}

.detail-number { font-size: 1.1875rem; font-weight: 700; color: var(--primary); margin: 0; }
.detail-subject { font-size: 0.8438rem; color: var(--text-light); margin: .2rem 0 0; }

/* Status badges, and beneath them the applicant portrait - both against the right edge. */
.detail-badges-row { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; justify-content: flex-end; }

.detail-facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: .75rem 1.5rem;
    margin-top: .9rem;
    padding-top: .9rem;
    border-top: 1px solid #f1f3f5;
}

.detail-fact-label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-light); }
.detail-fact-value { font-size: 0.8438rem; font-weight: 500; margin-top: .1rem; }
.detail-fact-note { font-size: 0.75rem; color: var(--text-light); margin-top: .1rem; overflow-wrap: anywhere; }

/* ============================ Tabs ============================ */

.portal-tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.portal-tabs::-webkit-scrollbar { display: none; }

.portal-tabs a {
    padding: .6rem 1rem;
    font-size: 0.8438rem;
    font-weight: 500;
    color: var(--text-light);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.portal-tabs a:hover { color: var(--primary); }

.portal-tabs a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.portal-tabs .tab-count {
    background: #f1f3f5;
    color: #495057;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 0.6875rem;
    font-weight: 600;
}

.portal-tabs a.active .tab-count { background: var(--primary); color: #fff; }

/* Sub-tabs inside a tab (the site inspection tab's PHD / MoH): the same strip, one size down. */
.portal-tabs.portal-subtabs { border-bottom-width: 1px; margin-top: -.5rem; margin-bottom: 1rem; }
.portal-tabs.portal-subtabs a { padding: .45rem .85rem; font-size: 0.8125rem; border-bottom-width: 2px; margin-bottom: -1px; }

/* ============================ Approval tier strip ============================ */

.tier-strip {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    padding: .25rem 0 .75rem;
    -webkit-overflow-scrolling: touch;
}

.tier-node {
    flex: 1 0 150px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: .7rem .8rem;
    background: #fff;
    position: relative;
}

.tier-node .tier-index {
    font-size: 0.6562rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-light);
}

.tier-node .tier-name { font-size: 0.8125rem; font-weight: 600; margin: .15rem 0 .3rem; }
.tier-node .tier-meta { font-size: 0.7188rem; color: var(--text-light); }

.tier-node.state-approved { border-color: #bbf7d0; background: #f0fdf4; }
.tier-node.state-current  { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,53,100,.1); }
.tier-node.state-returned { border-color: #fde68a; background: #fffbeb; }
.tier-node.state-rejected { border-color: #fecaca; background: #fef2f2; }
.tier-node.state-pending  { opacity: .62; }

/* Seven tiers do not fit across a side column, so the decision page stacks the same nodes. */
.tier-strip.is-vertical {
    display: block;
    overflow-x: visible;
    padding: .75rem;
}

.tier-strip.is-vertical .tier-node { margin-bottom: .45rem; }
.tier-strip.is-vertical .tier-node:last-child { margin-bottom: 0; }

/* An approval tier's reason for sending a dossier back to the committee.

   Amber rather than red: the file has not failed, it has been asked a question, and an officer
   scanning the page should read it as the instruction this round exists to answer. It sits above
   the standards picker because which standards to inspect is the first decision it informs. */
.card-body.tight.returned-note {
    padding: .85rem 1.25rem;
    background: #fff9ec;
    border-left: 3px solid var(--warning, #e0a800);
}

.returned-note-head {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #7a5600;
    margin-bottom: .35rem;
}

.returned-note-head i { margin-right: .4rem; }

.returned-note-by { font-weight: 700; }

/* The moment it was sent back, set apart from the name so the two do not read as one string. */
.returned-note-when {
    font-weight: 400;
    color: #8a6d3b;
    white-space: nowrap;
}

/* The approver's own words, set apart from the label above them. */
.returned-note-comment {
    margin: 0;
    padding: 0 0 0 .75rem;
    border-left: 2px solid #e8d5a8;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-color, #212529);
}

@media (max-width: 575.98px) {
    .card-body.tight.returned-note { padding: .75rem 1rem; }
}

/* ============================ Checklist ============================ */

/* Same story as the attachment groups: these sit in a `tight` body, which zeroes the padding,
   and their headings have to line up with the round title in the card header above rather than
   sitting hard against the card wall.

   The standards picker was missing from this list, so it alone rendered flush to the card edge
   while every section under it was inset. */
.card-body.tight.checklist-body,
.card-body.tight.standards-section {
    padding: 1rem 1.25rem 1.25rem;
}

.checklist-section { margin-bottom: 1.5rem; }

/* An MoH round answers as many as five ministry standards in one form - nearly three hundred
   questions. The banner is what tells the officer which room they are in; without it the
   headings inside two standards ("Section A: Room") are word for word identical. It is also the
   handle that folds the standard away, so an officer working one of the five can put the other
   four out of sight without losing the answers in them. */
.checklist-standard-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    width: 100%;
    margin: 1.5rem 0 1rem;
    padding: .6rem .9rem;
    background: var(--bg-subtle, #f4f6f9);
    border: 0;
    border-left: 4px solid var(--primary);
    border-radius: 4px;
    text-align: left;
    cursor: pointer;
}

.checklist-standard-banner:hover { background: #eaeef3; }

.checklist-standard-banner:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.checklist-standard-name {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--primary);
}

.checklist-standard-meta {
    display: flex;
    align-items: center;
    gap: .6rem;
    white-space: nowrap;
}

/* The first standard sits directly under the card header, which already provides the gap. */
.checklist-body > .checklist-standard:first-child > .checklist-standard-banner { margin-top: 0; }

/* Collapsed hides the questions and nothing else. The inputs are still in the form and still
   post, which is what makes folding a part-answered standard away safe. */
.checklist-standard.is-collapsed .checklist-standard-body { display: none; }

.checklist-standard.is-collapsed .checklist-standard-banner { margin-bottom: 0; }

/* All correct / all incorrect, above one standard's first heading. */
.checklist-bulk {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin: 0 0 1rem;
}

.checklist-standard-chevron { transition: transform .15s ease; }

.checklist-standard.is-collapsed .checklist-standard-chevron { transform: rotate(180deg); }

/* How much of a standard is answered. Under MANUAL - which every ministry standard uses -
   completeness is the only thing standing between the officer and their decision, so this is the
   number that says whether the round can be submitted today. */
.checklist-progress {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.checklist-progress.is-partial { background: #fdf3e3; color: #8a5a00; }
.checklist-progress.is-complete { background: #e6f5ea; color: #1c6b34; }

.checklist-progress-overall { margin-bottom: .25rem; }

/* The picker keeps the card's own rhythm; it is marked out for the script, not for the eye. */
.standard-picker { display: block; }

/* ==================== The inspection report on the case file ====================

   What a round found, laid out like the form it was answered on rather than as a grid. It was a
   four-column table with the section name repeated on every row, which reads as a spreadsheet:
   three hundred rows of identical section names, and no way to see which points sat under which
   heading. This groups by standard, keeps the headings as headings, and indents. */

.report-standard { margin-bottom: 1.25rem; }
.report-standard:last-child { margin-bottom: 0; }

.report-standard-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .5rem .7rem;
    background: var(--bg-subtle, #f4f6f9);
    border-left: 3px solid var(--primary);
    border-radius: 3px;
    margin-bottom: .35rem;
}

.report-standard-head h5 {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--primary);
}

/* The English title under the Khmer one, as the ministry's form prints it. Normal weight and
   muted, so the Khmer above it stays the heading. */
.report-standard-en {
    display: block;
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--text-muted, #6c757d);
}

.report-standard-tally { white-space: nowrap; }

/* One row: number, requirement, answer. Grid rather than a table so the indent can be a padding
   on the row itself - in a table the cells are what carry the padding, and indenting the first
   cell alone leaves the requirement text unmoved. */
.report-row {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    gap: .6rem;
    align-items: baseline;
    padding: .35rem .5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8125rem;
}

.report-row:last-child { border-bottom: 0; }

.report-row-number {
    font-size: 0.6875rem;
    color: var(--text-muted, #6c757d);
    font-variant-numeric: tabular-nums;
}

.report-row-text { min-width: 0; }

/* The English under the Khmer, the way the ministry's form prints it. */
.report-row-en {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-muted, #6c757d);
}

.report-row-answer { white-space: nowrap; }

/* A heading takes no answer, and is what tells the reader which room they are in. */
.report-row-heading {
    background: #fbfcfd;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    margin-top: .3rem;
}

.report-row-heading .report-row-text { color: var(--primary); }

/* On a narrow screen the answer drops under the requirement rather than squeezing it to a
   column two words wide. */
@media (max-width: 575.98px) {
    .report-row {
        grid-template-columns: 56px 1fr;
    }

    .report-row-answer {
        grid-column: 2;
        padding-top: .2rem;
    }
}

/* The standards list is styled by .checkbox-list, like every other checkbox list in the portal.
   It had a class of its own here and rendered nothing an operator could see; there was nothing
   this rule gave that the shared one does not. */

/* The last section carries the card's own bottom padding; a second gap under it reads as a
   stray empty row. */
.checklist-body .checklist-section:last-child { margin-bottom: 0; }

.checklist-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: .75rem;
}

.checklist-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: .9rem 1rem;
    margin-bottom: .65rem;
    background: #fff;
}

.checklist-item.is-fail { border-left: 4px solid var(--danger); background: #fffafa; }
.checklist-item.is-pass { border-left: 4px solid var(--success); }
.checklist-item.is-blocking .checklist-code { color: var(--danger); }

.checklist-item-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.checklist-code {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--text-light);
}

.checklist-question { font-size: 0.8438rem; font-weight: 500; margin: .2rem 0 0; }

.checklist-answers { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; flex-shrink: 0; }
.checklist-answers label { font-size: 0.8125rem; margin: 0; display: inline-flex; align-items: center; gap: .3rem; }

.checklist-comment { margin-top: .6rem; }
.checklist-comment .form-control + .form-control { margin-top: .4rem; }

/* RadioButtonList renders a table or a flow of spans depending on RepeatLayout; both need to
   read as a stack of labelled choices rather than as data. */
.decision-list label,
.checklist-answers label {
    font-size: 0.8125rem;
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    white-space: nowrap;
}


/* RepeatLayout="Flow" renders the three answers as bare <input><label> pairs inside one span, so
   the flex gap on .checklist-answers applies to that single span and not between the choices -
   which ran them together as "Yes○No○None / not applicable". The pairs are spaced here instead. */
.checklist-answers input[type="radio"] { margin: 0 .3rem 0 0; }
.checklist-answers label { margin-right: 1.1rem; }
.checklist-answers label:last-of-type { margin-right: 0; }

.decision-list td { padding: .1rem .4rem .1rem 0; border: 0; }
.decision-list input[type="radio"] { margin: 0; }

.checkbox-inline { margin-top: .5rem; }
.checkbox-inline label { font-size: 0.8125rem; display: inline-flex; align-items: center; gap: .3rem; }

/* Result of the dry-run evaluation, shown before the inspector commits. */
.preview-panel {
    border-top: 1px solid var(--border-color);
    background: var(--bg-light);
}

.preview-verdict { margin-bottom: .35rem; }

@media (max-width: 575.98px) {
    .checklist-answers { width: 100%; }
    .checklist-answers label { white-space: normal; }
}

/* ============================ Timeline ============================ */

.timeline-group {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    background: #fff;
    overflow: hidden;
}

.timeline-group-head {
    padding: .7rem 1rem;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    align-items: center;
}

.timeline-group-title { font-size: 0.8438rem; font-weight: 600; color: var(--primary); }

.timeline { list-style: none; margin: 0; padding: .75rem 1rem; position: relative; }

.timeline::before {
    content: '';
    position: absolute;
    left: 26px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #eef0f3;
}

.timeline li { position: relative; padding: .55rem 0 .55rem 44px; }

.timeline li .timeline-dot {
    position: absolute;
    left: 12px;
    top: .7rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-light);
}

.timeline-accent-success .timeline-dot { border-color: #86efac; color: #15803d; }
.timeline-accent-danger  .timeline-dot { border-color: #fca5a5; color: #b91c1c; }
.timeline-accent-warning .timeline-dot { border-color: #fcd34d; color: #b45309; }
.timeline-accent-info    .timeline-dot { border-color: #93c5fd; color: #1d4ed8; }
.timeline-accent-primary .timeline-dot { border-color: var(--primary); color: var(--primary); }

.timeline-title { font-size: 0.8438rem; font-weight: 600; }
.timeline-meta { font-size: 0.7188rem; color: var(--text-light); margin-top: .1rem; }
.timeline-comment {
    font-size: 0.8125rem;
    margin-top: .35rem;
    padding: .45rem .7rem;
    background: var(--bg-light);
    border-radius: 6px;
}

/* ============================ Document viewer ============================ */

.doc-viewer { border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; background: #fff; }

.doc-viewer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1rem;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.doc-viewer-title { font-size: 0.8438rem; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.doc-viewer-meta { font-size: 0.7188rem; color: var(--text-light); }

/* The frame scales with the viewport so the document stays usable on a laptop
   or tablet without the page itself scrolling sideways. */
.doc-viewer-frame {
    width: 100%;
    min-height: 320px;
    border: 0;
    display: block;
    background: #525659;
}

.doc-viewer-image { width: 100%; height: auto; display: block; background: #f1f3f5; }

.doc-viewer-unsupported { padding: 2.5rem 1.25rem; text-align: center; color: var(--text-light); }
.doc-viewer-unsupported i { font-size: 2.4rem; display: block; margin-bottom: .75rem; opacity: .5; }

/* ============================ Toasts ============================ */

.toast-container {
    position: fixed;
    top: 84px;
    right: 24px;
    z-index: 9999;
    pointer-events: none;
    max-width: 420px;
}

.toast-item {
    pointer-events: auto;
    margin-bottom: 10px;
    opacity: 0;
    transform: translateX(420px);
    transition: all .35s cubic-bezier(.68, -.55, .265, 1.55);
}

.toast-item.show { opacity: 1; transform: translateX(0); }
.toast-item.hide { opacity: 0; transform: translateX(420px); transition: all .25s ease-in; }

.toast-alert {
    position: relative;
    border-radius: 8px;
    padding: .95rem 2.8rem .95rem 1rem;
    border: 1px solid transparent;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .14);
    font-size: 0.8438rem;
    line-height: 1.5;
    min-width: 240px;
    overflow-wrap: anywhere;
}

.toast-alert.success { background: #ecfdf5; color: #065f46; border-left: 4px solid #10b981; }
.toast-alert.error   { background: #fef2f2; color: #991b1b; border-left: 4px solid #ef4444; }
.toast-alert.warning { background: #fffbeb; color: #92400e; border-left: 4px solid #f59e0b; }
.toast-alert.info    { background: #eff6ff; color: #1e40af; border-left: 4px solid #3b82f6; }

.toast-close {
    position: absolute;
    top: 50%; right: 1rem;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: .5;
    line-height: 1;
    font-weight: 700;
}

.toast-close:hover { opacity: 1; }

.toast-progress {
    position: absolute;
    bottom: 0; left: 0;
    height: 3px;
    background-color: currentColor;
    opacity: .3;
    width: 100%;
}

.toast-progress.animate { animation: toast-progress 5s linear forwards; }

@keyframes toast-progress { from { width: 100%; } to { width: 0%; } }

/* ============================ Modal ============================ */

.modal-content { border-radius: 8px; border: none; }
.modal-header { border-bottom: 1px solid var(--border-color); padding: 1rem 1.25rem; }
.modal-title { font-size: 0.9375rem; font-weight: 600; color: var(--primary); }
.modal-body { padding: 1.25rem; font-size: 0.875rem; }
.modal-footer { border-top: 1px solid var(--border-color); padding: .85rem 1.25rem; }

/* ============================ Responsive ============================ */

@media (max-width: 991.98px) {
    body:not(.sidebar-mini-md):not(.sidebar-mini-xs):not(.layout-top-nav) .content-wrapper,
    body:not(.sidebar-mini-md):not(.sidebar-mini-xs):not(.layout-top-nav) .main-footer,
    body:not(.sidebar-mini-md):not(.sidebar-mini-xs):not(.layout-top-nav) .main-header {
        margin-left: 0 !important;
    }

    .main-sidebar { margin-left: -250px; transition: margin-left .3s; }
    .sidebar-open .main-sidebar { margin-left: 0; }

    .detail-facts { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    table.grid { font-size: 0.8125rem; }
    table.grid th, table.grid td { padding: 8px 7px; }
}

@media (max-width: 767.98px) {
    .page-heading { flex-direction: column; align-items: stretch; }
    .page-heading-actions { justify-content: flex-start; }
    .page-heading h1 { font-size: 1.1875rem; }

    .action-bar { flex-direction: column; align-items: stretch; }
    .action-bar .btn { width: 100%; }

    .query-section { flex-direction: column; align-items: stretch; }
    .form-group.has-search { max-width: 100%; }

    /* 16px stops iOS from zooming when the field takes focus. */
    .inputSearch-control, .form-control { font-size: 1rem; }

    .filter-row { flex-direction: column; }
    .filter-group { min-width: 100%; }
    .advanced-filters-footer { flex-direction: column; }
    .advanced-filters-footer .btn { width: 100%; }

    /* Below the 56px header, not over it, and clear of a phone's notch. */
    .toast-container { top: calc(64px + env(safe-area-inset-top, 0px)); right: 10px; left: 10px; max-width: none; }
    .toast-item { transform: translateY(-120px); }
    .toast-item.show { transform: translateY(0); }
    .toast-item.hide { transform: translateY(-120px); }

    .stat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .stat-card .stat-value { font-size: 1.375rem; }

    .doc-viewer-frame { height: 58vh; }

    table.detail-table th, table.detail-table td { display: block; width: 100%; padding: 4px 0; }
    table.detail-table th { color: var(--text-light); font-size: 0.75rem; }
    table.detail-table tr + tr th { border-top: 1px solid #f1f3f5; padding-top: 10px; }
    table.detail-table tr + tr td { border-top: none; }

    .tier-node { flex: 1 0 130px; }
}

@media (max-width: 575.98px) {
    .content-header { padding: .75rem .75rem 0; }
    .card-body, .card-header { padding: 1rem; }
    /* Follow the header down to 1rem so these stay aligned on phones as well. */
    .card-body.tight.attachment-section { padding: .875rem 1rem 1rem; }
    .card-body.tight.checklist-body,
    .card-body.tight.standards-section { padding: .875rem 1rem 1rem; }
    .detail-header { padding: 1rem; }
    .page-heading h1 { font-size: 1.0625rem; }
}

/* ============================ Print ============================ */

@media print {
    .main-sidebar, .main-header, .main-footer, .action-bar,
    .sidebar-overlay, .query-section, .advanced-filters-panel,
    .pager, .portal-tabs, .page-heading-actions { display: none !important; }

    html, body { height: auto; overflow: visible; }
    .wrapper, .content-wrapper, section.content { height: auto; overflow: visible; display: block; }
    .content-wrapper { margin: 0 !important; }

    .card { border: 1px solid #000; box-shadow: none; break-inside: avoid; }
    table.grid th, table.grid td { border: 1px solid #000; padding: 5px; }
    table.grid thead { background: #fff !important; color: #000 !important; }
}

/* ---- Sidebar badge ---------------------------------------------------------- *
   A count sits at the trailing edge of a nav item, only where it means "this is waiting for
   you". Gold on the navy rail, so it reads as part of the ministry's trim rather than as an
   alert - the queue itself is where urgency belongs.
 * ---------------------------------------------------------------- */

.nav-sidebar .nav-link .nav-badge {
    margin-left: auto;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(201, 162, 39, .18);
    border: 1px solid rgba(201, 162, 39, .45);
    color: var(--accent-gold-soft);
    font-family: 'JetBrains Mono', 'Nokora', monospace;
    font-size: 0.625rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.6;
    flex-shrink: 0;
}

.nav-sidebar .nav-link.active .nav-badge {
    background: rgba(246, 211, 101, .22);
    border-color: rgba(246, 211, 101, .55);
    color: var(--accent-gold-bright);
}

.sidebar-mini.sidebar-collapse .nav-badge { display: none !important; }

/* ============================ Overview strip ============================ *
   The summary above a queue. It answers three questions before an officer reads a row: how
   much work exists, what kind is waiting, and where attention is required.

   Each card is also a way in - pressing one applies the same filter its matching quick-filter
   tab applies, because both are the same category. So a card is built to look pressable, and
   the one card that is a total rather than a filter deliberately is not.
 * ---------------------------------------------------------------- */

/* One row however many cards the desk has - four on most desks, five on SCU Back's. */
.portal-metrics {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: .9rem;
    margin-bottom: 1.1rem;
}

.portal-metric {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: 1rem 1.1rem;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-xs);
    text-align: left;
    text-decoration: none;

    /* Height follows the content. A fixed height clips Khmer, whose taller glyph stack needs
       more room than the same sentence in English. */
    min-height: 0;
}

.portal-metric-title {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-light);
    line-height: 1.45;
}

.portal-metric-value {
    font-size: 1.875rem;
    font-weight: 800;
    line-height: 1.15;
    color: var(--slate-900);
    font-variant-numeric: tabular-nums;
}

.portal-metric-desc {
    font-size: 0.7188rem;
    color: var(--muted);
    line-height: 1.45;
}

/* The number carries the meaning, in the same semantic colours the badges and rows use, so a
   card, a tab, a row accent and a status badge all say "correction" the same way. */
.portal-metric-info .portal-metric-value       { color: var(--info); }
.portal-metric-waiting .portal-metric-value    { color: #4338ca; }
.portal-metric-warning .portal-metric-value    { color: var(--warning); }
.portal-metric-correction .portal-metric-value { color: #c2410c; }
.portal-metric-success .portal-metric-value    { color: var(--success); }
.portal-metric-approval .portal-metric-value   { color: #6d28d9; }
.portal-metric-danger .portal-metric-value     { color: var(--danger); }

a.portal-metric.is-clickable { cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease; }

a.portal-metric.is-clickable:hover {
    border-color: var(--slate-300);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

a.portal-metric.is-clickable:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Two across on a tablet, and still two on a phone - four numbers in a column pushes the list
   itself below the fold, which defeats the point of a summary. */
@media (max-width: 1100px) {
    .portal-metrics { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 420px) {
    .portal-metrics { grid-auto-flow: row; grid-template-columns: minmax(0, 1fr); }
}

/* ==========================================================================
   Inspection attachments
   --------------------------------------------------------------------------
   The panel carries two lists that read differently. Evidence is scanned - an
   inspector looks for the photograph of the autoclave among twenty others, so
   the thumbnail does the identifying. An official document is looked up by
   name, so its title leads and the file name follows underneath.

   Cards rather than a table: a row would have to carry a title, a file name,
   a purpose, a size, an uploader, a date, a checklist reference and three
   actions, and at 430px that is a table nobody can read.
   ========================================================================== */

.attachment-panel .card-header h2,
.attachment-panel .card-header h3 {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.attachment-section + .attachment-section {
    border-top: 1px solid var(--border-color);
}

/* The attachment groups sit in a `tight` body so their dividers can run the full width of the
   card. Their contents still have to line up with the card's own heading above them, so the
   padding the `tight` modifier removed is put back here - matching .card-header's 1.25rem, which
   is what makes "Attachments and documents" sit under "Round 1", not to the left of it. */
.card-body.tight.attachment-section {
    padding: 1rem 1.25rem 1.25rem;
}

.attachment-section-title {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: .5rem;
    margin: 0 0 .75rem;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--slate-700);
}

.attachment-section-hint {
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-light);
}

.attachment-list {
    display: grid;
    gap: .625rem;
}

.attachment-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: .75rem;
    align-items: start;
    padding: .75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-control);
    background: var(--white);
}

.attachment-icon {
    font-size: 1.25rem;
    line-height: 1.2;
    color: var(--slate-400);
}

/* minmax(0, 1fr) above plus this is what keeps a 90-character Khmer file name from
   pushing the actions off the right edge of the page. */
.attachment-body { min-width: 0; }

.attachment-title {
    font-weight: 600;
    color: var(--text-dark);
    overflow-wrap: anywhere;
}

.attachment-filename,
.attachment-meta {
    font-size: 0.75rem;
    color: var(--text-light);
    overflow-wrap: anywhere;
}

.attachment-badges { display: flex; flex-wrap: wrap; gap: .25rem; margin: .25rem 0; }

.attachment-context,
.attachment-description {
    margin-top: .375rem;
    font-size: 0.75rem;
    color: var(--slate-700);
    overflow-wrap: anywhere;
}

.attachment-context { display: flex; gap: .375rem; align-items: baseline; }

.attachment-actions {
    display: flex;
    gap: .25rem;
    flex-shrink: 0;
}

/* A photograph identifies itself; capped so a portrait shot cannot make one card
   taller than the screen. */
.attachment-thumb { display: inline-block; margin-top: .5rem; }

.attachment-thumb img {
    max-width: 200px;
    max-height: 140px;
    width: auto;
    height: auto;
    border-radius: var(--radius-badge);
    border: 1px solid var(--border-color);
    object-fit: cover;
}

/* Collapsed by default, and the frame's source is only filled in when it is opened -
   twenty scanned reports on one page would otherwise be twenty storage reads nobody
   asked for. */
.attachment-preview { margin-top: .5rem; }

.attachment-preview > summary {
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--primary);
    width: fit-content;
}

.attachment-preview iframe {
    width: 100%;
    height: 480px;
    margin-top: .5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-badge);
    background: var(--slate-50);
}

.attachment-empty,
.attachment-closed {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .875rem;
    border-radius: var(--radius-control);
    background: var(--bg-light);
    font-size: 0.8125rem;
    color: var(--text-light);
}

.attachment-closed {
    background: var(--slate-100);
    color: var(--slate-700);
}

.attachment-upload {
    margin-top: .875rem;
    padding-top: .875rem;
    border-top: 1px dashed var(--border-color);
}

/* The round is closed to evidence but still open to paperwork. Saying so where the
   form is, rather than only in a banner at the top, is what stops an officer
   assuming the upload will not be recorded. */
.attachment-notice {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    margin-bottom: .75rem;
    padding: .625rem .75rem;
    border-radius: var(--radius-control);
    border: 1px solid #c4b5fd;
    background: #f5f3ff;
    font-size: 0.7812rem;
    color: #5b21b6;
}

.attachment-panel-history { opacity: .92; }

.attachment-list-compact .attachment-card { padding: .5rem .625rem; }

/* Phones. The actions move under the text rather than competing with it for width,
   and the preview frame shrinks to something that still fits above the fold. */
@media (max-width: 640px) {
    .attachment-card {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .attachment-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
        padding-top: .25rem;
        border-top: 1px solid var(--border-subtle);
    }

    .attachment-thumb img { max-width: 100%; max-height: 180px; }

    .attachment-preview iframe { height: 320px; }
}

/* ---------------------------------------------------------------------------
   Clickable queue rows

   The whole row opens the case file. The cursor and the focus ring are what say
   so - without them a row that navigates on click is a trap, because nothing
   distinguishes it from the static text it looks like.

   The row is focusable, so the shortcut works from the keyboard too and is not
   a mouse-only affordance.
   --------------------------------------------------------------------------- */
.portal-list-clickable { cursor: pointer; }

.portal-list-clickable:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

/* The action buttons keep their own pointer, so the row's cursor does not imply
   that pressing them does what pressing the row does. */
.portal-list-clickable a,
.portal-list-clickable button { cursor: pointer; }

/* ---------------------------------------------------------------------------
   Applicant portrait in the file header

   Fixed dimensions, not max-width. An unbounded image renders at its natural
   size - a 1200px photograph then sets the height of the whole header and
   pushes the facts and the tab strip off the first screen, which is what
   happened when this was first added.

   object-fit keeps a portrait that is not 4:5 from being stretched: it is
   cropped to the frame instead, which is what a passport-style photograph
   expects anyway.
   --------------------------------------------------------------------------- */
.detail-portrait {
    width: 96px;
    height: 120px;
    border-radius: var(--radius-sm, 6px);
    overflow: hidden;
    background-color: var(--slate-100, #f1f5f9);
    border: 1px solid var(--slate-200, #e2e8f0);
    flex: none;
}

.detail-portrait a { display: block; width: 100%; height: 100%; }

.detail-portrait-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* On a narrow screen the header stacks, so the portrait moves to the left edge
   with the rest of the content rather than sitting alone against the right. */
@media (max-width: 767.98px) {
    /* One column: the portrait moves above the facts and sits with the rest of the
       content on the left rather than alone against the right edge. */
    .detail-header-grid { grid-template-columns: minmax(0, 1fr); }

    .detail-side {
        grid-row: 1;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: .75rem;
        flex-wrap: wrap;
    }

    .detail-badges-row { justify-content: flex-start; }

    .detail-portrait { width: 72px; height: 90px; }
}
/* ---------------------------------------------------------------------------
   Document verification checklist

   Fifty-one rows. The whole design problem is density: at a comfortable row
   height the list is four screens long, and a reviewer answering point 40 has
   scrolled the document they are judging it against off the page.

   So the two columns are pinned to the same height and the list scrolls inside
   its own box. The document stays where it is, and the reviewer's eye moves
   between two fixed panels instead of hunting up and down one long page.
   --------------------------------------------------------------------------- */

.review-split {
    align-items: flex-start;
}

/* The height both panes are cut to.

   The document is the fixed thing: it is what the reviewer is reading, and it wants as much
   of the screen as it can have. So it sets the measure, and the checklist is capped to the
   same figure rather than the two being derived from some sum of the headers above them.
   That arithmetic was wrong on one of the two screens every time it was tried, because the
   case file carries an application header that the review desk does not. */
:root {
    --review-pane-height: 70vh;
}

/* 40 for the list, 60 for the document. The document is the thing being judged and wants
   the room; a requirement still reads on one or two lines at 40%. */
@media (min-width: 1200px) {
    .review-split > .review-pane-list { flex: 0 0 40%; max-width: 40%; }
    .review-split > .review-pane-doc  { flex: 0 0 60%; max-width: 60%; }
}

/* The list scrolls inside its own box so the document beside it never moves. Fifty-one
   points down a growing page meant scrolling the PDF out of view to reach point 40. */
.checklist-scroll {
    max-height: var(--review-pane-height);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.doc-viewer-frame {
    height: var(--review-pane-height);
}

/* The reviewer's comment is its own card under the list, not a footer inside it. Inside the
   card it had to be given height of its own, which it took from the points - and being
   shrinkable, it then lost that height again and rendered clipped. */
.checklist-comment-card .card-body {
    padding: .9rem 1.25rem 1rem;
}

.checklist-section + .checklist-section {
    margin-top: .85rem;
}

/* The heading is what tells a reviewer where they are once the list is
   scrolling. It sticks to the top of the scroll box for exactly that reason. */
.checklist-section-title {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 0 0 .25rem;
    padding: .35rem .6rem;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .01em;
    background: var(--surface-muted, #f5f6f8);
    border-left: 3px solid var(--primary-color, #1a5fb4);
    border-radius: 3px;
}

/* One point per row: number, requirement, answer. Top-aligned, because a
   requirement that wraps to two lines should not push its own number down. */
.checklist-row {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    padding: .3rem .6rem;
    border-bottom: 1px solid var(--border-color, #e6e8eb);
    font-size: .8125rem;
    line-height: 1.35;
}

.checklist-row:last-child {
    border-bottom: none;
}

.checklist-row:hover {
    background: var(--surface-hover, #fafbfc);
}

.checklist-num {
    flex: 0 0 1.75rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    text-align: right;
}

.checklist-req {
    flex: 1 1 auto;
    min-width: 0;
}

.checklist-required {
    margin-left: .35rem;
    font-size: .7rem;
    font-weight: 600;
    color: var(--danger-color, #b42318);
    white-space: nowrap;
}

/* Pass and Fail sit side by side on one line, hard against the right edge, so
   the answers form a single column the eye can run straight down. */
.checklist-choice {
    flex: 0 0 auto;
    display: flex;
    gap: .65rem;
    white-space: nowrap;
}

.checklist-choice label {
    margin: 0 0 0 .2rem;
    font-weight: 400;
    cursor: pointer;
}

.checklist-choice input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

/* The note a comment-only point takes in place of the pass/fail choice - see
   Points_ItemDataBound in DocumentReview.aspx.cs, which shows one or the other and never both.
   It fills the width the two radio choices would have taken, so a checklist mixing both kinds
   of point still reads as one column of answers rather than a layout that jumps between rows.
   Deliberately its own class rather than a reuse of .checklist-comment: that one is a block
   panel sitting *below* a row elsewhere on this page, and giving a flex sibling *inside* the
   row the same name is what misaligned it in the first place. */
.checklist-row .checklist-note {
    flex: 1 1 240px;
    min-width: 160px;
    max-width: 26rem;
    margin: 0;
    padding: .3rem .6rem;
    font-size: .8125rem;
    line-height: 1.35;
    resize: vertical;
}

/* One reviewer's comment from an earlier round. */
.review-comment {
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--border-color, #e6e8eb);
    font-size: .8125rem;
}

.review-comment:last-child {
    border-bottom: none;
}

/* Stacked columns have no neighbour to stand level with, so the list stops being a box
   inside a long page and simply becomes part of it. */
@media (max-width: 1199.98px) {
    .checklist-scroll {
        max-height: none;
        overflow-y: visible;
    }

    .checklist-section-title {
        position: static;
    }
}

/* ============================ Account menu ============================
   The profile block in the top bar is the button that opens it, so the two
   are styled as one control: the block keeps its shape, and the caret and
   the panel below inherit the same radius and hairline as every card. */

.user-profile-section > .user-info {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.user-profile-section > .user-info:hover,
.user-profile-section.show > .user-info { background: var(--bg-light); }

/* Bootstrap's own caret is a border triangle that sits badly next to an
   icon set; the chevron is the one the rest of the portal uses. */
.user-profile-section > .dropdown-toggle::after { display: none; }

.user-caret {
    margin-left: .55rem;
    font-size: 0.6875rem;
    color: var(--text-light);
    transition: transform .2s ease;
}

.user-profile-section.show .user-caret { transform: rotate(180deg); }

.user-menu {
    min-width: 260px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 35, 64, .14);
    overflow: hidden;
}

.user-menu-header { padding: .9rem 1rem .8rem; }
.user-menu-header p { margin: 0; line-height: 1.3; }
.user-menu-name { font-weight: 600; font-size: 0.875rem; color: var(--text-dark); }

.user-menu-account {
    font-size: 0.7812rem;
    color: var(--text-light);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    margin-bottom: .5rem !important;
}

/* Every role the operator holds, wrapping rather than truncating: this menu
   is where somebody goes to check what they are signed in as. */
.user-menu-header .badge { margin: 0 .25rem .25rem 0; }

.user-menu .dropdown-divider { margin: 0; border-color: var(--border-subtle); }

.user-menu-signout {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .7rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--danger);
}

.user-menu-signout:hover,
.user-menu-signout:focus { background: #fff1f2; color: var(--danger); }

/* ============================ Sign-in screen ============================
   No sidebar, no header - the one screen in the portal an operator reaches
   before the portal knows who they are. */

body.sign-in-page {
    min-height: 100vh;
    margin: 0;
    background: linear-gradient(160deg, var(--sidebar-top) 0%, var(--primary) 55%, var(--primary-dark) 100%);
}

.sign-in-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.sign-in-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border-radius: 18px;
    padding: 2.25rem 2rem 1.75rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}

.sign-in-language { position: absolute; top: 1rem; right: 1rem; }

.sign-in-brand { text-align: center; margin-bottom: 1.75rem; }

.sign-in-brand img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin-bottom: .9rem;
}

.sign-in-brand h1 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 .2rem;
}

.sign-in-brand p { font-size: 0.8438rem; color: var(--text-light); margin: 0; }

.sign-in-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: .4rem;
}

.sign-in-input {
    height: 46px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 0.9375rem;
}

.sign-in-input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(26, 53, 100, .12);
}

.sign-in-submit {
    /* Flex so the label sits in the middle whether this is an <input type="submit">, which
       centres its own text, or an <a class="btn">, which does not and would otherwise print
       the label against the top of a 46px box. */
    display: flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    border-radius: 10px;
    font-weight: 600;
    background: var(--primary);
    border-color: var(--primary);
    margin-top: .25rem;

    /* Stated here rather than left to Bootstrap. On a navy button the text has to be white,
       and Bootstrap's .btn defaults an <a> to near-black - which is why the access-denied
       page's "Back to sign in" read as black while the identical-looking submit button on the
       sign-in screen did not. Every link state is named, or :visited reverts it. */
    color: var(--white);
}

.sign-in-submit:hover,
.sign-in-submit:focus,
.sign-in-submit:active,
.sign-in-submit:visited {
    color: var(--white);
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.sign-in-error {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .7rem .85rem;
    margin-bottom: 1.1rem;
    border-radius: 10px;
    border: 1px solid #fecdd3;
    background: #fff1f2;
    color: #9f1239;
    font-size: 0.8438rem;
}

.sign-in-hint {
    margin: 1rem 0 0;
    text-align: center;
    font-size: 0.7812rem;
    color: var(--text-light);
}

/* Who stands behind the portal, at the foot of the sign-in card: one quiet line and the two
   marks under it. Ruled off from the hint above so it reads as a footer rather than as more
   of the sentence about DGConnect. */
.sign-in-credits {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .55rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.sign-in-credits-label {
    font-size: 0.75rem;
    color: var(--text-light);
}

.sign-in-credits-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.35rem;
}

/* Sized by height so the two marks sit on one line whatever their own proportions are: the
   ministry's is a tall portrait emblem and the committee's a square one. */
.sign-in-credits-logos img {
    height: 36px;
    width: auto;
}

/* The account picker's banner. Deliberately not a quiet hint: it says the screen is in a
   testing arrangement, which is something the person signing in should notice rather than
   read past. Same shape as .sign-in-error so the icon and text line up the same way. */
.sign-in-notice {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    margin-top: .6rem;
    padding: .6rem .85rem;
    border-radius: 10px;
    border: 1px solid #fde68a;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.7812rem;
    line-height: 1.5;
}

.sign-in-notice i {
    margin-top: .15rem;
}

/* ============================ DGConnect sign-in ============================
   The one control on the front door, and the page a refused person lands on.
   Both sit inside .sign-in-card above, so only what is new to them is here. */

/* The button carries an icon and a label, centred as a pair rather than the
   label centred with the icon floating beside it. */
.sign-in-dgconnect {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    color: var(--white);
    font-size: 0.9375rem;
}

.sign-in-dgconnect:hover,
.sign-in-dgconnect:focus { color: var(--white); }

/* A pressed button that is waiting on a redirect. It stays legible - a disabled
   control an operator cannot read looks like a fault rather than like progress. */
.sign-in-dgconnect.is-busy,
.sign-in-dgconnect:disabled {
    opacity: .72;
    cursor: progress;
}

/* Why the button leads somewhere else, said before the round trip rather than
   after it: anybody can authenticate to DGConnect, and most of them are not
   entitled to this portal. */
.sign-in-restricted {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    margin: 1rem 0 0;
    padding: .7rem .85rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--slate-50);
    color: var(--text-light);
    font-size: 0.7812rem;
    line-height: 1.6;
}

.sign-in-restricted i { margin-top: .2rem; color: var(--primary); }

/* ---- The access-denied page ---- */

.access-denied-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 1.1rem;
    border-radius: 50%;
    background: #fff1f2;
    color: #9f1239;
    font-size: 1.375rem;
}

/* tabindex="-1" makes this focusable so the keyboard starts on the message.
   The browser's own focus ring on a non-control reads as a fault, so it is
   suppressed here and nowhere else - nothing on this element is operable. */
.access-denied-body { text-align: center; }
.access-denied-body:focus { outline: none; }

.access-denied-body h2 {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 .6rem;
}

.access-denied-body p {
    font-size: 0.8438rem;
    line-height: 1.7;
    color: var(--text-light);
    margin: 0 0 .9rem;
}

/* The three things true of every refusal. Left-aligned inside a centred block:
   a centred list is markedly harder to read, and Khmer wraps more than English
   so the ragged edge would be worse again. */
.access-denied-reasons {
    text-align: start;
    margin: 0 0 1.1rem;
    padding: .85rem 1rem .85rem 2.1rem;
    border-radius: 10px;
    background: var(--slate-50);
    border: 1px solid var(--border-subtle);
    font-size: 0.8125rem;
    line-height: 1.75;
    color: var(--text-light);
}

.access-denied-reasons li + li { margin-top: .3rem; }

.access-denied-contact {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    text-align: start;
    margin-bottom: 1.25rem !important;
}

.access-denied-contact i { margin-top: .2rem; color: var(--info); }

/* ---- Small screens ----
   The card is already fluid to 420px. What needs saying is that it should not
   keep its generous padding on a 320px handset, where it costs a quarter of the
   readable width. */
@media (max-width: 480px) {
    .sign-in-shell { padding: 1rem .75rem; }

    .sign-in-card {
        padding: 1.75rem 1.25rem 1.35rem;
        border-radius: 14px;
    }

    .sign-in-brand img { width: 60px; height: 60px; }

    .access-denied-reasons { padding-left: 1.75rem; }
}

/* ======================= Telegram activation panel =======================
   On the operator accounts screen. Three facts and, once, one link. */

.activation-status {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem 2.5rem;
    padding: 0 0 1.1rem;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.activation-fact { display: flex; flex-direction: column; gap: .35rem; }

.activation-label {
    font-size: 0.7188rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-light);
}

/* The link, shown once. Deliberately loud - a superadmin who scrolls past it
   has lost it, and the only remedy is to generate another. */
.activation-link {
    padding: 1rem 1.1rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--accent-gold-soft);
    border-radius: var(--radius-control);
    background: #fffdf5;
}

.activation-link-warning {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    margin-bottom: .9rem;
    font-size: 0.7812rem;
    line-height: 1.6;
    color: #92400e;
}

.activation-link-warning i { margin-top: .15rem; }

.activation-link-body {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-start;
}

/* Fixed so the layout does not jump as the QR is drawn client-side after load. */
.activation-qr {
    flex: 0 0 auto;
    width: 176px;
    height: 176px;
    padding: 8px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
}

.activation-qr img,
.activation-qr canvas { display: block; width: 100%; height: 100%; }

.activation-link-text { flex: 1 1 260px; min-width: 0; }

/* The link is longer than the box. Monospace so a superadmin reading it aloud
   can tell l from 1, and break-all so it never widens the card. */
.activation-link-text .form-control {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.7812rem;
    word-break: break-all;
}

@media (max-width: 640px) {
    .activation-link-body { gap: 1rem; }
    .activation-qr { margin: 0 auto; }
}

/* ============================ Notification templates ============================ */

/* The template preview, drawn the way a Telegram chat draws one message: the text exactly as it
   will arrive - line breaks kept, nothing wrapped in markup - with the action button under it. */
.message-preview {
    max-width: 520px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    padding: 12px 14px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

.message-preview-action {
    max-width: 520px;
    margin-top: 6px;
    padding: 8px 12px;
    text-align: center;
    border-radius: var(--radius-control);
    background: var(--slate-100);
    color: var(--primary);
    font-weight: 600;
}

/* The body editors: a monospace face would misdraw Khmer, so only the height changes. */
.template-body { min-height: 220px; line-height: 1.6; }

/* The message as it was sent, on the notification log's detail view. */
.sent-text { white-space: pre-wrap; word-break: break-word; line-height: 1.6; }

/* ============================ Integration logs ============================ */

/* A stored payload on the outbox and payment callback logs: indented JSON, encoded, as text. It
   scrolls inside its own box rather than widening the page on a phone, and caps its height so a
   long payload does not push the Back button off the screen. */
.log-payload {
    margin: .35rem 0 0;
    max-height: 480px;
    overflow: auto;
    padding: 12px 14px;
    background: var(--slate-50, #f8fafc);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.55;
    white-space: pre;
    tab-size: 2;
}

/* Ids and tokens on the detail views: long and unbroken, so they wrap anywhere on a narrow screen. */
.log-id { word-break: break-all; }
