/* ============================================================
   OrthoPlan Pro — Frontend stylesheet
   v1.8 design system — clinical teal/slate, Plus Jakarta Sans
   ============================================================ */

/* ---------- Design tokens ---------- */
:root, .op-frontend, .op-shell {
    /* Brand — clinical teal/petrol (overridable via the Brand colour setting) */
    --op-primary:        #0e7c86;
    --op-primary-dark:   #0a5f68;
    --op-primary-light:  #e2f3f4;
    --op-primary-text:   #ffffff;
    --op-accent:         #f2a23c;

    /* Neutrals — cool slate */
    --op-bg:        #f3f6f8;
    --op-bg-alt:    #eaeff2;
    --op-surface:   #ffffff;
    --op-border:    #e3e9ed;
    --op-border-strong: #c8d2d9;
    --op-text:      #0e1c24;
    --op-text-muted:#51626c;
    --op-text-soft: #8595a0;

    /* Semantic */
    --op-success:   #0f9d6b;
    --op-success-bg:#e7f7f0;
    --op-success-text: #0a5c3f;
    --op-warning:   #d98324;
    --op-warning-bg:#fdf3e7;
    --op-warning-text:#8a5012;
    --op-danger:    #d64545;
    --op-danger-bg: #fdeced;
    --op-danger-text: #8f2b2b;
    --op-info:      #2a7de1;
    --op-info-bg:   #e8f1fc;
    --op-info-text: #15467f;

    /* Spacing */
    --op-sp-1:  4px;
    --op-sp-2:  8px;
    --op-sp-3:  12px;
    --op-sp-4:  16px;
    --op-sp-5:  20px;
    --op-sp-6:  24px;
    --op-sp-8:  32px;
    --op-sp-10: 40px;

    /* Radius */
    --op-radius-sm: 7px;
    --op-radius:    10px;
    --op-radius-md: 12px;
    --op-radius-lg: 16px;
    --op-radius-pill: 999px;

    /* Shadows — soft, neutral slate */
    --op-shadow-sm: 0 1px 2px rgba(14,28,36,.05);
    --op-shadow:    0 1px 3px rgba(14,28,36,.07), 0 1px 2px rgba(14,28,36,.04);
    --op-shadow-md: 0 6px 18px rgba(14,28,36,.08);
    --op-shadow-lg: 0 16px 40px rgba(14,28,36,.14);

    --op-transition: 150ms ease;
    --op-topbar-height: 66px;
    --op-sidebar-width: 244px;

    /* Typography */
    --op-font-display: "Plus Jakarta Sans", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --op-font-body:    "Plus Jakarta Sans", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --op-font-mono:    ui-monospace, "SFMono-Regular", "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;

    font-family: var(--op-font-body);
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--op-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.op-frontend *, .op-frontend *::before, .op-frontend *::after,
.op-shell *,    .op-shell *::before,    .op-shell *::after { box-sizing: border-box; }

.op-frontend a, .op-shell a { color: var(--op-primary); text-decoration: none; transition: color var(--op-transition); }
.op-frontend a:hover, .op-shell a:hover { color: var(--op-primary-dark); text-decoration: underline; }

.op-frontend h1, .op-shell h1 { font-family: var(--op-font-display); font-size: 25px; font-weight: 800; line-height: 1.2; margin: 0 0 var(--op-sp-2); letter-spacing: -0.02em; }
.op-frontend h2, .op-shell h2 { font-family: var(--op-font-display); font-size: 19px; font-weight: 700; line-height: 1.3;  margin: 0 0 var(--op-sp-3); letter-spacing: -0.015em; }
.op-frontend h3, .op-shell h3 { font-family: var(--op-font-display); font-size: 16px; font-weight: 700; line-height: 1.35; margin: 0 0 var(--op-sp-2); letter-spacing: -0.01em; }
.op-mono, .op-frontend .op-mono { font-family: var(--op-font-mono); font-size: 0.92em; letter-spacing: 0.01em; }
.op-frontend p,  .op-shell p  { margin: 0 0 var(--op-sp-3); }

.op-muted    { color: var(--op-text-muted); font-size: 13px; }
.op-mono     { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }


/* ---------- App shell ---------- */
.op-shell {
    background: var(--op-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.op-shell-body {
    display: flex;
    flex: 1;
    min-height: calc(100vh - var(--op-topbar-height));
}
.op-shell main {
    flex: 1;
    padding: var(--op-sp-6);
    max-width: 100%;
    overflow-x: hidden;
}


/* ---------- Topbar ---------- */
.op-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--op-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--op-sp-6);
    background: var(--op-surface);
    border-bottom: 1px solid var(--op-border);
}
.op-topbar-brand    { display: flex; align-items: center; }
.op-brand-link      { display: inline-flex; align-items: center; gap: var(--op-sp-3); color: var(--op-text) !important; text-decoration: none !important; font-weight: 600; }
.op-brand-link:hover { color: var(--op-primary) !important; }
.op-brand-mark      {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--op-radius);
    background: linear-gradient(135deg, var(--op-primary), var(--op-primary-dark));
    color: #fff; font-weight: 700; font-size: 16px;
}
.op-brand-name { font-size: 15px; font-weight: 600; color: var(--op-text); }
.op-brand-tag  { display: inline-block; padding: 2px var(--op-sp-2); border-radius: var(--op-radius-pill); background: var(--op-primary-light); color: var(--op-primary); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-left: var(--op-sp-2); }
.op-frontend[data-rtl="1"] .op-brand-tag { margin-left: 0; margin-right: var(--op-sp-2); }

.op-topbar-actions { display: flex; align-items: center; gap: var(--op-sp-2); }
.op-icon-btn {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--op-surface);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-pill);
    color: var(--op-text);
    cursor: pointer;
    text-decoration: none;
    font-size: 16px;
    transition: all var(--op-transition);
    position: relative;
}
.op-icon-btn:hover { background: var(--op-bg-alt); color: var(--op-text); }
.op-icon-btn:focus-visible { outline: 2px solid var(--op-primary); outline-offset: 2px; }


/* ---------- Sidebar ---------- */
.op-sidebar {
    width: var(--op-sidebar-width);
    background: var(--op-surface);
    border-right: 1px solid var(--op-border);
    padding: var(--op-sp-4) 0;
    flex-shrink: 0;
}
.op-frontend[data-rtl="1"] .op-sidebar { border-right: none; border-left: 1px solid var(--op-border); }
.op-sidenav { display: flex; flex-direction: column; gap: 2px; padding: 0 var(--op-sp-3); }
.op-sidenav-link {
    display: flex; align-items: center; gap: var(--op-sp-3);
    padding: var(--op-sp-3) var(--op-sp-4);
    border-radius: var(--op-radius);
    color: var(--op-text-muted) !important;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none !important;
    transition: all var(--op-transition);
}
.op-sidenav-link:hover { background: var(--op-bg-alt); color: var(--op-text) !important; }
.op-sidenav-link.active { background: var(--op-primary-light); color: var(--op-primary) !important; font-weight: 600; }
.op-sidenav-link .op-sidenav-icon, .op-sidenav-link .op-side-icon { font-size: 18px; line-height: 1; width: 22px; text-align: center; flex-shrink: 0; }
.op-sidenav-section { padding: var(--op-sp-4) var(--op-sp-5) var(--op-sp-2); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--op-text-soft); }


/* ---------- Page head ---------- */
.op-page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: var(--op-sp-4);
    margin-bottom: var(--op-sp-6);
    flex-wrap: wrap;
}
.op-page-head > div:first-child { flex: 1; min-width: 0; }
.op-page-head h1 { margin: 0 0 var(--op-sp-1); }
.op-page-head .op-muted { margin: 0; }
.op-page-head-actions { display: flex; gap: var(--op-sp-2); flex-wrap: wrap; align-items: center; }
.op-back-link { display: inline-block; color: var(--op-text-muted); font-size: 13px; margin-bottom: var(--op-sp-2); }
.op-back-link:hover { color: var(--op-primary); }


/* ---------- Cards ---------- */
.op-card {
    background: var(--op-surface);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-md);
    padding: var(--op-sp-6);
    box-shadow: var(--op-shadow-sm);
    margin-bottom: var(--op-sp-4);
}
.op-card > h2:first-child, .op-card > h3:first-child { margin-top: 0; }
.op-card > *:last-child { margin-bottom: 0; }
.op-card-flush  { padding: 0; overflow: hidden; }
.op-card-tight  { padding: var(--op-sp-4); }
.op-card-center { text-align: center; padding: var(--op-sp-10) var(--op-sp-6); }
.op-card-head   { display: flex; align-items: center; justify-content: space-between; gap: var(--op-sp-3); margin-bottom: var(--op-sp-4); }
.op-card-head h2, .op-card-head h3 { margin: 0; }


/* ---------- Buttons ---------- */
.op-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--op-sp-2);
    padding: 10px 18px;
    min-height: 40px;
    border-radius: var(--op-radius);
    border: 1px solid var(--op-border-strong);
    background: var(--op-surface);
    color: var(--op-text);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: all var(--op-transition);
    text-decoration: none !important;
    white-space: nowrap;
    font-family: inherit;
    box-shadow: var(--op-shadow-sm);
    -webkit-appearance: none;
    appearance: none;
}
.op-btn:hover {
    background: var(--op-bg-alt);
    border-color: var(--op-text-soft);
    transform: translateY(-1px);
    box-shadow: var(--op-shadow);
    color: var(--op-text);
}
.op-btn:active { transform: translateY(0); box-shadow: var(--op-shadow-sm); }
.op-btn:focus-visible { outline: 2px solid var(--op-primary); outline-offset: 2px; }
.op-btn:disabled, .op-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

.op-btn-primary {
    background: var(--op-primary);
    color: #fff !important;
    border-color: var(--op-primary);
    box-shadow: 0 1px 2px rgba(14,28,36,.18), inset 0 1px 0 rgba(255,255,255,.18);
}
.op-btn-primary:hover {
    background: var(--op-primary-dark);
    border-color: var(--op-primary-dark);
    color: #fff !important;
    box-shadow: var(--op-shadow-md);
}

.op-btn-success {
    background: var(--op-success);
    color: #fff !important;
    border-color: var(--op-success);
    box-shadow: 0 1px 2px rgba(16,185,129,.25);
}
.op-btn-success:hover { background: #059669; border-color: #059669; color: #fff !important; box-shadow: 0 4px 12px rgba(16,185,129,.3); }

.op-btn-danger {
    background: var(--op-surface);
    color: var(--op-danger);
    border-color: var(--op-danger);
}
.op-btn-danger:hover { background: var(--op-danger); color: #fff !important; box-shadow: 0 4px 12px rgba(239,68,68,.3); }

.op-btn-ghost { background: transparent; border-color: transparent; color: var(--op-text); box-shadow: none; }
.op-btn-ghost:hover { background: var(--op-bg-alt); color: var(--op-primary-dark); box-shadow: none; }

.op-btn-small  { min-height: 32px; padding: 6px 12px; font-size: 13px; border-radius: var(--op-radius-sm); }
.op-btn-large  { min-height: 48px; padding: 14px 24px; font-size: 15px; border-radius: var(--op-radius-md); }
.op-btn-block  { width: 100%; }
.op-btn-icon   { padding: 0; width: 40px; height: 40px; min-height: auto; }

.op-btn-row { display: flex; gap: var(--op-sp-2); flex-wrap: wrap; align-items: center; }
.op-btn-row.op-btn-row-end { justify-content: flex-end; }

.op-link-btn { background: none; border: none; padding: 0; color: var(--op-primary); cursor: pointer; font-size: 13px; font-weight: 600; }
.op-link-btn:hover { text-decoration: underline; }


/* ---------- Forms ---------- */
.op-frontend label { display: block; font-size: 13px; font-weight: 600; color: var(--op-text); margin-bottom: var(--op-sp-1); }
.op-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--op-sp-4); }
.op-form-grid > label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--op-text); }
.op-form-grid-full { grid-column: 1 / -1; }
.op-form-grid label.op-inline-check { flex-direction: row; align-items: center; gap: var(--op-sp-2); font-weight: 500; }
.op-form-grid label.op-inline-check input[type="checkbox"] { margin: 0; }

.op-frontend input[type="text"],
.op-frontend input[type="email"],
.op-frontend input[type="password"],
.op-frontend input[type="tel"],
.op-frontend input[type="number"],
.op-frontend input[type="url"],
.op-frontend input[type="date"],
.op-frontend input[type="search"],
.op-frontend select,
.op-frontend textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--op-border-strong);
    border-radius: var(--op-radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--op-text);
    background: var(--op-surface);
    line-height: 1.4;
    transition: border-color var(--op-transition), box-shadow var(--op-transition);
}
.op-frontend input:focus,
.op-frontend select:focus,
.op-frontend textarea:focus {
    outline: none;
    border-color: var(--op-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.op-frontend input:disabled,
.op-frontend select:disabled,
.op-frontend textarea:disabled { background: var(--op-bg); color: var(--op-text-muted); cursor: not-allowed; }
.op-frontend textarea { resize: vertical; min-height: 88px; }
.op-frontend input::placeholder, .op-frontend textarea::placeholder { color: var(--op-text-soft); }

.op-form-row { display: flex; gap: var(--op-sp-3); margin-bottom: var(--op-sp-4); flex-wrap: wrap; }
.op-form-row > * { flex: 1; min-width: 200px; }
.op-form-help { font-size: 12px; color: var(--op-text-muted); margin: 4px 0 0; }


/* ---------- Auth (login / signup) ---------- */
.op-auth {
    min-height: 80vh;
    display: flex; align-items: center; justify-content: center;
    padding: var(--op-sp-6);
    background: var(--op-bg);
}
.op-auth-inner { width: 100%; max-width: 440px; }
.op-auth-tabs {
    display: flex;
    background: var(--op-surface);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-md);
    padding: var(--op-sp-1);
    margin-bottom: var(--op-sp-5);
    box-shadow: var(--op-shadow-sm);
}
.op-auth-tabs a {
    flex: 1;
    text-align: center;
    padding: 10px var(--op-sp-3);
    border-radius: var(--op-radius-sm);
    color: var(--op-text-muted);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none !important;
    transition: all var(--op-transition);
}
.op-auth-tabs a.active { background: var(--op-primary); color: #fff; box-shadow: var(--op-shadow-sm); }
.op-auth-tabs a:not(.active):hover { color: var(--op-text); }

.op-auth-form {
    background: var(--op-surface);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-lg);
    padding: var(--op-sp-8);
    box-shadow: var(--op-shadow-md);
    display: flex; flex-direction: column;
    gap: var(--op-sp-4);
}
.op-auth-form h2 { text-align: center; margin: 0; font-size: 22px; }
.op-auth-form > p.op-muted { text-align: center; margin: 0; }
.op-auth-form > label { display: flex; flex-direction: column; gap: 6px; }
.op-auth-form > label.op-inline { flex-direction: row; align-items: center; gap: var(--op-sp-2); font-weight: 500; }
.op-auth-form .op-btn-block { margin-top: var(--op-sp-2); }


/* ---------- Alerts ---------- */
.op-alert {
    padding: var(--op-sp-3) var(--op-sp-4);
    border-radius: var(--op-radius);
    border: 1px solid;
    margin-bottom: var(--op-sp-4);
    font-size: 14px;
    line-height: 1.5;
    display: flex; align-items: flex-start; gap: var(--op-sp-2);
}
.op-alert-error   { background: var(--op-danger-bg);  border-color: #fecaca; color: var(--op-danger-text); }
.op-alert-success { background: var(--op-success-bg); border-color: #a7f3d0; color: var(--op-success-text); }
.op-alert-warning { background: var(--op-warning-bg); border-color: #fde68a; color: var(--op-warning-text); }
.op-alert-info    { background: var(--op-info-bg);    border-color: #bfdbfe; color: var(--op-info-text); }


/* ---------- Badges ---------- */
.op-badge {
    display: inline-block;
    padding: 3px var(--op-sp-2);
    border-radius: var(--op-radius-pill);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--op-bg-alt);
    color: var(--op-text-muted);
    line-height: 1.3;
    white-space: nowrap;
}
.op-badge-success { background: var(--op-success-bg); color: var(--op-success-text); }
.op-badge-warning { background: var(--op-warning-bg); color: var(--op-warning-text); }
.op-badge-danger  { background: var(--op-danger-bg);  color: var(--op-danger-text); }
.op-badge-info    { background: var(--op-info-bg);    color: var(--op-info-text); }
.op-badge-primary { background: var(--op-primary-light); color: var(--op-primary); }

.op-color-blue   { background: var(--op-info-bg);    color: var(--op-info-text); }
.op-color-green  { background: var(--op-success-bg); color: var(--op-success-text); }
.op-color-amber  { background: var(--op-warning-bg); color: var(--op-warning-text); }
.op-color-orange { background: #fff7ed; color: #9a3412; }
.op-color-red    { background: var(--op-danger-bg);  color: var(--op-danger-text); }
.op-color-purple { background: #f5f3ff; color: #5b21b6; }
.op-color-gray   { background: var(--op-bg-alt); color: var(--op-text-muted); }


/* ---------- Stats / KPI cards ---------- */
.op-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--op-sp-4); margin-bottom: var(--op-sp-6); }
.op-stat {
    background: var(--op-surface);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-md);
    padding: var(--op-sp-5);
    position: relative;
    overflow: hidden;
}
.op-stat::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--op-primary);
}
.op-stat-success::before { background: var(--op-success); }
.op-stat-warning::before { background: var(--op-warning); }
.op-stat-danger::before  { background: var(--op-danger); }
.op-stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--op-text-muted); margin-bottom: var(--op-sp-2); }
.op-stat-value { font-size: 28px; font-weight: 700; color: var(--op-text); line-height: 1.1; letter-spacing: -0.02em; }
.op-stat-sub   { font-size: 12px; color: var(--op-text-muted); margin-top: var(--op-sp-1); }


/* ---------- Tables ---------- */
.op-table-wrap { overflow-x: auto; border: 1px solid var(--op-border); border-radius: var(--op-radius-md); background: var(--op-surface); }
.op-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.op-table th, .op-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--op-border); vertical-align: middle; }
.op-frontend[data-rtl="1"] .op-table th, .op-frontend[data-rtl="1"] .op-table td { text-align: right; }
.op-table th { background: var(--op-bg); font-weight: 600; font-size: 12px; color: var(--op-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.op-table tbody tr:last-child td { border-bottom: none; }
.op-table tbody tr:hover { background: var(--op-bg); }


/* ---------- Tabs (sub-nav pills) ---------- */
.op-tab-pills { display: flex; gap: var(--op-sp-2); margin-bottom: var(--op-sp-5); flex-wrap: wrap; }
.op-tab-pill {
    padding: 8px 16px;
    border-radius: var(--op-radius-pill);
    background: var(--op-surface);
    border: 1px solid var(--op-border);
    color: var(--op-text-muted);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    transition: all var(--op-transition);
}
.op-tab-pill:hover { background: var(--op-bg-alt); color: var(--op-text); }
.op-tab-pill.active { background: var(--op-primary); border-color: var(--op-primary); color: #fff; }


/* ---------- Photo grid (case detail) ---------- */
.op-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--op-sp-3); }
.op-photo-slot {
    aspect-ratio: 1;
    border: 2px dashed var(--op-border-strong);
    border-radius: var(--op-radius-md);
    background: var(--op-bg);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--op-text-muted);
    font-size: 13px; font-weight: 500;
    cursor: pointer;
    text-align: center;
    padding: var(--op-sp-3);
    position: relative;
    transition: all var(--op-transition);
    overflow: hidden;
}
.op-photo-slot:hover, .op-photo-slot.is-dragover { border-color: var(--op-primary); background: var(--op-primary-light); color: var(--op-primary); }
.op-photo-slot input[type="file"] { display: none; }
.op-photo-slot-icon { font-size: 24px; margin-bottom: var(--op-sp-1); }
.op-photo-slot-label { font-size: 12px; }
.op-photo-thumb { position: relative; aspect-ratio: 1; border-radius: var(--op-radius-md); overflow: hidden; background: var(--op-bg); }
.op-photo-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 200ms ease; cursor: pointer; }
.op-photo-thumb:hover img { transform: scale(1.05); }
.op-delete-att {
    position: absolute; top: 6px; right: 6px;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity var(--op-transition);
}
.op-photo-thumb:hover .op-delete-att { opacity: 1; }


/* ---------- Drop zone (file upload) ---------- */
.op-upload-drop {
    border: 2px dashed var(--op-border-strong);
    border-radius: var(--op-radius-md);
    background: var(--op-bg);
    padding: var(--op-sp-6);
    text-align: center;
    color: var(--op-text-muted);
    cursor: pointer;
    transition: all var(--op-transition);
}
.op-upload-drop:hover, .op-upload-drop.is-dragover {
    border-color: var(--op-primary);
    background: var(--op-primary-light);
    color: var(--op-primary);
}
.op-upload-drop input[type="file"] { display: none; }


/* ---------- Progress + timeline ---------- */
.op-progress { width: 100%; height: 6px; background: var(--op-bg-alt); border-radius: var(--op-radius-pill); overflow: hidden; }
.op-progress-large { height: 10px; }
.op-progress-bar { height: 100%; background: linear-gradient(90deg, var(--op-primary), var(--op-primary-dark)); border-radius: var(--op-radius-pill); transition: width 400ms ease; }

.op-timeline { display: flex; gap: var(--op-sp-2); margin-top: var(--op-sp-4); flex-wrap: wrap; }
.op-timeline-step { flex: 1; min-width: 80px; text-align: center; font-size: 11px; color: var(--op-text-muted); padding: var(--op-sp-2); }
.op-timeline-step.is-done   { color: var(--op-primary); font-weight: 600; }
.op-timeline-step.is-active { color: var(--op-primary); font-weight: 700; }


/* ---------- Toast notifications ---------- */
#op-toast-host {
    position: fixed; bottom: var(--op-sp-6); right: var(--op-sp-6);
    z-index: 9999;
    display: flex; flex-direction: column; gap: var(--op-sp-2);
    pointer-events: none;
}
.op-frontend[data-rtl="1"] #op-toast-host, [data-rtl="1"] #op-toast-host { right: auto; left: var(--op-sp-6); }
.op-toast {
    background: var(--op-text);
    color: #fff;
    padding: 12px 18px;
    border-radius: var(--op-radius-md);
    box-shadow: var(--op-shadow-lg);
    font-size: 14px;
    font-weight: 500;
    pointer-events: auto;
    max-width: 360px;
    animation: opToastIn 200ms ease;
}
.op-toast.success { background: var(--op-success); }
.op-toast.error   { background: var(--op-danger); }
.op-toast.warning { background: var(--op-warning); color: var(--op-text); }
.op-toast.info    { background: var(--op-info); }
@keyframes opToastIn {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}


/* ---------- Modals ---------- */
.op-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.5);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: var(--op-sp-4);
    animation: opFadeIn 200ms ease;
}
.op-modal {
    background: var(--op-surface);
    border-radius: var(--op-radius-lg);
    padding: var(--op-sp-6);
    max-width: 500px;
    width: 100%;
    box-shadow: var(--op-shadow-lg);
    animation: opModalIn 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.op-modal h3 { margin-top: 0; }
.op-modal-actions { display: flex; gap: var(--op-sp-2); justify-content: flex-end; margin-top: var(--op-sp-5); flex-wrap: wrap; }
@keyframes opFadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes opModalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }


/* ---------- Lightbox ---------- */
.op-lightbox {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.92);
    z-index: 1001;
    display: flex; align-items: center; justify-content: center;
    padding: var(--op-sp-6);
}
.op-lightbox img { max-width: 95vw; max-height: 85vh; object-fit: contain; border-radius: var(--op-radius); }
.op-lightbox-close {
    position: absolute; top: var(--op-sp-4); right: var(--op-sp-4);
    width: 44px; height: 44px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.op-lightbox-close:hover { background: rgba(255,255,255,0.25); }
.op-lightbox-original {
    position: absolute; bottom: var(--op-sp-5); left: 50%; transform: translateX(-50%);
    background: var(--op-surface); color: var(--op-text);
    padding: 8px 16px;
    border-radius: var(--op-radius-pill);
    font-size: 13px; font-weight: 600;
    text-decoration: none !important;
}


/* ---------- Notification bell ---------- */
.op-bell-count {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 20px; height: 20px;
    background: var(--op-danger); color: #fff;
    border-radius: 10px;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 5px;
    border: 2px solid var(--op-surface);
}
.op-bell-panel {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 360px; max-width: 90vw;
    background: var(--op-surface);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-md);
    box-shadow: var(--op-shadow-lg);
    overflow: hidden;
    max-height: 480px;
    display: none;
}
.op-bell-panel.is-open { display: block; }
.op-bell-head { padding: var(--op-sp-3) var(--op-sp-4); border-bottom: 1px solid var(--op-border); display: flex; justify-content: space-between; align-items: center; }
.op-bell-head h4 { margin: 0; font-size: 14px; }
.op-bell-list  { max-height: 360px; overflow-y: auto; }
.op-bell-empty { padding: var(--op-sp-6); text-align: center; color: var(--op-text-muted); font-size: 13px; }
.op-bell-item  { padding: var(--op-sp-3) var(--op-sp-4); border-bottom: 1px solid var(--op-border); cursor: pointer; transition: background var(--op-transition); }
.op-bell-item:last-child { border-bottom: none; }
.op-bell-item:hover { background: var(--op-bg); }
.op-bell-item.is-unread { background: var(--op-primary-light); }
.op-bell-item-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; color: var(--op-text); }
.op-bell-item-msg   { font-size: 12px; color: var(--op-text-muted); line-height: 1.4; }
.op-bell-item-time  { font-size: 11px; color: var(--op-text-soft); margin-top: 4px; }


/* ---------- Help FAB + tour ---------- */
.op-help-fab {
    position: fixed; bottom: var(--op-sp-6); right: var(--op-sp-6);
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--op-primary);
    color: #fff;
    border: none;
    font-size: 22px; font-weight: 700;
    cursor: pointer;
    box-shadow: var(--op-shadow-md);
    z-index: 100;
    transition: transform var(--op-transition), box-shadow var(--op-transition);
}
.op-help-fab:hover { transform: translateY(-2px); box-shadow: var(--op-shadow-lg); }
.op-frontend[data-rtl="1"] .op-help-fab { right: auto; left: var(--op-sp-6); }


/* ---------- Filter bar ---------- */
.op-filter-bar {
    background: var(--op-surface);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-md);
    padding: var(--op-sp-3);
    margin-bottom: var(--op-sp-4);
    display: flex;
    gap: var(--op-sp-2);
    align-items: center;
    flex-wrap: wrap;
}


/* ---------- Empty state ---------- */
.op-empty {
    text-align: center;
    padding: var(--op-sp-10) var(--op-sp-6);
    color: var(--op-text-muted);
}
.op-empty-icon { font-size: 48px; margin-bottom: var(--op-sp-3); opacity: 0.5; }
.op-empty h3 { color: var(--op-text); margin-bottom: var(--op-sp-2); }


/* ---------- Welcome / signed-in card ---------- */
.op-welcome-card { text-align: center; padding: var(--op-sp-8); max-width: 480px; margin: var(--op-sp-8) auto; }
.op-welcome-icon { font-size: 56px; margin-bottom: var(--op-sp-3); }
.op-welcome-actions { display: flex; gap: var(--op-sp-2); justify-content: center; margin-top: var(--op-sp-4); flex-wrap: wrap; }
.op-card-wrap { display: flex; align-items: center; justify-content: center; min-height: 60vh; padding: var(--op-sp-4); }


/* ---------- Misc ---------- */
.op-frontend hr, .op-shell hr { border: none; border-top: 1px solid var(--op-border); margin: var(--op-sp-5) 0; }
.op-frontend code, .op-shell code { background: var(--op-bg-alt); padding: 2px 6px; border-radius: 4px; font-size: 13px; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }


/* ---------- Mobile breakpoints ---------- */
@media (max-width: 1024px) {
    .op-sidebar { width: 200px; }
}
@media (max-width: 768px) {
    .op-shell-body { flex-direction: column; }
    .op-sidebar    { width: 100%; padding: var(--op-sp-2); border-right: none; border-bottom: 1px solid var(--op-border); }
    .op-frontend[data-rtl="1"] .op-sidebar { border-left: none; border-bottom: 1px solid var(--op-border); }
    .op-sidenav    { flex-direction: row; overflow-x: auto; padding: 0; gap: var(--op-sp-1); }
    .op-sidenav-link { white-space: nowrap; padding: var(--op-sp-2) var(--op-sp-3); }
    .op-sidenav-section { display: none; }
    .op-shell main { padding: var(--op-sp-4); }
    .op-topbar     { padding: 0 var(--op-sp-4); }
    .op-page-head  { flex-direction: column; gap: var(--op-sp-3); }
    .op-card       { padding: var(--op-sp-4); }
    .op-stats      { grid-template-columns: 1fr 1fr; }
    .op-bell-panel { right: -100px; }
}
@media (max-width: 480px) {
    .op-stats { grid-template-columns: 1fr; }
    .op-brand-tag { display: none; }
    .op-stat-value { font-size: 24px; }
}


/* ---------- RTL fixes ---------- */
.op-frontend[data-rtl="1"] .op-table th,
.op-frontend[data-rtl="1"] .op-table td { text-align: right; }
.op-frontend[data-rtl="1"] .op-page-head { flex-direction: row-reverse; }
.op-frontend[data-rtl="1"] .op-back-link::before { content: " →"; }


/* ============================================================
   v1.6 additions — pills, free/refinement badges, auth polish,
   and stronger responsive behaviour.
   ============================================================ */

/* ---------- Status pills (free / refinement) ---------- */
.op-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px;
    border-radius: var(--op-radius-pill);
    font-size: 11px; font-weight: 700;
    letter-spacing: .02em;
    vertical-align: middle;
    margin-inline-start: 6px;
}
.op-pill-free   { background: var(--op-success-bg); color: var(--op-success-text); }
.op-pill-free::before   { content: "✓"; font-size: 10px; }
.op-pill-refine { background: var(--op-warning-bg); color: var(--op-warning-text); }
.op-pill-refine::before { content: "↻"; font-size: 11px; }

/* ---------- Transition button cluster ---------- */
.op-trans-buttons { display: flex; flex-wrap: wrap; gap: var(--op-sp-2); }
.op-trans-buttons .op-btn { flex: 0 1 auto; }

/* ---------- Auth page: center it and make it breathe ---------- */
.op-auth {
    max-width: 460px;
    margin: clamp(24px, 6vh, 72px) auto;
    padding: 0 var(--op-sp-4);
}
.op-auth-tabs {
    display: flex; gap: 4px;
    background: var(--op-bg-alt);
    border-radius: var(--op-radius-md);
    padding: 4px;
    margin-bottom: var(--op-sp-4);
}
.op-auth-tabs a {
    flex: 1; text-align: center;
    padding: var(--op-sp-3);
    border-radius: var(--op-radius);
    font-weight: 600; font-size: 14px;
    color: var(--op-text-muted) !important;
    text-decoration: none !important;
    transition: all var(--op-transition);
}
.op-auth-tabs a.active { background: var(--op-surface); color: var(--op-primary) !important; box-shadow: var(--op-shadow-sm); }
.op-auth-form label { display: block; margin-bottom: var(--op-sp-3); font-size: 13px; font-weight: 600; color: var(--op-text); }
.op-auth-form input[type="text"],
.op-auth-form input[type="email"],
.op-auth-form input[type="tel"],
.op-auth-form input[type="password"] { margin-top: 6px; }
.op-auth-form .op-inline { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.op-auth-form .op-btn-block { width: 100%; margin-top: var(--op-sp-2); }

/* ---------- Touch-friendly controls on small screens ---------- */
@media (max-width: 768px) {
    .op-frontend input,
    .op-frontend select,
    .op-frontend textarea { font-size: 16px; } /* stops iOS zoom-on-focus */
    .op-frontend .op-btn { min-height: 44px; }
    .op-tabs-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; flex-wrap: nowrap; }
    .op-tabs-nav .op-tab-link { flex: 0 0 auto; }
    .op-case-detail .op-page-head { flex-direction: column; align-items: flex-start; gap: var(--op-sp-2); }
    .op-form-grid { grid-template-columns: 1fr !important; }
    .op-case-grid { grid-template-columns: 1fr; }
    .op-info-table { display: block; overflow-x: auto; }
}
@media (max-width: 480px) {
    .op-frontend h1, .op-shell h1 { font-size: 20px; }
    .op-topbar-user span:not(.op-topbar-avatar) { display: none; }
    .op-pill { margin-top: 4px; }
}

/* Make any wide table scroll instead of breaking the layout. */
.op-table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* RTL: pills sit on the correct side via logical margins (already handled). */


/* ============================================================
   v1.7 additions — case messaging thread + consultation UI.
   ============================================================ */

/* ---------- Messaging thread ---------- */
.op-thread {
    max-height: 420px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--op-sp-2);
    padding: var(--op-sp-2);
    background: var(--op-bg-alt);
    border-radius: var(--op-radius-md);
    margin-bottom: var(--op-sp-3);
    min-height: 80px;
}
.op-msg {
    max-width: 78%;
    padding: var(--op-sp-2) var(--op-sp-3);
    border-radius: var(--op-radius-md);
    background: var(--op-surface);
    border: 1px solid var(--op-border);
    box-shadow: var(--op-shadow-sm);
}
.op-msg-mine     { align-self: flex-end; background: var(--op-primary-light); border-color: transparent; }
.op-frontend[data-rtl="1"] .op-msg-mine  { align-self: flex-start; }
.op-frontend[data-rtl="1"] .op-msg-other { align-self: flex-end; }
.op-msg-other    { align-self: flex-start; }
.op-msg-internal { background: var(--op-warning-bg); border-color: #f3e2bd; }
.op-msg-meta { font-size: 11px; color: var(--op-text-soft); margin-bottom: 2px; }
.op-msg-body { font-size: 14px; color: var(--op-text); white-space: pre-wrap; word-break: break-word; }

.op-message-form { display: flex; flex-direction: column; gap: var(--op-sp-2); }
.op-message-form textarea { width: 100%; resize: vertical; }
.op-message-form-row { display: flex; align-items: center; justify-content: space-between; gap: var(--op-sp-3); flex-wrap: wrap; }
.op-message-form-row .op-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--op-text-muted); }

/* ---------- Consultation page ---------- */
.op-consult .op-table td { vertical-align: top; }
.op-consult .op-page-head { padding: var(--op-sp-5) var(--op-sp-6); }
@media (max-width: 768px) {
    .op-msg { max-width: 90%; }
    .op-message-form-row { flex-direction: column; align-items: stretch; }
}


/* ============================================================
   v1.7.2 — Full-screen app template.
   Renders OrthoPlan pages edge-to-edge with no theme chrome.
   ============================================================ */
body.orthoplan-fullscreen {
    margin: 0 !important;
    padding: 0 !important;
    background: var(--op-bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
body.orthoplan-fullscreen .orthoplan-app-shell {
    width: 100%;
    min-height: 100vh;
}
/* The dashboards/login use .op-frontend internally; make sure it fills height. */
body.orthoplan-fullscreen .op-frontend,
body.orthoplan-fullscreen .op-shell {
    min-height: 100vh;
}
/* Keep the sticky app bar clear of the WordPress admin bar (staff only). */
body.orthoplan-fullscreen.admin-bar .op-topbar { top: 32px; }
@media screen and (max-width: 782px) {
    body.orthoplan-fullscreen.admin-bar .op-topbar { top: 46px; }
}
/* Belt-and-braces: hide any stray theme leftovers if a plugin/theme injects
   into the body of our template (rare, but cheap to guard). */
body.orthoplan-fullscreen > header:not(.op-topbar),
body.orthoplan-fullscreen > footer,
body.orthoplan-fullscreen > .site-header,
body.orthoplan-fullscreen > .site-footer { display: none !important; }


/* ============================================================
   v1.8 — Modal/tour fix (help guide), pills, plans & users UI
   ============================================================ */

/* ---- Modal system: outer .op-modal is the overlay, .op-modal-content is the box ---- */
.op-modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: var(--op-sp-4);
    background: none; max-width: none; width: auto;
    border-radius: 0; box-shadow: none;
    animation: opFadeIn 180ms ease;
}
.op-modal[hidden] { display: none !important; }
.op-modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(14,28,36,.55);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.op-modal-content {
    position: relative; z-index: 1;
    background: var(--op-surface);
    border-radius: var(--op-radius-lg);
    padding: var(--op-sp-8);
    max-width: 520px; width: 100%;
    max-height: 90vh; overflow-y: auto;
    box-shadow: var(--op-shadow-lg);
    animation: opModalIn 240ms cubic-bezier(.34,1.56,.64,1);
}
.op-modal-small { max-width: 420px; }
.op-modal-tour  { max-width: 480px; text-align: center; }
.op-modal-close {
    position: absolute; top: 12px; inset-inline-end: 14px;
    width: 34px; height: 34px;
    border: none; background: var(--op-bg-alt); color: var(--op-text-muted);
    border-radius: 50%; font-size: 20px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--op-transition);
}
.op-modal-close:hover { background: var(--op-border); color: var(--op-text); }

/* ---- Quick-tour (help guide) ---- */
.op-tour-progress {
    height: 5px; background: var(--op-border); border-radius: 999px;
    overflow: hidden; margin-bottom: var(--op-sp-6);
}
.op-tour-progress::after {
    content: ''; display: block; height: 100%;
    width: var(--op-tour-pct, 20%);
    background: var(--op-primary); border-radius: 999px;
    transition: width 260ms ease;
}
.op-tour-step { display: none; }
.op-tour-step.active { display: block; animation: opFadeIn 200ms ease; }
.op-tour-icon { font-size: 46px; line-height: 1; margin-bottom: var(--op-sp-3); }
.op-tour-step h3 { margin-bottom: var(--op-sp-2); }
.op-tour-step p { color: var(--op-text-muted); margin: 0; }
.op-tour-actions { align-items: center; justify-content: space-between; margin-top: var(--op-sp-6); }
.op-tour-counter { font-size: 13px; color: var(--op-text-soft); font-variant-numeric: tabular-nums; }

/* ---- Help floating button ---- */
.op-help-fab {
    position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 60;
    width: 48px; height: 48px; border-radius: 50%;
    border: none; cursor: pointer;
    background: var(--op-primary); color: #fff;
    font-size: 22px; font-weight: 700;
    box-shadow: var(--op-shadow-md);
    transition: transform var(--op-transition), box-shadow var(--op-transition);
}
.op-help-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: var(--op-shadow-lg); }

/* ---- Pills / badges ---- */
.op-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 11px; border-radius: 999px;
    font-size: 12px; font-weight: 700; line-height: 1.4;
    background: var(--op-bg-alt); color: var(--op-text-muted);
}
.op-pill-refine { background: #fbe7cd; color: #8a5012; }

/* Plan badges */
.op-plan-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 11px; border-radius: 999px;
    font-size: 12px; font-weight: 700; letter-spacing: .02em;
    text-transform: uppercase;
}
.op-plan-free { background: var(--op-bg-alt); color: var(--op-text-muted); }
.op-plan-pro  { background: linear-gradient(120deg, #0e7c86, #12a3a0); color: #fff; }

/* Refinement marker in case list rows */
.op-refine-tag {
    display: inline-block; margin-inline-start: 6px;
    padding: 1px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 700;
    background: #fbe7cd; color: #8a5012; vertical-align: middle;
}

/* ---- Users / doctors management table ---- */
.op-users-table { width: 100%; border-collapse: collapse; }
.op-users-table th, .op-users-table td {
    padding: 12px 14px; text-align: start; font-size: 13.5px;
    border-bottom: 1px solid var(--op-border); vertical-align: middle;
}
.op-users-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--op-text-soft); font-weight: 700; }
.op-users-table tr:hover td { background: var(--op-bg-alt); }
.op-user-name { font-weight: 700; color: var(--op-text); }
.op-user-email { font-size: 12px; color: var(--op-text-soft); }
.op-user-controls { display: flex; gap: var(--op-sp-2); align-items: center; flex-wrap: wrap; }
.op-user-controls select { min-width: 120px; }
.op-status-dot { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; }
.op-status-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--op-text-soft); }
.op-status-active::before   { background: var(--op-success); }
.op-status-pending::before  { background: var(--op-warning); }
.op-status-suspended::before{ background: var(--op-danger); }

/* Plan rules editor */
.op-plan-rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--op-sp-5); }
.op-plan-card { border: 1px solid var(--op-border); border-radius: var(--op-radius-md); padding: var(--op-sp-5); background: var(--op-surface); }
.op-plan-card h4 { margin: 0 0 var(--op-sp-4); font-family: var(--op-font-display); display: flex; align-items: center; gap: 8px; }
.op-plan-card .op-inline { display: flex; align-items: center; gap: 8px; margin-bottom: var(--op-sp-3); font-size: 13.5px; }

@media (max-width: 768px) {
    .op-users-table thead { display: none; }
    .op-users-table, .op-users-table tbody, .op-users-table tr, .op-users-table td { display: block; width: 100%; }
    .op-users-table tr { border: 1px solid var(--op-border); border-radius: var(--op-radius-md); margin-bottom: var(--op-sp-3); padding: var(--op-sp-2); }
    .op-users-table td { border: none; padding: 6px 10px; }
}


/* ============================================================
   v1.8.1 — Tab system, fullscreen layout container, safety
   ============================================================ */

/* ---- Case-detail tab system (was missing base styles) ---- */
.op-tabs-wrapper { margin-top: var(--op-sp-5); }
.op-tabs-nav {
    display: flex; flex-wrap: wrap; gap: 2px;
    border-bottom: 1px solid var(--op-border);
    margin-bottom: var(--op-sp-5);
}
.op-tab-link {
    appearance: none; background: none; border: none;
    padding: 11px 16px; margin-bottom: -1px;
    font-family: var(--op-font-body); font-size: 14px; font-weight: 600;
    color: var(--op-text-muted); cursor: pointer;
    border-bottom: 2.5px solid transparent;
    text-decoration: none !important; white-space: nowrap;
    transition: color var(--op-transition), border-color var(--op-transition);
}
.op-tab-link:hover { color: var(--op-text); }
.op-tab-link.active { color: var(--op-primary); border-bottom-color: var(--op-primary); }

/* THE important fix: only the active panel shows. */
.op-tab-panel { display: none; }
.op-tab-panel.active { display: block; animation: opFadeIn 180ms ease; }

/* ---- Fullscreen layout: centered comfortable column (single-column views only) ---- */
body.orthoplan-fullscreen .op-frontend:not(.op-shell) {
    max-width: 1240px;
    margin-inline: auto;
    padding: 0 24px 64px;
}
/* Sticky top bar breaks out to the column edges and stays full-bleed-feeling. */
body.orthoplan-fullscreen .op-frontend:not(.op-shell) .op-topbar {
    margin: 0 -24px var(--op-sp-2);
    padding-left: 24px; padding-right: 24px;
}
/* The admin shell (with sidebar) uses the whole screen, capped only on huge monitors. */
body.orthoplan-fullscreen .op-shell { max-width: 1700px; margin-inline: auto; }
@media (max-width: 700px) {
    body.orthoplan-fullscreen .op-frontend:not(.op-shell) { padding: 0 14px 48px; }
    body.orthoplan-fullscreen .op-frontend:not(.op-shell) .op-topbar { margin: 0 -14px var(--op-sp-2); padding-left: 14px; padding-right: 14px; }
}

/* ---- Safety fallbacks so controls stay visible even if a var fails ---- */
.op-btn { background: var(--op-surface, #fff); color: var(--op-text, #0e1c24); border-color: var(--op-border-strong, #c8d2d9); }
.op-btn-primary { background: var(--op-primary, #0e7c86); color: #fff !important; border-color: var(--op-primary, #0e7c86); }
.op-btn-ghost  { background: transparent; color: var(--op-text, #0e1c24); }
.op-btn-success { background: var(--op-success, #0f9d6b); color: #fff !important; border-color: var(--op-success, #0f9d6b); }
.op-btn-danger  { background: var(--op-surface, #fff); color: var(--op-danger, #d64545); border-color: var(--op-danger, #d64545); }
.op-modal-content { background: var(--op-surface, #fff); color: var(--op-text, #0e1c24); }
.op-help-fab { background: var(--op-primary, #0e7c86); color: #fff; }


/* ============================================================
   v1.8.2 — Beat theme button rules, real process-flow stepper
   ============================================================ */

/* ---- Buttons: force plugin styling over aggressive theme rules ---- */
.op-btn { background: var(--op-surface,#fff) !important; color: var(--op-text,#0e1c24) !important; border: 1px solid var(--op-border-strong,#c8d2d9) !important; }
.op-btn:hover { background: var(--op-bg-alt,#eaeff2) !important; color: var(--op-text,#0e1c24) !important; }
.op-btn-primary { background: var(--op-primary,#0e7c86) !important; color: #fff !important; border-color: var(--op-primary,#0e7c86) !important; }
.op-btn-primary:hover { background: var(--op-primary-dark,#0a5f68) !important; border-color: var(--op-primary-dark,#0a5f68) !important; color:#fff !important; }
.op-btn-success { background: var(--op-success,#0f9d6b) !important; color:#fff !important; border-color: var(--op-success,#0f9d6b) !important; }
.op-btn-success:hover { background:#0b7e55 !important; color:#fff !important; }
.op-btn-danger { background: var(--op-surface,#fff) !important; color: var(--op-danger,#d64545) !important; border-color: var(--op-danger,#d64545) !important; }
.op-btn-danger:hover { background: var(--op-danger,#d64545) !important; color:#fff !important; }
.op-btn-ghost { background: transparent !important; color: var(--op-text,#0e1c24) !important; border-color: transparent !important; }
.op-btn-ghost:hover { background: var(--op-bg-alt,#eaeff2) !important; color: var(--op-primary-dark,#0a5f68) !important; }
.op-help-fab { background: var(--op-primary,#0e7c86) !important; color:#fff !important; border: none !important; }
.op-bell-btn { background: transparent !important; border: none !important; color: inherit !important; font-size: 20px; cursor: pointer; }
.op-link-btn { background: none !important; border: none !important; color: var(--op-primary,#0e7c86) !important; }
.op-modal-close { background: var(--op-bg-alt,#eaeff2) !important; border: none !important; color: var(--op-text-muted,#51626c) !important; }
/* inputs/selects shouldn't inherit the theme's button border colour either */
.op-frontend input, .op-frontend select, .op-frontend textarea { border-color: var(--op-border-strong); }

/* ---- Process-flow stepper (markup uses .op-tl-*) ---- */
.op-timeline-card { padding: var(--op-sp-6) var(--op-sp-6) var(--op-sp-5); }
.op-timeline {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-top: var(--op-sp-5); gap: 4px; position: relative;
}
.op-tl-step {
    flex: 1 1 0; min-width: 0; text-align: center; position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
/* connector line between dots */
.op-tl-step::before {
    content: ''; position: absolute; top: 9px; height: 3px;
    background: var(--op-border); z-index: 0;
    inset-inline-start: -50%; width: 100%;
}
.op-tl-step:first-child::before { display: none; }
.op-tl-dot {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--op-surface); border: 3px solid var(--op-border);
    position: relative; z-index: 1; transition: all var(--op-transition);
}
.op-tl-label { font-size: 11.5px; line-height: 1.3; color: var(--op-text-soft); font-weight: 600; }
/* done state */
.op-tl-step.op-tl-done .op-tl-dot { background: var(--op-primary); border-color: var(--op-primary); }
.op-tl-step.op-tl-done .op-tl-dot::after {
    content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 11px; font-weight: 800;
}
.op-tl-step.op-tl-done::before { background: var(--op-primary); }
.op-tl-step.op-tl-done .op-tl-label { color: var(--op-primary); }
/* current (last done) gets a ring */
.op-tl-step.op-tl-done:last-of-type .op-tl-dot,
.op-tl-step.op-tl-current .op-tl-dot { box-shadow: 0 0 0 4px var(--op-primary-light); }

@media (max-width: 760px) {
    .op-timeline { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
    .op-tl-step { min-width: 84px; flex: 0 0 84px; }
}

/* Brand logo image in topbars */
.op-topbar-logo-img { height: 32px; width: auto; max-width: 160px; object-fit: contain; display: block; }
.op-brand-mark .op-topbar-logo-img { height: 28px; }

/* ---- Help modal hardening (always renders over theme) ---- */
.op-modal:not([hidden]) { display: flex !important; }
.op-modal[hidden] { display: none !important; }
.op-modal-content { background: var(--op-surface,#fff) !important; color: var(--op-text,#0e1c24) !important; }
.op-tour-step { color: var(--op-text,#0e1c24); }
.op-tour-step p { color: var(--op-text-muted,#51626c); }
/* Inline "how it works" helper button */
.op-help-inline {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 14px; border-radius: var(--op-radius-pill);
    background: var(--op-primary-light) !important; color: var(--op-primary-dark) !important;
    border: 1px solid transparent !important; cursor: pointer;
    font-weight: 700; font-size: 13px; font-family: var(--op-font-body);
}
.op-help-inline:hover { background: #d2ebec !important; }
.op-help-banner {
    display: flex; align-items: center; justify-content: space-between; gap: var(--op-sp-4);
    background: var(--op-primary-light); border: 1px solid #bfe3e5;
    border-radius: var(--op-radius-md); padding: var(--op-sp-4) var(--op-sp-5);
    margin-bottom: var(--op-sp-5); flex-wrap: wrap;
}
.op-help-banner .op-help-banner-txt { font-size: 13.5px; color: var(--op-primary-dark); }
.op-field-hint { display: block; font-size: 12px; color: var(--op-text-soft); margin-top: 4px; font-weight: 400; }


/* ============================================================
   v1.8.3 — Doctor case cards, photo uploader, tour polish
   ============================================================ */

/* ---- Doctor case list cards ---- */
.op-case-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--op-sp-4);
    margin-top: var(--op-sp-2);
}
.op-case-card {
    display: block; text-decoration: none !important;
    background: var(--op-surface);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-lg);
    padding: var(--op-sp-5);
    box-shadow: var(--op-shadow-sm);
    transition: transform var(--op-transition), box-shadow var(--op-transition), border-color var(--op-transition);
}
.op-case-card:hover { transform: translateY(-2px); box-shadow: var(--op-shadow-md); border-color: var(--op-border-strong); text-decoration: none !important; }
.op-case-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--op-sp-2); margin-bottom: var(--op-sp-3); }
.op-case-code { font-family: var(--op-font-mono); font-size: 12.5px; color: var(--op-text-soft); letter-spacing: .01em; }
.op-case-name { font-family: var(--op-font-display); font-size: 16px; font-weight: 700; color: var(--op-text); margin: 0 0 6px; }
.op-case-meta { font-size: 12.5px; color: var(--op-text-muted); margin-bottom: var(--op-sp-3); }
.op-case-card .op-progress { margin-top: var(--op-sp-2); }

/* ---- Photo / X-ray uploader (clickable + drag-drop) ---- */
.op-photo-slot { display: flex; flex-direction: column; gap: var(--op-sp-2); }
.op-photo-upload {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    border: 1.5px dashed var(--op-border-strong);
    border-radius: var(--op-radius-md);
    padding: var(--op-sp-4); min-height: 64px;
    background: var(--op-bg);
    color: var(--op-text-muted);
    cursor: pointer; text-align: center;
    transition: all var(--op-transition);
}
.op-photo-upload:hover, .op-photo-upload.is-dragover { border-color: var(--op-primary); background: var(--op-primary-light); color: var(--op-primary-dark); }
.op-photo-upload-cta { font-size: 13px; font-weight: 700; }
.op-photo-upload-hint { font-size: 11px; color: var(--op-text-soft); }
.op-photo-thumb { position: relative; border-radius: var(--op-radius); overflow: hidden; border: 1px solid var(--op-border); }
.op-photo-thumb img { width: 100%; height: 120px; object-fit: cover; display: block; }
.op-photo-thumb .op-file-icon { display: flex; align-items: center; gap: 6px; padding: 14px; font-size: 12px; word-break: break-all; }
.op-delete-att {
    position: absolute; top: 6px; inset-inline-end: 6px;
    width: 26px; height: 26px; border-radius: 50%;
    background: rgba(14,28,36,.6) !important; color: #fff !important; border: none !important;
    cursor: pointer; font-size: 16px; line-height: 1;
}
.op-delete-att:hover { background: var(--op-danger) !important; }
.op-photo-empty { font-size: 12px; color: var(--op-text-soft); padding: 10px 0; }

/* ---- Tour modal polish ---- */
.op-modal-tour .op-tour-icon {
    width: 64px; height: 64px; margin: 0 auto var(--op-sp-3);
    display: flex; align-items: center; justify-content: center;
    background: var(--op-primary-light); border-radius: 50%; font-size: 30px;
}

/* ---- Share-with-clinic choice & state ---- */
.op-share-choice { display: flex; flex-direction: column; gap: var(--op-sp-3); margin: var(--op-sp-5) 0; }
.op-share-choice-title { font-weight: 700; font-size: 14px; margin: 0 0 2px; }
.op-share-opt {
    display: flex; gap: var(--op-sp-3); align-items: flex-start;
    border: 1.5px solid var(--op-border); border-radius: var(--op-radius-md);
    padding: var(--op-sp-4); cursor: pointer; transition: all var(--op-transition);
}
.op-share-opt:hover { border-color: var(--op-border-strong); }
.op-share-opt input { margin-top: 3px; accent-color: var(--op-primary); }
.op-share-opt:has(input:checked) { border-color: var(--op-primary); background: var(--op-primary-light); }
.op-share-opt-body { display: flex; flex-direction: column; gap: 3px; }
.op-share-opt-body strong { font-size: 14px; }
.op-share-opt-body .op-muted { font-size: 12.5px; }
.op-share-state { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.op-pill-private { background: var(--op-bg-alt); color: var(--op-text-muted); }
