:root {
    --bg: #eaf0f7;
    --bg-gradient-top: #f8fbff;
    --bg-gradient-bottom: #e2ebf6;
    --card: rgba(255, 255, 255, 0.94);
    --line: #d4dfed;
    --line-strong: #bfd2e8;
    --ink: #12253c;
    --ink-muted: #5b6f8a;
    --ink-soft: #7689a2;
    --brand: #0f4f84;
    --brand-2: #1c6fa8;
    --accent: #189786;
    --danger: #c03d3d;
    --success-bg: #e7f8ee;
    --success-ink: #1f7a41;
    --error-bg: #fdebec;
    --error-ink: #8f2f2f;
    --info-bg: #eaf3ff;
    --info-ink: #1f4d80;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --shadow: 0 18px 40px rgba(12, 35, 61, 0.11);
    --focus-ring: 0 0 0 3px rgba(33, 110, 176, 0.22);
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: "Manrope", "Segoe UI", Tahoma, sans-serif;
    line-height: 1.45;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    background: linear-gradient(168deg, var(--bg-gradient-top), var(--bg-gradient-bottom));
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -3;
    pointer-events: none;
    opacity: 0.7;
    background-image:
        radial-gradient(circle at 14% 18%, rgba(20, 117, 158, 0.09), rgba(20, 117, 158, 0) 38%),
        radial-gradient(circle at 90% 84%, rgba(24, 151, 134, 0.08), rgba(24, 151, 134, 0) 38%),
        linear-gradient(rgba(255, 255, 255, 0.2) 1px, transparent 1px);
    background-size: auto, auto, 100% 26px;
}

::selection {
    background: rgba(25, 98, 160, 0.2);
}

.bg-accent {
    position: fixed;
    z-index: -2;
    border-radius: 999px;
    filter: blur(2px);
    animation: float-drift 16s ease-in-out infinite alternate;
}

.bg-accent-one {
    width: 380px;
    height: 380px;
    top: -120px;
    right: -90px;
    background: radial-gradient(circle, rgba(25, 110, 145, 0.2), rgba(25, 110, 145, 0));
}

.bg-accent-two {
    width: 420px;
    height: 420px;
    bottom: -160px;
    left: -120px;
    animation-delay: 1.4s;
    background: radial-gradient(circle, rgba(31, 127, 139, 0.18), rgba(31, 127, 139, 0));
}

.main-header {
    position: sticky;
    top: 0;
    z-index: 48;
    color: #fff;
    padding: 0.72rem 1.55rem 0.65rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.9rem;
    background:
        radial-gradient(circle at 82% -70%, rgba(189, 234, 255, 0.26), rgba(189, 234, 255, 0) 40%),
        linear-gradient(135deg, #0c4370 0%, #175f95 60%, #2577ad 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 14px 34px rgba(10, 35, 60, 0.32);
    backdrop-filter: blur(8px) saturate(120%);
}

.main-header::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
}

.main-header > * {
    position: relative;
    z-index: 1;
}

.header-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.85rem;
    order: 2;
    margin-left: auto;
}

.app-eyebrow {
    margin: 0;
    font-size: 0.76rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 700;
    opacity: 0.82;
}

.main-header h1 {
    margin: 0.2rem 0 0;
    font-family: "Sora", "Manrope", sans-serif;
    font-size: 2.05rem;
    line-height: 1.12;
    letter-spacing: -0.02em;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.9rem;
}

.user-actions span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.42rem 0.66rem;
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 999px;
    background: rgba(6, 35, 63, 0.22);
}

.user-actions strong {
    font-family: "Sora", "Manrope", sans-serif;
    font-weight: 700;
}

.global-back-icon {
    position: fixed;
    top: 9px;
    left: 12px;
    z-index: 96;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    background: rgba(8, 45, 76, 0.48);
    color: #ecf5ff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.global-back-icon .icon {
    display: block;
}

.global-back-icon .icon path {
    fill: currentColor;
}

.global-back-icon:hover {
    border-color: rgba(255, 255, 255, 0.68);
    background: rgba(7, 37, 62, 0.64);
    transform: translateY(-1px);
}

.global-back-icon:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.global-forward-icon {
    left: 58px;
}

.date-ddmmyyyy-wrap {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
}

.date-ddmmyyyy-wrap .date-ddmmyyyy-display {
    flex: 1 1 auto;
    min-width: 0;
}

.date-ddmmyyyy-button {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #f7fbff;
    color: #173a60;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.date-ddmmyyyy-button:hover {
    border-color: #9bb7d8;
    background: #f0f7ff;
}

.date-ddmmyyyy-button:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.date-ddmmyyyy-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.date-ddmmyyyy-wrap > input[type="date"][data-ddmmyyyy-enhanced="1"] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.ribbon-trigger {
    display: none;
}

.main-nav {
    margin-top: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.56rem;
    order: 1;
    flex: 1 1 auto;
    padding-left: 2.35rem;
}

body.has-global-nav-controls .main-nav {
    padding-left: 6rem;
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ecf5ff;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(7, 34, 58, 0.2);
    border-radius: 999px;
    padding: 0.43rem 0.92rem;
    font-size: 0.89rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.main-nav a:hover {
    border-color: rgba(255, 255, 255, 0.52);
    background: rgba(0, 27, 52, 0.32);
    transform: translateY(-1px);
}

.main-nav a.active {
    color: #114572;
    background: #ffffff;
    border-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 20px rgba(3, 26, 48, 0.2);
}

.main-nav .nav-dropdown {
    position: relative;
}

.main-nav .nav-dropdown > summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    color: #ecf5ff;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(7, 34, 58, 0.2);
    border-radius: 999px;
    padding: 0.43rem 0.92rem;
    font-size: 0.89rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    cursor: pointer;
    user-select: none;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.main-nav .nav-dropdown > summary::-webkit-details-marker {
    display: none;
}

.main-nav .nav-dropdown > summary::marker {
    content: "";
}

.main-nav .nav-dropdown > summary::after {
    content: "v";
    font-size: 0.74rem;
    opacity: 0.86;
    transform: translateY(-1px);
}

.main-nav .nav-dropdown > summary:hover {
    border-color: rgba(255, 255, 255, 0.52);
    background: rgba(0, 27, 52, 0.32);
    transform: translateY(-1px);
}

.main-nav .nav-dropdown[open] > summary::after {
    content: "^";
}

.main-nav .nav-dropdown.active > summary,
.main-nav .nav-dropdown[open] > summary {
    color: #114572;
    background: #ffffff;
    border-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 20px rgba(3, 26, 48, 0.2);
}

.nav-submenu {
    position: absolute;
    top: calc(100% + 0.46rem);
    left: 0;
    z-index: 120;
    min-width: 220px;
    padding: 0.4rem;
    border-radius: 14px;
    border: 1px solid #bdd4ea;
    background: linear-gradient(180deg, #fbfdff, #f2f8ff);
    box-shadow: 0 18px 26px rgba(8, 34, 60, 0.22);
}

.main-nav .nav-dropdown:not([open]) > .nav-submenu {
    display: none;
}

/* Desktop ribbon: keep only a thin strip visible, drop down on hover/focus as an overlay. */
@media (min-width: 701px) {
    .ribbon-trigger {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 10px;
        z-index: 94;
    }

    .main-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        transform: translateY(calc(-100% + 8px));
        transition: transform 0.24s ease;
        will-change: transform;
        overflow: visible;
        pointer-events: none;
    }

    body.ribbon-open .main-header,
    .main-header:focus-within {
        transform: translateY(0);
        pointer-events: auto;
    }

    .main-header > * {
        opacity: 0;
        transform: translateY(-10px);
        transition: opacity 0.18s ease, transform 0.18s ease;
    }

    body.ribbon-open .main-header > *,
    .main-header:focus-within > * {
        opacity: 1;
        transform: translateY(0);
    }

    .main-nav {
        margin-top: 0;
        overflow: visible;
        pointer-events: auto;
        align-items: flex-start;
    }

    .main-nav .nav-dropdown {
        display: inline-flex;
        align-items: center;
    }

    .main-nav .nav-dropdown > .nav-submenu {
        position: absolute;
        top: calc(100% + 0.46rem);
        left: 0;
        z-index: 130;
        margin-top: 0;
    }

    .main-nav .nav-dropdown:not([open]) > .nav-submenu {
        display: none;
    }

    .main-nav .nav-dropdown[open] > .nav-submenu {
        display: block;
        pointer-events: auto;
    }

    .main-nav .nav-dropdown:hover > summary,
    .main-nav .nav-dropdown:focus-within > summary {
        color: #114572;
        background: #ffffff;
        border-color: rgba(255, 255, 255, 0.95);
        box-shadow: 0 10px 20px rgba(3, 26, 48, 0.2);
    }
}

.nav-submenu a {
    display: block;
    color: #18436e;
    text-decoration: none;
    border-radius: 10px;
    border: 1px solid transparent;
    padding: 0.46rem 0.58rem;
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1.3;
    transition: all 0.14s ease;
}

.nav-submenu a + a {
    margin-top: 0.22rem;
}

.nav-submenu a:hover {
    border-color: #b5d0ea;
    background: #edf5ff;
    transform: translateX(1px);
}

.nav-submenu a.active {
    color: #fff;
    border-color: #1f6ba4;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
}

.main-nav a[href*="/admin/"] {
    border-color: rgba(170, 255, 233, 0.5);
    background: rgba(19, 108, 102, 0.2);
}

.main-nav a[href*="/admin/"]:hover {
    border-color: rgba(201, 255, 241, 0.8);
    background: rgba(15, 122, 114, 0.33);
}

.container {
    width: min(1920px, 99%);
    margin: 1.35rem auto 2rem;
}

@media (min-width: 701px) {
    .container {
        margin-top: 0.45rem;
    }
}

.messages {
    margin-bottom: 0.9rem;
}

.message {
    border-radius: 12px;
    padding: 0.68rem 0.92rem;
    margin-bottom: 0.45rem;
    font-size: 0.92rem;
    font-weight: 600;
}

.message.success {
    background: var(--success-bg);
    color: var(--success-ink);
    border: 1px solid #b6dec4;
}

.message.error {
    background: var(--error-bg);
    color: var(--error-ink);
    border: 1px solid #e6bdc0;
}

.message.info,
.message.warning {
    background: var(--info-bg);
    color: var(--info-ink);
    border: 1px solid #bfd6f1;
}

.card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 252, 255, 0.94));
    backdrop-filter: blur(4px);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    padding: 1.35rem 1.35rem 1.45rem;
    margin-bottom: 1.1rem;
    animation: card-enter 0.42s cubic-bezier(0.2, 0.75, 0.3, 1) both;
}

.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, rgba(25, 102, 164, 0.08), rgba(25, 102, 164, 0.45), rgba(24, 151, 134, 0.14));
}

.card:nth-of-type(2) {
    animation-delay: 0.05s;
}

.card:nth-of-type(3) {
    animation-delay: 0.1s;
}

.card:nth-of-type(4) {
    animation-delay: 0.15s;
}

.card-heading {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.8rem;
    margin-bottom: 0.95rem;
}

.card-heading > * {
    min-width: 0;
}

.card-heading h2 {
    margin: 0;
    font-family: "Sora", "Manrope", sans-serif;
    font-size: 1.95rem;
    line-height: 1.18;
    letter-spacing: -0.02em;
    flex: 1 1 320px;
}

.card-heading p {
    margin: 0.2rem 0 0;
    color: var(--ink-muted);
    font-size: 0.92rem;
    font-weight: 600;
    max-width: 58ch;
    flex: 1 1 320px;
}

.card-heading > .list-toolbar,
.card-heading > form.list-toolbar {
    margin-left: auto;
    flex: 1 1 460px;
    min-width: min(100%, 320px);
    justify-content: flex-end;
}

.card-heading > .list-toolbar input[type="search"],
.card-heading > form.list-toolbar input[type="search"] {
    flex: 1 1 260px;
    min-width: 200px;
    max-width: 420px;
}

.subsection-title {
    margin: 1rem 0 0.45rem;
    font-family: "Sora", "Manrope", sans-serif;
    font-size: 1.08rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.subsection-meta {
    margin: 0 0 0.72rem;
    color: var(--ink-muted);
    font-size: 0.91rem;
}

.danger-zone-card {
    border-color: #e6bdc1;
    background: linear-gradient(180deg, #fff8f8, #ffffff);
}

.danger-zone-card::before {
    background: linear-gradient(90deg, rgba(161, 41, 41, 0.14), rgba(192, 61, 61, 0.45), rgba(192, 61, 61, 0.1));
}

.kpi-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.95rem;
}

.kpi-chip {
    background: linear-gradient(160deg, #f4f9ff, #e9f2ff);
    border: 1px solid #ccddf0;
    color: #1a4a78;
    border-radius: 999px;
    padding: 0.4rem 0.74rem;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.9rem;
}

.compact-grid {
    grid-template-columns: minmax(220px, 460px);
}

p {
    margin: 0;
}

label {
    display: block;
    margin-bottom: 0.28rem;
    font-weight: 700;
    font-size: 0.9rem;
    color: #193654;
}

small {
    display: block;
    margin-top: 0.32rem;
    color: var(--ink-soft);
    font-size: 0.8rem;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    padding: 0.62rem 0.76rem;
    font: 600 0.92rem/1.45 "Manrope", "Segoe UI", Tahoma, sans-serif;
    color: var(--ink);
    background: linear-gradient(180deg, #ffffff, #fdfefe);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
    min-height: 108px;
    resize: vertical;
}

textarea.auto-expand-textarea {
    min-height: 48px;
    height: 48px;
    resize: none;
    overflow-y: hidden;
}

input[readonly] {
    background: linear-gradient(180deg, #f6f9fc, #f0f6fc);
    color: var(--ink-soft);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #3e88c3;
    box-shadow: var(--focus-ring);
    background: #fff;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
}

.checkbox-field input {
    width: auto;
    margin: 0;
    accent-color: #1f6daa;
}

.checkbox-field label {
    margin: 0;
}

.error-text {
    display: inline-block;
    color: var(--error-ink);
    font-size: 0.8rem;
    margin-top: 0.28rem;
    font-weight: 700;
}

.error-list {
    margin-top: 0.75rem;
    padding: 0.6rem 0.74rem;
    border-radius: 12px;
    border: 1px solid #e6bbc0;
    background: var(--error-bg);
    color: var(--error-ink);
    font-size: 0.91rem;
}

.action-row {
    margin-top: 0.9rem;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.55rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.08rem;
}

.action-row > * {
    flex: 0 0 auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.34rem;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 0.56rem 0.94rem;
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 10px 20px rgba(13, 65, 108, 0.2);
    font-family: "Sora", "Manrope", sans-serif;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
    filter: saturate(1.08) brightness(1.03);
    transform: translateY(-1px);
    box-shadow: 0 14px 24px rgba(10, 52, 90, 0.23);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 8px 14px rgba(10, 52, 90, 0.18);
}

.btn-light {
    background: linear-gradient(180deg, #f3f8ff, #e9f3ff);
    color: #184f7f;
    border-color: #c3d9ef;
    box-shadow: 0 8px 18px rgba(30, 85, 126, 0.12);
}

.btn-danger {
    background: linear-gradient(135deg, #af3232, var(--danger));
    box-shadow: 0 10px 20px rgba(142, 41, 41, 0.2);
}

.btn-sm {
    padding: 0.36rem 0.64rem;
    font-size: 0.76rem;
}

.icon-btn {
    width: 1.78rem;
    height: 1.78rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    border: 1px solid #c4d9ef;
    background: linear-gradient(180deg, #f4f9ff, #eaf3ff);
    color: #1d5382;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.14s ease, filter 0.14s ease, border-color 0.14s ease;
}

.icon-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
    border-color: #9fc0e0;
}

.icon-btn-delete {
    border-color: #e4b6b9;
    background: linear-gradient(180deg, #fff4f4, #fdeeee);
    color: #9b2f2f;
}

.icon {
    width: 0.82rem;
    height: 0.82rem;
}

.icon path {
    fill: currentColor;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.item-create-card {
    position: sticky;
    top: 12px;
    z-index: 1;
}

.items-list-card {
    position: relative;
    z-index: 2;
    margin-top: 1rem;
}

.items-table-scroll {
    height: 470px;
    overflow-y: auto;
}

.items-table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.purchases-table-scroll {
    height: 470px;
    overflow-y: auto;
}

.purchases-table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}


.purchases-table-scroll.created-batches-table-scroll {
    height: auto;
    max-height: 470px;
}

/* Keep Bora Stock table height content-driven, with scroll only when needed. */
.purchases-table-scroll.batch-stock-table-scroll {
    height: auto;
    max-height: 470px;
}

.stock-filter-grid {
    margin-bottom: 0.9rem;
}

.stock-filter-action {
    display: flex;
    align-items: flex-end;
}

.chart-metric-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-metric-row label {
    margin: 0;
}

.chart-metric-row select {
    width: 150px;
}

.stock-chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 0.9rem;
}

.stock-chart-card {
    border: 1px solid #d5e2f1;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, #ffffff, #f9fcff);
    padding: 0.82rem;
    min-height: 282px;
}

.stock-chart-card canvas {
    width: 100%;
    height: 220px !important;
    max-height: 220px;
}

.stock-table-scroll {
    height: 470px;
    overflow-y: auto;
}

.stock-table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.suppliers-table-scroll {
    height: 470px;
    overflow-y: auto;
}

.suppliers-table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.batch-ingredient-controls {
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    margin-bottom: 0.55rem;
}

.batch-ingredient-controls .subsection-title {
    margin: 0;
}

.batch-ingredient-actions {
    display: inline-flex !important;
    align-items: center;
    flex-wrap: nowrap !important;
    gap: 0.5rem;
    white-space: nowrap;
}

.batch-ingredient-actions > * {
    flex: 0 0 auto;
}

.csv-upload-input {
    width: 360px !important;
    min-width: 260px;
    max-width: 360px;
    padding: 0.46rem 0.6rem;
}

.csv-upload-help {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
}

.batch-ingredient-scroll {
    max-height: 430px;
    overflow-y: auto;
}

.batch-ingredient-scroll .quantity-unit-pair {
    grid-template-columns: minmax(140px, 1fr);
}

.batch-ingredient-scroll th.total-qty-col,
.batch-ingredient-scroll td.total-qty-col {
    text-align: center;
    white-space: nowrap;
}

.batch-ingredient-scroll td.total-qty-col .js-total-quantity,
.batch-ingredient-scroll th.total-qty-col .js-grand-total-quantity {
    font-weight: 800;
    color: #173f68;
}

.batch-ingredient-scroll th.total-qty-col .total-qty-header-value {
    margin-top: 0.14rem;
    font-size: 0.9rem;
    line-height: 1.15;
}

.batch-ingredient-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.list-toolbar > * {
    min-width: 0;
}

.list-toolbar label {
    margin: 0;
    font-size: 0.84rem;
    color: var(--ink-muted);
    font-weight: 700;
}

.list-toolbar input,
.list-toolbar select {
    width: 360px;
    max-width: 55vw;
    min-width: 0;
}

.ledger-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.6rem;
    margin-bottom: 0.95rem;
}

.ledger-date-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.45rem;
    flex: 1 1 auto;
    min-width: 0;
}

.ledger-date-toolbar .btn {
    white-space: nowrap;
}

.ledger-date-toolbar label {
    white-space: nowrap;
}

.ledger-date-toolbar .ledger-date-input {
    width: 170px;
    max-width: 170px;
    min-width: 150px;
}

.ledger-date-toolbar .date-ddmmyyyy-wrap {
    width: auto;
    flex: 0 0 auto;
}

.ledger-party-toolbar {
    margin-left: auto;
}

.ledger-party-toolbar input {
    width: 240px;
    max-width: 240px;
}

.supplier-ledger-heading {
    align-items: flex-end;
    gap: 0.6rem;
}

.supplier-ledger-title {
    font-size: 1.4rem;
    line-height: 1.12;
    white-space: nowrap;
    flex: 1 1 340px;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.supplier-ledger-heading > h2:not(.supplier-ledger-title) {
    font-size: 1.4rem;
    line-height: 1.12;
    white-space: nowrap;
    flex: 1 1 340px;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.supplier-ledger-toolbar {
    flex: 1 1 620px;
    min-width: min(100%, 340px);
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.supplier-ledger-toolbar .ledger-date-input {
    width: 150px;
    max-width: 150px;
    min-width: 120px;
}

.supplier-ledger-toolbar .date-ddmmyyyy-wrap {
    width: auto;
    flex: 0 0 auto;
}

.supplier-ledger-toolbar label {
    white-space: nowrap;
}

.supplier-ledger-toolbar #supplier-ledger-search,
.supplier-ledger-toolbar #purchase-transport-ledger-search,
.supplier-ledger-toolbar #sales-transport-ledger-search,
.supplier-ledger-toolbar #sales-party-ledger-search {
    width: 220px;
    max-width: 320px;
    min-width: 150px;
    flex: 1 1 220px;
}

.supplier-ledger-overview-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: nowrap;
    justify-content: space-between;
    margin-bottom: 0.95rem;
}

.supplier-ledger-kpi-inline {
    margin: 0;
    flex-wrap: nowrap;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    padding-bottom: 0.15rem;
}

.supplier-ledger-kpi-inline .kpi-chip {
    white-space: nowrap;
    flex: 0 0 auto;
}

.supplier-ledger-overview-actions {
    margin: 0 0 0 auto;
    flex-wrap: nowrap;
    flex: 0 0 auto;
}

.batch-stock-toolbar-inline {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.95rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.1rem;
}

.batch-filter-inline-field {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.22rem;
    flex: 0 0 auto;
    white-space: nowrap;
}

.batch-stock-toolbar-inline label {
    margin: 0;
    font-size: 0.84rem;
    color: var(--ink-muted);
    font-weight: 700;
    white-space: nowrap;
    display: block;
    line-height: 1.1;
}

.batch-stock-toolbar-inline .ledger-date-input {
    width: 128px !important;
    max-width: 128px !important;
    min-width: 128px !important;
    padding: 0.5rem 0.55rem;
}

.batch-stock-toolbar-inline .batch-stock-name-select {
    width: 120px !important;
    max-width: 120px !important;
    min-width: 120px !important;
    padding: 0.5rem 0.55rem;
}

.batch-stock-toolbar-inline .btn {
    white-space: nowrap;
}

.batch-stock-toolbar-inline > .btn {
    align-self: flex-end;
}

.batch-stock-search-group {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex: 0 0 auto;
}

.batch-stock-search-group #batch-stock-search {
    width: 210px !important;
    max-width: 210px !important;
    min-width: 180px !important;
    padding: 0.5rem 0.6rem;
}

.batch-actual-bora-form {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.batch-stock-edit-btn {
    padding: 0.4rem 0.68rem;
}

.batch-actual-bora-input {
    width: 110px;
    min-width: 95px;
    max-width: 130px;
    padding: 0.42rem 0.5rem;
}

.batch-actual-bora-save {
    padding: 0.42rem 0.65rem;
}

.batch-actual-bora-edit,
.batch-actual-bora-cancel {
    padding: 0.42rem 0.65rem;
}

.batch-type-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.54rem;
    margin-bottom: 0.95rem;
}

.batch-tab {
    text-decoration: none;
    border: 1px solid #c4d9ee;
    background: linear-gradient(180deg, #f3f8ff, #e9f2ff);
    color: #1f5283;
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    font-weight: 700;
    font-size: 0.84rem;
    transition: all 0.16s ease;
}

.batch-tab:hover {
    border-color: #9fc0df;
    transform: translateY(-1px);
}

.batch-tab.active {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    border-color: #1f6ba4;
}

.batch-type-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-bottom: 0.95rem;
}

.batch-type-inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
    background: linear-gradient(180deg, #f4f9ff, #edf5ff);
    border: 1px solid #d3e2f2;
    border-radius: 14px;
    padding: 0.56rem 0.66rem;
}

.batch-type-inline-form label {
    margin: 0;
    font-size: 0.84rem;
}

.batch-type-inline-form input,
.batch-type-inline-form select {
    width: 280px;
}

.batch-type-inline-form select {
    width: 150px;
}

.bora-equation-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 0.62rem;
    align-items: end;
    margin-bottom: 0.3rem;
}

.bora-equation-field {
    margin: 0;
}

.bora-equation-field label {
    text-align: center;
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
}

.bora-equation-field input {
    border-width: 2px;
    border-radius: 0;
    min-height: 44px;
}

.bora-equation-field input[readonly] {
    color: var(--ink);
    font-weight: 700;
}

.quantity-unit-pair {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(110px, 1fr);
    gap: 0.45rem;
    align-items: start;
}

.quantity-unit-pair > * {
    min-width: 0;
}

.checkbox-cell {
    text-align: center;
}

.checkbox-cell input {
    width: auto;
    accent-color: #1f6daa;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    border-bottom: 1px solid #e2ecf7;
    padding: 0.34rem 0.52rem;
    text-align: left;
    font-size: 0.84rem;
    vertical-align: middle;
    line-height: 1.2;
}

th {
    background: linear-gradient(180deg, #f2f7fd, #eaf2fb);
    color: #183d60;
    font-size: 0.78rem;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    font-weight: 800;
}

.table-meta-row th {
    background: linear-gradient(180deg, #e8f1fc, #dce9f8);
    color: #2b5276;
    font-size: 0.76rem;
    text-transform: none;
    letter-spacing: 0.01em;
}

.bora-split-head,
.bora-split-subhead,
.bora-split-col {
    text-align: center;
}

.batch-stock-center-col {
    text-align: center;
}

.table-link {
    color: #1a5d93;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px dashed rgba(26, 93, 147, 0.42);
}

.table-link:hover {
    color: #0f3f66;
    border-bottom-color: rgba(15, 63, 102, 0.62);
}

tbody tr {
    transition: transform 0.14s ease, box-shadow 0.14s ease;
}

tbody tr td {
    background: linear-gradient(180deg, #ffffff, #fbfdff);
    transition: background 0.14s ease, border-color 0.14s ease;
}

tbody tr:nth-child(2n) td {
    background: linear-gradient(180deg, #f8fbff, #f2f8ff);
}

tbody tr:hover td,
tbody tr:focus-within td {
    background: linear-gradient(180deg, #eef6ff, #e5f1ff);
    border-bottom-color: #c6d8ec;
}

tbody tr:hover td:first-child,
tbody tr:focus-within td:first-child {
    box-shadow: inset 3px 0 0 rgba(27, 100, 159, 0.55);
}

.code-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.52rem;
    border-radius: 999px;
    background: linear-gradient(180deg, #f4f9ff, #e7f1ff);
    border: 1px solid #c2d6ef;
    color: #144b7a;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 0.76rem;
    font-weight: 700;
}

.action-cell {
    white-space: nowrap;
    vertical-align: middle;
}

.action-cell > * + * {
    margin-left: 0.35rem;
}

.inline-form {
    margin: 0;
    display: inline-flex;
    align-items: center;
}

.muted-text {
    margin-top: 0.72rem;
    color: var(--ink-muted);
    font-size: 0.91rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.46rem;
    border-radius: 999px;
    border: 1px solid #b8d3ea;
    background: #edf6ff;
    color: #1b4f7f;
    font-size: 0.76rem;
    font-weight: 700;
}

.status-badge-danger {
    border-color: #e3b1b1;
    background: #fdeeee;
    color: #8f2f2f;
}

.login-card {
    max-width: 500px;
    margin: 2.2rem auto;
}

@keyframes card-enter {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float-drift {
    from {
        transform: translate3d(0, 0, 0);
    }
    to {
        transform: translate3d(16px, -12px, 0);
    }
}

@media (max-width: 980px) {
    .container {
        width: min(1920px, 98.6%);
    }

    .main-header h1 {
        font-size: 1.82rem;
    }

    .card-heading {
        flex-direction: column;
        align-items: flex-start;
    }

    .supplier-ledger-title {
        font-size: 1.3rem;
    }

    .item-create-card {
        position: static;
        top: auto;
    }
}

@media (max-width: 700px) {
    .main-header {
        display: block;
        padding: 0.9rem 0.95rem 1rem;
    }

    .main-header h1 {
        font-size: 1.48rem;
    }

    .user-actions {
        width: 100%;
        justify-content: space-between;
    }

    .header-top {
        order: initial;
        margin-left: 0;
    }

    .main-nav {
        order: initial;
        gap: 0.42rem;
        margin-top: 0.42rem;
        padding-left: 0;
    }

    .main-nav a {
        padding: 0.36rem 0.68rem;
        font-size: 0.8rem;
    }

    .main-nav .nav-dropdown > summary {
        padding: 0.36rem 0.68rem;
        font-size: 0.8rem;
    }

    .main-nav .nav-dropdown {
        width: 100%;
    }

    .main-nav .nav-dropdown > summary {
        width: 100%;
        justify-content: center;
    }

    .global-back-icon {
        top: 7px;
        left: 8px;
        width: 38px;
        height: 38px;
    }

    .global-forward-icon {
        left: 50px;
    }

    .nav-submenu {
        position: static;
        margin-top: 0.42rem;
        min-width: 0;
        width: 100%;
        box-shadow: 0 10px 16px rgba(8, 34, 60, 0.18);
    }

    .container {
        width: 98%;
        margin-top: 0.95rem;
    }

    .card {
        border-radius: 16px;
        padding: 1rem;
    }

    .card-heading h2 {
        font-size: 1.54rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .items-table-scroll,
    .purchases-table-scroll,
    .suppliers-table-scroll,
    .stock-table-scroll {
        height: 360px;
    }

    .purchases-table-scroll.batch-stock-table-scroll {
        height: auto;
        max-height: 360px;
    }

    .purchases-table-scroll.created-batches-table-scroll {
        height: auto;
        max-height: 360px;
    }

    .stock-chart-grid {
        grid-template-columns: 1fr;
    }

    .stock-chart-card {
        min-height: 250px;
    }

    .stock-chart-card canvas {
        height: 180px !important;
        max-height: 180px;
    }

    .list-toolbar {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }

    .list-toolbar input {
        width: 100%;
        max-width: 100%;
    }

    .list-toolbar select {
        width: 100%;
        max-width: 100%;
    }

    .ledger-filter-row {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .ledger-date-toolbar,
    .ledger-party-toolbar {
        width: 100%;
    }

    .ledger-party-toolbar {
        margin-left: 0;
    }

    .ledger-date-toolbar .ledger-date-input {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .ledger-date-toolbar .date-ddmmyyyy-wrap,
    .supplier-ledger-toolbar .date-ddmmyyyy-wrap {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        flex: 1 1 100%;
    }

    .supplier-ledger-toolbar {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .supplier-ledger-toolbar #supplier-ledger-search,
    .supplier-ledger-toolbar #purchase-transport-ledger-search,
    .supplier-ledger-toolbar #sales-transport-ledger-search,
    .supplier-ledger-toolbar #sales-party-ledger-search {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .supplier-ledger-overview-row {
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .supplier-ledger-kpi-inline {
        flex-wrap: wrap;
        width: 100%;
        overflow-x: visible;
        padding-bottom: 0;
    }

    .supplier-ledger-overview-actions {
        width: 100%;
        margin-top: 0;
        margin-left: 0;
    }

    .batch-stock-toolbar-inline {
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .batch-type-inline-form {
        width: 100%;
    }

    .batch-type-inline-form input,
    .batch-type-inline-form select {
        width: 100%;
    }

    .csv-upload-input {
        width: 220px;
        min-width: 180px;
    }

}

@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;
    }
}

::-webkit-scrollbar {
    width: 11px;
    height: 11px;
}

::-webkit-scrollbar-thumb {
    border-radius: 999px;
    border: 2px solid #ecf2fa;
    background: linear-gradient(180deg, #b7cde4, #95b4d3);
}

::-webkit-scrollbar-track {
    background: #ecf2fa;
}


