/* ==========================================================================
   AgriKhataPro - design system
   Theme, layout shell, components, loaders and animations used by every page.
   Palette: field green (growth), wheat gold (harvest), earth (soil), sky (water).
   ========================================================================== */

:root {
    /* Brand */
    --ak-green-950: #052e16;
    --ak-green-900: #0b3d24;
    --ak-green-800: #14532d;
    --ak-green-700: #15803d;
    --ak-green-600: #16a34a;
    --ak-green-500: #22c55e;
    --ak-green-200: #bbf7d0;
    --ak-green-100: #dcfce7;
    --ak-green-50: #f0fdf4;
    --ak-gold-600: #b7791f;
    --ak-gold-500: #d69e2e;
    --ak-gold-400: #f6c343;
    --ak-gold-100: #fef6d8;
    --ak-earth-700: #7c4a1e;
    --ak-sky-600: #0284c7;
    --ak-red-600: #dc2626;
    --ak-red-50: #fef2f2;
    --ak-amber-600: #d97706;

    /* Surfaces */
    --ak-bg: #f3f6f0;
    --ak-surface: #ffffff;
    --ak-surface-2: #f8faf7;
    --ak-border: #e3eadf;
    --ak-border-strong: #cfd9cb;
    --ak-text: #13231a;
    --ak-text-2: #334155;
    --ak-muted: #64748b;

    /* Shape & depth */
    --ak-radius-sm: 10px;
    --ak-radius: 14px;
    --ak-radius-lg: 20px;
    --ak-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
    --ak-shadow-sm: 0 2px 8px -2px rgba(15, 61, 36, 0.10), 0 1px 2px rgba(15, 23, 42, 0.04);
    --ak-shadow: 0 14px 36px -14px rgba(15, 61, 36, 0.22);
    --ak-shadow-lg: 0 30px 70px -20px rgba(5, 46, 22, 0.45);
    --ak-glow: 0 0 0 4px rgba(34, 197, 94, 0.18);

    /* Motion */
    --ak-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --ak-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Layout */
    --ak-sb-w: 272px;
    --ak-sb-w-mini: 84px;
    --ak-topbar-h: 66px;
    --ak-bottomnav-h: 72px;

    /* Bootstrap hooks so stock components pick up the brand */
    --bs-primary: #15803d;
    --bs-primary-rgb: 21, 128, 61;
    --bs-success: #15803d;
    --bs-success-rgb: 21, 128, 61;
    --bs-link-color: #15803d;
    --bs-link-hover-color: #14532d;
    --bs-body-font-family: "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Nastaliq Urdu", sans-serif;
    --bs-body-bg: var(--ak-bg);
    --bs-body-color: var(--ak-text);
    --bs-border-color: var(--ak-border);
    --bs-border-radius: var(--ak-radius-sm);
    --bs-border-radius-lg: var(--ak-radius);
    --bs-focus-ring-color: rgba(34, 197, 94, 0.25);
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

html, body {
    min-height: 100%;
}

body.ak-body {
    margin: 0;
    font-family: var(--bs-body-font-family);
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--ak-text);
    background:
        radial-gradient(1100px 500px at 110% -10%, rgba(34, 197, 94, 0.10), transparent 60%),
        radial-gradient(900px 480px at -10% 110%, rgba(246, 195, 67, 0.12), transparent 60%),
        var(--ak-bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

[lang="ur"] body.ak-body,
html[lang="ur"] body {
    font-family: "Noto Nastaliq Urdu", "Inter", "Segoe UI", sans-serif;
    line-height: 2;
}

::selection {
    background: rgba(34, 197, 94, 0.25);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--ak-text);
    letter-spacing: -0.01em;
}

a {
    color: var(--ak-green-700);
    text-decoration: none;
}

a:hover {
    color: var(--ak-green-800);
}

:focus-visible {
    outline: 2px solid var(--ak-green-500);
    outline-offset: 2px;
}

/* ---------- Loader (page load, every request, button clicks) ---------- */
.ak-loader {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(243, 246, 240, 0.72);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s var(--ak-ease), visibility 0.28s;
}

.ak-loader.is-on {
    opacity: 1;
    visibility: visible;
}

.ak-loader-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    padding: 1.6rem 2rem;
    border-radius: var(--ak-radius-lg);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--ak-shadow-lg);
    transform: translateY(8px) scale(0.96);
    transition: transform 0.35s var(--ak-spring);
}

.ak-loader.is-on .ak-loader-card {
    transform: none;
}

.ak-loader-ring {
    position: relative;
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--ak-green-700);
    font-size: 1.9rem;
    background: var(--ak-green-50);
}

.ak-loader-ring::before,
.ak-loader-ring::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 3px solid transparent;
}

.ak-loader-ring::before {
    border-top-color: var(--ak-green-600);
    border-right-color: var(--ak-gold-400);
    animation: akSpin 0.9s linear infinite;
}

.ak-loader-ring::after {
    inset: -14px;
    border: 2px dashed rgba(22, 163, 74, 0.25);
    animation: akSpin 3.2s linear infinite reverse;
}

.ak-loader-ring i {
    animation: akPulse 1.4s ease-in-out infinite;
}

.ak-loader-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ak-text-2);
    letter-spacing: 0.02em;
}

/* Spinner that is injected inside a button while it waits */
.ak-btn-spin {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: 0.45rem;
    vertical-align: -0.15em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: akSpin 0.7s linear infinite;
}

.btn.ak-is-loading {
    pointer-events: none;
    opacity: 0.85;
}

.btn.ak-is-loading > i:not(.ak-btn-spin) {
    opacity: 0.35;
}

/* ---------- Sidebar (desktop) & drawer (mobile) ---------- */
.ak-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    width: var(--ak-sb-w);
    display: flex;
    flex-direction: column;
    color: #d1fae5;
    background:
        radial-gradient(160% 40% at 0% 0%, rgba(74, 222, 128, 0.22), transparent 60%),
        radial-gradient(120% 45% at 100% 100%, rgba(246, 195, 67, 0.12), transparent 70%),
        linear-gradient(180deg, #0b3d24 0%, #0f4a2b 55%, #0a2f1b 100%);
    box-shadow: 10px 0 40px -18px rgba(3, 30, 15, 0.55);
    transition: width 0.3s var(--ak-ease), transform 0.3s var(--ak-ease);
}

.ak-sidebar::after {
    /* Subtle wheat-field pattern at the bottom of the menu */
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 120px;
    pointer-events: none;
    background:
        radial-gradient(circle at 20% 100%, rgba(246, 195, 67, 0.12) 0 6px, transparent 7px),
        radial-gradient(circle at 50% 100%, rgba(246, 195, 67, 0.09) 0 8px, transparent 9px),
        radial-gradient(circle at 80% 100%, rgba(246, 195, 67, 0.12) 0 6px, transparent 7px);
    opacity: 0.9;
}

.ak-sb-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.1rem 1.1rem 0.9rem;
    min-height: var(--ak-topbar-h);
}

.ak-sb-logo {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    font-size: 1.35rem;
    color: #3b2a07;
    background: linear-gradient(145deg, #fde68a, #f6c343 55%, #d69e2e);
    box-shadow: 0 8px 20px -6px rgba(246, 195, 67, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.ak-sb-brand {
    min-width: 0;
    line-height: 1.2;
}

.ak-sb-brand-name {
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ak-sb-brand-sub {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(209, 250, 229, 0.65);
}

.ak-sb-close {
    margin-left: auto;
    display: none;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 12px;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.ak-sb-search {
    position: relative;
    margin: 0 1rem 0.6rem;
}

.ak-sb-search i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(209, 250, 229, 0.7);
    font-size: 0.9rem;
}

.ak-sb-search input {
    width: 100%;
    height: 40px;
    padding: 0 0.85rem 0 2.4rem;
    border: 1px solid rgba(187, 247, 208, 0.16);
    border-radius: 12px;
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.ak-sb-search input::placeholder {
    color: rgba(209, 250, 229, 0.55);
}

.ak-sb-search input:focus {
    border-color: rgba(246, 195, 67, 0.7);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 4px rgba(246, 195, 67, 0.15);
}

.ak-sb-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.25rem 0.6rem 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(187, 247, 208, 0.25) transparent;
}

.ak-sb-section {
    margin: 0.9rem 0.6rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(209, 250, 229, 0.5);
    white-space: nowrap;
    overflow: hidden;
}

.ak-sb-link,
.ak-sb-group-toggle {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    margin: 2px 0;
    border: 0;
    border-radius: 12px;
    color: #d1fae5;
    background: transparent;
    font-size: 0.92rem;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
    transition: background-color 0.2s var(--ak-ease), color 0.2s, transform 0.2s var(--ak-ease);
}

.ak-sb-link:hover,
.ak-sb-group-toggle:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
    transform: translateX(3px);
}

.ak-sb-link.is-active {
    color: #fff;
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.35), rgba(34, 197, 94, 0.08));
    box-shadow: inset 0 0 0 1px rgba(134, 239, 172, 0.18);
}

.ak-sb-link.is-active::before {
    content: "";
    position: absolute;
    left: -0.6rem;
    top: 22%;
    bottom: 22%;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--ak-gold-400);
    box-shadow: 0 0 12px rgba(246, 195, 67, 0.7);
}

.ak-sb-ico {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    font-size: 1.02rem;
    background: rgba(255, 255, 255, 0.06);
    transition: background-color 0.2s, color 0.2s, transform 0.3s var(--ak-spring);
}

.ak-sb-link:hover .ak-sb-ico {
    transform: scale(1.08) rotate(-4deg);
}

.ak-sb-link.is-active .ak-sb-ico {
    color: #3b2a07;
    background: linear-gradient(145deg, #fde68a, #f6c343);
}

.ak-sb-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.ak-sb-group-toggle .ak-sb-chev {
    margin-left: auto;
    font-size: 0.8rem;
    opacity: 0.7;
    transition: transform 0.3s var(--ak-ease);
}

.ak-sb-group-toggle[aria-expanded="true"] .ak-sb-chev {
    transform: rotate(180deg);
}

.ak-sb-sub {
    padding: 0.1rem 0 0.35rem 1.15rem;
    margin-left: 1.05rem;
    border-left: 1px dashed rgba(187, 247, 208, 0.22);
}

.ak-sb-sub .ak-sb-link {
    padding: 0.42rem 0.6rem;
    font-size: 0.88rem;
}

.ak-sb-sub .ak-sb-ico {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
    border-radius: 9px;
}

.ak-sb-hidden {
    display: none !important;
}

/* Collapsed (mini) desktop rail */
@media (min-width: 992px) {
    html.ak-sb-collapsed .ak-sidebar {
        width: var(--ak-sb-w-mini);
    }

    html.ak-sb-collapsed .ak-sb-brand,
    html.ak-sb-collapsed .ak-sb-search,
    html.ak-sb-collapsed .ak-sb-label,
    html.ak-sb-collapsed .ak-sb-chev,
    html.ak-sb-collapsed .ak-sb-section {
        display: none;
    }

    html.ak-sb-collapsed .ak-sb-head {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    html.ak-sb-collapsed .ak-sb-link,
    html.ak-sb-collapsed .ak-sb-group-toggle {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    html.ak-sb-collapsed .ak-sb-sub {
        position: absolute;
        left: 100%;
        top: 0;
        width: 230px;
        margin: 0;
        padding: 0.6rem;
        border-radius: 14px;
        background: #0f4a2b;
        box-shadow: var(--ak-shadow-lg);
        display: none;
    }

    html.ak-sb-collapsed .ak-sb-sub.is-open {
        display: block;
    }

    html.ak-sb-collapsed .ak-sb-group {
        position: relative;
    }

    html.ak-sb-collapsed .ak-sb-sub .ak-sb-label {
        display: inline;
    }

    html.ak-sb-collapsed .ak-sb-sub .ak-sb-link {
        justify-content: flex-start;
        padding-left: 0.6rem;
    }
}

/* ---------- Main area & top bar ---------- */
.ak-main {
    margin-left: var(--ak-sb-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s var(--ak-ease);
}

html.ak-sb-collapsed .ak-main {
    margin-left: var(--ak-sb-w-mini);
}

.ak-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: var(--ak-topbar-h);
    padding: 0.6rem 1.25rem;
    background: rgba(255, 255, 255, 0.78);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid rgba(227, 234, 223, 0.9);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6), 0 8px 24px -18px rgba(15, 61, 36, 0.35);
}

.ak-icon-btn {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--ak-border);
    border-radius: 12px;
    color: var(--ak-green-800);
    background: var(--ak-surface);
    font-size: 1.1rem;
    box-shadow: var(--ak-shadow-xs);
    transition: transform 0.2s var(--ak-spring), background-color 0.2s, border-color 0.2s, color 0.2s;
}

.ak-icon-btn:hover {
    transform: translateY(-1px);
    background: var(--ak-green-50);
    border-color: var(--ak-green-200);
}

.ak-icon-btn:active {
    transform: scale(0.94);
}

.ak-page-title {
    min-width: 0;
    line-height: 1.2;
}

.ak-page-title .ak-crumb {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ak-muted);
}

.ak-page-title .ak-name {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--ak-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ak-top-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.ak-lang-btn {
    height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.85rem;
    border: 1px solid var(--ak-border);
    border-radius: 12px;
    background: var(--ak-surface);
    color: var(--ak-text-2);
    font-size: 0.85rem;
    font-weight: 600;
}

.ak-lang-btn:hover {
    background: var(--ak-green-50);
    color: var(--ak-green-800);
}

.ak-user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0.85rem 0.3rem 0.3rem;
    border: 1px solid var(--ak-border);
    border-radius: 999px;
    background: var(--ak-surface);
    box-shadow: var(--ak-shadow-xs);
}

.ak-avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.82rem;
    color: #fff;
    background: linear-gradient(135deg, #22c55e, #14532d);
    box-shadow: 0 4px 10px -3px rgba(20, 83, 45, 0.6);
}

.ak-user-meta {
    line-height: 1.15;
    min-width: 0;
}

.ak-user-name {
    font-size: 0.85rem;
    font-weight: 700;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ak-role {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ak-green-700);
}

.ak-btn-logout {
    height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.95rem;
    border: 0;
    border-radius: 12px;
    color: #fff;
    font-weight: 600;
    font-size: 0.87rem;
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    box-shadow: 0 8px 18px -8px rgba(185, 28, 28, 0.6);
    transition: transform 0.2s var(--ak-spring), box-shadow 0.2s;
}

.ak-btn-logout:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 12px 22px -8px rgba(185, 28, 28, 0.65);
}

.ak-btn-logout:active {
    transform: scale(0.96);
}

.ak-content {
    flex: 1 1 auto;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 3rem;
}

/* Page header rows (title + action buttons) wrap cleanly on phones */
.ak-content > .d-flex.justify-content-between {
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
}

.ak-content > .d-flex.justify-content-between > div:last-child:not(:first-child) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

@media (max-width: 575.98px) {
    .ak-content > .d-flex.justify-content-between > div:last-child:not(:first-child) {
        width: 100%;
    }

    .ak-content > .d-flex.justify-content-between > div:last-child:not(:first-child) > .btn {
        flex: 1 1 auto;
    }
}

/* Page entrance: each block eases in one after another */
.ak-content > * {
    /* "backwards" (not "both"): a finished animation must not keep a transform,
       because a transform would trap position: fixed children such as the bill bar */
    animation: akFadeUp 0.5s var(--ak-ease) backwards;
}

.ak-content > *:nth-child(2) { animation-delay: 60ms; }
.ak-content > *:nth-child(3) { animation-delay: 120ms; }
.ak-content > *:nth-child(4) { animation-delay: 180ms; }
.ak-content > *:nth-child(5) { animation-delay: 240ms; }
.ak-content > *:nth-child(n+6) { animation-delay: 300ms; }

/* Page heading (every page starts with an h2 header row) */
.ak-content > h2,
.ak-content > .d-flex > div > h2,
.ak-content > .d-flex > h2 {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ak-text);
}

.ak-content > .d-flex > div > p.text-muted,
.ak-content > .d-flex > .text-muted {
    font-size: 0.9rem;
}

/* ---------- Bottom navigation (mobile / tablet) ---------- */
.ak-bottomnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1035;
    display: none;
    padding: 0.4rem 0.6rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    backdrop-filter: saturate(160%) blur(16px);
    border-top: 1px solid var(--ak-border);
    box-shadow: 0 -10px 30px -18px rgba(15, 61, 36, 0.4);
}

.ak-bottomnav-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ak-bottomnav-link {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-height: 56px;
    border: 0;
    border-radius: 16px;
    color: var(--ak-muted);
    background: transparent;
    font-size: 0.7rem;
    font-weight: 600;
    width: 100%;
    transition: color 0.25s, background-color 0.25s, transform 0.2s var(--ak-spring);
}

.ak-bottomnav-link i {
    font-size: 1.3rem;
    transition: transform 0.35s var(--ak-spring);
}

.ak-bottomnav-link.is-active {
    color: var(--ak-green-800);
    background: var(--ak-green-50);
}

.ak-bottomnav-link.is-active i {
    transform: translateY(-2px) scale(1.12);
    color: var(--ak-green-700);
}

.ak-bottomnav-link.is-active::after {
    content: "";
    position: absolute;
    top: 4px;
    width: 22px;
    height: 4px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--ak-gold-400), var(--ak-green-500));
}

.ak-bottomnav-link:active {
    transform: scale(0.94);
}

/* Drawer backdrop */
.ak-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1039;
    background: rgba(5, 30, 15, 0.45);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s var(--ak-ease), visibility 0.3s;
}

html.ak-drawer-open .ak-backdrop {
    opacity: 1;
    visibility: visible;
}

/* ---------- Responsive shell ---------- */
@media (max-width: 991.98px) {
    .ak-sidebar {
        width: min(86vw, 320px);
        transform: translateX(-102%);
        box-shadow: 20px 0 50px -20px rgba(3, 30, 15, 0.6);
    }

    html.ak-drawer-open .ak-sidebar {
        transform: none;
    }

    .ak-sb-close {
        display: inline-grid;
        place-items: center;
    }

    .ak-main {
        margin-left: 0;
    }

    html.ak-sb-collapsed .ak-main {
        margin-left: 0;
    }

    .ak-bottomnav {
        display: block;
    }

    .ak-content {
        padding: 1.1rem 1rem calc(var(--ak-bottomnav-h) + 1.25rem);
    }

    .ak-user-meta,
    .ak-btn-logout span {
        display: none;
    }

    .ak-btn-logout {
        width: 42px;
        padding: 0;
        justify-content: center;
    }

    .ak-lang-btn span {
        display: none;
    }

    .ak-lang-btn {
        width: 42px;
        padding: 0;
        justify-content: center;
    }

    .ak-user-chip {
        padding: 0.2rem;
    }

    .ak-content > h2,
    .ak-content > .d-flex > div > h2,
    .ak-content > .d-flex > h2 {
        font-size: 1.3rem;
    }
}

@media (max-width: 575.98px) {
    .ak-topbar {
        padding: 0.55rem 0.75rem;
        gap: 0.5rem;
    }

    .ak-top-actions {
        gap: 0.4rem;
    }

    .ak-page-title .ak-crumb {
        display: none;
    }

    .ak-content {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }
}

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius);
    background: var(--ak-surface);
    box-shadow: var(--ak-shadow-sm);
    transition: box-shadow 0.3s var(--ak-ease), transform 0.3s var(--ak-ease), border-color 0.3s;
}

.card.shadow-sm {
    box-shadow: var(--ak-shadow-sm) !important;
}

.card:hover {
    box-shadow: var(--ak-shadow);
}

.card-header {
    background: var(--ak-surface-2);
    border-bottom: 1px solid var(--ak-border);
    font-weight: 700;
}

.card-body {
    padding: 1.25rem;
}

@media (max-width: 575.98px) {
    .card-body {
        padding: 1rem;
    }
}

/* Stock Bootstrap "primary" colours (blue) are mapped to the brand green */
.btn-primary {
    color: #fff;
    border: 0;
    background: linear-gradient(135deg, #22c55e 0%, #15803d 60%, #14532d 100%);
    box-shadow: 0 8px 18px -8px rgba(21, 128, 61, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-primary:hover,
.btn-primary:focus {
    color: #fff;
    background: linear-gradient(135deg, #16a34a 0%, #166534 60%, #14532d 100%);
}

.btn-outline-primary {
    color: var(--ak-green-700);
    border-color: var(--ak-green-600);
}

.btn-outline-primary:hover {
    color: #fff;
    background: var(--ak-green-700);
    border-color: var(--ak-green-700);
}

.list-group-item.active,
.list-group-item-action.active {
    color: #fff;
    background: linear-gradient(135deg, #22c55e, #15803d);
    border-color: transparent;
    box-shadow: 0 8px 18px -10px rgba(21, 128, 61, 0.8);
}

.list-group-item-action:hover {
    background: var(--ak-green-50);
    color: var(--ak-green-800);
}

.text-primary { color: var(--ak-green-700) !important; }
.bg-primary { background-color: var(--ak-green-700) !important; }
.badge.bg-primary { background-color: var(--ak-green-700) !important; }
.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
    background: linear-gradient(135deg, #22c55e, #15803d);
}
.nav-tabs .nav-link.active {
    color: var(--ak-green-800);
    border-color: var(--ak-border) var(--ak-border) #fff;
    font-weight: 700;
}
.nav-tabs .nav-link:hover { color: var(--ak-green-700); }
.page-link.active, .active > .page-link {
    background-color: var(--ak-green-700);
    border-color: var(--ak-green-700);
}

/* ---------- Buttons ---------- */
.btn {
    position: relative;
    border-radius: var(--ak-radius-sm);
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 0.5rem 1rem;
    transition: transform 0.2s var(--ak-spring), box-shadow 0.25s var(--ak-ease), background-color 0.2s, color 0.2s, border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled,
.btn.disabled {
    transform: none;
    box-shadow: none;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 9px;
}

.btn-lg {
    padding: 0.75rem 1.4rem;
    border-radius: var(--ak-radius);
}

.btn-success {
    color: #fff;
    border: 0;
    background: linear-gradient(135deg, #22c55e 0%, #15803d 60%, #14532d 100%);
    box-shadow: 0 8px 18px -8px rgba(21, 128, 61, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-success:hover,
.btn-success:focus {
    color: #fff;
    background: linear-gradient(135deg, #16a34a 0%, #166534 60%, #14532d 100%);
    box-shadow: 0 12px 24px -10px rgba(21, 128, 61, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-outline-success {
    color: var(--ak-green-700);
    border-color: var(--ak-green-600);
    background: var(--ak-surface);
}

.btn-outline-success:hover {
    color: #fff;
    background: var(--ak-green-700);
    border-color: var(--ak-green-700);
}

.btn-warning {
    color: #3b2a07;
    border: 0;
    background: linear-gradient(135deg, #fde68a, #f6c343 55%, #d69e2e);
    box-shadow: 0 8px 18px -8px rgba(214, 158, 46, 0.7);
}

.btn-warning:hover {
    color: #3b2a07;
    background: linear-gradient(135deg, #fde68a, #facc15 55%, #ca8a04);
}

.btn-danger {
    border: 0;
    background: linear-gradient(135deg, #f87171, #dc2626);
    box-shadow: 0 8px 18px -8px rgba(220, 38, 38, 0.6);
}

.btn-outline-secondary,
.btn-outline-danger,
.btn-outline-primary,
.btn-outline-info {
    background: var(--ak-surface);
}

.btn-outline-secondary {
    color: var(--ak-text-2);
    border-color: var(--ak-border-strong);
}

.btn-outline-secondary:hover {
    color: var(--ak-text);
    background: var(--ak-surface-2);
    border-color: var(--ak-muted);
}

.btn-light {
    background: var(--ak-surface-2);
    border-color: var(--ak-border);
}

.btn-close {
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.3s var(--ak-spring);
}

.btn-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}

/* ---------- Forms ---------- */
.form-label {
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ak-text-2);
}

.form-control,
.form-select,
.input-group-text {
    min-height: 44px;
    border-radius: var(--ak-radius-sm);
    border: 1px solid var(--ak-border-strong);
    background-color: #fff;
    font-size: 0.95rem;
    transition: border-color 0.2s var(--ak-ease), box-shadow 0.2s var(--ak-ease), background-color 0.2s;
}

.form-control:hover,
.form-select:hover {
    border-color: #b6c6b0;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ak-green-500);
    box-shadow: var(--ak-glow);
    outline: 0;
}

.form-control[readonly],
.form-control:disabled,
.form-select:disabled {
    background-color: var(--ak-surface-2);
    color: var(--ak-muted);
}

.form-control-sm,
.form-select-sm {
    min-height: 38px;
    font-size: 0.88rem;
}

textarea.form-control {
    min-height: 88px;
}

.input-group-text {
    color: var(--ak-muted);
    background: var(--ak-surface-2);
}

.form-check-input:checked {
    background-color: var(--ak-green-600);
    border-color: var(--ak-green-600);
}

.form-check-input:focus {
    box-shadow: var(--ak-glow);
}

.form-text {
    color: var(--ak-muted);
}

/* Tom Select (searchable dropdowns) skinned to match inputs */
.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--ak-border-strong);
    border-radius: var(--ak-radius-sm);
    background: #fff;
    box-shadow: none;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ts-wrapper.focus .ts-control {
    border-color: var(--ak-green-500);
    box-shadow: var(--ak-glow);
}

.ts-wrapper.form-control-sm .ts-control,
.ts-wrapper.form-select-sm .ts-control {
    min-height: 38px;
}

.ts-dropdown {
    z-index: 2100;
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-sm);
    box-shadow: var(--ak-shadow);
    overflow: hidden;
    animation: akDropIn 0.2s var(--ak-ease) both;
}

.ts-dropdown .ts-dropdown-content {
    max-height: 300px;
}

.ts-dropdown .option {
    padding: 0.5rem 0.75rem;
}

.ts-dropdown .active {
    background: var(--ak-green-50);
    color: var(--ak-green-800);
}

.ts-dropdown input[type="text"] {
    border-radius: 8px;
}

.ts-dropdown .no-results {
    padding: 0.6rem 0.75rem;
    color: var(--ak-muted);
}

.ts-wrapper.disabled .ts-control {
    background: var(--ak-surface-2);
}

/* ---------- Tables ---------- */
.table-responsive {
    border-radius: var(--ak-radius);
}

.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: var(--ak-green-50);
    --bs-table-border-color: var(--ak-border);
    font-size: 0.9rem;
    color: var(--ak-text);
}

.table > :not(caption) > * > * {
    padding: 0.7rem 0.8rem;
    vertical-align: middle;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ak-muted);
    background: var(--ak-surface-2);
    border-bottom: 1px solid var(--ak-border) !important;
    white-space: nowrap;
}

.table-hover > tbody > tr {
    transition: background-color 0.2s;
}

.table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: transparent;
}

.table tbody td {
    border-color: var(--ak-border);
}

.table-sm > :not(caption) > * > * {
    padding: 0.5rem 0.6rem;
}

tbody.ak-anim > tr:not(.dt-hidden) {
    animation: akRowIn 0.35s var(--ak-ease) both;
}

tbody.ak-anim > tr:not(.dt-hidden):nth-child(2) { animation-delay: 20ms; }
tbody.ak-anim > tr:not(.dt-hidden):nth-child(3) { animation-delay: 40ms; }
tbody.ak-anim > tr:not(.dt-hidden):nth-child(4) { animation-delay: 60ms; }
tbody.ak-anim > tr:not(.dt-hidden):nth-child(5) { animation-delay: 80ms; }
tbody.ak-anim > tr:not(.dt-hidden):nth-child(6) { animation-delay: 100ms; }

.dt-hidden {
    display: none !important;
}

/* Table tools: search, page size, info, pager */
.ak-table-tools,
.ak-table-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 0.9rem;
    padding: 0.75rem 1rem;
}

.ak-table-tools {
    padding-bottom: 0.5rem;
}

.ak-table-search {
    position: relative;
    flex: 1 1 260px;
    max-width: 420px;
}

.ak-table-search i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ak-muted);
    pointer-events: none;
}

.ak-table-search input {
    padding-left: 2.4rem;
    padding-right: 2.2rem;
    height: 40px;
    border-radius: 12px;
    background: var(--ak-surface);
}

.ak-table-search .ak-clear {
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 9px;
    color: var(--ak-muted);
    background: transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, background-color 0.2s;
}

.ak-table-search.has-value .ak-clear {
    opacity: 1;
    pointer-events: auto;
}

.ak-table-search .ak-clear:hover {
    background: var(--ak-surface-2);
    color: var(--ak-text);
}

.ak-table-size {
    width: auto;
    min-width: 92px;
    height: 40px;
    border-radius: 12px;
    font-size: 0.88rem;
}

.ak-table-info {
    font-size: 0.84rem;
    color: var(--ak-muted);
}

.ak-pager {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.ak-pager button {
    min-width: 36px;
    height: 36px;
    padding: 0 0.6rem;
    border: 1px solid var(--ak-border);
    border-radius: 10px;
    background: var(--ak-surface);
    color: var(--ak-text-2);
    font-size: 0.86rem;
    font-weight: 600;
    transition: transform 0.2s var(--ak-spring), background-color 0.2s, color 0.2s, border-color 0.2s;
}

.ak-pager button:hover:not(:disabled):not(.is-active) {
    background: var(--ak-green-50);
    border-color: var(--ak-green-200);
    transform: translateY(-1px);
}

.ak-pager button.is-active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, #22c55e, #15803d);
    box-shadow: 0 6px 14px -4px rgba(22, 163, 74, 0.5);
}

.ak-pager button:disabled {
    opacity: 0.4;
}

.ak-pager .ak-gap {
    padding: 0 0.2rem;
    color: var(--ak-muted);
}

th.ak-sortable {
    cursor: pointer;
    user-select: none;
}

th.ak-sortable::after {
    content: "\F283";
    font-family: "bootstrap-icons";
    margin-left: 0.35rem;
    opacity: 0.3;
    font-size: 0.7rem;
}

th.ak-sortable:hover {
    color: var(--ak-green-700);
}

th.ak-sort-asc::after {
    content: "\F148";
    opacity: 1;
    color: var(--ak-green-700);
}

th.ak-sort-desc::after {
    content: "\F12C";
    opacity: 1;
    color: var(--ak-green-700);
}

tr.ak-empty td {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--ak-muted);
}

tr.ak-empty i {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.4rem;
    color: var(--ak-green-500);
}

/* Mobile: each table row becomes a card with labelled values */
@media (max-width: 767.98px) {
    .ak-table-cards thead {
        display: none;
    }

    .ak-table-cards,
    .ak-table-cards tbody {
        display: block;
        width: 100%;
    }

    .ak-table-cards tbody tr {
        display: block;
        margin-bottom: 0.75rem;
        padding: 0.4rem 0.9rem;
        border: 1px solid var(--ak-border);
        border-radius: var(--ak-radius);
        background: var(--ak-surface);
        box-shadow: var(--ak-shadow-sm);
    }

    .ak-table-cards tbody tr:hover {
        background: var(--ak-surface);
    }

    .ak-table-cards td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 0.8rem;
        padding: 0.42rem 0 !important;
        border: 0 !important;
        text-align: right;
        word-break: break-word;
    }

    .ak-table-cards td + td {
        border-top: 1px dashed var(--ak-border) !important;
    }

    .ak-table-cards td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--ak-muted);
        text-align: left;
    }

    .ak-table-cards td:empty::before,
    .ak-table-cards td[data-label=""]::before {
        display: none;
    }

    .ak-table-cards td[colspan] {
        display: block;
        text-align: center;
    }

    .ak-table-cards td[colspan]::before {
        content: none;
    }

    .ak-table-cards tr.ak-empty {
        border: 0;
        background: transparent;
        box-shadow: none;
        padding: 0;
    }

    .ak-table-cards td .btn,
    .ak-table-cards td a.btn {
        white-space: nowrap;
    }

    .ak-table-tools > * {
        flex: 1 1 100%;
    }

    .ak-table-size {
        flex: 0 0 auto;
    }

    .ak-table-foot {
        justify-content: center;
        text-align: center;
    }
}

/* ---------- Badges, alerts, misc ---------- */
.badge {
    font-weight: 700;
    letter-spacing: 0.02em;
    border-radius: 999px;
    padding: 0.4em 0.7em;
}

.alert {
    border: 0;
    border-radius: var(--ak-radius);
    box-shadow: var(--ak-shadow-xs);
    animation: akFadeUp 0.4s var(--ak-ease) both;
}

.alert-danger {
    background: var(--ak-red-50);
    color: #991b1b;
}

.alert-success {
    background: var(--ak-green-50);
    color: var(--ak-green-800);
}

.alert-warning {
    background: var(--ak-gold-100);
    color: #854d0e;
}

.alert-info {
    background: #eff8ff;
    color: #075985;
}

.modal-content {
    border: 0;
    border-radius: var(--ak-radius-lg);
    box-shadow: var(--ak-shadow-lg);
    overflow: hidden;
}

.modal-header {
    padding: 1.1rem 1.25rem;
    background: linear-gradient(180deg, var(--ak-green-50), #fff);
    border-bottom: 1px solid var(--ak-border);
}

.modal-title {
    font-weight: 800;
    font-size: 1.05rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 0.9rem 1.25rem;
    background: var(--ak-surface-2);
    border-top: 1px solid var(--ak-border);
}

.modal.fade .modal-dialog {
    transform: translateY(18px) scale(0.97);
    transition: transform 0.38s var(--ak-spring), opacity 0.25s ease;
}

.modal.show .modal-dialog {
    transform: none;
}

/* Modals become bottom sheets on phones */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0;
        margin-top: auto;
        max-width: 100%;
        min-height: auto;
        display: flex;
        align-items: flex-end;
    }

    .modal-dialog .modal-content {
        width: 100%;
        border-radius: 22px 22px 0 0;
        max-height: 92vh;
    }

    .modal-dialog .modal-body {
        overflow-y: auto;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }

    .modal.fade .modal-dialog {
        transform: translateY(100%);
    }

    .modal.show .modal-dialog {
        transform: none;
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        z-index: 1;
        padding-bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
    }

    .modal-footer .btn {
        flex: 1 1 auto;
    }
}

/* Toasts */
.ak-toast-stack {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2200;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: min(380px, calc(100vw - 2rem));
    pointer-events: none;
}

.ak-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: var(--ak-radius);
    background: #fff;
    box-shadow: var(--ak-shadow-lg);
    border-left: 5px solid var(--ak-green-600);
    animation: akToastIn 0.45s var(--ak-spring) both;
}

.ak-toast.is-hiding {
    animation: akToastOut 0.3s var(--ak-ease) forwards;
}

.ak-toast i.ak-toast-ico {
    font-size: 1.2rem;
    color: var(--ak-green-600);
    margin-top: 0.1rem;
}

.ak-toast.is-danger {
    border-left-color: var(--ak-red-600);
}

.ak-toast.is-danger i.ak-toast-ico {
    color: var(--ak-red-600);
}

.ak-toast.is-warning {
    border-left-color: var(--ak-gold-500);
}

.ak-toast.is-warning i.ak-toast-ico {
    color: var(--ak-gold-500);
}

.ak-toast.is-info {
    border-left-color: var(--ak-sky-600);
}

.ak-toast.is-info i.ak-toast-ico {
    color: var(--ak-sky-600);
}

.ak-toast-body {
    flex: 1 1 auto;
    font-size: 0.92rem;
    color: var(--ak-text-2);
}

.ak-toast-close {
    border: 0;
    background: transparent;
    color: var(--ak-muted);
    padding: 0.1rem;
    line-height: 1;
}

/* Page-level helpers */
.ak-stat {
    position: relative;
    overflow: hidden;
    padding: 1.1rem 1.2rem;
    border-radius: var(--ak-radius);
    background: var(--ak-surface);
    border: 1px solid var(--ak-border);
    box-shadow: var(--ak-shadow-sm);
    transition: transform 0.35s var(--ak-spring), box-shadow 0.3s;
}

.ak-stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--ak-shadow);
}

.ak-stat::after {
    content: "";
    position: absolute;
    right: -30px;
    top: -30px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(34, 197, 94, 0.14), transparent 70%);
}

.ak-ico-chip {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    font-size: 1.3rem;
    color: var(--ak-green-800);
    background: var(--ak-green-100);
}

.ak-ico-chip.is-gold {
    color: #854d0e;
    background: var(--ak-gold-100);
}

.ak-ico-chip.is-red {
    color: #b91c1c;
    background: #fee2e2;
}

.ak-ico-chip.is-blue {
    color: #075985;
    background: #e0f2fe;
}

.ak-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1rem;
}

.ak-section-title i {
    color: var(--ak-green-700);
}

.ak-empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--ak-muted);
}

.ak-empty-state i {
    font-size: 2.4rem;
    color: var(--ak-green-500);
}

.ak-kbd {
    padding: 0.1rem 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 0.72rem;
}

.ak-shimmer {
    background: linear-gradient(90deg, #eef3ec 25%, #f7faf6 37%, #eef3ec 63%);
    background-size: 400% 100%;
    animation: akShimmer 1.4s ease infinite;
    border-radius: 8px;
}

/* ==========================================================================
   Entry forms (sales, purchases): page head, tabs, numbered steps,
   segmented choices, bill summary, and line items that become cards on phones
   ========================================================================== */
.ak-pagehead {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin-bottom: 1.1rem;
}

.ak-pagehead-main {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

.ak-pagehead h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.ak-pagehead-sub {
    font-size: 0.88rem;
    color: var(--ak-muted);
}

.ak-editbadge {
    font-size: 0.86rem;
    padding: 0.55em 0.85em;
    border-radius: 12px;
}

.ak-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.35rem;
    background: var(--ak-surface);
    border: 1px solid var(--ak-border);
    border-radius: 16px;
    box-shadow: var(--ak-shadow-xs);
}

.ak-tabs .nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    padding: 0.6rem 1.1rem;
    border: 0;
    border-radius: 12px;
    color: var(--ak-text-2);
    font-weight: 700;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.25s;
}

.ak-tabs .nav-link:hover:not(.active) {
    color: var(--ak-green-800);
    background: var(--ak-green-50);
}

.ak-tabs .nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, #22c55e 0%, #15803d 70%, #14532d 100%);
    box-shadow: 0 8px 18px -8px rgba(21, 128, 61, 0.7);
}

.ak-tabcount {
    font-size: 0.72rem;
    color: var(--ak-green-800);
    background: var(--ak-green-100);
}

.ak-tabs .nav-link.active .ak-tabcount {
    color: #fff;
    background: rgba(255, 255, 255, 0.25);
}

.tab-content > .tab-pane.fade {
    transition: opacity 0.25s var(--ak-ease), transform 0.3s var(--ak-ease);
    transform: translateY(6px);
}

.tab-content > .tab-pane.fade.show {
    transform: none;
}

.ak-step {
    border: 1px solid var(--ak-border);
}

.ak-step-head {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.ak-step-no {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    font-weight: 800;
    color: #3b2a07;
    background: linear-gradient(145deg, #fde68a, #f6c343 60%, #d69e2e);
    box-shadow: 0 6px 14px -6px rgba(214, 158, 46, 0.7);
}

.ak-step-head .btn {
    white-space: nowrap;
}

.ak-step-title {
    font-weight: 800;
    font-size: 1.02rem;
}

.ak-step-sub {
    font-size: 0.84rem;
    color: var(--ak-muted);
}

/* Segmented choices (radio buttons styled as a button group) */
.ak-seg {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ak-seg > .btn {
    flex: 1 1 auto;
    margin: 0 !important;
    border-radius: 12px !important;
    padding: 0.6rem 0.8rem;
    font-weight: 600;
}

/* Bill summary: beside the form on desktop, a bar above the bottom nav on phones */
.ak-summary {
    border: 1px solid var(--ak-border);
    box-shadow: var(--ak-shadow);
}

.ak-summary-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    font-weight: 800;
}

.ak-summary-title i {
    color: var(--ak-green-700);
}

.ak-kv {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0;
    border-bottom: 1px dashed var(--ak-border);
    font-size: 0.92rem;
}

.ak-kv > span:last-child {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.ak-inline-input {
    width: 140px;
    text-align: right;
}

.ak-net {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0.9rem 0;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--ak-green-200);
    background: linear-gradient(135deg, #f0fdf4, #fef6d8);
}

.ak-net > span {
    white-space: nowrap;
    font-weight: 700;
    color: var(--ak-green-800);
}

.ak-net > strong {
    white-space: nowrap;
    font-size: 1.2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--ak-text);
}

.ak-save {
    height: 52px;
    border-radius: 14px;
    font-size: 1.02rem;
    font-weight: 700;
}

.ak-hint {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--ak-muted);
}

@media (max-width: 1199.98px) {
    .ak-summary {
        max-width: 520px;
        margin-left: auto;
    }
}

@media (min-width: 1200px) {
    .ak-summary {
        position: sticky;
        top: calc(var(--ak-topbar-h) + 1rem);
    }
}

/* Line items: desktop table; phone cards with labelled fields */
table.ak-lines .form-control-sm,
table.ak-lines .form-select-sm {
    min-width: 84px;
}

table.ak-lines td {
    vertical-align: middle;
}

@media (max-width: 767.98px) {
    table.ak-lines thead {
        display: none;
    }

    table.ak-lines,
    table.ak-lines tbody {
        display: block;
        width: 100%;
    }

    table.ak-lines tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.7rem 0.8rem;
        position: relative;
        margin-bottom: 0.8rem;
        padding: 1rem;
        border: 1px solid var(--ak-border);
        border-radius: 16px;
        background: var(--ak-surface);
        box-shadow: var(--ak-shadow-sm);
    }

    table.ak-lines td {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        min-width: 0;
        padding: 0 !important;
        border: 0 !important;
        text-align: left !important;
    }

    table.ak-lines td::before {
        font-size: 0.68rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: var(--ak-muted);
    }

    table.ak-lines td:last-child {
        position: absolute;
        top: 0.45rem;
        right: 0.45rem;
    }

    table.ak-lines td:last-child::before {
        content: none;
    }

    table.ak-lines td:last-child .btn {
        width: 38px;
        height: 38px;
        padding: 0;
    }

    /* Sales: product, batch | qty, rate, discount, amount (subsidy is hidden) */
    .ak-lines-sales td:nth-child(1),
    .ak-lines-sales td:nth-child(2) {
        grid-column: 1 / -1;
    }

    .ak-lines-sales td:nth-child(1) {
        padding-right: 2.4rem !important;
    }

    .ak-lines-sales td:nth-child(1)::before { content: "Product"; }
    .ak-lines-sales td:nth-child(2)::before { content: "Batch (FIFO)"; }
    .ak-lines-sales td:nth-child(3)::before { content: "Qty"; }
    .ak-lines-sales td:nth-child(4)::before { content: "Rate"; }
    .ak-lines-sales td:nth-child(5)::before { content: "Discount / unit"; }
    .ak-lines-sales td:nth-child(7)::before { content: "Amount"; }

    .ak-lines-sales td:nth-child(7) {
        font-weight: 800;
        font-size: 1.02rem;
    }

    /* Purchase: product | batch, expiry, qty, rate, amount */
    .ak-lines-purchase td:nth-child(1) {
        grid-column: 1 / -1;
        padding-right: 2.4rem !important;
    }

    .ak-lines-purchase td:nth-child(1)::before { content: "Product"; }
    .ak-lines-purchase td:nth-child(2)::before { content: "Batch no"; }
    .ak-lines-purchase td:nth-child(3)::before { content: "Expiry date"; }
    .ak-lines-purchase td:nth-child(4)::before { content: "Qty"; }
    .ak-lines-purchase td:nth-child(5)::before { content: "Rate"; }
    .ak-lines-purchase td:nth-child(6)::before { content: "Amount"; }

    .ak-lines-purchase td:nth-child(6) {
        grid-column: 1 / -1;
        font-weight: 800;
        font-size: 1.02rem;
    }

    .ak-tabs {
        display: flex;
        width: 100%;
    }

    .ak-tabs .nav-item {
        flex: 1 1 0;
    }

    .ak-tabs .nav-link {
        justify-content: center;
        padding: 0.55rem 0.4rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .ak-seg > .btn {
        flex: 1 1 100%;
    }
}


/* Sales bill summary: pinned to the bottom of the screen on phones only (save is always in reach).
   From tablets up it sits under the form (or beside it on wide screens), so it never covers rows. */
@media (max-width: 991.98px) {
    .ak-summary.is-bar {
        position: fixed;
        z-index: 1032;
        left: 0.6rem;
        right: 0.6rem;
        bottom: calc(var(--ak-bottomnav-h) + env(safe-area-inset-bottom, 0px) + 0.5rem);
        margin: 0;
        border: 1px solid var(--ak-green-200);
        border-radius: 18px;
        box-shadow: var(--ak-shadow-lg);
    }

    .ak-summary.is-bar .card-body {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 0.6rem 0.9rem;
        padding: 0.7rem 0.9rem;
    }

    .ak-summary.is-bar .ak-summary-title,
    .ak-summary.is-bar .ak-sum-detail,
    .ak-summary.is-bar .ak-hint {
        display: none;
    }

    .ak-summary.is-bar .ak-net {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        margin: 0;
        padding: 0.35rem 0.8rem;
        border-radius: 12px;
    }

    .ak-summary.is-bar .ak-net > span {
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .ak-summary.is-bar .ak-net > strong {
        font-size: 1.2rem;
    }

    .ak-summary.is-bar .ak-save {
        height: 46px;
        width: auto;
        padding: 0 1.2rem;
        font-size: 0.95rem;
    }

    .ak-content:has(.ak-summary.is-bar) {
        padding-bottom: calc(var(--ak-bottomnav-h) + 110px);
    }
}

/* ---------- Login page ---------- */
.ak-login {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    background: #0b3d24;
}

.ak-login-hero {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(1.5rem, 3vw, 3rem);
    color: #ecfdf5;
    background:
        radial-gradient(900px 500px at 0% 0%, rgba(74, 222, 128, 0.25), transparent 60%),
        radial-gradient(700px 500px at 100% 100%, rgba(246, 195, 67, 0.22), transparent 60%),
        linear-gradient(160deg, #0b3d24 0%, #14532d 55%, #0a2e18 100%);
}

.ak-login-hero .ak-hero-art {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 42%;
    width: 100%;
    z-index: 0;
    pointer-events: none;
}

.ak-login-hero .ak-sun {
    transform-origin: center;
    animation: akSunPulse 6s ease-in-out infinite;
}

.ak-wheat {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: akSway 4.5s ease-in-out infinite;
}

.ak-wheat:nth-child(2n) { animation-delay: -1.2s; animation-duration: 5.2s; }
.ak-wheat:nth-child(3n) { animation-delay: -2.4s; animation-duration: 4.1s; }

.ak-brand-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    position: relative;
    z-index: 1;
}

.ak-brand-row .ak-sb-logo {
    width: 54px;
    height: 54px;
    font-size: 1.7rem;
    border-radius: 16px;
}

.ak-hero-title {
    position: relative;
    z-index: 1;
    max-width: 560px;
    font-size: clamp(1.9rem, 3.6vw, 3.1rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.025em;
    color: #fff;
    margin: 0 0 0.9rem;
}

.ak-hero-title span {
    background: linear-gradient(90deg, #fde68a, #f6c343 40%, #bbf7d0);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.ak-hero-sub {
    position: relative;
    z-index: 1;
    max-width: 520px;
    color: rgba(236, 253, 245, 0.82);
    font-size: 1.02rem;
}

.ak-hero-chips {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.4rem;
}

.ak-hero-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.8rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #ecfdf5;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(187, 247, 208, 0.22);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    animation: akFadeUp 0.7s var(--ak-ease) both;
}

.ak-hero-chip:nth-child(2) { animation-delay: 120ms; }
.ak-hero-chip:nth-child(3) { animation-delay: 240ms; }
.ak-hero-chip:nth-child(4) { animation-delay: 360ms; }

.ak-login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
    background:
        radial-gradient(600px 300px at 100% 0%, rgba(34, 197, 94, 0.10), transparent 60%),
        var(--ak-bg);
}

.ak-login-card {
    width: 100%;
    max-width: 430px;
    padding: 2.2rem 2rem 1.8rem;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--ak-shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.8);
    animation: akCardIn 0.7s var(--ak-spring) both;
}

.ak-login-card h1 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.ak-login-card .ak-login-sub {
    color: var(--ak-muted);
    margin-bottom: 1.4rem;
    font-size: 0.93rem;
}

.ak-field {
    position: relative;
    margin-bottom: 1rem;
}

.ak-field > i {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ak-muted);
    font-size: 1.02rem;
    pointer-events: none;
    transition: color 0.2s;
    z-index: 2;
}

.ak-field input {
    height: 52px;
    padding: 1.1rem 2.8rem 0.45rem 2.7rem;
    border-radius: 14px;
    font-size: 1rem;
}

.ak-field label {
    position: absolute;
    left: 2.7rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.95rem;
    color: var(--ak-muted);
    pointer-events: none;
    transition: all 0.2s var(--ak-ease);
    background: transparent;
    z-index: 2;
}

.ak-field input:focus + label,
.ak-field input:not(:placeholder-shown) + label {
    top: 0.55rem;
    transform: none;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--ak-green-700);
}

.ak-field input:focus ~ i {
    color: var(--ak-green-700);
}

.ak-field .ak-toggle-pass {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ak-muted);
    z-index: 3;
}

.ak-field .ak-toggle-pass:hover {
    background: var(--ak-surface-2);
    color: var(--ak-green-700);
}

.ak-login-btn {
    width: 100%;
    height: 52px;
    border-radius: 14px;
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    position: relative;
    overflow: hidden;
}

.ak-login-btn::after {
    content: "";
    position: absolute;
    top: 0;
    left: -60%;
    width: 50%;
    height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: skewX(-18deg);
    animation: akSheen 3.2s ease-in-out infinite;
}

.ak-login-error {
    display: none;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    font-size: 0.9rem;
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.ak-login-error.is-visible {
    display: flex;
    animation: akShake 0.5s var(--ak-ease), akFadeUp 0.3s var(--ak-ease);
}

.ak-login-foot {
    margin-top: 1.2rem;
    text-align: center;
    font-size: 0.78rem;
    color: var(--ak-muted);
}

.ak-login-lang {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.6rem;
}

@media (max-width: 991.98px) {
    .ak-login {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .ak-login-hero {
        padding: 1.4rem 1.25rem 4.5rem;
    }

    .ak-login-hero .ak-hero-art {
        height: 30%;
    }

    .ak-hero-title {
        font-size: 1.7rem;
    }

    .ak-hero-sub,
    .ak-hero-chips {
        display: none;
    }

    .ak-login-panel {
        margin-top: -3.2rem;
        border-radius: 26px 26px 0 0;
        padding: 1.5rem 1rem 2rem;
        min-height: 60vh;
        position: relative;
        z-index: 2;
        align-items: flex-start;
    }

    .ak-login-card {
        box-shadow: 0 -10px 40px -18px rgba(5, 46, 22, 0.35), var(--ak-shadow);
        padding: 1.6rem 1.25rem 1.4rem;
    }
}

/* ---------- Motion keyframes ---------- */
@keyframes akSpin { to { transform: rotate(360deg); } }
@keyframes akPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes akFadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes akRowIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes akDropIn { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes akToastIn { from { opacity: 0; transform: translateX(30px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes akToastOut { to { opacity: 0; transform: translateX(30px); } }
@keyframes akCardIn { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes akShake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes akSheen { 0% { left: -60%; } 60%, 100% { left: 130%; } }
@keyframes akShimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes akSway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes akSunPulse { 0%, 100% { opacity: 0.85; transform: scale(1); } 50% { opacity: 1; transform: scale(1.06); } }

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Print: clean report output */
@media print {
    .ak-sidebar,
    .ak-topbar,
    .ak-bottomnav,
    .ak-backdrop,
    .ak-loader,
    .ak-toast-stack,
    .ak-table-tools,
    .ak-table-foot,
    .btn,
    .modal-footer {
        display: none !important;
    }

    .ak-main {
        margin: 0 !important;
    }

    .ak-content {
        padding: 0 !important;
        max-width: none !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }

    .dt-hidden {
        display: table-row !important;
    }
}


/* Rows that open something when tapped (the all-farmers and all-suppliers lists) */
tr[role="button"] { cursor: pointer; }
tr[role="button"]:hover > td { background: rgba(21, 128, 61, 0.06); }

/* The old print-only shop heading on report pages: printing now uses the shared print layout (ak/report.js). */
#printShopHeader { display: none !important; }

/* Chat view on phones, table view on larger screens (ledgers and transactions) */
.view-table { display: none; }
@media (min-width: 768px) {
    .view-chat { display: none !important; }
    .view-table { display: block; }
}
.view-table .ak-act { white-space: nowrap; text-align: right; }
.view-table .ak-act .btn { padding: 0.1rem 0.45rem; }