:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #101828;
    --muted: #64748b;
    --line: #e5eaf2;
    --blue: #0f62fe;
    --blue-soft: #eaf2ff;
    --green-soft: #dcfce7;
    --green: #166534;
    --red: #dc2626;
    --red-soft: #fff1f2;
    --shadow: 0 16px 40px rgba(15, 23, 42, .07);
    --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--blue); text-decoration: none; }
.app-layout { display: flex; min-height: 100vh; }
.auth-layout { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(135deg, #f8fbff, #eef4ff); }
.sidebar { width: 260px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 20; }
.sidebar-brand { height: 86px; display: flex; gap: 14px; align-items: center; padding: 0 24px; border-bottom: 1px solid var(--line); }
.brand-icon { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, #0f62fe, #60a5fa); color: #fff; display: grid; place-items: center; font-size: 28px; font-weight: 800; }
.sidebar-brand strong { display: block; font-size: 18px; }
.sidebar-brand span, .topbar-user span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.side-nav { padding: 18px 14px; flex: 1; overflow-y: auto; }
.side-nav a, .sidebar-footer a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: #1e293b; border-radius: 10px; margin: 3px 0; font-weight: 600; }
.side-nav a span, .sidebar-footer a span { width: 20px; text-align: center; opacity: .9; }
.side-nav a:hover, .side-nav a.active { background: var(--blue-soft); color: var(--blue); }
.nav-label { color: #64748b; text-transform: uppercase; letter-spacing: .04em; font-weight: 800; font-size: 12px; margin: 22px 14px 8px; }
.sidebar-footer { border-top: 1px solid var(--line); padding: 14px; }
.main-shell { margin-left: 260px; min-width: 0; width: calc(100% - 260px); }
.topbar { height: 86px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 10; }
.topbar-left { display: flex; align-items: center; gap: 20px; }
.menu-toggle { border: 0; background: transparent; font-size: 21px; color: #334155; padding: 0; margin: 0; cursor: pointer; }
.global-search { width: 340px; max-width: 42vw; border: 1px solid #d7deea; color: #94a3b8; padding: 13px 16px; border-radius: 8px; background: #fff; }
.topbar-user { display: flex; align-items: center; gap: 12px; position: relative; }
.notification-dot { background: #ef4444; color: #fff; width: 18px; height: 18px; border-radius: 999px; display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.avatar { width: 42px; height: 42px; border-radius: 999px; background: #dbe4f0; display: grid; place-items: center; color: #334155; font-weight: 800; }
.container { max-width: none; margin: 0; padding: 32px; }
.auth-container { width: 100%; }
.page-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.page-header h1, .card h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.02em; }
.page-header p, .card > p:first-of-type { margin: 0; color: var(--muted); font-size: 16px; }
.card { background: var(--card); padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid #eef2f7; margin-bottom: 22px; }
.login-card { max-width: 430px; margin: 0 auto; }
.login-card h1 { font-size: 30px; }
label { display: block; font-weight: 800; margin-top: 14px; margin-bottom: 7px; }
input, select, textarea { width: 100%; padding: 12px 13px; border: 1px solid #d7deea; border-radius: 8px; font: inherit; background: #fff; color: #111827; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(15,98,254,.12); }
textarea { min-height: 110px; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--blue); color: #fff; border: 1px solid var(--blue); padding: 11px 16px; border-radius: 8px; cursor: pointer; margin-top: 16px; font-weight: 700; line-height: 1; }
.button:hover, button:hover { filter: brightness(.96); }
.button.secondary { background: #fff; color: var(--blue); border-color: #7aa7ff; }
.button.danger, button.danger { background: #fff; color: var(--red); border-color: #ff7a87; }
.button.small, .actions .button, .actions button { padding: 9px 12px; margin-top: 0; }
.error { background: #fee2e2; color: #991b1b; padding: 12px; border-radius: 8px; margin-bottom: 14px; }
.success { background: var(--green-soft); color: var(--green); padding: 12px; border-radius: 8px; margin-bottom: 14px; }
.table-card { overflow-x: auto; padding: 12px; }
table { width: 100%; min-width: 980px; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 18px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { background: #f8fafc; font-weight: 800; color: #111827; }
td:first-child, th:first-child { min-width: 230px; white-space: normal; }
td:nth-child(3), th:nth-child(3) { min-width: 150px; }
td:nth-child(8), th:nth-child(8) { min-width: 140px; }
.actions { display: flex; gap: 8px; align-items: center; }
.actions a { display: inline-flex; padding: 9px 12px; border: 1px solid #7aa7ff; border-radius: 7px; font-weight: 700; }
.actions form { display: inline-flex; margin: 0; }
.inline-form { display: inline; }
.badge { display: inline-flex; align-items: center; padding: 8px 12px; border-radius: 7px; font-weight: 700; font-size: 13px; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.gray { background: #eef2f7; color: #475569; }
.filter-card { padding: 24px 28px; }
.search-form .filter-grid { display: grid; grid-template-columns: minmax(260px, 1.5fr) repeat(3, minmax(160px, .8fr)) auto; gap: 20px; align-items: end; }
.search-form button, .search-form .button { margin-top: 0; height: 43px; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-row { display: flex; gap: 10px; align-items: center; }
.form-row input { flex: 1; }
.checkbox-list label { font-weight: 500; display: flex; gap: 8px; align-items: center; }
.checkbox-list input { width: auto; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.module-card { display: block; border: 1px solid var(--line); border-radius: 12px; padding: 18px; color: #111827; background: #fff; box-shadow: 0 8px 20px rgba(15,23,42,.04); }
.module-card strong { display: block; margin-bottom: 6px; }
.module-card span { color: var(--muted); }
.pagination-note { color: var(--muted); padding: 16px 4px 4px; }
@media (max-width: 980px) {
    .sidebar { transform: translateX(-100%); }
    .main-shell { margin-left: 0; width: 100%; }
    .global-search { display: none; }
    .search-form .filter-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
}
@media (max-width: 700px) {
    .container { padding: 20px; }
    .form-grid.two-col { grid-template-columns: 1fr; }
    .form-row { display: block; }
    .form-row button, .form-row .button { margin-top: 10px; }
}


.badge.blue { background: var(--blue-soft); color: var(--blue); }
.muted { color: var(--muted); font-size: 13px; }
.order-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; }
.summary-card span { display: block; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; font-size: 12px; margin-bottom: 8px; }
.summary-card strong { display: block; font-size: 24px; margin-bottom: 6px; }
.summary-card p { margin: 0; color: var(--muted); }
.orders-filter-grid { grid-template-columns: minmax(260px, 1.5fr) repeat(3, minmax(150px, .7fr)) auto !important; }
@media (max-width: 980px) { .order-summary-grid { grid-template-columns: 1fr; } .orders-filter-grid { grid-template-columns: 1fr !important; } }

.alert-success { border-left: 4px solid #16a34a; color: #166534; background: #f0fdf4; font-weight: 700; }
.table-toolbar { display: flex; justify-content: flex-end; gap: 10px; padding: 6px 6px 14px; }
.table-toolbar.left { justify-content: flex-start; }
.table-toolbar .button, .table-toolbar button { margin-top: 0; }
.actions button.button.small { margin-top: 0; }

.tier-section { margin: 28px 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.tier-section-header { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 20px 22px; background: #f8fafc; border-bottom: 1px solid var(--line); }
.tier-section-header h2 { margin: 0; font-size: 22px; }
.tier-section-header p { margin: 0; color: var(--muted); }
.toggle-row { display: inline-flex; align-items: center; gap: 10px; margin: 0; white-space: nowrap; background: #fff; border: 1px solid #d7deea; border-radius: 999px; padding: 10px 14px; }
.toggle-row input { width: auto; }
.tier-table-wrap { overflow-x: auto; }
.tier-table { min-width: 760px; }
.tier-table td:first-child, .tier-table th:first-child { min-width: 120px; white-space: nowrap; }
.tier-table td:nth-child(2), .tier-table th:nth-child(2) { min-width: 220px; }
.tier-table td:nth-child(3), .tier-table th:nth-child(3), .tier-table td:nth-child(4), .tier-table th:nth-child(4) { min-width: 160px; }
.tier-money-input { display: inline-block; width: 130px; padding: 9px 10px; }
.money-prefix { display: inline-block; margin-right: 6px; font-weight: 800; color: #334155; }
@media (max-width: 700px) { .tier-section-header { flex-direction: column; align-items: flex-start; } .toggle-row { white-space: normal; } }


/* v12 cleanup */
.order-number-col {
    width: 92px;
    white-space: nowrap;
}
.thumb-col {
    width: 74px;
    text-align: center;
}
.order-item-thumb {
    width: 54px;
    height: 54px;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 18px;
}

/* v14 pay for orders */
.pay-filter-grid {
    grid-template-columns: minmax(260px, 1fr) auto !important;
}
.payment-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.payment-form h2 {
    margin-top: 0;
}
@media (max-width: 980px) {
    .pay-filter-grid,
    .payment-summary-grid {
        grid-template-columns: 1fr !important;
    }
}

/* v15 receipts */
.alert.success,
.alert-success {
    border-left: 4px solid #16a34a;
    color: #166534;
    background: #f0fdf4;
    font-weight: 700;
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 18px;
}

/* V19 approval shipping controls */
.inline-approve-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}
.compact-select {
    max-width: 180px;
    padding: 6px 8px;
    font-size: 13px;
}
.inline-label {
    font-size: 13px;
    font-weight: 600;
    margin-right: 6px;
}
.patient-ship-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 6px;
    max-width: 420px;
}
.patient-ship-fields input {
    padding: 6px 8px;
    font-size: 13px;
}
