:root {
    --bg: #b8cec3;
    --surface: #ffffff;
    --surface-2: #f7faf8;
    --ink: #14231d;
    --muted: #68766f;
    --line: #dfe8e3;
    --line-strong: #cfddd5;
    --brand: #167a58;
    --brand-dark: #0c503b;
    --brand-bright: #20a675;
    --danger: #c84f5f;
    --ok: #16845a;
    --radius-xl: 26px;
    --radius-lg: 18px;
    --shadow: 0 14px 40px rgba(18, 54, 40, .08), 0 2px 8px rgba(18, 54, 40, .04);
    --shadow-raised: 0 24px 64px rgba(16, 54, 39, .14), 0 3px 12px rgba(16, 54, 39, .08);
}

html { scroll-behavior: smooth; }

body {
    background:
        radial-gradient(circle at 88% -8%, rgba(95, 210, 164, .38) 0, transparent 34rem),
        radial-gradient(circle at 4% 105%, rgba(8, 65, 45, .28) 0, transparent 38rem),
        linear-gradient(145deg, #d9e7e0 0%, #c2d8cd 44%, #a4c3b4 100%);
    background-attachment: fixed;
    min-width: 320px;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .26;
    background-image: linear-gradient(rgba(12, 67, 46, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(12, 67, 46, .05) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: linear-gradient(to bottom, #000, transparent 70%);
}

::selection { background: rgba(31, 164, 115, .2); color: var(--brand-dark); }

.app-shell {
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 20px;
    padding: 20px;
    align-items: stretch;
}
.app-shell.full-view,
.app-shell:fullscreen {
    background:
        radial-gradient(circle at 88% -8%, rgba(95, 210, 164, .38) 0, transparent 34rem),
        radial-gradient(circle at 4% 105%, rgba(8, 65, 45, .28) 0, transparent 38rem),
        linear-gradient(145deg, #d9e7e0 0%, #c2d8cd 44%, #a4c3b4 100%);
}

.app-shell .side-stack {
    height: calc(var(--zoom-fill-vh, 111.111vh) - 40px) !important;
    height: calc(var(--zoom-fill-dvh, 111.111dvh) - 40px) !important;
    min-height: calc(var(--zoom-fill-vh, 111.111vh) - 40px) !important;
    min-height: calc(var(--zoom-fill-dvh, 111.111dvh) - 40px) !important;
    max-height: calc(var(--zoom-fill-vh, 111.111vh) - 40px);
    max-height: calc(var(--zoom-fill-dvh, 111.111dvh) - 40px);
    align-self: stretch;
}

.app-shell.full-view .side-stack,
.app-shell:fullscreen .side-stack {
    height: calc(var(--zoom-fill-vh, 111.111vh) - 24px) !important;
    height: calc(var(--zoom-fill-dvh, 111.111dvh) - 24px) !important;
    min-height: calc(var(--zoom-fill-vh, 111.111vh) - 24px) !important;
    min-height: calc(var(--zoom-fill-dvh, 111.111dvh) - 24px) !important;
    max-height: calc(var(--zoom-fill-vh, 111.111vh) - 24px);
    max-height: calc(var(--zoom-fill-dvh, 111.111dvh) - 24px);
}

.side-rail {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    overflow-y: auto;
    background: linear-gradient(175deg, #10291f 0%, #0c2019 58%, #071712 100%);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 28px;
    padding: 16px 12px;
    box-shadow: 0 28px 70px rgba(5, 26, 18, .24);
}

.brand-dot {
    color: #e5fff4;
    background: linear-gradient(145deg, rgba(57, 210, 151, .24), rgba(255,255,255,.07));
    border: 1px solid rgba(123, 239, 194, .2);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 12px 28px rgba(0,0,0,.18);
}

.side-link { color: #aebeb7; border-radius: 14px; min-height: 46px; font-weight: 650; }
.side-link i { color: #78a993; transition: transform .18s ease, color .18s ease; }
.side-link:hover { color: #fff; background: rgba(255,255,255,.075); transform: translateX(2px); }
.side-link:hover i { color: #7be0b6; transform: scale(1.08); }
.side-link.is-active {
    color: #082117;
    background: linear-gradient(135deg, #8de8c1, #52c996);
    box-shadow: 0 10px 25px rgba(25, 176, 116, .23), inset 0 1px 0 rgba(255,255,255,.48);
}
.side-link.is-active i { color: #0a563c; }

.side-account-dock {
    margin-top: auto;
    flex: 0 0 auto;
    background: linear-gradient(175deg, #10291f 0%, #0c2019 100%);
    border-color: rgba(255,255,255,.08);
    box-shadow: 0 18px 40px rgba(5, 26, 18, .18);
}
.side-footer-btn {
    color: #dcefe8;
    background: rgba(255,255,255,.075);
    border-color: rgba(123, 239, 194, .16);
}
.side-footer-btn:hover {
    color: #fff;
    background: rgba(255,255,255,.12);
}
.side-footer-btn.is-active {
    color: #082117;
    background: linear-gradient(135deg, #8de8c1, #52c996);
    border-color: transparent;
}

.topbar { padding: 8px 4px 2px; }
.topbar h1 { color: #10271e; font-weight: 800; letter-spacing: -.035em; }
.topbar p { color: #718078; }

.search-pill, .tool-btn {
    border-color: rgba(191, 210, 200, .78);
    box-shadow: 0 8px 28px rgba(24, 68, 50, .075);
}
.search-pill { min-width: min(360px, 30vw); }
.search-pill:focus-within { border-color: #61b994; box-shadow: 0 0 0 4px rgba(41, 155, 111, .11), var(--shadow); }
.tool-btn { transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.tool-btn:hover { transform: translateY(-2px); border-color: #8fc9b0; box-shadow: 0 12px 30px rgba(24, 68, 50, .12); }

.branch-mode-chip {
    color: #11563e;
    background: rgba(229, 248, 239, .9);
    border-color: #bfe2d2;
    box-shadow: 0 4px 14px rgba(21, 97, 68, .07);
}

.content-canvas { gap: 18px; padding-bottom: 24px; }
.panel {
    border: 1px solid rgba(207, 221, 213, .9);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    padding: clamp(18px, 2vw, 26px);
    position: relative;
}
.panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 28px;
    right: 28px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.96), transparent);
}
.panel .panel { border-radius: 20px; }
.panel-title { color: #173126; font-weight: 800; letter-spacing: -.02em; }
.panel-sub { color: #718078; line-height: 1.55; }

.metric-card {
    border-color: #dce7e1;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(22, 64, 47, .055);
    transition: transform .18s ease, box-shadow .18s ease;
}
.metric-card:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(22, 64, 47, .09); }
.metric-card.is-brand { background: linear-gradient(145deg, #18825d, #0b543d); box-shadow: 0 16px 34px rgba(15, 105, 73, .22); }

.soft-form .form-control, .soft-form .form-select, .soft-form .input-group-text {
    min-height: 44px;
    border-color: #d8e4dd;
    border-radius: 13px;
    background-color: #f8fbf9;
    transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.soft-form .input-group .input-group-text { border-radius: 13px 0 0 13px; color: #39705a; }
.soft-form .input-group .form-control { border-radius: 0 13px 13px 0; }
.soft-form .form-control:hover, .soft-form .form-select:hover { border-color: #b9d0c4; background: #fff; }
.soft-form .form-control:focus, .soft-form .form-select:focus {
    border-color: #45a77f;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(31, 151, 105, .12);
}
.soft-form .form-label { color: #334d42; font-weight: 750; margin-bottom: 7px; }

.btn { transition: transform .16s ease, box-shadow .16s ease, filter .16s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-main {
    background: linear-gradient(135deg, #19845f, #0d5c43);
    border-radius: 13px;
    box-shadow: 0 8px 18px rgba(16, 108, 75, .18);
    padding: .66rem 1.1rem;
}
.btn-main:hover { box-shadow: 0 12px 25px rgba(16, 108, 75, .26); }
.btn-ghost { border-color: #d5e2db; border-radius: 13px; background: rgba(255,255,255,.9); }
.btn-ghost:hover { color: #135a40; border-color: #9dcab5; background: #f5fbf8; }
.btn-danger-soft { border-radius: 11px; }

.table-responsive { border-radius: 17px; border: 1px solid #e0e9e4; overflow: auto; }
.table-clean { border-collapse: separate; border-spacing: 0; }
.table-clean thead { position: sticky; top: 0; z-index: 3; }
.table-clean thead th {
    background: #f2f7f4;
    border-bottom: 1px solid #d8e4dd;
    color: #52655c;
    padding: .82rem .75rem;
    white-space: nowrap;
}
.table-clean tbody td { border-bottom: 1px solid #e9efec; padding: .82rem .75rem; }
.table-clean tbody tr { transition: background .14s ease, box-shadow .14s ease; }
.table-clean tbody tr:hover td { background: #f7fbf9; }
.table-clean tbody tr:last-child td { border-bottom: 0; }
.table-clean tbody tr.keyboard-active td { background: #eaf7f1 !important; box-shadow: inset 0 1px 0 #cae8d9, inset 0 -1px 0 #cae8d9; }
.table-clean tbody tr.keyboard-active td:first-child { box-shadow: inset 3px 0 0 #23966b, inset 0 1px 0 #cae8d9, inset 0 -1px 0 #cae8d9; }
.table-clean tbody tr:focus { outline: none; }

.chip, .status-badge { border: 1px solid rgba(60, 123, 94, .1); }
.invoice-link { color: #116b4c; font-weight: 800; text-decoration: none; white-space: nowrap; }
.invoice-link:hover { color: #0a4c35; text-decoration: underline; text-underline-offset: 3px; }

.settings-subpanel {
    padding: 20px;
    border: 1px solid #d9e8e0;
    border-radius: 18px;
    background: linear-gradient(145deg, #f3faf6, #fbfdfc);
}

.inventory-filter-bar { align-items: stretch; }
.inventory-source { display: block; margin-top: 4px; white-space: nowrap; }
.inventory-group-row td { background: linear-gradient(90deg, #eff8f3, #f7fbf9) !important; }
.inventory-row.is-matching-batch td { background: #fff9e7 !important; }
.inventory-row.is-matching-batch td:first-child { box-shadow: inset 3px 0 0 #e0a126; }

/* Sale item rows: one continuous, polished card instead of broken table lines. */
.sale-workspace {
    overflow: visible;
    border-color: #95bdaa !important;
    background:
        radial-gradient(circle at 92% 8%, rgba(93, 188, 148, .28), transparent 24rem),
        linear-gradient(145deg, #d8e9e1 0%, #bfd8cc 48%, #a8cbbb 100%) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 16px 38px rgba(23, 75, 54, .12) !important;
}
.sale-workspace::before {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.85), transparent);
}
.sale-workspace .panel-title { color: #123c2b; }
.sale-workspace > .row .form-control {
    border-color: #9fc5b4;
    background: rgba(249, 253, 251, .88);
}
.sale-workspace #fetchMedicineBarcode,
.sale-workspace #addItemRow {
    border-color: #8eb8a5;
    background: rgba(255,255,255,.74);
}
.sales-items-wrap { overflow: visible !important; background: transparent; }
.sales-items-table { background: transparent !important; }
.sales-items-table tbody { display: grid !important; gap: 12px; }
.sale-item-block {
    border: 1px solid #9fc5b4 !important;
    border-radius: 18px !important;
    background:
        linear-gradient(135deg, rgba(242, 249, 246, .96), rgba(215, 235, 226, .96)) !important;
    padding: 14px !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.75), 0 8px 22px rgba(18, 74, 50, .10);
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.sale-item-block:focus-within {
    border-color: #29956b !important;
    background: linear-gradient(135deg, #eef9f4, #cce8dc) !important;
    box-shadow: 0 0 0 4px rgba(25, 132, 92, .14), 0 14px 30px rgba(18, 74, 50, .15);
    transform: translateY(-1px);
}
.sale-pricing-row { border-top-color: #e0ebe5 !important; }
.sale-field-label { color: #587066 !important; letter-spacing: .015em; }
.sales-items-table .form-control, .sales-items-table .form-select {
    border-color: #a9cbbb !important;
    border-radius: 10px !important;
    background: rgba(255,255,255,.82) !important;
}
.sales-items-table .form-control:focus, .sales-items-table .form-select:focus {
    border-color: #3ea579 !important;
    box-shadow: 0 0 0 3px rgba(37, 154, 109, .11) !important;
}
.sale-remove { border-radius: 11px !important; }
.medicine-search-results, .select-search-results, .quick-search-results {
    border: 1px solid #cfe0d7 !important;
    border-radius: 14px !important;
    background: rgba(255,255,255,.98) !important;
    box-shadow: var(--shadow-raised) !important;
    padding: 6px !important;
    backdrop-filter: blur(14px);
}
.medicine-search-result, .select-search-result, .quick-search-option {
    border-radius: 9px !important;
    padding: 9px 10px !important;
}

.quick-search-host { position: relative; }
.quick-search-results {
    position: absolute;
    z-index: 2500;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 330px;
    overflow-y: auto;
}
.quick-search-results[hidden] { display: none; }
.quick-search-option {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    background: transparent;
    color: #243d32;
    text-align: left;
    font-size: .84rem;
}
.quick-search-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-search-option i { color: #759187; }
.quick-search-option:hover, .quick-search-option.is-active { background: #e9f7f0; color: #0f5a3f; }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid rgba(35, 157, 111, .32);
    outline-offset: 2px;
}

@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 88px minmax(0,1fr); padding: 12px; gap: 12px; }
    .side-rail { align-items: center; padding-inline: 10px; }
    .side-label { display: none; }
    .side-link { width: 48px; justify-content: center; padding: 0; }
    .top-tools .search-pill { display: none; }
}

@media (max-width: 768px) {
    .app-shell { display: block; padding: 10px; }
    .app-shell .side-stack { height: auto !important; min-height: 0 !important; max-height: none !important; }
    .side-rail { position: static; max-height: none; flex-direction: row; overflow-x: auto; border-radius: 20px; margin-bottom: 12px; }
    .side-group { flex-direction: row; width: auto; }
    .brand-dot { margin: 0; flex: 0 0 48px; width: 48px; height: 48px; }
    .topbar { align-items: start; }
    .top-tools { gap: 6px; }
    .tool-btn { width: 40px; height: 40px; }
    .panel { border-radius: 20px; padding: 16px; }
    .table-responsive { border-radius: 13px; }
}

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