/* HIMS Next shared UI styles. Design tokens are plan section 10.6; the MudBlazor palette (Theme/HimsTheme.cs)
   carries the same values. Custom components use these variables, never raw colours. */

:root {
    --hm-primary: #0E6E63;
    --hm-primary-strong: #0A4F47;
    --hm-primary-soft: #E3F0EE;
    --hm-secondary: #01485B;
    --hm-secondary-2: #006A72;
    --hm-accent: #008F78;
    --hm-bg: #EEF3F1;
    --hm-surface: #FFFFFF;
    --hm-surface-2: #F6F9F8;
    --hm-text: #172029;
    --hm-text-2: #5B6B77;
    --hm-text-3: #5B6670;
    /* Phase 9: was #8A96A0 (3.0:1); now 5.0:1 or better on every light background */
    --hm-border: #DDE3E6;
    --hm-border-strong: #C3CCD1;
    --hm-success: #1F6B3D;
    /* Phase 9: was #2E7D4F (4.0:1 on soft green chips) */
    --hm-warning: #8A5B14;
    /* Phase 9: was #B8863B (3.0:1) */
    --hm-danger: #B23B3B;
    --hm-info: #245B96;
    /* Phase 9: was #2B6CB0 (4.45:1 on tinted pills) */

    --hm-radius-sm: 6px;
    --hm-radius-card: 12px;
    --hm-radius-dialog: 14px;
    --hm-shadow-1: 0 1px 2px rgba(16, 24, 40, .06);
    --hm-shadow-2: 0 2px 8px rgba(16, 24, 40, .08);
    --hm-shadow-3: 0 12px 32px rgba(16, 24, 40, .18);

    --hm-space-1: 4px;
    --hm-space-2: 8px;
    --hm-space-3: 12px;
    --hm-space-4: 16px;
    --hm-space-5: 20px;
    --hm-space-6: 24px;

    --hm-tabstrip-height: 38px;
    --hm-statusbar-height: 26px;
}

/* MudBlazor marks dark mode on the provider; mirror it for custom components. */
.mud-theme-dark,
body:has(.mud-theme-dark) {
    --hm-primary: #3FB8A8;
    --hm-primary-strong: #2E9A8C;
    --hm-primary-soft: #1C3A36;
    --hm-secondary: #0B2F38;
    --hm-secondary-2: #0E4550;
    --hm-accent: #4CC3AE;
    --hm-bg: #0F1418;
    --hm-surface: #161D22;
    --hm-surface-2: #1C252B;
    --hm-text: #E6EDF1;
    --hm-text-2: #A9B6BF;
    --hm-text-3: #94A2AC;
    /* Phase 9: was #6B7A85 (3.9:1 on dark surfaces) */
    --hm-border: #2A353D;
    --hm-border-strong: #3A4750;
    --hm-success: #5FB384;
    --hm-warning: #D9AE6A;
    --hm-danger: #E07A7A;
    --hm-info: #6FA3DA;
}

html,
body {
    margin: 0;
    height: 100%;
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
}

/* ---- boot / empty layouts ------------------------------------------------------------------- */

.hims-boot {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--hm-space-3);
}

.hims-empty {
    min-height: 100vh;
    background: var(--mud-palette-background);
}

.hims-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--hm-space-4);
    background: linear-gradient(135deg, var(--hm-secondary) 0%, var(--hm-secondary-2) 100%);
}

.hims-login-card {
    width: 100%;
    max-width: 400px;
    padding: 32px 28px 28px;
    border-radius: var(--hm-radius-card) !important;
}

.hims-login-brand {
    display: flex;
    align-items: center;
    gap: var(--hm-space-3);
    margin-bottom: var(--hm-space-5);
}

.hims-caps {
    display: flex;
    align-items: center;
    gap: var(--hm-space-1);
    color: var(--hm-warning);
    font-size: .8125rem;
}

/* ---- form fields: one size and look everywhere ----------------------------------------------- */
/* Every text box, dropdown, date picker and number box in the application, whether the page asks for the dense or the
   normal margin, is the same size: about 42px tall, 15px text, the same corner radius, and a label that sits in the
   middle of the box until it floats. */

.mud-input-control .mud-input.mud-input-outlined {
    border-radius: 6px;
    font-size: .9375rem;
}

.mud-input-control .mud-input.mud-input-outlined .mud-input-slot.mud-input-root-outlined,
.mud-input-control .mud-input.mud-input-outlined input.mud-input-root-outlined {
    padding: 10px 14px;
    height: 1.4em;
    line-height: 1.4;
}

.mud-input-control .mud-input.mud-input-outlined.mud-input-adorned-end .mud-input-slot {
    padding-right: 0;
}

/* Multi-line boxes keep their own height, but get the same padding and text size. */
.mud-input-control .mud-input.mud-input-outlined .mud-input-slot.mud-input-root-outlined:is(textarea),
.mud-input-control .mud-input.mud-input-outlined textarea.mud-input-slot.mud-input-root-outlined {
    height: auto;
    min-height: 1.4em;
    line-height: 1.4;
    padding: 10px 14px;
}

/* One placeholder look: a quiet grey that is still readable, never clipped. */
.mud-input-control .mud-input-slot::placeholder {
    color: var(--hm-text-3);
    opacity: 1;
    font-size: .9375rem;
}

.mud-input-control .mud-input:not(.mud-shrink):not(:focus-within)~label.mud-input-label.mud-input-label-inputcontrol.mud-input-label-outlined {
    font-size: .9375rem;
    line-height: 1.15rem;
    transform: translate(14px, 11px) scale(1);
}

.mud-input-control>.mud-input-control-input-container>.mud-input-helper-text,
.mud-input-control .mud-input-helper-text {
    font-size: .8125rem;
}

.mud-input-control {
    margin-top: 2px;
}

/* ---- shell ---------------------------------------------------------------------------------- */

.hims-appbar.mud-appbar {
    background: linear-gradient(90deg, var(--hm-secondary) 0%, var(--hm-secondary-2) 100%);
}

.hims-appbar .mud-toolbar {
    gap: var(--hm-space-1);
    padding-left: var(--hm-space-3);
    padding-right: var(--hm-space-2);
}

.hims-brand {
    display: flex;
    align-items: center;
    gap: var(--hm-space-2);
    color: inherit;
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    margin-right: var(--hm-space-3);
    white-space: nowrap;
}

.hims-menus {
    display: flex;
    align-items: center;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    min-width: 0;
}

.hims-menu-button.mud-button-root,
.hims-menu .mud-button-root {
    white-space: nowrap;
    padding: 6px 8px;
    font-size: .8125rem;
    text-transform: none;
    flex-shrink: 0;
}

/* Tighter icon gaps and a smaller drop-down arrow so all ten module menus fit one row without a menu being cut off. */
.hims-menus .mud-button-icon-start {
    margin-right: 4px;
    margin-inline-end: 4px;
}

.hims-menus .mud-button-icon-end {
    margin-left: 0;
    margin-inline-start: 0;
}

.hims-menus .mud-button-icon-end .mud-icon-root {
    font-size: 1.25rem;
}

.hims-menus .mud-button-icon-start .mud-icon-root {
    font-size: 1.15rem;
}

.hims-appbar .mud-spacer {
    min-width: 8px;
}

/* Narrower windows: drop the menu icons first, then the branch name, so the labels stay whole. */
@media (max-width: 1700px) {
    .hims-menus .mud-button-icon-start {
        display: none;
    }
}

@media (max-width: 1400px) {
    .hims-branch {
        display: none;
    }
}

.hims-branch {
    opacity: .85;
    font-size: .8125rem;
    margin-right: var(--hm-space-2);
    white-space: nowrap;
}

.hims-user-button.mud-button-root,
.hims-user-button .mud-button-root {
    white-space: nowrap;
}

.hims-user-card {
    padding: 12px 16px;
    min-width: 220px;
}

/* ---- date / time picker popovers (PT-9) --------------------------------------------------------
   Measured against the running app (DevTools on an open "From" picker), not guessed: MudBlazor writes
   its own inline style on the calendar paper - `max-width: 150px` - taken from the activator field's
   rendered width, not from the calendar's own content. A MudDatePicker with no explicit Style is about
   150px wide (Margin="Dense"), so every calendar in the app was being squeezed into the width of the
   text field that opened it: the month header wrapped onto the weekday row, "November" ran into the
   "10", the next-month arrow pushed off the edge entirely - not hidden, just unreadably overlapping.
   An inline style only beats a stylesheet rule without `!important`, so `!important` here is load-
   bearing, not decoration.

   The popover itself already behaved correctly once freed of that: position is `fixed` (MudBlazor adds
   the `mud-popover-fixed` class), and MudBlazor's own overflow-flip (`mud-popover-overflow-flip-onopen`)
   already keeps the full box inside the viewport, measured in the same session. The max-height / scroll
   pair below is a second, independent safety margin for a very short window, where even a correctly-
   sized calendar could still run past the bottom - never relying on the flip alone. */
.mud-picker-popover-paper,
.mud-picker-calendar-container {
    max-width: 328px !important;
    max-height: calc(100vh - 32px) !important;
    overflow-y: auto !important;
}

/* The drop-down panel: rounded, lifted off the page, a light top edge in the brand colour; columns divided by a hairline;
   each item a roomy row with a soft highlight. */
/* ---- Modern Executive Mega Menu Redesign ----------------------------------------- */
.mud-popover.hims-mega-popover {
    border-radius: 14px !important;
    border: 1px solid var(--hm-border) !important;
    box-shadow: 0 18px 42px -8px rgba(10, 30, 36, 0.18), 0 0 1px 1px rgba(0, 0, 0, 0.04) !important;
    background: var(--hm-surface) !important;
    margin-top: 8px !important;
    max-height: calc(100vh - 68px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: thin !important;
    scrollbar-color: var(--hm-border) transparent !important;
}

.mud-popover.hims-mega-popover::-webkit-scrollbar {
    width: 6px;
}

.mud-popover.hims-mega-popover::-webkit-scrollbar-thumb {
    background-color: var(--hm-border);
    border-radius: 4px;
}

.hims-mega {
    display: flex;
    align-items: flex-start;
    gap: 0;
    padding: 16px 20px;
    max-width: min(96vw, 1150px);
}

.hims-mega-column {
    display: flex;
    flex-direction: column;
    padding: 0 16px;
    box-sizing: border-box;
}

.hims-mega-column:first-child {
    padding-left: 0;
}

.hims-mega-column:last-child {
    padding-right: 0;
}

.hims-mega-column+.hims-mega-column {
    border-left: 1px solid var(--hm-border);
}

/* Section Header */
.hims-mega-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 4px 10px 4px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--hm-border);
}

.hims-mega-heading-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--hm-primary);
}

.hims-mega-heading-pill {
    width: 3.5px;
    height: 13px;
    background: var(--hm-primary);
    border-radius: 2px;
}

.hims-mega-heading-count {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--hm-text-3);
    background: var(--hm-surface-2);
    padding: 2px 7px;
    border-radius: 10px;
    border: 1px solid var(--hm-border);
}

/* Grids */
.hims-grid-1col {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 195px;
}

.hims-grid-2col {
    display: grid;
    grid-template-columns: repeat(2, minmax(185px, 1fr));
    gap: 4px 8px;
    min-width: 380px;
}

.hims-grid-3col {
    display: grid;
    grid-template-columns: repeat(3, minmax(175px, 1fr));
    gap: 4px 8px;
    min-width: 540px;
}

/* Item Card Styling */
.hims-mega-popover .mud-menu-item.hims-mega-item,
.hims-mega-popover .mud-menu-item {
    display: flex !important;
    align-items: center !important;
    padding: 7px 10px !important;
    border-radius: 8px !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    min-height: 38px !important;
    margin: 0 !important;
    cursor: pointer !important;
    transition: all 0.16s ease-in-out !important;
    box-sizing: border-box !important;
}

/* Hover State - Soft Pill Highlight */
.hims-mega-popover .mud-menu-item:hover,
.hims-mega-popover .mud-menu-item:focus-visible {
    background: var(--hm-primary-soft) !important;
    border-color: transparent !important;
    box-shadow: none !important;
    transform: translateX(3px) !important;
}

.mud-theme-dark .hims-mega-popover .mud-menu-item:hover,
.mud-theme-dark .hims-mega-popover .mud-menu-item:focus-visible {
    background: var(--hm-primary-soft) !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

/* Clean Icon without Box Background */
.hims-mega-popover .mud-menu-item .mud-menu-item-icon,
.hims-mega-popover .mud-menu-item .mud-icon-root,
.hims-mega-popover .mud-menu-item-icon,
.hims-mega-popover .mud-menu-item-icon * {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.hims-mega-popover .mud-menu-item .mud-menu-item-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    color: var(--hm-primary) !important;
    margin-right: 10px !important;
    transition: transform 0.15s ease, color 0.15s ease !important;
}

.mud-theme-dark .hims-mega-popover .mud-menu-item .mud-menu-item-icon {
    color: var(--hm-primary) !important;
}

/* Icon Hover */
.hims-mega-popover .mud-menu-item:hover .mud-menu-item-icon {
    color: var(--hm-primary-strong) !important;
    transform: scale(1.12) !important;
}

.mud-theme-dark .hims-mega-popover .mud-menu-item:hover .mud-menu-item-icon {
    color: #4ECDC4 !important;
}

.hims-mega-popover .mud-menu-item .mud-menu-item-icon .mud-icon-root {
    font-size: 1.25rem !important;
    color: inherit !important;
}

/* Title Typography */
.hims-mega-popover .mud-menu-item .mud-menu-item-text,
.hims-mega-title {
    font-size: 0.835rem !important;
    font-weight: 500 !important;
    color: var(--hm-text) !important;
    line-height: 1.3 !important;
    margin: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    transition: color 0.15s ease !important;
}

.hims-mega-popover .mud-menu-item:hover .hims-mega-title,
.hims-mega-popover .mud-menu-item:hover .mud-menu-item-text {
    color: #0E6E63 !important;
    font-weight: 600 !important;
}

.mud-theme-dark .hims-mega-popover .mud-menu-item:hover .hims-mega-title,
.mud-theme-dark .hims-mega-popover .mud-menu-item:hover .mud-menu-item-text {
    color: #3FB8A8 !important;
}

.hims-menu .mud-button-root:hover,
.hims-menu .mud-button-root[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.16) !important;
    border-radius: 8px;
}

/* ---- dialogs (modal boxes) ---------------------------------------------------------------------- */
/* Redesign: a teal title bar in the colours of the application header with white text; a clean white body (the old grey
   body made the fields blend into it) whose fields are white with a visible border; a light footer bar for the buttons. */
.mud-dialog {
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(10, 30, 36, .35);
    overflow: hidden;
    background: var(--hm-surface);
}

.mud-dialog .mud-dialog-title {
    padding: 16px 24px;
    background: linear-gradient(90deg, var(--hm-secondary) 0%, var(--hm-secondary-2) 100%);
    border-bottom: none;
    font-size: 1.125rem;
    font-weight: 600;
    color: #fff;
}

.mud-dialog .mud-dialog-title .mud-typography,
.mud-dialog .mud-dialog-title .mud-icon-button {
    color: #fff;
}

.mud-dialog .mud-dialog-title .mud-typography-h6 {
    font-size: 1.125rem;
    font-weight: 600;
}

.mud-dialog .mud-dialog-content {
    padding: 24px;
    /* a soft teal tint, with the fields kept white so they stand out against it */
    background: color-mix(in srgb, var(--hm-primary-soft) 60%, var(--hm-surface));
}

.mud-dialog .mud-dialog-content .mud-input-control .mud-input.mud-input-outlined {
    background: var(--hm-surface);
}

.mud-dialog .mud-dialog-content .mud-input-control .mud-input-outlined-border {
    border-color: var(--hm-border-strong);
}

.mud-dialog .mud-dialog-actions {
    padding: 14px 24px;
    gap: var(--hm-space-2);
    background: var(--hm-surface);
    border-top: 1px solid var(--hm-border);
}

/* Narrower boxes: the dialog sizes were wider than their forms need (Large 1280px, Medium 960px). The document preview
   dialog keeps the full Large width. */
.mud-dialog.mud-dialog-width-sm {
    max-width: 520px;
}

.mud-dialog.mud-dialog-width-md {
    max-width: 760px;
}

.mud-dialog.mud-dialog-width-lg {
    max-width: 1040px;
}

.mud-dialog.mud-dialog-width-xl {
    max-width: 1280px;
}

.mud-dialog.hims-pdf-dialog.mud-dialog-width-lg {
    max-width: 1280px;
}

.mud-overlay.mud-overlay-dialog .mud-overlay-scrim {
    background: rgba(10, 24, 30, .55);
}

.hims-main.mud-main-content {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: var(--hm-statusbar-height);
    box-sizing: border-box;
}

/* ---- tabs ----------------------------------------------------------------------------------- */

/* Redesign: open pages are rounded "pills" on a quiet bar. The page you are on is a white pill with a brand-colour
   outline and a soft shadow; the others are plain text that fill in on hover; the close button is a round dot. */
.hims-tabstrip {
    display: flex;
    align-items: center;
    gap: var(--hm-space-1);
    height: var(--hm-tabstrip-height);
    padding: 0 var(--hm-space-3);
    background: var(--hm-surface);
    border-bottom: 1px solid var(--hm-border);
    overflow-x: auto;
    scrollbar-width: thin;
    flex-shrink: 0;
}

.hims-tab {
    display: flex;
    align-items: center;
    gap: var(--hm-space-1);
    height: 100%;
    padding: 0 6px 0 12px;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    color: var(--hm-text-2);
    cursor: pointer;
    white-space: nowrap;
    font-size: .875rem;
    user-select: none;
    transition: color .12s, border-color .12s;
}

.hims-tab:hover {
    color: var(--hm-text);
    border-bottom-color: var(--hm-border-strong);
}

/* The current page: a thick teal line under it, nothing else. */
.hims-tab-active,
.hims-tab-active:hover {
    border-bottom-color: var(--hm-primary);
    color: var(--hm-primary-strong);
    font-weight: 600;
}

.hims-tab-close {
    border: none;
    background: transparent;
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
}

.hims-tab-close:hover {
    background: var(--hm-border-strong);
    color: var(--hm-text);
}

.hims-tab-close:focus-visible,
.hims-tab:focus-visible,
.hims-tab-title:focus-visible {
    outline: 2px solid var(--hm-accent);
    outline-offset: 1px;
}

/* The page title in a tab chip is a button that looks like plain text. */
.hims-tab-title {
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    padding: 0;
    cursor: pointer;
    white-space: nowrap;
}

.hims-tabpanels {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.hims-tabpanel[hidden] {
    display: none !important;
}

/* ---- pages ---------------------------------------------------------------------------------- */

.hims-page {
    padding: var(--hm-space-4) var(--hm-space-5) var(--hm-space-6);
}

.hims-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--hm-space-3);
    flex-wrap: wrap;
    margin-bottom: var(--hm-space-2);
}

.hims-page-toolbar {
    display: flex;
    gap: var(--hm-space-2);
    flex-wrap: wrap;
    align-items: center;
}

.hims-busy {
    margin-bottom: var(--hm-space-3);
}

.hims-hidden {
    visibility: hidden;
}

.hims-card {
    padding: var(--hm-space-4);
    border-radius: var(--hm-radius-card) !important;
    height: 100%;
}

/* ---- patient picker ------------------------------------------------------------------------- */

.hims-patient-chip {
    display: flex;
    align-items: center;
    gap: var(--hm-space-3);
    padding: var(--hm-space-2) var(--hm-space-3);
    border-radius: var(--hm-radius-sm) !important;
    background: var(--hm-primary-soft) !important;
}

.hims-picker-results {
    max-height: 280px;
    overflow: auto;
}

/* ---- documents ------------------------------------------------------------------------------ */

.hims-pdf-dialog .mud-dialog-content {
    padding: 0;
}

.hims-pdf-frame {
    display: block;
    width: 100%;
    height: 75vh;
    border: 0;
    background: #525659;
}

.hims-image-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 75vh;
    background: #525659;
    overflow: auto;
}

.hims-image-frame img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ---- status bar ----------------------------------------------------------------------------- */

.hims-statusbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--hm-statusbar-height);
    display: flex;
    align-items: center;
    gap: var(--hm-space-3);
    padding: 0 var(--hm-space-3);
    background: var(--hm-surface-2);
    border-top: 1px solid var(--hm-border);
    color: var(--hm-text-2);
    font-size: .75rem;
    z-index: 1200;
    white-space: nowrap;
    overflow: hidden;
}

.hims-status-sep {
    width: 1px;
    height: 14px;
    background: var(--hm-border);
}

.hims-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hims-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--hm-text-3);
}

.hims-dot-connected {
    background: var(--hm-success);
}

.hims-dot-connecting,
.hims-dot-reconnecting {
    background: var(--hm-warning);
}

.hims-dot-refused {
    background: var(--hm-danger);
}

/* ---- list grids (keyboard-selectable rows) -------------------------------------------------- */

.hims-grid-wrap {
    overflow: auto;
    max-height: calc(100vh - 330px);
    min-height: 160px;
    border: 1px solid var(--hm-border);
    border-radius: 12px;
    background: var(--hm-surface);
    box-shadow: var(--hm-shadow-1);
}

.hims-grid-wrap:focus-visible {
    outline: 2px solid var(--hm-accent);
    outline-offset: 1px;
}

/* Redesign: a solid teal header band with white small-caps column titles, roomier rows, a faint stripe on every second
   row, a soft teal hover and a teal bar on the selected row. */
.hims-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .875rem;
}

.hims-grid th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--hm-secondary);
    color: #fff;
    font-weight: 600;
    font-size: .75rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    text-align: left;
    padding: 12px 12px;
    border-bottom: none;
    white-space: nowrap;
}

/* Both ends of the header band are curved the same, also when a scroll bar sits to the right of the last column. */
.hims-grid th:first-child {
    border-top-left-radius: 11px;
}

.hims-grid th:last-child {
    border-top-right-radius: 11px;
}

.hims-grid td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--hm-border);
    white-space: nowrap;
}

.hims-grid tbody tr:last-child td {
    border-bottom: none;
}

.hims-grid tbody tr {
    cursor: default;
}

.hims-grid tbody tr:nth-child(even) {
    background: var(--hm-surface-2);
}

.hims-grid tbody tr:hover {
    background: var(--hm-primary-soft);
}

.hims-grid tbody tr.hims-row-selected {
    background: var(--hm-primary-soft);
    box-shadow: inset 4px 0 0 var(--hm-primary);
    font-weight: 500;
}

.hims-grid .text-right,
.hims-grid th.text-right {
    text-align: right;
}

.hims-ellipsis {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hims-muted,
.hims-muted td {
    color: var(--hm-text-3);
}

.hims-empty-row {
    text-align: center;
    color: var(--hm-text-3);
    padding: 24px !important;
}

/* ---- master screens (list + editor) --------------------------------------------------------- */

.hims-master {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.5fr);
    gap: var(--hm-space-4);
    align-items: start;
}

.hims-master-editor {
    position: sticky;
    top: 0;
    border-radius: var(--hm-radius-card) !important;
    max-height: calc(100vh - 230px);
    overflow: auto;
}

@media (max-width: 1100px) {
    .hims-master {
        grid-template-columns: 1fr;
    }

    .hims-master-editor {
        position: static;
        max-height: none;
    }
}

/* ---- stat tiles ----------------------------------------------------------------------------- */

.hims-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--hm-space-3);
}

.hims-tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--hm-space-3) var(--hm-space-4);
    border-radius: var(--hm-radius-card);
    border: 1px solid var(--hm-border);
}

.hims-tile span {
    font-size: .75rem;
    color: var(--hm-text-2);
}

.hims-tile b {
    font-size: 1.25rem;
}

.hims-tile-info {
    background: color-mix(in srgb, var(--hm-info) 9%, var(--hm-surface));
}

.hims-tile-good {
    background: color-mix(in srgb, var(--hm-success) 9%, var(--hm-surface));
}

.hims-tile-warn {
    background: color-mix(in srgb, var(--hm-warning) 12%, var(--hm-surface));
}

/* ---- bills and visits ----------------------------------------------------------------------- */

.hims-totals {
    display: grid;
    grid-template-columns: 1fr auto;
    row-gap: 4px;
    column-gap: var(--hm-space-4);
    font-size: .875rem;
}

.hims-totals> :nth-child(even) {
    text-align: right;
}

.hims-money {
    font-size: 1.125rem;
    color: var(--hm-primary);
}

.hims-vitals {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--hm-space-2);
}

.hims-token {
    width: 84px;
    height: 84px;
    border-radius: var(--hm-radius-card);
    background: var(--hm-primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hims-token span {
    font-size: .7rem;
    letter-spacing: .06em;
}

.hims-token b {
    font-size: 1.75rem;
    line-height: 1.1;
}

/* ---- attendance grid ------------------------------------------------------------------------ */

.hims-att-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: var(--hm-space-3);
    font-size: .8125rem;
}

.hims-att-wrap {
    overflow: auto;
    max-height: 62vh;
    border: 1px solid var(--hm-border);
    border-radius: var(--hm-radius-sm);
}

.hims-att {
    border-collapse: separate;
    border-spacing: 0;
    font-size: .75rem;
}

.hims-att th,
.hims-att td {
    padding: 2px;
    text-align: center;
    border-bottom: 1px solid var(--hm-border);
    background: var(--hm-surface);
    white-space: nowrap;
}

.hims-att thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--hm-surface-2);
    font-weight: 600;
    color: var(--hm-text-2);
    padding: 4px 2px;
}

.hims-att .hims-att-name {
    position: sticky;
    left: 0;
    z-index: 1;
    text-align: left;
    padding: 4px 10px;
    min-width: 130px;
    border-right: 1px solid var(--hm-border);
}

.hims-att thead .hims-att-name {
    z-index: 3;
}

.hims-att .hims-att-sun {
    color: var(--hm-danger);
}

.hims-att-total {
    font-weight: 600;
    padding: 0 8px !important;
}

.hims-att-cell {

    width: 30px;
    height: 24px;
    border: 1px solid transparent;
    border-radius: 4px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    background: var(--hm-surface-2);
    color: var(--hm-text-3);
}

.hims-att-cell:focus-visible {
    outline: 2px solid var(--hm-accent);
    outline-offset: 1px;
}

.hims-att-p {
    background: var(--hm-primary-soft);
    color: var(--hm-success);
}

.hims-att-a {
    background: color-mix(in srgb, var(--hm-danger) 15%, transparent);
    color: var(--hm-danger);
}

.hims-att-l {
    background: color-mix(in srgb, var(--hm-info) 15%, transparent);
    color: var(--hm-info);
}

.hims-att-hd {
    background: color-mix(in srgb, var(--hm-warning) 18%, transparent);
    color: var(--hm-warning);
}

.hims-att-wo,
.hims-att-h {
    background: var(--hm-surface-2);
    color: var(--hm-text-2);
}

/* ---- small screens -------------------------------------------------------------------------- */

@media (max-width: 959px) {
    .hims-branch {
        display: none;
    }

    .hims-page {
        padding: var(--hm-space-3);
    }
}

@media (max-width: 599px) {
    .hims-brand span {
        display: none;
    }

    .hims-user-button .mud-button-label {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* Right-click menus opened by their host (bed tile, attendance sheet): the menu's own empty activator is not a
   keyboard stop or a nameless button for screen readers. */
.hims-context-menu>.mud-menu-activator {
    visibility: hidden;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* A simple table inside a scrolling, focusable wrapper: the wrapper scrolls, not the table's own container. */
.hims-scroll-wrap .mud-table-container {
    overflow: visible;
}