:root {
    /* Optical clinic brand palette — clinical, calm teal */
    --oms-teal: #0f7a72;
    --oms-teal-dark: #0b5f59;
    --oms-teal-light: #5cb3ac;
    --oms-cream: #eaf6f4;
    --oms-charcoal: #24312f;
    /* Inter renders noticeably crisper than the system-UI default at small
       dashboard sizes; the stack falls back gracefully if the CDN is unreachable. */
    --oms-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: #f4f6f9;
    font-family: var(--oms-font);
    color: var(--oms-charcoal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.navbar-brand, .stat-value, .card-title, .btn {
    letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--oms-charcoal);
}

/* ---------- Login screen ---------- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--oms-teal) 0%, var(--oms-teal-dark) 100%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.25);
}

.public-booking-card {
    max-width: 720px;
}

.login-logo {
    width: auto;
    height: 80px;
    max-width: 220px;
}

/* ---------- Top navbar ---------- */
.oms-navbar {
    background-color: var(--oms-teal);
}

.oms-navbar .navbar-brand {
    font-weight: 700;
    color: #fff !important;
    letter-spacing: 0.02em;
}

.oms-navbar .navbar-brand small {
    display: block;
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--oms-cream);
    letter-spacing: 0.08em;
}

.navbar-brand-logo {
    height: 56px;
    width: 56px;
    object-fit: contain;
}

/* ---------- Sidebar ----------
   On a desktop the toggle folds it to icons only (the choice is kept in a
   cookie); below 992px it slides in over the page. Same as rcms. */
.oms-sidebar {
    width: 280px;
    min-height: calc(100vh - 56px);
    background-color: #fff;
    border-right: 1px solid #e3e6ea;
    flex-shrink: 0;
    position: relative;
    transition: width 0.2s ease, transform 0.2s ease;
}

.oms-sidebar .nav-link {
    color: #33404d;
    border-radius: 0.375rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.oms-sidebar .nav-link.active {
    background-color: var(--oms-teal);
    color: #fff !important;
}

.oms-sidebar .nav-link:hover:not(.active) {
    background-color: var(--oms-cream);
}

.oms-sidebar .sidebar-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9aa5b1;
    margin: 0.9rem 0.9rem 0.3rem;
    white-space: nowrap;
    overflow: hidden;
}

/* The toggle sits at the top of the sidebar; the burger in the navbar opens
   the sidebar on a small screen. */
.sidebar-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.5rem 0.25rem;
}

/* Logo (or the heart-pulse icon) and the system's short name, left of the toggle. */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    padding-left: 0.65rem;
    color: var(--oms-teal);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
    white-space: nowrap;
}

.sidebar-brand:hover {
    color: var(--oms-teal-dark);
}

.sidebar-brand i {
    font-size: 1.35rem;
    line-height: 1;
}

.sidebar-brand img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.sidebar-toggle-btn,
.navbar-burger {
    padding: 6px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: #6c757d;
    font-size: 1.25rem;
    line-height: 1;
}

.sidebar-toggle-btn:hover {
    background-color: var(--oms-cream);
    color: var(--oms-charcoal);
}

.navbar-burger {
    color: #fff;
}

.navbar-burger:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(0, 0, 0, 0.45);
}

.oms-content {
    flex-grow: 1;
    padding: 1rem 1.75rem 1.75rem;
    min-width: 0; /* let a collapsed sidebar actually free up space */
}

@media (min-width: 992px) {
    .sidebar-collapsed .oms-sidebar {
        width: 64px;
    }

    .sidebar-collapsed .sidebar-toggle-row {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    .sidebar-collapsed .oms-sidebar .nav-label,
    .sidebar-collapsed .sidebar-brand {
        display: none;
    }

    /* A section title becomes a rule between the groups of icons. */
    .sidebar-collapsed .oms-sidebar .sidebar-section {
        height: 0;
        margin: 0.5rem;
        border-top: 1px solid #e3e6ea;
        font-size: 0;
    }

    .sidebar-collapsed .oms-sidebar .nav-link {
        text-align: center;
        padding: 0.55rem 0;
    }

    .sidebar-collapsed .oms-sidebar .nav-link i {
        margin-right: 0 !important;
        font-size: 1.05rem;
    }
}

@media (max-width: 991.98px) {
    .oms-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1040;
        min-height: 0;
        overflow-y: auto;
        transform: translateX(-100%);
    }

    .sidebar-open .oms-sidebar {
        transform: none;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.18);
    }

    .sidebar-open .sidebar-backdrop {
        display: block;
    }

    /* The navbar, with the burger that opens the menu, stays in reach while
       the page scrolls; the page behind an open menu does not scroll. */
    .oms-navbar { position: sticky; top: 0; z-index: 1020; }
    body.sidebar-open { overflow: hidden; }
    .oms-sidebar { max-width: 85vw; overscroll-behavior: contain; }
    .oms-sidebar .nav-link { padding-top: 0.65rem; padding-bottom: 0.65rem; } /* finger-sized rows */
}

@media (max-width: 767.98px) {
    .oms-content { padding: 1rem; }
}

@media (max-width: 575.98px) {
    .oms-content { padding: 0.75rem; }
}

/* ---------- Reusable bits ---------- */
.stat-card {
    border: none;
    border-radius: 0.6rem;
    box-shadow: 0 0.125rem 0.5rem rgba(36, 49, 47, 0.08);
    height: 100%;
}

.stat-card .stat-value {
    font-size: 1.9rem;
    font-weight: 700;
}

/* Dashboard breakdown charts — one column per day / month, growing from a shared
   baseline. The whole column is the hover target for its tooltip. */
.trend-plot {
    display: flex;
    align-items: stretch;
    height: 120px;
    border-bottom: 1px solid #dfe3e2;
}

.trend-col {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 1px;
}

.trend-col:hover {
    background-color: rgba(36, 49, 47, 0.05);
}

.trend-bar {
    width: 100%;
    max-width: 24px;
    min-height: 2px;
    border-radius: 4px 4px 0 0;
    background-color: var(--oms-teal);
}

.trend-col:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 4px;
    padding: 0.2rem 0.5rem;
    border-radius: 0.3rem;
    background-color: var(--oms-charcoal);
    color: #fff;
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
}

.trend-col.trend-tip-start:hover::after {
    left: 0;
    transform: none;
}

.trend-col.trend-tip-end:hover::after {
    left: auto;
    right: 0;
    transform: none;
}

.trend-axis {
    display: flex;
    margin-top: 0.25rem;
    color: #5f6b69;
    font-size: 0.6875rem;
}

.trend-axis span {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    white-space: nowrap;
}

.table-responsive-card {
    background: #fff;
    border-radius: 0.6rem;
    box-shadow: 0 0.125rem 0.5rem rgba(36, 49, 47, 0.06);
    padding: 1.25rem;
}

.table thead th {
    text-align: center;
    vertical-align: middle;
}

/* ---------- Password field with an inline show/hide toggle ---------- */
.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 2.75rem;
}

.password-toggle-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 2.75rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #6c757d;
    padding: 0;
}

.password-toggle-btn:hover,
.password-toggle-btn:focus {
    color: var(--oms-charcoal);
}

.password-toggle-btn:focus {
    outline: none;
    box-shadow: none;
}

/* ---------- Refraction / prescription grid (eye examination, prescriptions) ---------- */
.rx-table th, .rx-table td {
    text-align: center;
    vertical-align: middle;
}

.rx-table th:first-child, .rx-table td:first-child {
    text-align: left;
    font-weight: 600;
}

.rx-table input.form-control {
    text-align: center;
}

.eye-badge-od { color: #0b5f59; font-weight: 700; }
.eye-badge-os { color: #b5651d; font-weight: 700; }

/* ---------- Optical order status timeline ---------- */
.status-timeline {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    list-style: none;
    padding: 0;
    margin: 0;
}

.status-timeline li {
    flex: 1 1 0;
    min-width: 110px;
    text-align: center;
    padding: 0.6rem 0.3rem;
    position: relative;
    font-size: 0.78rem;
    color: #9aa5b1;
    border-top: 3px solid #e3e6ea;
}

.status-timeline li.done {
    color: var(--oms-teal-dark);
    border-top-color: var(--oms-teal);
    font-weight: 600;
}

.status-timeline li.current {
    color: #fff;
    background-color: var(--oms-teal);
    border-radius: 0.35rem;
    border-top-color: var(--oms-teal);
}

/* ---------- POS ---------- */
.pos-product-card {
    border: 1px solid #e3e6ea;
    border-radius: 0.5rem;
    padding: 0.75rem;
    cursor: pointer;
    background: #fff;
    height: 100%;
}

.pos-product-card:hover {
    border-color: var(--oms-teal);
    box-shadow: 0 0.125rem 0.5rem rgba(15, 122, 114, 0.15);
}

/* Category filter buttons above the product grid. */
.pos-category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.pos-category-pills .btn {
    border-radius: 2rem;
    font-size: 0.85rem;
    padding: 0.35rem 0.9rem;
}

/* One light color per category (pos/index.php hands out c1..c8 in category order,
   repeating), shown on its product cards and on its category button. */
.pos-tile-c1 { --pos-tile-bg: #e8f1fd; --pos-tile-border: #1d6fd1; } /* blue */
.pos-tile-c2 { --pos-tile-bg: #e6f6ec; --pos-tile-border: #198754; } /* green */
.pos-tile-c3 { --pos-tile-bg: #fdf3dc; --pos-tile-border: #b98200; } /* yellow */
.pos-tile-c4 { --pos-tile-bg: #fde9e7; --pos-tile-border: #dc3545; } /* coral */
.pos-tile-c5 { --pos-tile-bg: #f0eafc; --pos-tile-border: #7b3fc4; } /* violet */
.pos-tile-c6 { --pos-tile-bg: #e2f5f6; --pos-tile-border: #0b8aa3; } /* teal */
.pos-tile-c7 { --pos-tile-bg: #fdeadb; --pos-tile-border: #d9640a; } /* orange */
.pos-tile-c8 { --pos-tile-bg: #fce8f1; --pos-tile-border: #c2255c; } /* pink */
.pos-product-card[class*="pos-tile-c"] { background: var(--pos-tile-bg); border: 2px solid var(--pos-tile-border); }
.pos-product-card[class*="pos-tile-c"]:hover { border-color: var(--pos-tile-border); transform: translateY(-2px); box-shadow: 0 .4rem 1rem rgba(36, 49, 47, 0.18); }
.pos-product-card { transition: transform .15s ease, box-shadow .15s ease; }
/* Only the resting color: the selected / hovered button keeps Bootstrap's dark fill. */
.pos-category-pills .btn[class*="pos-tile-c"] { --bs-btn-bg: var(--pos-tile-bg); --bs-btn-border-color: var(--pos-tile-border); --bs-btn-border-width: 2px; }

@media (max-width: 767.98px) {
    .pos-category-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        padding-bottom: 0.25rem;
    }
    .pos-category-pills::-webkit-scrollbar { display: none; }
    .pos-category-pills .btn { flex: 0 0 auto; white-space: nowrap; }
}

.pos-cart {
    background: #fff;
    border-radius: 0.6rem;
    box-shadow: 0 0.125rem 0.5rem rgba(36, 49, 47, 0.08);
}

/* ---------- Typography ----------
   Inter, with rcms's weights at slightly larger sizes for readability.
   Printouts keep their own table sizes, and phones keep 16px+ fields (no iOS zoom). */
body { font-size: 1rem; }
@media screen {
    .table thead th { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
    .table tbody td { font-size: 1rem; font-weight: 500; }
    .badge { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; }
}
.form-control, .form-select { font-size: 1rem; font-weight: 500; }
select option { font-weight: 500; }
.form-label { font-size: 0.95rem; font-weight: 600; margin-bottom: 5px; }
.btn { font-size: 0.95rem; font-weight: 600; }
.btn-sm { font-size: 0.85rem; font-weight: 600; letter-spacing: 0.01em; }
.dropdown-menu { font-size: 0.95rem; }
.dropdown-item { font-size: 0.95rem; font-weight: 500; }
.oms-sidebar .nav-link { font-size: 1rem; font-weight: 500; }
.oms-sidebar .sidebar-section { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.09em; }
.nav-tabs .nav-link { font-size: 0.9rem; font-weight: 600; letter-spacing: 0.02em; }
.alert { font-size: 0.95rem; }
.modal-title { font-size: 1.1rem; font-weight: 700; }
.oms-content .small, .oms-content small { font-size: 0.9em; }

@media (max-width: 767.98px) {
    .form-control, .form-select, .input-group-sm > .form-control, .input-group-sm > .form-select { font-size: 1rem; }
}

/* ---------- Phones & tablets: app-like layout ----------
   Listings as cards (.table-stack), wide tables
   scroll sideways, popups slide up as sheets, room for the notch / home bar
   when installed (manifest.php). */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }

/* The brand takes the free space, so the right-hand menus stay right even when
   the branch name is hidden; a long clinic name ends in an ellipsis. */
.oms-navbar { flex-wrap: nowrap; padding-top: max(0.5rem, env(safe-area-inset-top)); }
.oms-navbar .navbar-brand { min-width: 0; margin-right: auto; }
.oms-navbar .navbar-brand-logo { flex-shrink: 0; }
.navbar-brand-text { min-width: 0; }
.navbar-brand-text, .navbar-brand-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 991.98px) {
    .oms-sidebar { padding-top: env(safe-area-inset-top); padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important; }
    .oms-content { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }

    /* Listing as cards: .table-stack on the table; script.js copies each column
       heading into data-label, makes the first cell the card's title and the
       unlabeled (actions) cell a right-aligned footer. */
    .table.table-stack, .table.table-stack tbody { display: block; }
    .table.table-stack thead { display: none; }
    .table.table-stack tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 0.75rem; }
    .table.table-stack tr { display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: 0.5rem 0.75rem; padding: 0.85rem; background: #fff; border: 1px solid #e3e6ea; border-radius: 0.6rem; }
    .table.table-stack td { display: block; min-width: 0; padding: 0; border: 0; text-align: left !important; overflow-wrap: anywhere; }
    .table.table-stack td[data-label]::before { content: attr(data-label); display: block; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #8a96a3; }
    .table.table-stack td.stack-full { grid-column: 1 / -1; }
    .table.table-stack td.stack-title { font-weight: 600; font-size: 0.95rem; padding-bottom: 0.4rem; border-bottom: 1px solid #eef0f3; }
    .table.table-stack td.stack-end { text-align: right !important; padding-top: 0.4rem; border-top: 1px solid #eef0f3; }
    .table.table-stack td.stack-end:empty { display: none; }
    .table.table-stack td.stack-end .btn { margin: 0.15rem 0 0.15rem 0.25rem; }
    .table-responsive:has(> .table-stack) { overflow: visible; }
}

/* Heading rows (title + buttons) and filter bars wrap instead of running off the screen. */
@media (max-width: 767.98px) {
    .oms-content .d-flex.justify-content-between:is(.mb-2, .mb-3, .mb-4) { flex-wrap: wrap; gap: 0.5rem; }
    .oms-content .d-flex.justify-content-between:is(.mb-2, .mb-3, .mb-4) > .d-flex { flex-wrap: wrap; }
    .oms-content h4 { font-size: 1.15rem; }
    .table-responsive-card { padding: 1rem; border-radius: 0.75rem; }
    .pagination { flex-wrap: wrap; }
    .stat-card .stat-value { font-size: 1.45rem; }

    /* Tabs stay on one line and are swiped sideways. */
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link { white-space: nowrap; }
}

@media (max-width: 575.98px) {
    .oms-navbar .navbar-brand { font-size: 1rem; }
    .oms-navbar .navbar-brand small { display: none; }
    .navbar-brand-logo { height: 36px; width: 36px; }
    .oms-content { padding-top: 0.75rem; }

    /* Popups slide up from the bottom as a sheet. */
    .modal-dialog, .modal-dialog-centered { display: flex; align-items: flex-end; min-height: 100%; margin: 0; max-width: none; }
    .modal.fade .modal-dialog { transform: translateY(100%); transition: transform 0.25s ease-out; }
    .modal.show .modal-dialog { transform: none; }
    .modal-content { width: 100%; max-height: 92vh; max-height: 92dvh; overflow-y: auto; border: 0; border-radius: 1rem 1rem 0 0; padding-bottom: env(safe-area-inset-bottom); }
    .modal-footer { position: sticky; bottom: 0; background: inherit; }
    .modal-footer > .btn { flex: 1 1 0; }
}

/* Fingers, not a mouse pointer: bigger targets for small buttons and checkboxes. */
@media (pointer: coarse) {
    .btn-sm { padding: 0.375rem 0.7rem; }
    .form-check-input { width: 1.2em; height: 1.2em; }
    .dropdown-item { padding-top: 0.55rem; padding-bottom: 0.55rem; }
}

/* ---------- Print (e.g. prescriptions, invoices, receipts) ---------- */
@media print {
    .oms-navbar, .oms-sidebar, .sidebar-backdrop, .navbar-burger, .no-print { display: none !important; }
    .oms-content { padding: 0; }
    .table-responsive-card { box-shadow: none; padding: 0; margin-bottom: 1rem !important; }
}

/* ---------- Colored, clickable dashboard stat cards ---------- */
.stat-card { --sc: #0f7a72; --sc-bg: #e6f4f2; background-color: var(--sc-bg); border: 2px solid var(--sc); color: var(--oms-charcoal); text-decoration: none; position: relative; overflow: hidden; transition: transform .15s ease, box-shadow .15s ease; }
.stat-card .stat-label, .stat-card .stat-sub { color: rgba(36, 49, 47, 0.7); }
.stat-card .stat-value { color: var(--sc); }
.stat-card .stat-icon { position: absolute; right: .9rem; top: .8rem; font-size: 1.6rem; color: var(--sc); opacity: .35; }
a.stat-link { cursor: pointer; }
a.stat-link:hover, a.stat-link:focus-visible { transform: translateY(-2px); box-shadow: 0 .4rem 1rem rgba(36, 49, 47, 0.18); color: var(--oms-charcoal); }
.stat-teal   { --sc: #0f7a72; --sc-bg: #e6f4f2; }
.stat-blue   { --sc: #1d6fd1; --sc-bg: #e7f0fc; }
.stat-purple { --sc: #7b3fc4; --sc-bg: #f0e9fa; }
.stat-indigo { --sc: #4455c7; --sc-bg: #eaecfb; }
.stat-cyan   { --sc: #0b8aa3; --sc-bg: #e2f4f8; }
.stat-amber  { --sc: #b98200; --sc-bg: #fff4d6; }
.stat-green  { --sc: #198754; --sc-bg: #e3f4ea; }
.stat-red    { --sc: #dc3545; --sc-bg: #fde8ea; }
.stat-orange { --sc: #d9640a; --sc-bg: #feeddc; }
.stat-rose   { --sc: #c2255c; --sc-bg: #fce7ef; }

/* ---------- Colored quick-action buttons (reuse .stat-* color vars) ---------- */
.qa-btn { background-color: var(--sc-bg); border: 2px solid var(--sc); color: var(--sc); font-weight: 600; transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, color .15s ease; }
.qa-btn:hover, .qa-btn:focus-visible { background-color: var(--sc); color: #fff; transform: translateY(-2px); box-shadow: 0 .3rem .8rem rgba(36, 49, 47, 0.18); }

/* No underline on hyperlinks */
a, a:hover, a:focus { text-decoration: none; }

/* Outline-secondary buttons: light back color so they stand out */
.btn-outline-secondary {
    background-color: #e9ecef;
    border-color: #adb5bd;
    color: #495057;
}
.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-outline-secondary:active {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

/* ---------- Tab strip that stays on a single line (scrolls sideways when it can't fit) ---------- */
.nav-tabs-single { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.nav-tabs-single .nav-item { flex: 0 0 auto; }
.nav-tabs-single .nav-link { white-space: nowrap; padding: .5rem .7rem; font-size: .9rem; }

/* ---------- Patient photo (patientPhotoTag() in functions.php) ---------- */
.patient-photo { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; border-radius: 50%; object-fit: cover; border: 1px solid #dee2e6; vertical-align: middle; }
.patient-photo-empty { background-color: #e9ecef; color: #868e96; }
