/* PharmacyMS — professional app styles */
:root {
    --pm-ink: #14242b;
    --pm-muted: #5d6f78;
    --pm-line: #d7e0e4;
    --pm-paper: #f3f6f5;
    --pm-panel: #ffffff;
    --pm-teal: #0d5c63;
    --pm-teal-deep: #09464c;
    --pm-teal-soft: rgba(13, 92, 99, 0.1);
    --pm-sage: #2f6f4e;
    --pm-amber: #b45309;
    --pm-danger: #b42318;
    --pm-sidebar: 248px;
    --pm-radius: 14px;
    --pm-shadow: 0 18px 40px rgba(20, 36, 43, 0.08);
    --pm-font-display: "Fraunces", Georgia, serif;
    --pm-font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

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

html, body {
    margin: 0;
    min-height: 100%;
    font-family: var(--pm-font-body);
    color: var(--pm-ink);
    background: var(--pm-paper);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--pm-teal); }
a:hover { color: var(--pm-teal-deep); }

h1, h2, h3 {
    font-family: var(--pm-font-display);
    letter-spacing: -0.02em;
    font-weight: 600;
}

/* —— Auth —— */
.auth-body {
    min-height: 100vh;
    background: var(--pm-paper);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(300px, 1.05fr) minmax(340px, 0.95fr);
}

.auth-brand {
    position: relative;
    overflow: hidden;
    color: #fff;
    background:
        radial-gradient(circle at 12% 18%, rgba(255,255,255,0.16), transparent 40%),
        linear-gradient(155deg, #0d5c63 0%, #0b4a6f 48%, #16324a 100%);
    padding: clamp(1.75rem, 4vw, 3rem);
}

.auth-brand-inner {
    position: relative;
    z-index: 1;
    max-width: 30rem;
    margin: 0 auto;
    padding-top: clamp(1rem, 10vh, 5rem);
}

.auth-eyebrow {
    margin: 0 0 0.9rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    opacity: 0.88;
}

.auth-brand h1 {
    margin: 0 0 0.85rem;
    font-size: clamp(2.4rem, 5vw, 3.4rem);
    line-height: 1.02;
}

.auth-brand h1 a {
    color: inherit;
    text-decoration: none;
}

.auth-brand h1 a:hover {
    color: inherit;
    opacity: 0.92;
}

.auth-lead {
    margin: 0 0 1.6rem;
    font-size: 1.08rem;
    line-height: 1.55;
    opacity: 0.92;
}

.auth-points {
    list-style: none;
    margin: 0 0 2rem;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.auth-points li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
}

.auth-points i {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255,255,255,0.14);
}

.auth-hub-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.75rem 1.05rem;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.35);
    color: #fff !important;
    text-decoration: none !important;
    font-weight: 700;
    background: rgba(255,255,255,0.08);
}

.auth-hub-link:hover { background: rgba(255,255,255,0.16); }

.auth-brand-inner {
    animation: pm-rise 0.55s ease-out both;
}

.auth-card {
    animation: pm-rise 0.55s ease-out 0.08s both;
}

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

.sidebar-brand {
    font-family: var(--pm-font-display);
    font-size: 1.35rem;
    letter-spacing: -0.03em;
}

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
}

.auth-card {
    width: min(440px, 100%);
    padding: 2rem 1.8rem 1.7rem;
    border-radius: calc(var(--pm-radius) + 4px);
    background: var(--pm-panel);
    border: 1px solid var(--pm-line);
    box-shadow: var(--pm-shadow);
}

.auth-card h2 {
    margin: 0 0 0.35rem;
    font-size: 1.9rem;
}

.auth-card-sub {
    margin: 0 0 1.35rem;
    color: var(--pm-muted);
}

.auth-card .form-label {
    font-weight: 700;
    color: var(--pm-ink);
}

.auth-card .form-control {
    border-color: var(--pm-line);
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
}

.auth-card .form-control:focus {
    border-color: var(--pm-teal);
    box-shadow: 0 0 0 0.2rem rgba(13, 92, 99, 0.18);
}

.auth-submit {
    margin-top: 0.4rem;
    border: 0;
    border-radius: 999px;
    background: var(--pm-teal) !important;
    font-weight: 700;
    padding: 0.8rem 1rem;
}

.auth-submit:hover { background: var(--pm-teal-deep) !important; }

.auth-footnote {
    margin: 1.2rem 0 0;
    text-align: center;
    color: var(--pm-muted);
    font-size: 0.86rem;
}

/* —— App shell —— */
.app-body { background: var(--pm-paper); }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--pm-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    color: #fff;
    background: linear-gradient(180deg, #0d5c63 0%, #0a4650 55%, #16324a 100%);
    transition: transform 0.2s ease;
}

.sidebar-header {
    padding: 1.35rem 1.15rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

.sidebar-brand {
    display: block;
    color: #fff !important;
    text-decoration: none !important;
    font-family: var(--pm-font-display);
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-tagline {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.72);
}

.sidebar .nav {
    padding: 0.85rem 0.7rem 1rem;
    gap: 0.25rem;
    flex: 1;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: rgba(255,255,255,0.9) !important;
    border-radius: 10px;
    padding: 0.72rem 0.85rem;
    font-weight: 600;
}

.sidebar .nav-link:hover,
.sidebar .nav-link:focus,
.sidebar .nav-link.active {
    background: rgba(255,255,255,0.14);
    color: #fff !important;
}

.sidebar .nav-link i { width: 1.15rem; text-align: center; }

.sidebar-spacer {
    flex: 1 1 auto;
    min-height: 0.75rem;
    list-style: none;
}

.main-content {
    margin-left: var(--pm-sidebar);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    min-height: 3.6rem;
    background: #fff !important;
    border-bottom: 1px solid var(--pm-line);
}

.topbar-toggle {
    color: var(--pm-ink) !important;
    text-decoration: none !important;
}

.topbar-title {
    font-family: var(--pm-font-display);
    font-weight: 650;
    font-size: 1.1rem;
}

.user-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--pm-ink) !important;
    text-decoration: none !important;
}

.user-menu-btn i {
    font-size: 1.55rem;
    color: var(--pm-teal);
}

.content-wrapper {
    padding: 1.35rem 1.5rem 2.25rem;
    flex: 1;
}

.saas-trial-bar {
    margin: 0 0 1rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--pm-line);
    border-radius: var(--pm-radius);
    background: var(--pm-teal-soft);
    color: var(--pm-teal-deep);
    font-size: 0.95rem;
}

.saas-trial-bar a {
    font-weight: 600;
}

body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main-content { margin-left: 0; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open { overflow: hidden; }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 1035;
    }
    body.sidebar-open .sidebar-overlay { display: block; }
}

/* —— Page patterns —— */
.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1.35rem;
}

.page-eyebrow {
    margin: 0 0 0.3rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pm-muted);
}

.page-header h1 {
    margin: 0;
    font-size: clamp(1.7rem, 3vw, 2.1rem);
}

.page-subtitle {
    margin: 0.4rem 0 0;
    color: var(--pm-muted);
    max-width: 40rem;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.btn-primary {
    background: var(--pm-teal) !important;
    border-color: var(--pm-teal) !important;
    font-weight: 700;
    border-radius: 999px;
}

.btn-primary:hover {
    background: var(--pm-teal-deep) !important;
    border-color: var(--pm-teal-deep) !important;
}

.btn-outline-primary,
.btn-outline-secondary {
    border-radius: 999px;
    font-weight: 700;
}

.btn-outline-primary {
    color: var(--pm-teal) !important;
    border-color: var(--pm-teal) !important;
}

.btn-outline-primary:hover {
    background: var(--pm-teal) !important;
    color: #fff !important;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.15rem;
}

.stat-card {
    background: var(--pm-panel);
    border: 1px solid var(--pm-line);
    border-radius: var(--pm-radius);
    padding: 1.1rem 1.15rem;
    border-left: 4px solid var(--pm-teal);
    box-shadow: 0 1px 0 rgba(20,36,43,0.02);
}

.stat-card--sales {
    border-left-color: var(--pm-sage);
    background: linear-gradient(165deg, #ffffff 55%, #f1f8f4 100%);
}
.stat-card--sales .stat-card-value { font-size: 1.85rem; }
.stat-card--products { border-left-color: var(--pm-teal); }
.stat-card--customers { border-left-color: #5c3d2e; }
.stat-card--alerts { border-left-color: var(--pm-amber); }

.stat-card-label {
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pm-muted);
}

.stat-card-value {
    margin-top: 0.35rem;
    font-family: var(--pm-font-display);
    font-size: 1.75rem;
    font-weight: 650;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat-card-meta {
    margin-top: 0.35rem;
    color: var(--pm-muted);
    font-size: 0.88rem;
}

a.stat-card {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
a.stat-card:hover,
a.stat-card:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(15, 61, 58, 0.1);
    color: inherit;
}

.ops-attention {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 0.85rem;
    margin: 0 0 1rem;
    padding: 0.7rem 0.95rem;
    border-radius: var(--pm-radius);
    background: #fff7ed;
    border: 1px solid #fed7aa;
    font-size: 0.92rem;
}
.ops-attention a {
    color: #9a3412;
    font-weight: 700;
    text-decoration: none;
}
.ops-attention a:hover { text-decoration: underline; }

.dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(270px, 0.9fr);
    gap: 1rem;
}

.dash-side {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel {
    background: var(--pm-panel);
    border: 1px solid var(--pm-line);
    border-radius: var(--pm-radius);
    overflow: hidden;
    box-shadow: 0 1px 0 rgba(20,36,43,0.02);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.95rem 1.15rem;
    border-bottom: 1px solid #eef3f4;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.panel-header a {
    font-size: 0.86rem;
    font-weight: 700;
    text-decoration: none;
}

.panel-body { padding: 1.15rem; }

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    padding: 0.95rem;
}

.quick-action {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.9rem 0.8rem;
    border-radius: 12px;
    border: 1px solid var(--pm-line);
    background: #f7faf9;
    color: var(--pm-ink) !important;
    text-decoration: none !important;
    font-weight: 700;
    font-size: 0.9rem;
}

.quick-action:hover {
    border-color: #b9d2d4;
    background: var(--pm-teal-soft);
}

.quick-action i { color: var(--pm-teal); }

.alert-list {
    list-style: none;
    margin: 0;
    padding: 0.2rem 0;
}

.alert-list li a {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.8rem 1.15rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #eef3f4;
}

.alert-list li a:hover { background: #f7faf9; }
.alert-list li a span { color: var(--pm-muted); font-size: 0.84rem; }

.empty-cell {
    text-align: center !important;
    color: var(--pm-muted);
    padding: 1.6rem 1rem !important;
}

.entity-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.entity-icon {
    width: 2.2rem;
    height: 2.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--pm-teal-soft);
    color: var(--pm-teal);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    align-items: end;
}

.filter-field { min-width: 160px; }
.filter-field.grow { flex: 1 1 220px; }
.filter-actions { min-width: 120px; }

.search-bar { position: relative; }
.search-bar .form-control { padding-left: 2.4rem; }
.search-bar i {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--pm-muted);
}

.table { margin-bottom: 0; }
.table thead th {
    background: #f7faf9;
    color: var(--pm-muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 750;
    border-bottom-color: var(--pm-line);
}

.table > :not(caption) > * > * {
    padding: 0.85rem 1rem;
}

.badge.text-bg-danger { background: #f8e4e1 !important; color: var(--pm-danger) !important; }
.badge.text-bg-success { background: #e5f3ea !important; color: var(--pm-sage) !important; }
.badge.text-bg-warning { background: #fff1df !important; color: var(--pm-amber) !important; }

.form-page {
    max-width: 720px;
}

.form-card .form-label { font-weight: 700; }
.form-card .form-control,
.form-card .form-select {
    border-radius: 10px;
    border-color: var(--pm-line);
}

.pos-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}
.pos-toolbar h1 { margin: 0; font-size: 1.65rem; }

.pos-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
    gap: 1.25rem;
    align-items: start;
}
.pos-layout--modern {
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
}

.pos-scan-panel { margin-bottom: 0.9rem; }
.pos-scan-row {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    padding: 0.85rem 1rem 0.35rem;
}
.pos-scan-row > i { color: var(--pm-teal); }
.pos-scan-row .grow { flex: 1; }
.pos-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.35rem 1rem 0.9rem;
}
.pos-chip {
    border: 1px solid var(--pm-line);
    background: #fff;
    border-radius: 999px;
    padding: 0.28rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--pm-muted);
}
.pos-chip.active {
    background: var(--pm-teal);
    border-color: var(--pm-teal);
    color: #fff;
}
.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 0.7rem;
}
.pos-product {
    text-align: left;
    border: 1px solid var(--pm-line);
    background: #fff;
    border-radius: 14px;
    padding: 0.8rem 0.75rem 0.7rem;
    min-height: 118px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    box-shadow: 0 8px 18px rgba(20, 36, 43, 0.04);
}
.pos-product:hover { border-color: var(--pm-teal); }
.pos-product.is-out { opacity: 0.45; cursor: not-allowed; }
.pos-product-stock {
    align-self: flex-end;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--pm-sage);
}
.pos-product-stock.is-low { color: var(--pm-amber); }
.pos-product-name { font-weight: 700; line-height: 1.25; }
.pos-product-meta { color: var(--pm-muted); font-size: 0.78rem; }
.pos-product-price { margin-top: auto; font-weight: 700; color: var(--pm-teal-deep); }
.pos-empty-grid { grid-column: 1 / -1; padding: 2rem; text-align: center; }
.pos-customer-row { display: flex; gap: 0.4rem; }
.pos-quick-customer {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.4rem;
    margin-top: 0.5rem;
}
.pos-adjust {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}
.pos-inline { display: flex; gap: 0.35rem; }
.pos-inline .form-select { max-width: 4.5rem; }
.pos-totals {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
    font-size: 0.92rem;
}
.pos-totals > div { display: flex; justify-content: space-between; }
.pos-pay-methods {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}
.pos-pay-btn {
    border: 1px solid var(--pm-line);
    background: #fff;
    border-radius: 10px;
    padding: 0.45rem 0.3rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--pm-muted);
}
.pos-pay-btn i { display: block; margin-bottom: 0.15rem; }
.pos-pay-btn.active {
    border-color: var(--pm-teal);
    background: var(--pm-teal-soft);
    color: var(--pm-teal-deep);
}
.pos-pay-extra { margin-bottom: 0.75rem; }
.pos-change { margin: 0.4rem 0 0; display: flex; justify-content: space-between; }
.pos-split-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; margin-bottom: 0.4rem; }
.pos-actions { display: flex; flex-direction: column; gap: 0.45rem; }
.pos-hold-row { display: flex; gap: 0.4rem; }
.pos-held-list { list-style: none; margin: 0; padding: 0.35rem 0.9rem 0.8rem; }
.pos-held-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--pm-line);
}
.pay-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 700;
}
.pay-badge--paid { background: #e7f6ee; color: var(--pm-sage); }
.pay-badge--partial { background: #fff1df; color: var(--pm-amber); }
.pay-badge--unpaid { background: #fde8e6; color: var(--pm-danger); }
.receipt-sheet {
    max-width: 420px;
    margin: 0 auto;
    background: #fff;
    border: 1px dashed var(--pm-line);
    padding: 1.4rem 1.25rem;
}
.receipt-sheet h1 { font-size: 1.2rem; text-align: center; }
.receipt-meta { text-align: center; color: var(--pm-muted); margin-bottom: 1rem; }
.receipt-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 1.05rem; }

.pos-catalog-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.pos-search { width: min(100%, 260px); }

.pos-cart {
    position: sticky;
    top: 1rem;
}

.pos-cart-empty {
    text-align: center;
    color: var(--pm-muted);
    padding: 1.5rem 0.5rem 1.25rem;
}

.pos-cart-empty i {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

.pos-cart-lines {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
    max-height: 420px;
    overflow: auto;
}

.pos-cart-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.65rem;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--pm-line);
    border-radius: 12px;
    background: #fbfefd;
}

.pos-cart-line-qty {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.pos-cart-line-qty .qty-val {
    min-width: 1.5rem;
    text-align: center;
    font-weight: 700;
}

.pos-cart-line-total {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
    font-weight: 700;
}

.pos-cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.5rem 0 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--pm-line);
    font-size: 1.05rem;
}

.pos-cart-total strong {
    font-family: "Fraunces", Georgia, serif;
    font-size: 1.35rem;
    color: var(--pm-ink);
}

@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-grid { grid-template-columns: 1fr; }
    .pos-layout { grid-template-columns: 1fr; }
    .pos-cart { position: static; }
}

@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-points { display: none; }
    .auth-brand { min-height: auto; }
    .auth-brand-inner { padding-top: 0.25rem; }
}

@media (max-width: 640px) {
    .stat-grid { grid-template-columns: 1fr; }
    .page-actions,
    .page-actions .btn { width: 100%; }
    .content-wrapper { padding: 1rem; }
}
