:root {
    /* Brand: Kenyan Coffee Agriculture (Solid, No Gradients) — Warm Stone + Emerald */
    --primary: #047857;
    --primary-dark: #065f46;
    --primary-light: #d1fae5;
    --primary-active: #064e3b;
    --primary-text: #ffffff;
    --secondary: #57534e;
    --secondary-light: #f5f5f4;
    --secondary-dark: #292524;

    /* Backgrounds: Solid, Practical Enterprise Neutral (Warm Stone) */
    --bg-body: #f5f5f4;
    --bg-sidebar: #ffffff;
    --bg-sidebar-soft: #f5f5f4;
    --bg-sidebar-hover: #f5f5f4;
    --bg-sidebar-active: #d1fae5;
    --bg-card: #ffffff;
    --bg-topbar: #ffffff;
    --bg-surface-soft: #f5f5f4;
    --border-color: #d6d3d1;
    --border-subtle: #e7e5e4;

    /* Typography & Contrast */
    --text-dark: #1c1917;
    --text-body: #44403c;
    --text-muted: #78716c;
    --text-sidebar: #44403c;
    --text-sidebar-active: #047857;

    /* Semantic Status (100% Solid) */
    --success: #047857;
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --warning: #b45309;
    --warning-bg: #fef3c7;
    --warning-text: #78350f;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --info: #0369a1;
    --info-bg: #e0f2fe;
    --info-text: #075985;

    /* Layout Dimensions */
    --sidebar-width: 260px;
    --sidebar-mini-width: 78px;
    --topbar-height: 62px;
    --border-radius: 6px;
    --border-radius-sm: 4px;
    --border-radius-lg: 8px;

    /* Focus & Elevation (Crisp, No Fuzzy Blurs) */
    --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.05);
    --shadow: 0 1px 3px rgba(28, 25, 23, 0.08);
    --ring: 0 0 0 3px rgba(4, 120, 87, 0.2);
}

html[data-theme="dark"] {
    --primary: #34d399;
    --primary-dark: #10b981;
    --primary-light: #065f46;
    --primary-active: #059669;
    --primary-text: #064e3b;
    --secondary: #a8a29e;
    --secondary-light: #292524;
    --secondary-dark: #1c1917;

    --bg-body: #1c1917;
    --bg-sidebar: #292524;
    --bg-sidebar-soft: #44403c;
    --bg-sidebar-hover: #44403c;
    --bg-sidebar-active: #14532d;
    --bg-card: #292524;
    --bg-topbar: #292524;
    --bg-surface-soft: #1c1917;
    --border-color: #44403c;
    --border-subtle: #292524;

    --text-dark: #fafaf9;
    --text-body: #e7e5e4;
    --text-muted: #a8a29e;
    --text-sidebar: #d6d3d1;
    --text-sidebar-active: #6ee7b7;

    --success: #34d399;
    --success-bg: #064e3b;
    --success-text: #a7f3d0;
    --warning: #fbbf24;
    --warning-bg: #451a03;
    --warning-text: #fde68a;
    --danger: #f87171;
    --danger-bg: #450a0a;
    --danger-text: #fecaca;
    --info: #38bdf8;
    --info-bg: #082f49;
    --info-text: #bae6fd;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    --ring: 0 0 0 3px rgba(52, 211, 153, 0.25);
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-body);
    font-size: 0.875rem; /* 14px */
    line-height: 1.45;
    overflow-x: hidden;
    transition: background-color 0.15s ease, color 0.15s ease;
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover {
    color: var(--primary-dark);
}

/* ==========================================================================
   Admin Shell Layout
   ========================================================================== */
.admin-shell {
    min-height: 100vh;
    display: flex;
}

.admin-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar);
    border-right: 1px solid var(--border-color);
    transform: translateX(0);
    transition: width 0.2s ease, transform 0.2s ease;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.6);
    z-index: 1030;
}

.sidebar-header {
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-sidebar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* Close button for the mobile drawer (hidden on desktop) */
.sidebar-close {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-surface-soft);
    color: var(--text-body);
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
}
.sidebar-close:hover {
    background-color: var(--bg-sidebar-hover);
    color: var(--text-dark);
}
@media (min-width: 992px) {
    .sidebar-close {
        display: none !important;
    }
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    color: var(--text-dark);
}
.brand-mark:hover, .brand-mark:focus {
    color: var(--text-dark);
}

.brand-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-sm);
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    padding: 2px;
}
.brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.brand-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.brand-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
    white-space: nowrap;
}
.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.2;
    white-space: nowrap;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0.75rem 0.65rem;
    flex: 1;
    overflow-y: auto;
}

.sidebar-section {
    padding: 0.85rem 0.65rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
}
.sidebar-section.is-active {
    color: var(--primary);
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 38px;
    padding: 0.45rem 0.65rem;
    border-radius: var(--border-radius-sm);
    color: var(--text-sidebar);
    font-size: 0.84rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.sidebar-nav .nav-link:hover {
    background-color: var(--bg-sidebar-hover);
    color: var(--text-dark);
}

.sidebar-nav .nav-link.active {
    background-color: var(--primary);
    color: #ffffff;
    font-weight: 600;
}
.sidebar-nav .nav-link.active .nav-icon {
    color: #ffffff;
}

.nav-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 20px;
    font-size: 1rem;
    color: var(--text-muted);
}
.sidebar-nav .nav-link:hover .nav-icon {
    color: var(--primary);
}

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    min-height: 38px;
    padding: 0.45rem 0.65rem;
    border: none;
    border-radius: var(--border-radius-sm);
    background: none;
    color: var(--text-sidebar);
    font-size: 0.84rem;
    font-weight: 600;
    white-space: nowrap;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.sidebar-group-toggle:hover {
    background-color: var(--bg-sidebar-hover);
    color: var(--text-dark);
}
.sidebar-group-toggle .caret {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.16s ease;
}
.sidebar-group-toggle:not(.collapsed) .caret {
    transform: rotate(90deg);
}
.sidebar-group.is-open .sidebar-group-toggle {
    color: var(--primary);
}

.nav-child {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-left: 1rem;
    margin-top: 1px;
}
.nav-child .nav-link {
    font-size: 0.8125rem;
    min-height: 34px;
    padding: 0.35rem 0.65rem;
}

/* Nested submenu (Master Payroll streams) */
.nav-child-inner {
    padding-left: 0.85rem;
    margin-left: 1.15rem;
    border-left: 1px solid var(--border-subtle);
}
.sidebar-subgroup-toggle {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    min-height: 34px;
    padding: 0.35rem 0.65rem;
    border: none;
    border-radius: var(--border-radius-sm);
    background: none;
    color: var(--text-sidebar);
    font-size: 0.8125rem;
    font-weight: 700;
    white-space: nowrap;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.sidebar-subgroup-toggle:hover {
    background-color: var(--bg-sidebar-hover);
    color: var(--text-dark);
}
.sidebar-subgroup-toggle .caret {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.16s ease;
}
.sidebar-subgroup-toggle:not(.collapsed) .caret {
    transform: rotate(90deg);
}
.sidebar-subgroup-toggle .nav-icon {
    color: var(--primary);
}

.sidebar-user {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-sidebar-soft);
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.sidebar-user .profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    background-color: var(--primary);
    color: #ffffff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.85rem;
}
.sidebar-user-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.sidebar-user-name {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.sidebar-footer {
    padding: 0.5rem 1rem 0.75rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-sidebar-soft);
}
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--success);
    flex-shrink: 0;
}

/* Mini Sidebar (Desktop) */
body.sidebar-mini .admin-sidebar {
    width: var(--sidebar-mini-width);
}
body.sidebar-mini .brand-copy,
body.sidebar-mini .brand-subtitle,
body.sidebar-mini .nav-text,
body.sidebar-mini .sidebar-section,
body.sidebar-mini .sidebar-group-toggle .caret,
body.sidebar-mini .sidebar-user-info,
body.sidebar-mini .sidebar-footer-text,
body.sidebar-mini .nav-child,
body.sidebar-mini .nav-child-inner {
    display: none !important;
}
body.sidebar-mini .admin-main {
    margin-left: var(--sidebar-mini-width);
}

/* ==========================================================================
   Main Content Area & Topbar
   ========================================================================== */
.admin-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.2s ease;
}

.admin-navbar {
    height: var(--topbar-height);
    background-color: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.sidebar-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-surface-soft);
    cursor: pointer;
    padding: 8px;
}
.sidebar-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-body);
}

.topbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
}

.topbar-date-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.775rem;
    color: var(--text-muted);
    background-color: var(--bg-surface-soft);
    padding: 0.25rem 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
}

.icon-button {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface-soft);
    color: var(--text-body);
    display: grid;
    place-items: center;
    cursor: pointer;
}
.icon-button:hover {
    background-color: var(--bg-sidebar-hover);
    color: var(--primary);
}

.profile-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.25rem 0.65rem;
    background-color: var(--bg-surface-soft);
    cursor: pointer;
    color: var(--text-body);
}
.profile-button:hover {
    background-color: var(--bg-sidebar-hover);
}

.dashboard-content {
    flex: 1;
    padding: 1.25rem 0 2rem;
}

.admin-footer {
    padding: 0.85rem 0;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-topbar);
    font-size: 0.775rem;
    color: var(--text-muted);
}
.admin-footer .container-fluid {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ==========================================================================
   Page Headings & Actions
   ========================================================================== */
.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.15rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
}

.page-heading-copy {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.page-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-sm);
    background-color: var(--primary-light);
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.page-heading h1, .page-heading h5 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.heading-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Breadcrumbs */
.breadcrumb-nav .breadcrumb {
    margin-bottom: 0.5rem;
    font-size: 0.775rem;
}
.breadcrumb-item a {
    color: var(--text-muted);
}
.breadcrumb-item a:hover {
    color: var(--primary);
}
.breadcrumb-item.active {
    color: var(--text-body);
    font-weight: 600;
}

/* ==========================================================================
   Buttons (FarmLedger Standard — Clear Labels, High Contrast, Solid)
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.84rem;
    border-radius: var(--border-radius-sm);
    padding: 0.45rem 0.95rem;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    line-height: 1.35;
}
.btn:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.btn-sm {
    font-size: 0.775rem;
    padding: 0.28rem 0.65rem;
}
.btn-lg {
    font-size: 0.95rem;
    padding: 0.65rem 1.25rem;
}

/* Solid Variants */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #ffffff;
}
.btn-primary:active {
    background-color: var(--primary-active);
    border-color: var(--primary-active);
    color: #ffffff;
}

.btn-secondary {
    background-color: var(--secondary);
    border-color: var(--secondary);
    color: #ffffff;
}
.btn-secondary:hover {
    background-color: var(--secondary-dark);
    border-color: var(--secondary-dark);
    color: #ffffff;
}

.btn-success {
    background-color: var(--success);
    border-color: var(--success);
    color: #ffffff;
}
.btn-success:hover {
    background-color: #065f46;
    border-color: #065f46;
    color: #ffffff;
}

.btn-danger {
    background-color: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}
.btn-danger:hover {
    background-color: #b91c1c;
    border-color: #b91c1c;
    color: #ffffff;
}

.btn-outline-primary {
    background-color: transparent;
    border-color: var(--primary);
    color: var(--primary);
}
.btn-outline-primary:hover {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.btn-outline-secondary {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-body);
}
.btn-outline-secondary:hover {
    background-color: var(--bg-surface-soft);
    border-color: var(--text-muted);
    color: var(--text-dark);
}

.btn-outline-danger {
    background-color: transparent;
    border-color: var(--danger);
    color: var(--danger);
}
.btn-outline-danger:hover {
    background-color: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

.btn-outline-success {
    background-color: transparent;
    border-color: var(--success);
    color: var(--success);
}
.btn-outline-success:hover {
    background-color: var(--success);
    border-color: var(--success);
    color: #ffffff;
}

/* ==========================================================================
   Operational Metric Cards (Solid, Compact, Practical)
   ========================================================================== */
.metric-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary);
    border-radius: var(--border-radius-sm);
    padding: 0.95rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.metric-card.metric-success {
    border-left-color: var(--success);
}
.metric-card.metric-warning {
    border-left-color: var(--warning);
}
.metric-card.metric-danger {
    border-left-color: var(--danger);
}
.metric-card.metric-info {
    border-left-color: var(--info);
}
.metric-card.metric-secondary {
    border-left-color: var(--secondary);
}

.metric-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.metric-label {
    font-size: 0.775rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
.metric-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-surface-soft);
    color: var(--text-muted);
    display: grid;
    place-items: center;
    font-size: 0.95rem;
}
.metric-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-dark);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.metric-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==========================================================================
   Panels, Cards & Containers (No Cards Inside Cards, Solid 1px Borders)
   ========================================================================== */
.panel, .card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    margin-bottom: 1.25rem;
}

.panel-header, .card-header {
    padding: 0.85rem 1.15rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-body, .panel-body {
    padding: 1.15rem;
}

.card-title, .section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.info-list div {
    display: flex;
    justify-content: space-between;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.84rem;
}
.info-list div:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.info-list span {
    color: var(--text-muted);
}
.info-list strong {
    color: var(--text-dark);
    font-weight: 600;
}

/* Stat Cards in Profile */
.stat-card {
    background-color: var(--bg-surface-soft);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem;
}
.stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}
.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dark);
    font-variant-numeric: tabular-nums;
}

/* Dashboard greeting (compact, time-aware) */
.dashboard-greeting {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Compact status/alert rows used on the dashboard side panel */
.status-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.15rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.84rem;
}
.status-row:last-child {
    border-bottom: none;
}
.status-row .status-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--border-radius-sm);
    display: inline-grid;
    place-items: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    background-color: var(--bg-surface-soft);
    color: var(--text-muted);
}
.status-row .status-body {
    flex: 1 1 auto;
    min-width: 0;
}
.status-row .status-title {
    font-weight: 600;
    color: var(--text-dark);
}
.status-row .status-meta {
    font-size: 0.76rem;
    color: var(--text-muted);
}
.status-row .status-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
    color: var(--text-dark);
    text-align: right;
    flex-shrink: 0;
}
.status-row .status-value.is-warn {
    color: var(--warning);
}
.status-row .status-value.is-ok {
    color: var(--success);
}
.status-row .status-value.is-danger {
    color: var(--danger);
}
.status-action-link:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Tables & DataTables (High Density, Clear Headers, Right-Aligned Numbers)
   ========================================================================== */
.table-responsive {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-card);
}

.table {
    margin-bottom: 0;
    color: var(--text-body);
    font-size: 0.84rem;
    border-collapse: collapse;
}

.table thead th {
    background-color: var(--bg-surface-soft);
    color: var(--text-dark);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--border-color);
    padding: 0.65rem 0.75rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.6rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table-hover tbody tr:hover {
    background-color: var(--bg-sidebar-hover);
}

.table tfoot td, .table tfoot th {
    background-color: var(--bg-surface-soft);
    font-weight: 700;
    color: var(--text-dark);
    border-top: 2px solid var(--border-color);
    padding: 0.65rem 0.75rem;
}

.tabular-nums, .text-end {
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Forms & Data Entry (Grouped, Clear Labels, High Contrast)
   ========================================================================== */
.form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.35rem;
    display: block;
}
.form-label .required, .form-label.required::after {
    content: " *";
    color: var(--danger);
}

.form-control, .form-select {
    font-size: 0.84rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-card);
    color: var(--text-body);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: var(--ring);
}

.form-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-fieldset {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 1.15rem;
    margin-bottom: 1.25rem;
    background-color: var(--bg-card);
}
.form-fieldset-legend {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--primary);
    padding: 0 0.5rem;
    margin-bottom: 0.75rem;
}

/* Filter Bars */
.filter-bar {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.85rem 1rem;
    margin-bottom: 1.15rem;
}
.filter-bar label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    display: block;
}

/* Report toolbar (perfFilterBar) — groups the period filter with the
   Excel / CSV / Print actions and adds a clear reporting-period caption. */
.filter-bar.report-toolbar {
    padding: 0.6rem 1rem 0.7rem;
}
.filter-bar .report-toolbar-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.filter-bar .report-toolbar-form {
    flex: 1 1 auto;
}
.filter-bar .report-field label {
    margin-bottom: 0.2rem;
}
.filter-bar .report-actions {
    flex: 0 0 auto;
    align-items: flex-end;
    padding-bottom: 1px;
}
.filter-bar .report-period-meta {
    margin-top: 0.55rem;
    padding-top: 0.55rem;
    border-top: 1px dashed var(--border-color);
    font-size: 0.82rem;
    color: var(--text-muted);
}
.filter-bar .report-period-meta strong {
    color: var(--text);
    font-weight: 600;
}

/* Printed report header (shown only when printing) */
.report-print-heading {
    display: none;
}

/* Print-only company letterhead: hidden on screen, shown when printing so
   every report prints with the company logo + letterhead. */
.print-letterhead {
    display: none;
}

/* Clickable drill-down zone link (Zone Performance) */
.zone-drill {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 1px;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.zone-drill:hover,
.zone-drill:focus {
    color: var(--primary);
    border-bottom-color: var(--primary);
    text-decoration: none;
}
.zone-drill .bi-chevron-right {
    font-size: 0.7rem;
    transition: transform 0.12s ease;
}
.zone-drill:hover .bi-chevron-right,
.zone-drill:focus .bi-chevron-right {
    transform: translateX(2px);
}

/* ==========================================================================
   Badges (100% Solid, High Contrast)
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25em 0.6em;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: var(--border-radius-sm);
    text-transform: capitalize;
    white-space: nowrap;
}

.badge-success, .bg-success {
    background-color: var(--success) !important;
    color: #ffffff !important;
}
.badge-warning, .bg-warning {
    background-color: var(--warning) !important;
    color: #ffffff !important;
}
.badge-danger, .bg-danger {
    background-color: var(--danger) !important;
    color: #ffffff !important;
}
.badge-info, .bg-info {
    background-color: var(--info) !important;
    color: #ffffff !important;
}
.badge-secondary, .bg-secondary {
    background-color: var(--secondary) !important;
    color: #ffffff !important;
}
.badge-primary, .bg-primary {
    background-color: var(--primary) !important;
    color: #ffffff !important;
}
.badge-dark, .bg-dark {
    background-color: #292524 !important;
    color: #ffffff !important;
}

/* ==========================================================================
   Tabs & Navigation (Nav-Tabs)
   ========================================================================== */
.nav-tabs {
    border-bottom: 2px solid var(--border-color);
    gap: 0.25rem;
}
.nav-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.84rem;
    padding: 0.65rem 1rem;
    border-radius: 0;
    background: none;
    cursor: pointer;
}
.nav-tabs .nav-link:hover {
    color: var(--primary);
    border-bottom-color: var(--border-color);
}
.nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: none;
}

/* ==========================================================================
   Modals (Structured, Solid Headers, Explicit Actions)
   ========================================================================== */
.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
}
.modal-header {
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface-soft);
    padding: 0.85rem 1.15rem;
}
.modal-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark);
}
.modal-body {
    padding: 1.15rem;
}
.modal-footer {
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-surface-soft);
    padding: 0.75rem 1.15rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ==========================================================================
   Alerts & Notifications
   ========================================================================== */
.alert {
    border-radius: var(--border-radius-sm);
    padding: 0.75rem 1rem;
    font-size: 0.84rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert-success {
    background-color: var(--success-bg);
    border-color: var(--success);
    color: var(--success-text);
}
.alert-warning {
    background-color: var(--warning-bg);
    border-color: var(--warning);
    color: var(--warning-text);
}
.alert-danger {
    background-color: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger-text);
}
.alert-info {
    background-color: var(--info-bg);
    border-color: var(--info);
    color: var(--info-text);
}

/* ==========================================================================
   Empty States
   ========================================================================== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.empty-state-icon {
    font-size: 2.5rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.empty-state-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.35rem;
}
.empty-state-text {
    font-size: 0.84rem;
    color: var(--text-muted);
    max-width: 420px;
    margin-bottom: 1.25rem;
}

/* ==========================================================================
   Login / Authentication Page (Kenyan Enterprise Portal)
   ========================================================================== */
.auth-body {
    background-color: #1c1917; /* Solid deep stone enterprise background */
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-page {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-card {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-top: 5px solid var(--primary);
    border-radius: var(--border-radius);
    padding: 2.25rem 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}
.auth-logo {
    width: 46px;
    height: 46px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    padding: 2px;
    display: grid;
    place-items: center;
}
.auth-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.auth-brand-copy strong {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-dark);
    display: block;
}
.auth-brand-copy small {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.auth-card-head {
    margin-bottom: 1.5rem;
}
.auth-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}
.auth-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.auth-field {
    margin-bottom: 1.15rem;
}
.auth-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.35rem;
    display: block;
}
.auth-input-wrap {
    position: relative;
}
.auth-input-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
}
.auth-input {
    width: 100%;
    padding: 0.55rem 0.85rem 0.55rem 2.4rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: #ffffff;
    color: var(--text-body);
}
.auth-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: var(--ring);
}
.auth-password-toggle {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}
.auth-password-toggle:hover {
    color: var(--text-dark);
}

.auth-submit {
    width: 100%;
    padding: 0.65rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    background-color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    margin-top: 0.5rem;
    transition: background-color 0.12s ease;
}
.auth-submit:hover {
    background-color: var(--primary-dark);
}

.auth-alert {
    padding: 0.65rem 0.85rem;
    border-radius: var(--border-radius-sm);
    background-color: var(--danger-bg);
    border: 1px solid var(--danger);
    color: var(--danger-text);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.auth-alert.is-hidden {
    display: none;
}

.auth-hint {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}
.auth-footer {
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 991.98px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    body.sidebar-open .admin-sidebar {
        transform: translateX(0);
    }
    body.sidebar-open .sidebar-backdrop {
        display: block;
    }
    .admin-main {
        margin-left: 0 !important;
    }
}

@media (max-width: 575.98px) {
    .page-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.65rem;
    }
    .heading-actions {
        width: 100%;
    }
    .heading-actions .btn {
        flex: 1;
    }
    .metric-value {
        font-size: 1.25rem;
    }
}

/* ==========================================================================
   Skeleton Loading (Neutral placeholders — matches farm-software palette).
   Use the .sk-* placeholders inside the page's existing card/table wrappers so
   the final layout stays stable while async content loads. No gradients, no
   neon — just a quiet pulse on the surface tone.
   ========================================================================== */
.sk, .sk-line, .sk-num, .sk-th, .sk-td, .sk-btn, .sk-chip, .sk-avatar {
    background-color: var(--border-subtle);
    border-radius: var(--border-radius-sm);
    animation: sk-pulse 1.5s ease-in-out infinite;
}

@keyframes sk-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
    .sk, .sk-line, .sk-num, .sk-th, .sk-td, .sk-btn, .sk-chip, .sk-avatar {
        animation: none;
    }
}

/* Text-line placeholders (heights match body copy at 14px) */
.sk-line        { height: 0.8rem; margin: 0.5rem 0; }
.sk-line--title { height: 1.05rem; width: 40%; }
.sk-line--sub   { width: 72%; }
.sk-num         { height: 1.4rem; width: 6.5rem; margin: 0.45rem 0; }

/* KPI / value card placeholder: label + figure + footnote */
.sk-kpi {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    padding: 1.05rem 1.2rem;
}

/* Table placeholder: header strip + optional trailing rows of equal height */
.sk-table { width: 100%; }
.sk-tr {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 0.7rem 0.15rem;
    border-bottom: 1px solid var(--border-subtle);
}
.sk-td { flex: 1 1 0; height: 0.85rem; }

/* Generic blocks */
.sk-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    padding: 1.1rem 1.25rem;
}
.sk-btn    { height: 2.05rem; width: 6.5rem; border-radius: var(--border-radius-sm); }
.sk-chip   { height: 1.15rem; width: 5rem; border-radius: 999px; }
.sk-avatar { height: 2.4rem; width: 2.4rem; border-radius: 50%; }

/* Search / selection result placeholder row */
.sk-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
}
.sk-result .sk { flex: 1 1 0; }

/* Width utilities for controlled placeholders */
.sk-w-10 { width: 10% !important; }
.sk-w-20 { width: 20% !important; }
.sk-w-30 { width: 30% !important; }
.sk-w-40 { width: 40% !important; }
.sk-w-50 { width: 50% !important; }
.sk-w-60 { width: 60% !important; }
.sk-w-70 { width: 70% !important; }
.sk-w-80 { width: 80% !important; }
.sk-inline { display: inline-block !important; }
.sk-multiline { height: auto; }

/* ==========================================================================
   Print Styles (Clean Official Statements & Slips)
   ========================================================================== */
@media print {
    .admin-sidebar, .admin-navbar, .sidebar-toggle, .heading-actions, .filter-bar, .admin-footer, .btn, .nav-tabs {
        display: none !important;
    }
    .admin-main {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 11pt;
    }
    .table thead th {
        background-color: #f1f5f9 !important;
        color: #000000 !important;
    }
.panel, .card {
        border: 1px solid #000000 !important;
        box-shadow: none !important;
    }
    .report-period-meta {
        border-top: none !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    .report-print-heading {
        display: block !important;
        margin-bottom: 0.5rem;
    }
    .print-letterhead {
        display: block !important;
        margin-bottom: 1rem;
    }
    .print-letterhead table.ph-table {
        width: 100%;
        border-collapse: collapse;
    }
    .print-letterhead td.ph-logo {
        width: 30mm;
        padding-right: 4mm;
        vertical-align: middle;
    }
    .print-letterhead td.ph-logo img {
        max-width: 28mm;
        height: auto;
    }
    .print-letterhead td.ph-org {
        vertical-align: middle;
    }
    .print-letterhead .ph-name {
        font-size: 16pt;
        font-weight: 800;
        letter-spacing: -0.01em;
        color: #000000;
        line-height: 1.15;
    }
    .print-letterhead .ph-addr {
        font-size: 9.5pt;
        color: #1c1917;
        margin-top: 1px;
    }
    .print-letterhead .ph-contact {
        font-size: 8.5pt;
        color: #44403c;
        margin-top: 2px;
    }
    .print-letterhead .ph-rule {
        border-bottom: 2.5px solid #047857;
        margin-top: 6px;
    }
}
