/* Shared operational components. Home keeps its launcher layout; operational
   views and portals use the same tokens, typography and interaction rules. */
/* Dashboard: neutral surfaces and a consistent, readable hierarchy. */
.ds-dashboard{font-family:var(--ws-font);font-size:16px;line-height:1.5}
.ds-dashboard .metric-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:20px;margin-bottom:24px}
.ds-dashboard :is(.metric,.panel,.owner-action-queue,.loss-panel){background:#fff!important;border:1px solid #e2e8f0!important;border-radius:12px!important;box-shadow:none!important;min-width:0}
.ds-dashboard .metric{padding:20px!important}
.ds-dashboard .metric::after,.ds-dashboard .owner-action-queue::before{display:none!important}
.ds-dashboard .metric-top{font-size:14px;font-weight:500;color:#475569;gap:12px}
.ds-dashboard .metric-icon{background:#eef2ff;color:#4338ca;border-radius:8px}
.ds-dashboard .metric>b{display:block;font-size:28px!important;font-weight:600!important;line-height:1.25;margin-block:16px 10px;font-variant-numeric:tabular-nums;overflow-wrap:anywhere;color:#0f172a}
.ds-dashboard .metric>b.warning{color:#b45309}
.ds-dashboard .metric>b.negative{color:#dc2626}
.ds-dashboard .metric>b.positive{color:#15803d}
.ds-dashboard :is(.metric small,.panel small){font-size:13px!important;line-height:1.5!important;font-weight:400;color:#475569}
.ds-dashboard .panel-grid{gap:24px;margin-block:24px}
.ds-dashboard .panel-head{padding:20px!important;gap:16px;border-bottom:1px solid #e2e8f0;background:#fff;align-items:flex-start;flex-wrap:wrap}
.ds-dashboard :is(.panel-head h2,.owner-action-queue h2,.loss-panel h2){font-size:20px!important;font-weight:600!important;line-height:1.3!important;margin:0 0 8px}
.ds-dashboard .panel-body{padding:20px!important}
.ds-dashboard .panel .link-btn{font-size:14px!important;font-weight:500!important;color:#4338ca;min-height:44px}
.ds-dashboard .row-icon{background:#eef2ff;color:#4338ca}
.ds-dashboard .progress{background:#e2e8f0}
.ds-dashboard .progress i{background:#4f46e5}
.ds-dashboard .progress i.warn{background:#b45309}
.ds-dashboard .stock-line>b{font-size:14px;font-weight:600;flex-shrink:0;white-space:nowrap;font-variant-numeric:tabular-nums}
.ds-dashboard :is(.record-row,.stock-row){padding-block:14px;gap:14px;border-color:#e2e8f0}
.ds-dashboard :is(.record-row b,.stock-line,.finance-summary){font-size:16px;font-weight:500;line-height:1.5}
.ds-dashboard .finance-summary b{font-size:20px;font-weight:600;font-variant-numeric:tabular-nums;color:#0f172a}
.ds-dashboard .record-row>div{min-width:0;overflow-wrap:anywhere}
.ds-dashboard .owner-action-queue{padding:0!important;margin-block:24px}
.ds-dashboard .owner-action-queue-head{background:#fff;padding:20px;gap:20px;border-color:#e2e8f0;grid-template-columns:minmax(0,1fr)}
:is(.ds-dashboard,#modal-root.ds-dashboard) .management-kicker{font-size:14px!important;font-weight:500!important;text-transform:none;line-height:1.5!important;color:#475569;margin-bottom:8px}
.ds-dashboard .owner-action-queue-head p{font-size:14px;line-height:1.5;color:#475569}
.ds-dashboard .owner-action-summary{justify-content:flex-start;gap:8px}
.ds-dashboard .owner-action-summary>*{font-size:13px;font-weight:500;line-height:1.5;background:#f8fafc;border-color:#e2e8f0;color:#475569;padding:6px 10px}
.ds-dashboard .owner-action-summary :is(b,strong){font-size:14px;font-weight:600;color:#0f172a;line-height:1.5}
.ds-dashboard .finance-action-list{padding:20px!important;gap:12px}
.ds-dashboard .finance-action-row{padding:16px;gap:12px 16px;box-shadow:none}
.ds-dashboard .finance-action-row h3{font-size:16px!important;font-weight:600!important;line-height:1.3}
.ds-dashboard .finance-action-row :is(small,p,span){font-size:13px;line-height:1.5;font-weight:400}
.ds-dashboard .finance-action-row :is(b,strong){font-weight:600}
.ds-dashboard .finance-action-row button{font-family:var(--ws-font);font-size:14px;font-weight:500;min-height:44px;padding:10px 12px;background:#fff;border:1px solid #cbd5e1;border-radius:8px;color:#4338ca}
.ds-dashboard .loss-panel{padding:20px;margin-block:24px}
.ds-dashboard .loss-panel p{font-size:14px;line-height:1.5;color:#475569}
.ds-dashboard .loss-note{font-size:13px!important;background:#f8fafc;padding:12px 16px}
.ds-dashboard :is(button,summary):focus-visible{outline:2px solid #4f46e5;outline-offset:3px}
@media(max-width:1000px){.ds-dashboard .metric-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.ds-dashboard .finance-action-row{grid-template-columns:auto minmax(0,1fr)}.ds-dashboard .panel-grid{grid-template-columns:minmax(0,1fr)}.ds-dashboard .panel-grid>.panel{grid-area:auto!important}}
@media(max-width:600px){.ds-dashboard .metric-grid{grid-template-columns:minmax(0,1fr)}.ds-dashboard .finance-action-row{grid-template-columns:minmax(0,1fr)}.ds-dashboard .owner-action-summary>*{white-space:normal}.ds-dashboard .panel-head{flex-direction:column}}
.ds-workspace .animal-operations-heading{align-items:flex-start;gap:24px;margin-block:0 24px;text-align:start;font-family:var(--ws-font)}
.ds-workspace .animal-operations-heading>div:first-child{min-width:0}
:is(.ds-workspace,#modal-root) .animal-operations-heading .eyebrow{font-family:var(--ws-font);font-size:14px!important;font-weight:500!important;line-height:1.5!important;text-transform:none!important;letter-spacing:normal!important;color:#475569;margin:0 0 8px;padding:0}
.ds-workspace .animal-operations-heading h1{font-size:32px!important;font-weight:600!important;line-height:1.25!important;margin:0 0 8px!important}
.ds-workspace .animal-operations-heading p{font-size:16px!important;font-weight:400;line-height:1.5!important;color:#475569;margin:0;max-width:70ch}
@media(max-width:700px){.ds-workspace .animal-operations-heading{flex-wrap:wrap;gap:16px}.ds-workspace .animal-operations-heading h1{font-size:28px!important}.ds-workspace .animal-operations-heading .page-actions{flex-wrap:wrap}}
.ds-workspace .ms-saved{background:#fff;border:1px solid #e2e8f0;border-radius:12px}
#modal-root .product-category-choice.selected{border-color:#a5b4fc!important;background:#eef2ff!important;box-shadow:none!important}
#modal-root .product-category-choice.selected .product-category-choice-check{background:#4f46e5!important;border-color:#4f46e5!important}
:root{--ds-ink:#0f172a;--ds-muted:#475569;--ds-border:#e2e8f0;--ds-surface:#fff;--ds-canvas:#f8fafc;--ds-primary:#4f46e5;--ds-selected:#eef2ff;--ds-radius:12px;--ds-space:20px;--ds-control:44px;--ds-success:#15803d;--ds-warning:#b45309;--ds-danger:#b91c1c;--ds-modal-layer:1000}
:is(.ds-workspace,#modal-root){color:var(--ds-ink);font-family:var(--ws-font);font-size:15px;line-height:1.55;--aw-green:var(--ds-primary);--aw-ink:var(--ds-ink);--aw-muted:var(--ds-muted);--vw-green:var(--ds-primary);--vw-line:var(--ds-border);--am-border:var(--ds-border);--am-ink:var(--ds-ink);--purchase-accent:var(--ds-primary);--purchase-accent-ink:var(--ds-ink);--purchase-accent-wash:var(--ds-selected);--clinical-accent:var(--ds-primary);--clinical-accent-deep:#4338ca;--medicine-picker-accent:var(--ds-primary);--medicine-picker-ink:var(--ds-ink)}
:is(.ds-workspace,#modal-root) :is(h1,h2,h3,h4){color:var(--ds-ink)!important;font-family:var(--ws-font)!important;font-weight:600!important;letter-spacing:normal;line-height:1.35}
.ds-workspace h1{font-size:28px!important;margin-block:0 10px!important}.ds-workspace h2,#modal-root h2{font-size:20px!important}.ds-workspace h3,#modal-root h3{font-size:17px!important}.ds-workspace h4,#modal-root h4{font-size:15px!important}
:is(.ds-workspace,#modal-root) :is(p,dt,dd){font-size:14px;line-height:1.6}
:is(.ds-workspace,#modal-root) :is(small,label,.field>span,[class*="-caption"],[class*="-kicker"],[class*="-hint"],[class*="-eyebrow"]){font-size:13px!important;line-height:1.5!important;letter-spacing:normal!important}
:is(.ds-workspace,#modal-root) .ds-readable{font-size:13px!important;line-height:1.5!important}
:is(.ds-workspace,#modal-root) :is(b,strong){font-weight:600}
:is(.ds-workspace,#modal-root) :is(.subtle,.aw-muted,[class*="-caption"],[class*="-kicker"],[class*="-hint"]){color:var(--ds-muted)!important}
/* Page title, toolbar and tab components. */
.ds-workspace :is(.page-head,.aw-heading,.vw-heading,.bw-heading){margin-block:0 20px!important;gap:16px;align-items:center}
.ds-workspace :is(.page-head,.aw-heading,.vw-heading,.bw-heading) p{color:var(--ds-muted);font-size:15px!important;margin-block:0!important}
.ds-workspace :is(.aw,.vw,.bw,.am){color:var(--ds-ink)}
.ds-workspace :is(.aw-tabs,.vw-tabs,.am-tabs,.bw-tabs,.profile-tabs,.tabs){margin-block:16px 20px;border-color:var(--ds-border);gap:4px}
.ds-workspace :is(.aw-tabs,.vw-tabs,.am-tabs,.bw-tabs,.profile-tabs,.tabs) button{font-size:14px!important;font-weight:500!important;min-height:44px;padding:10px 16px;color:var(--ds-muted);white-space:nowrap}
.ds-workspace :is(.aw-tabs,.vw-tabs,.am-tabs,.bw-tabs,.profile-tabs,.tabs) :is(.active,[aria-selected=true],[aria-current=page]){background:var(--ds-selected)!important;color:var(--ds-primary)!important;border-color:var(--ds-primary)!important;box-shadow:none}
.ds-workspace :is(.aw-toolbar,.vw-toolbar,.bw-toolbar,.catalogue-toolbar,.production-toolbar,.clinical-toolbar,.treatment-register-toolbar,.treatment-toolbar,.inventory-toolbar){padding:16px;background:var(--ds-surface);border:1px solid var(--ds-border);border-radius:var(--ds-radius);gap:12px;align-items:end;flex-wrap:wrap}
.ds-workspace :is(.aw-toolbar,.vw-toolbar,.bw-toolbar,.catalogue-toolbar) label{min-width:0}
/* Neutral summary tiles; badges continue to communicate clinical/stock states. */
.ds-workspace :is(.aw-metric,.vw-metrics>button,.bw-metrics>button,.bw-metrics>article,.management-stat,.inventory-stat,.metric-card,.metric,.clinical-kpi,.treatment-kpi,.animal-purchase-kpi,.purchase-kpi){background:var(--ds-surface)!important;border:1px solid var(--ds-border)!important;border-radius:var(--ds-radius)!important;box-shadow:none!important;color:var(--ds-ink)!important;padding:16px 18px!important;min-height:110px}
.ds-workspace :is(.management-stat,.inventory-stat,.clinical-kpi,.treatment-kpi,.animal-purchase-kpi,.purchase-kpi)::after{display:none!important}
.ds-workspace :is(.aw-metric strong,.vw-metrics b,.bw-metrics b,.metric-value,.management-stat-value,.inventory-stat-value){font-size:28px!important;line-height:1.25!important;font-weight:600!important;color:var(--ds-ink)!important;margin-block:6px!important;font-variant-numeric:tabular-nums}
.ds-workspace :is(.vw-metrics,.aw-metrics,.bw-metrics){gap:14px;margin-block:16px 24px!important}
/* Reusable surface component adapters for existing record views. */
:is(.ds-workspace,#modal-root) :is(.form-card,.panel,.aw-card,.vw-case-card,.bw-card,.management-card,.inventory-card,.report-card,.product-builder-section,.product-section,.purchase-receipt-lines-panel,.animal-purchase-header-card,.animal-purchase-line,.treatment-guided-step-panel,.treatment-issue-medicine-card,.product-details-section){background:var(--ds-surface)!important;border-color:var(--ds-border)!important;border-radius:var(--ds-radius)!important;box-shadow:none!important}
:is(.ds-workspace,#modal-root) :is(.management-directory-head,.inventory-directory-head,.product-section-head,.product-builder-head,.animal-purchase-section-head,.animal-purchase-line-head,.purchase-receipt-lines-head,.treatment-issue-section-head,.product-details-section-head){background:var(--ds-surface)!important;border-color:var(--ds-border)!important;color:var(--ds-ink)!important}
.ds-workspace :is(.am-intro,.ap-hero,.management-hero,.bw-hero,.profile-hero,.aw-hero){background:var(--ds-surface)!important;border:1px solid var(--ds-border)!important;color:var(--ds-ink)!important;padding:20px!important;border-radius:var(--ds-radius)!important;box-shadow:none!important}
.ds-workspace :is(.am-intro,.ap-hero,.management-hero,.bw-hero,.profile-hero,.aw-hero) p{color:var(--ds-muted)!important}
.ds-workspace :is(.aw-table,.table){font-size:14px!important;font-variant-numeric:tabular-nums}
.ds-workspace :is(.aw-table,.table) th{font-size:13px!important;font-weight:600!important;letter-spacing:normal!important;text-transform:none!important;background:#f8fafc!important;color:var(--ds-muted)!important;padding:13px 16px}
.ds-workspace :is(.aw-table,.table) td{font-size:14px!important;line-height:1.5;padding:14px 16px;border-color:var(--ds-border)}
.ds-workspace :is(.aw-table,.table) tr:hover{background:#f8faff}
.ds-workspace :is(.table-card,.aw-table-wrap){border:1px solid var(--ds-border);border-radius:var(--ds-radius);box-shadow:none;overflow-x:auto}
/* Form controls and actions are shared by page forms and modal portals. */
:is(.ds-workspace,#modal-root) :is(input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=color]):not([type=range]),select,textarea){font-family:var(--ws-font)!important;font-size:16px!important;line-height:1.4!important;min-height:var(--ds-control);border:1px solid #cbd5e1;border-radius:8px;background:#fff;color:var(--ds-ink);padding:10px 12px;max-width:100%;box-sizing:border-box}
:is(.ds-workspace,#modal-root) textarea{min-height:96px;resize:vertical}
:is(.ds-workspace,#modal-root) :is(input,select,textarea):disabled{background:#f1f5f9;color:#64748b;cursor:not-allowed}
:is(.ds-workspace,#modal-root) :is(input[type=checkbox],input[type=radio]){accent-color:var(--ds-primary);min-width:18px;min-height:18px}
:is(.ds-workspace,#modal-root) .field{gap:7px;color:var(--ds-muted);min-width:0}
:is(.ds-workspace,#modal-root) .form-grid{gap:18px 20px}
:is(.ds-workspace,#modal-root) .btn{font-family:var(--ws-font)!important;font-size:14px!important;font-weight:600!important;line-height:1.4!important;min-height:42px;padding:10px 16px;border-radius:8px!important;box-shadow:none!important}
:is(.ds-workspace,#modal-root) .btn-primary{background:var(--ds-primary)!important;border:1px solid var(--ds-primary)!important;color:#fff!important}
:is(.ds-workspace,#modal-root) .btn-primary:hover{background:#4338ca!important}
:is(.ds-workspace,#modal-root) .btn-secondary{background:#fff!important;border:1px solid #cbd5e1!important;color:#334155!important}
:is(.ds-workspace,#modal-root) :is(.link-btn,.am-link,.aw-animal){font-size:14px!important;color:var(--ds-primary)}
:is(.ds-workspace,#modal-root) :is(.danger-link,.btn-danger){color:var(--ds-danger)!important}
:is(.ds-workspace,#modal-root) button:disabled{opacity:.55;cursor:not-allowed}
:is(.ds-workspace,#modal-root) :is(.status,.aw-badge,.vw-pill){font-size:13px!important;line-height:1.4;font-weight:500}
/* Portal: one scrolling body, persistent title/actions, above all application chrome. */
#modal-root{position:relative;z-index:var(--ds-modal-layer)}
#modal-root .modal-backdrop{z-index:var(--ds-modal-layer)!important;background:rgb(15 23 42 / 48%)!important;backdrop-filter:blur(3px);padding:24px!important;overflow:hidden;align-items:center;isolation:isolate}
#modal-root .modal{display:flex!important;flex-direction:column!important;width:min(720px,100%)!important;max-width:100%!important;inline-size:min(720px,100%)!important;max-inline-size:100%!important;min-height:0!important;max-height:calc(100dvh - 48px)!important;max-block-size:calc(100dvh - 48px)!important;overflow:hidden!important;border:1px solid var(--ds-border)!important;border-radius:16px!important;background:#fff!important;color:var(--ds-ink)!important;box-shadow:0 24px 80px #0f172a40!important;margin:0!important}
#modal-root .modal.ds-dialog-wide{width:min(1120px,100%)!important;inline-size:min(1120px,100%)!important}
#modal-root .modal.ds-dialog-xl{width:min(1360px,100%)!important;inline-size:min(1360px,100%)!important}
#modal-root .modal>.modal-head{flex:0 0 auto!important;position:relative!important;inset:auto!important;padding:20px 24px!important;background:#fff!important;border-bottom:1px solid var(--ds-border)!important;color:var(--ds-ink);gap:20px}
#modal-root .modal-head h2{font-size:22px!important;margin:0!important;line-height:1.35!important}
#modal-root .modal-head p{font-size:14px!important;line-height:1.5!important;color:var(--ds-muted)!important;margin:6px 0 0!important;max-width:80ch}
#modal-root .modal-head .close{display:grid;place-items:center;flex:0 0 40px;min-width:40px;min-height:40px;border:1px solid var(--ds-border);border-radius:9px;background:#fff;color:#334155;font-size:22px!important}
#modal-root .modal>.modal-body{flex:1 1 auto!important;min-height:0!important;min-block-size:0!important;max-height:none!important;max-block-size:none!important;overflow:auto!important;overscroll-behavior:contain;scrollbar-gutter:stable;padding:24px!important;background:var(--ds-canvas)!important;scroll-padding-block:20px}
#modal-root .modal>.modal-footer{flex:0 0 auto!important;position:relative!important;inset:auto!important;display:flex!important;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:12px!important;margin:0!important;padding:16px 24px!important;border-top:1px solid var(--ds-border)!important;background:#fff!important;color:var(--ds-muted)!important;max-height:35dvh;overflow:auto}
#modal-root .modal-footer :is(small,p,[class*="note"],.animal-purchase-footer-note){font-size:13px!important;line-height:1.5!important;color:var(--ds-muted)!important}
#modal-root .modal-footer>div{min-width:0;flex-wrap:wrap}
#modal-root .modal-footer>.ap-draft-save{flex:1 0 100%;width:100%;justify-content:space-between}
#modal-root .modal-footer .animal-purchase-footer-note{flex:1 1 360px;min-width:0}
#modal-root :is(.product-builder-section,.animal-purchase-header-card,.animal-purchase-line,.treatment-guided-step-panel){padding:20px!important}
#modal-root :is(.seller-picker,.vw-info,.treatment-guided-recording-note,.product-context,.product-builder-review,.animal-purchase-review,.purchase-receipt-summary){background:#f1f5f9!important;border-color:var(--ds-border)!important;color:var(--ds-ink)!important;box-shadow:none!important}
#modal-root :is(.treatment-guided-progress,.treatment-guided-stage-nav){background:#fff!important;border-color:var(--ds-border)!important;gap:10px}
#modal-root .treatment-guided-progress{position:static!important;margin-bottom:20px;padding:0!important}
#modal-root :is(.treatment-guided-progress,.product-category-choices) :is(.active,.is-active,[aria-current=step],[aria-selected=true]){background:var(--ds-selected)!important;border-color:#a5b4fc!important;color:#4338ca!important}
#modal-root .treatment-guided-stage-nav{flex:1 1 auto;flex-wrap:wrap}
#modal-root .treatment-guided-stage-nav>div{flex-wrap:wrap}
#modal-root .seller-results{max-height:220px;overflow:auto}
#modal-root .treatment-medicine-picker-option:is(.selected,.is-selected,[aria-selected=true]){background:var(--ds-selected)!important;border-color:#a5b4fc!important}
#modal-root :is(.animal-purchase-summary-head,.purchase-receipt-total-card){background:var(--ds-selected)!important;color:var(--ds-ink)!important}
body.ds-modal-open{overflow:hidden!important}
:is(.ds-workspace,#modal-root) [hidden]{display:none!important}
:is(.ds-workspace,#modal-root) :focus-visible{outline:3px solid #818cf8!important;outline-offset:3px}
#toast{z-index:1100!important}
@media(max-width:800px){.ds-workspace h1{font-size:25px!important}.ds-workspace :is(.page-head,.aw-heading,.vw-heading){align-items:flex-start}.ds-workspace :is(.vw-metrics,.aw-metrics,.bw-metrics){grid-template-columns:repeat(2,minmax(0,1fr))}.ds-workspace :is(.vw-toolbar,.aw-toolbar,.bw-toolbar){gap:12px}.ds-workspace :is(.vw-toolbar,.aw-toolbar,.bw-toolbar)>*{min-width:0;max-width:100%}#modal-root .modal-backdrop{padding:10px!important}#modal-root .modal{max-height:calc(100dvh - 20px)!important;max-block-size:calc(100dvh - 20px)!important}#modal-root .modal>.modal-head,#modal-root .modal>.modal-body{padding:18px!important}#modal-root .modal>.modal-footer{padding:12px 18px!important}#modal-root .modal-head h2{font-size:20px!important}#modal-root .form-grid{grid-template-columns:1fr!important}#modal-root .modal-footer .animal-purchase-footer-note{display:none}#modal-root .modal-footer>.ap-draft-save{align-items:center}#modal-root .treatment-guided-progress{grid-template-columns:repeat(2,minmax(0,1fr))!important}}
@media(prefers-reduced-motion:reduce){:is(.ds-workspace,#modal-root) *{scroll-behavior:auto!important;transition:none!important}}
