/* ============================================================
   RIMS Public Servicing Portal — Design System
   Department of Community Safety, Security & Liaison
   Mpumalanga Province

   Structure, spacing scale, component vocabulary and typographic
   rhythm follow the RIMS POS V3 design system (theme.css /
   SPECS/06-Shared-Patterns.md) so the two products read as one
   family. The palette is re-based on the departmental green
   sampled from the provincial wordmark (#1E5A26) rather than the
   POS blue.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* --- Brand: departmental green -------------------------------
       --primary is the wordmark green from the provincial logo.
       8.25:1 on white, so it clears WCAG AA for body text and AAA
       for large text without needing a darker variant for copy. */
    --primary: #1e5a26;
    --primary-hover: #164419;
    --primary-active: #0f3312;
    --primary-light: #e6f0e7;
    --primary-lighter: #f2f7f2;

    /* Coat-of-arms green — secondary/decorative accent */
    --accent: #3d6b46;
    --accent-light: #eaf1eb;

    /* Gold from the provincial crest — used sparingly for emphasis */
    --gold: #c9932a;
    --gold-light: #fdf6e6;

    --secondary: #5a6660;
    --secondary-hover: #47514c;

    /* --- Status ------------------------------------------------- */
    --success: #10804a;
    --success-hover: #0b6339;
    --success-light: #dff2e8;
    --danger: #b3261e;
    --danger-hover: #8c1d17;
    --danger-light: #fbe6e5;
    --warning: #a86a00;
    --warning-hover: #855400;
    --warning-light: #fdf1dc;
    --info: #1c5c86;
    --info-hover: #16496a;
    --info-light: #e2eff7;

    /* --- Neutrals ----------------------------------------------- */
    --gray-50: #f7f8f7;
    --gray-100: #eff1ef;
    --gray-200: #e1e5e2;
    --gray-300: #cbd2cd;
    --gray-400: #9aa49d;
    --gray-500: #6f7a73;
    --gray-600: #55605a;
    --gray-700: #3f4844;
    --gray-800: #2a312d;
    --gray-900: #171c19;

    --background: #f4f6f4;
    --surface: #ffffff;
    --surface-hover: #f7f8f7;
    --border: #e1e5e2;
    --border-hover: #cbd2cd;
    --text-primary: #171c19;
    --text-secondary: #55605a;
    --text-muted: #6f7a73;

    /* --- Shadows ------------------------------------------------ */
    --shadow-sm: 0 1px 2px 0 rgba(23, 28, 25, .05);
    --shadow: 0 1px 3px 0 rgba(23, 28, 25, .1), 0 1px 2px 0 rgba(23, 28, 25, .06);
    --shadow-md: 0 4px 6px -1px rgba(23, 28, 25, .1), 0 2px 4px -1px rgba(23, 28, 25, .06);
    --shadow-lg: 0 10px 15px -3px rgba(23, 28, 25, .1), 0 4px 6px -2px rgba(23, 28, 25, .05);

    /* --- Scale -------------------------------------------------- */
    --spacing-xs: .25rem;
    --spacing-sm: .5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    --radius-sm: .25rem;
    --radius-md: .375rem;
    --radius-lg: .5rem;
    --radius-xl: .75rem;
    --radius-full: 9999px;

    --transition-fast: 150ms ease-in-out;
    --transition-base: 200ms ease-in-out;
}

/* ============================================================
   Base
   ============================================================ */

* { box-sizing: border-box; }

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--background);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    margin: 0 0 var(--spacing-md);
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--primary-hover); text-decoration: underline; }

.mono {
    font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
}

/* Every figure in the portal is money, a count or a date — keep the
   digits on a fixed pitch so columns line up. */
.num, .totals, .field-row .v, .tile .val, .lt-tile .val {
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   App chrome — top bar
   ============================================================ */

.top-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
}

.top-bar .brand {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: inherit;
}

.top-bar .brand:hover { text-decoration: none; color: inherit; }

/* The provincial wordmark is a fixed-aspect raster; cap the height and
   let width follow so it never distorts. */
.top-bar .brand img.dept-logo {
    height: 44px;
    width: auto;
    display: block;
}

.top-bar .brand .brand-text {
    border-left: 1px solid var(--border);
    padding-left: 14px;
    line-height: 1.2;
}

.top-bar .brand .brand-text .t {
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.01em;
}

.top-bar .brand .brand-text .s {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.top-bar .user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.top-bar .user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-700);
    padding-right: 4px;
}

.top-bar .user-chip .avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .5px;
}

/* Environment banners ---------------------------------------- */
.environment-banner {
    padding: 6px 12px;
    text-align: center;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: #fff;
}

.dev-banner { background-color: var(--danger); }
.uat-banner { background-color: var(--warning); }

/* Navigation drawer ------------------------------------------ */
.navigation-drawer-header {
    background: var(--primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navigation-drawer-header .name {
    font-weight: 700;
    font-size: 13px;
    line-height: 1.2;
    color: #fff;
}

.navigation-drawer-header .name small {
    display: block;
    font-weight: 400;
    font-size: 10px;
    color: rgba(255, 255, 255, .75);
    margin-top: 2px;
}

.drawer-footer {
    padding: var(--spacing-md);
    background: var(--gray-50);
    border-top: 1px solid var(--border);
}

/* site.css (Blazor template leftover) centres .main-content with
   display:flex + align-items:center, which lays page sections out in a row and
   vertically centres them. Pages need normal block flow. */
.main-content {
    display: block;
    padding: 22px;
    width: 100%;
    background-color: var(--background);
}

/* ============================================================
   Page header  (POS: SPECS/06 §2)
   ============================================================ */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--gray-900);
    letter-spacing: -0.01em;
}

.page-header .subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.page-header .actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* ============================================================
   Doc paper — the application "document" card  (POS: SPECS/06 §4)
   ============================================================ */

.doc-paper {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    border-top: 4px solid var(--primary);
    padding: 28px 32px;
    box-shadow: var(--shadow);
}

.doc-paper .doc-h {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--gray-900);
}

.doc-paper .doc-h .issuer {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.doc-paper .doc-h .issuer img {
    height: 46px;
    width: auto;
}

.doc-paper .doc-h .issuer .org {
    font-weight: 700;
    font-size: 14px;
    color: var(--gray-900);
}

.doc-paper .doc-h .issuer .org small {
    display: block;
    font-weight: 400;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.doc-paper h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
    color: var(--gray-900);
}

/* Inverted typeset rib — the document's name (POS: SPECS/06 §5) */
.label-rib {
    display: inline-block;
    background: var(--gray-900);
    color: #fff;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    border-radius: 2px;
    text-transform: uppercase;
}

.doc-num {
    font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.doc-section-h {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.doc-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
    padding-top: 22px;
}

@media (max-width: 860px) {
    .doc-grid-2 { grid-template-columns: 1fr; gap: 18px; }
    .doc-paper { padding: 20px 18px; }
}

/* Callout block for the applicant (POS .billto) */
.applicant-block {
    background: var(--gray-50);
    border-left: 3px solid var(--primary);
    padding: 12px 14px;
    border-radius: 0 6px 6px 0;
}

/* Dotted label/value rows (POS: SPECS/06 §6) */
.field-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 12px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dotted var(--gray-200);
    font-size: 13px;
}

.field-row:last-child { border-bottom: 0; }

.field-row .k {
    color: var(--text-secondary);
    font-size: 11px;
    letter-spacing: .4px;
    text-transform: uppercase;
    font-weight: 600;
}

.field-row .v { font-weight: 500; }

.doc-footer {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 24px;
}

@media (max-width: 860px) {
    .doc-footer { grid-template-columns: 1fr; }
}

/* ============================================================
   Wizard progress steps
   ============================================================ */

.progress-steps {
    display: flex;
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
    counter-reset: step;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.progress-step {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    position: relative;
    color: var(--text-muted);
    min-width: 0;
}

/* Chevron divider between steps, drawn with a rotated square so it
   survives the container's overflow clipping at both ends. */
.progress-step + .progress-step::before {
    content: '';
    position: absolute;
    left: -9px;
    top: 50%;
    width: 18px;
    height: 18px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    border-top: 1px solid var(--border);
    transform: translateY(-50%) rotate(45deg);
    z-index: 1;
}

.progress-step .step-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    color: var(--gray-500);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    z-index: 2;
}

.progress-step .step-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 2;
}

.progress-step.active { color: var(--primary); }
.progress-step.active .step-icon { background: var(--primary); color: #fff; }
.progress-step.completed { color: var(--gray-700); }
.progress-step.completed .step-icon { background: var(--success-light); color: var(--success); }

@media (max-width: 720px) {
    .progress-step .step-label { display: none; }
    .progress-step { justify-content: center; }
}

/* ============================================================
   Document upload  (Step 3)
   ============================================================ */

.doc-checklist {
    display: grid;
    gap: 10px;
}

.doc-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.doc-item:hover { border-color: var(--border-hover); }
.doc-item.uploaded { border-left: 3px solid var(--success); background: var(--primary-lighter); }
.doc-item.required-missing { border-left: 3px solid var(--warning); }

.doc-item .doc-ico {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    background: var(--gray-100);
    color: var(--gray-500);
}

.doc-item.uploaded .doc-ico { background: var(--success-light); color: var(--success); }
.doc-item.required-missing .doc-ico { background: var(--warning-light); color: var(--warning); }

.doc-item .doc-meta { flex: 1; min-width: 0; }

.doc-item .doc-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.doc-item .doc-sub {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-item .doc-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

/* A styled <label> wrapping a visually-hidden <InputFile>; the input
   itself cannot be restyled reliably across browsers. */
.file-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid var(--primary);
    color: var(--primary);
    background: transparent;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}

.file-trigger:hover { background: var(--primary); color: #fff; }
.file-trigger.busy { opacity: .6; pointer-events: none; }

.file-trigger input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.upload-hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============================================================
   Badges  (POS: SPECS/06 §10)
   ============================================================ */

.badge, .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--gray-700);
    white-space: nowrap;
    letter-spacing: .2px;
}

.status-draft          { background: var(--gray-100);    color: var(--gray-600); }
.status-submitted      { background: var(--info-light);  color: var(--info); }
.status-badge.status-returned { background: #fff3e0; color: #9a5312; border: 1px solid #d9822b; }
.status-badge.status-closed { background: #eceff1; color: #546e7a; border: 1px solid #b0bec5; }
.status-badge.status-approved { background: #e8f5e9; color: #1b5e20; border: 1px solid #66bb6a; }
.status-under-review   { background: var(--warning-light); color: var(--warning); }
.status-deposit-pending{ background: var(--warning-light); color: var(--warning); }
.status-approved,
.status-active         { background: var(--success-light); color: var(--success); }
.status-rejected       { background: var(--danger-light); color: var(--danger); }

.badge-required { background: var(--danger-light); color: var(--danger); }
.badge-optional { background: var(--gray-100); color: var(--gray-600); }

/* ============================================================
   Tiles  (POS: theme.css .lt-tile)
   ============================================================ */

.tiles-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.lt-tile {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    overflow: hidden;
}

.lt-tile.accent { border-left-width: 3px; }
.lt-tile.accent.primary { border-left-color: var(--primary); }
.lt-tile.accent.warning { border-left-color: var(--warning); }
.lt-tile.accent.danger  { border-left-color: var(--danger); }
.lt-tile.accent.success { border-left-color: var(--success); }

.lt-tile .lbl {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-secondary);
    font-weight: 700;
}

.lt-tile .val {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.1;
    margin-top: 6px;
}

.lt-tile .sub { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

.lt-tile .ico {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--gray-100);
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.lt-tile.accent.primary .ico { background: var(--primary-light); color: var(--primary); }
.lt-tile.accent.warning .ico { background: var(--warning-light); color: var(--warning); }
.lt-tile.accent.success .ico { background: var(--success-light); color: var(--success); }

/* ============================================================
   Totals block  (POS: SPECS/06 §9)
   ============================================================ */

.totals {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-size: 13px;
}

/* Deliberately not called .row — Bootstrap's grid .row forces width:100% on its
   children, which stacks the label above the value. */
.totals .t-row { display: flex; justify-content: space-between; padding: 4px 0; gap: 12px; }
.totals .t-row .lbl { color: var(--gray-700); }
.totals .t-row .val { font-weight: 500; }
.totals .t-row.muted { color: var(--text-secondary); }
.totals .sep { height: 1px; background: var(--border); margin: 8px 0; }
.totals .total .lbl { font-weight: 600; color: var(--gray-900); }
.totals .total .val { font-weight: 700; font-size: 17px; color: var(--primary); }

/* ============================================================
   Right rail + sticky action bar  (POS: SPECS/06 §11, §13)
   ============================================================ */

/* minmax(0, 1fr) rather than 1fr: a bare 1fr track refuses to shrink below the
   main column's min-content width, which pushed the right rail off-screen on
   narrower viewports once the navigation drawer was open. */
.page-layout-with-rail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
    padding-bottom: 96px;
}

.right-rail {
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (max-width: 1200px) {
    .page-layout-with-rail { grid-template-columns: 1fr; }
    .right-rail { position: static; }
}

.rail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.rail-card .rail-h {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Validation checklist in the rail */
.check-list { display: grid; gap: 7px; }

.check-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: var(--gray-700);
}

.check-item i { width: 14px; flex-shrink: 0; margin-top: 2px; }
.check-item.ok i { color: var(--success); }
.check-item.todo { color: var(--text-muted); }
.check-item.todo i { color: var(--gray-400); }

.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-top: 16px;
}

.action-bar .left  { display: flex; gap: 8px; align-items: center; }
.action-bar .right { display: flex; gap: 8px; align-items: center; }

.action-bar.sticky-bottom {
    position: sticky;
    bottom: 16px;
    z-index: 10;
    box-shadow: 0 -2px 10px rgba(23, 28, 25, .06);
    /* The bar spans the full content width; let clicks fall through the
       empty middle and re-enable them on the controls themselves. */
    pointer-events: none;
}

.action-bar.sticky-bottom > * { pointer-events: auto; }

.action-hint { font-size: 12px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.action-hint.ok { color: var(--success); }

/* ============================================================
   Cards, forms, alerts
   ============================================================ */

.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 16px;
}

.info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    height: 100%;
}

.info-card h5, .info-card h6 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--gray-900);
}

.form-section {
    padding-bottom: 4px;
    margin-bottom: 18px;
}

.form-section + .form-section {
    border-top: 1px solid var(--border);
    padding-top: 18px;
}

.form-section h3 {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 5px;
}

/* Two-column form grid. Fields declare their own span so a lone field fills the
   row instead of leaving an empty half. */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
}

.form-grid .field-full { grid-column: 1 / -1; }

@media (max-width: 620px) {
    .form-grid { grid-template-columns: minmax(0, 1fr); }
}

.field-hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* The DevExpress bs5 theme ships its own .form-control; these rules load after it
   and re-point the sizing and focus ring at the departmental tokens. */
.form-control, .form-select {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--surface);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(30, 90, 38, .12);
}

.form-control::placeholder { color: var(--gray-400); }

.form-control.invalid, .form-control.modified.invalid {
    border-color: var(--danger);
}

input[type="checkbox"] { accent-color: var(--primary); }

.alert {
    padding: 11px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 14px;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid transparent;
}

.alert-success { background: var(--success-light); border-color: #b6dfc9; color: #0b5132; }
.alert-danger  { background: var(--danger-light);  border-color: #f0c2bf; color: #7d1a15; }
.alert-warning { background: var(--warning-light); border-color: #f0d9ac; color: #6b4400; }
.alert-info    { background: var(--info-light);    border-color: #bcd8e8; color: #133f5c; }

.validation-message { color: var(--danger); font-size: 11px; margin-top: 4px; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    background: var(--surface);
    border: 1px dashed var(--border-hover);
    border-radius: var(--radius-md);
}

.empty-state .ico {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 14px;
}

.empty-state h4 { font-size: 16px; margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--text-secondary); margin-bottom: 18px; }

/* ============================================================
   Buttons — Bootstrap class names, departmental palette
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    padding: 7px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }

.btn-lg { font-size: 14px; padding: 11px 20px; }
.btn-sm { font-size: 12px; padding: 5px 10px; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }

/* The DevExpress bs5 theme styles :disabled buttons with its own purple, which
   outranks the plain .btn-primary rule above and made disabled CTAs read lavender.
   Hold the departmental green and let .btn:disabled's opacity do the muting. */
.btn-primary:disabled, .btn-primary.disabled,
.btn-success:disabled, .btn-success.disabled,
.btn-outline-primary:disabled, .btn-outline-primary.disabled {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

.btn-success:disabled, .btn-success.disabled {
    background-color: var(--success) !important;
    border-color: var(--success) !important;
}

.btn-outline-primary:disabled, .btn-outline-primary.disabled {
    background-color: transparent !important;
    color: var(--primary) !important;
}

.btn-outline-primary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover:not(:disabled) { background: var(--primary); color: #fff; }

.btn-secondary { background: var(--surface); color: var(--gray-700); border-color: var(--border-hover); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); color: var(--gray-900); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover:not(:disabled) { background: var(--success-hover); border-color: var(--success-hover); color: #fff; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); color: #fff; }

.btn-link { background: transparent; border-color: transparent; color: var(--primary); }
.btn-link:hover:not(:disabled) { background: var(--primary-light); }

.btn-danger-link { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-link:hover:not(:disabled) { background: var(--danger-light); }

/* ============================================================
   Tables
   ============================================================ */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }

.table th {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-secondary);
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--gray-50);
}

.table td {
    padding: 10px;
    border-bottom: 1px dotted var(--gray-200);
    vertical-align: middle;
}

.table tfoot th {
    background: transparent;
    border-top: 2px solid var(--gray-900);
    border-bottom: 0;
    font-size: 12px;
    color: var(--gray-900);
    text-transform: none;
    letter-spacing: 0;
}

.table .num { text-align: right; }

/* ============================================================
   DevExpress overrides — align DX controls with the tokens
   ============================================================ */

.dxbl-btn.dxbl-btn-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.dxbl-btn.dxbl-btn-primary:hover {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
}

.dxbl-grid {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    font-size: 13px;
}

.dxbl-grid thead th,
.dxbl-grid .dxbl-grid-header-content {
    background: var(--gray-50) !important;
    color: var(--text-secondary) !important;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: .8px;
    font-weight: 700;
}

.dxbl-grid tbody tr:hover {
    background: linear-gradient(90deg, var(--primary-light), transparent 60%) !important;
}

.dxbl-text-edit, .dxbl-combobox, .dxbl-spin-edit {
    font-size: 13px;
}

/* Reference numbers read as identifiers, not prose. */
.refnum {
    font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
    color: var(--primary);
    font-weight: 600;
    font-size: 12px;
}

.refnum:hover { text-decoration: underline; }

/* ============================================================
   Auth pages — centred card over a departmental green field
   ============================================================ */

/* Owned by AuthLayout.razor — these pages render outside the app shell, with no
   navigation drawer. */
.auth-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Layered radial tints over the deep green give the flat brand
       colour some depth without needing a background image. */
    background:
        radial-gradient(1100px 520px at 10% -12%, rgba(61, 107, 70, .60), transparent 62%),
        radial-gradient(900px 460px at 102% 108%, rgba(201, 147, 42, .16), transparent 58%),
        var(--primary);
}

.auth-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-layout-foot {
    padding: 18px 20px 26px;
    text-align: center;
    font-size: 11px;
    color: rgba(255, 255, 255, .65);
}

.auth-layout-foot a { color: rgba(255, 255, 255, .9); text-decoration: underline; }
.auth-layout-foot a:hover { color: #fff; }
.auth-layout-foot .sep { margin: 0 6px; }

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 60px rgba(15, 51, 18, .38), 0 4px 12px rgba(15, 51, 18, .2);
    padding: 32px;
}

.auth-card.wide { max-width: 780px; padding: 36px 40px; }

@media (max-width: 640px) {
    .auth-card, .auth-card.wide { padding: 24px 20px; }
    .auth-main { padding: 24px 14px; }
}

.auth-card .auth-brand {
    text-align: center;
    margin-bottom: 22px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.auth-card .auth-brand img { height: 52px; width: auto; }

.auth-card h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px;
    text-align: center;
}

.auth-card .sub {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 22px;
}

.auth-foot {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.support-line {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-muted);
}

.support-line b { color: var(--text-secondary); font-weight: 600; }

/* ============================================================
   Home / landing
   ============================================================ */

.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

/* Faint crest watermark, clipped by the hero's overflow. */
.hero::after {
    content: '';
    position: absolute;
    right: -40px;
    bottom: -60px;
    width: 260px;
    height: 260px;
    background: url('../images/mpumalanga-crest.jpg') center/contain no-repeat;
    opacity: .07;
    pointer-events: none;
}

.hero h1 {
    color: #fff;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
    max-width: 620px;
}

.hero p {
    color: rgba(255, 255, 255, .85);
    font-size: 14px;
    max-width: 560px;
    margin-bottom: 22px;
}

.hero .btn-primary {
    background: #fff;
    color: var(--primary);
    border-color: #fff;
}

.hero .btn-primary:hover { background: var(--gray-100); color: var(--primary-active); }

.hero .btn-secondary {
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border-color: rgba(255, 255, 255, .4);
}

.hero .btn-secondary:hover { background: rgba(255, 255, 255, .2); color: #fff; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.feature-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    transition: border-color var(--transition-base), transform var(--transition-base);
}

.feature-box:hover { border-color: var(--primary); transform: translateY(-2px); }

.feature-box .ico {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-lg);
    background: var(--primary-light);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    margin-bottom: 10px;
}

.feature-box h4 { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.feature-box p { font-size: 12px; color: var(--text-secondary); margin: 0; }

/* ============================================================
   Utilities
   ============================================================ */

.text-muted { color: var(--text-secondary) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-end { text-align: right; }
.text-center { text-align: center; }

.stack { display: flex; flex-direction: column; }
.row-flex { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

@media print {
    .top-bar, .environment-banner, .action-bar,
    .right-rail, .progress-steps, .no-print { display: none !important; }

    body { background: #fff; }
    .doc-paper { border: 1px solid #000; box-shadow: none; }
}

/* Application timeline (shared by applicant and admin pages) */
.timeline { border-left: 2px solid #cfd8dc; margin-left: 8px; padding-left: 16px; }
.timeline-item { position: relative; margin: 0 0 14px; }
.timeline-dot { position: absolute; left: -23px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #1f6f3f; }
.timeline-item.kind-returned .timeline-dot { background: #d9822b; }
.timeline-item.kind-closed .timeline-dot { background: #b23a3a; }
.timeline-item.kind-note .timeline-dot { background: #78909c; }
.timeline-title { font-size: 13px; }
.timeline-text { font-size: 13px; white-space: pre-wrap; margin: 2px 0; }
.timeline-when { font-size: 11px; color: #78909c; }
.doc-item.superseded { opacity: .6; }
.doc-item label.disabled { opacity: .5; pointer-events: none; }
