/* Mahin Inventory | Dashboard
   Live source grouped by responsibility. Keep shared values in components.css. */

/* Origin: css/pages/dashboard_widgets.css; structure and behavior preserved */
/* Mahin Inventory V2 — Dashboard editor (scoped; no sidebar or Settings overrides) */
#appScreen #miDashboardView{display:block;min-width:0}
#appScreen #miDashboardView.hidden{display:none!important}
#appScreen #miDashboardView .mi-dashboard-original-kpis{display:none!important}
#appScreen #miDashboardView .mi-dashboard-business-access{margin:22px 0 10px;opacity:.92}
#appScreen #dashboardWidgets{min-width:0;margin:0;color:var(--text,#162d4c)}
#appScreen .mi-dash-toolbar{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;margin:0 0 16px}
#appScreen .mi-dash-heading{display:flex;align-items:center;gap:10px;min-width:0}
#appScreen .mi-dash-heading h1{margin:0;font-size:clamp(23px,2.2vw,29px);line-height:1.2;letter-spacing:-.03em}
#appScreen .mi-dash-mode{padding:4px 8px;border-radius:99px;background:color-mix(in srgb,var(--primary,#2463c8) 13%,var(--surface,#fff));color:var(--primary,#2463c8);font-size:11px}
#appScreen .mi-dash-actions,#appScreen .mi-dash-editor-actions{display:flex;gap:7px;align-items:center;flex-wrap:wrap}
#appScreen .mi-dash-button{min-height:36px;padding:7px 12px;border:1px solid var(--border,#d5deec);border-radius:9px;background:var(--surface,#fff);color:var(--text,#162d4c);font:inherit;font-size:12px;cursor:pointer;white-space:nowrap}
#appScreen .mi-dash-button:hover:not(:disabled){border-color:var(--primary,#2463c8)}
#appScreen .mi-dash-button:disabled{opacity:.44;cursor:not-allowed}
#appScreen .mi-dash-button.mi-dash-primary{background:var(--primary,#2563c9);border-color:var(--primary,#2563c9);color:#fff}
#appScreen .mi-dash-editor{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:9px;padding:10px 12px;margin:0 0 13px;border:1px dashed color-mix(in srgb,var(--primary,#2563c9) 55%,var(--border,#d5deec));border-radius:11px;background:color-mix(in srgb,var(--primary,#2563c9) 4%,var(--surface,#fff));font-size:12px}
#appScreen .mi-dash-editor[hidden]{display:none!important}
#appScreen .mi-dash-grid{--mi-dash-columns:8;--mi-dash-gap:var(--mi-dashboard-widget-gap,12px);--mi-dash-unit:100px;display:grid;grid-template-columns:repeat(var(--mi-dash-columns),minmax(0,1fr));grid-auto-rows:var(--mi-dash-unit);gap:var(--mi-dash-gap);min-width:0;align-content:start;position:relative;touch-action:pan-y}
#appScreen .mi-dash-card{position:relative;display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden;border:1px solid var(--border,#d7e1ed);border-radius:var(--mi-ui-radius-card,15px);background:var(--mi-ui-surface,var(--surface,#fff));box-shadow:var(--mi-ui-shadow-card)}
#appScreen .mi-dash-card-header{display:flex;align-items:center;gap:9px;padding:12px 13px 6px;min-height:42px;user-select:none}
#appScreen .mi-dash-card-icon{display:grid;place-items:center;flex:none;width:31px;height:31px;border-radius:9px;background:color-mix(in srgb,var(--primary,#2463c8) 10%,var(--surface,#fff));color:var(--primary,#2463c8);font-size:16px}
#appScreen .mi-dash-card-title{min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;font-weight:650}
#appScreen .mi-dash-card-body{display:flex;flex:1;flex-direction:column;justify-content:center;gap:7px;min-height:0;min-width:0;padding:10px 13px 15px;overflow:auto}
#appScreen .mi-dash-metric{font-size:clamp(23px,2.7vw,34px);font-weight:760;font-variant-numeric:tabular-nums;letter-spacing:-.035em;overflow-wrap:anywhere}
#appScreen .mi-dash-caption{font-size:11px;color:var(--muted,#718299);line-height:1.55}
#appScreen .mi-dash-shortcuts{display:flex;flex-wrap:wrap;gap:7px}
#appScreen .mi-dash-shortcuts button{border:1px solid var(--border,#d7e1ed);border-radius:8px;padding:8px 10px;background:transparent;color:var(--primary,#2463c8);font:inherit;font-size:12px;cursor:pointer}
#appScreen .mi-dash-grid.mi-dash-editing .mi-dash-card-header{cursor:grab;touch-action:none}
#appScreen .mi-dash-grid.mi-dash-editing .mi-dash-card-header:active{cursor:grabbing}
#appScreen .mi-dash-card.mi-dash-selected{outline:2px solid var(--primary,#2563c9);outline-offset:-2px}

#appScreen .mi-dash-card.mi-dash-dragging{z-index:2;opacity:.55}
#appScreen .mi-dash-select{display:none;align-items:center;justify-content:center;width:23px;height:23px;flex:none;border:1px solid var(--border,#d7e1ed);border-radius:6px;background:var(--surface,#fff);cursor:pointer}
#appScreen .mi-dash-grid.mi-dash-editing .mi-dash-select{display:flex}
#appScreen .mi-dash-resize{display:none;position:absolute;right:2px;bottom:2px;width:29px;height:29px;border:0;border-radius:7px;background:color-mix(in srgb,var(--primary,#2563c9) 12%,var(--surface,#fff));color:var(--primary,#2563c9);cursor:nwse-resize;touch-action:none;font-size:20px}
#appScreen .mi-dash-grid.mi-dash-editing .mi-dash-resize{display:block}
#appScreen .mi-dash-remove{display:none;flex:none;border:0;background:transparent;color:var(--muted,#718299);cursor:pointer;font-size:17px}
#appScreen .mi-dash-grid.mi-dash-editing .mi-dash-remove{display:block}
#appScreen .mi-dash-status{min-height:15px;margin:8px 0;color:var(--muted,#718299);font-size:11px}
#appScreen .mi-dash-icon-button{width:33px;height:33px;border:1px solid var(--border,#d7e1ed);border-radius:8px;background:transparent;color:inherit;cursor:pointer}
#appScreen .mi-dash-catalog-items{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
#appScreen .mi-dash-catalog-option{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:13px;border:1px solid var(--border,#d7e1ed);border-radius:10px;background:transparent;color:inherit;text-align:left;font:inherit;font-size:12px;cursor:pointer}
#appScreen .mi-dash-catalog-option:disabled{opacity:.55;cursor:default}
#appScreen :is(.mi-dash-button,.mi-dash-select,.mi-dash-resize,.mi-dash-remove,.mi-dash-catalog-option,.mi-dash-shortcuts button):focus-visible{outline:2px solid var(--primary,#2563c9);outline-offset:2px}
@media(max-width:1100px){#appScreen .mi-dash-grid{--mi-dash-columns:4}}
@media(max-width:620px){#appScreen .mi-dash-grid{--mi-dash-columns:2;--mi-dash-gap:8px}#appScreen .mi-dash-card-header{padding:8px 8px 0;gap:6px}#appScreen .mi-dash-card-body{padding:5px 9px 11px}#appScreen .mi-dash-card-title{font-size:11px}#appScreen .mi-dash-catalog-items{grid-template-columns:1fr}#appScreen .mi-dash-button{padding:7px 9px}#appScreen .mi-dash-toolbar{align-items:flex-start}}
@media(prefers-reduced-motion:reduce){#appScreen .mi-dash-card{transition:none!important}}

/* Edit-mode add tile, searchable catalog, live placement footprint. */
#appScreen .mi-dash-add-tile{display:flex;align-items:center;justify-content:center;flex-direction:column;gap:5px;min-height:0;border:1px dashed var(--primary,#2563c9);border-radius:12px;background:color-mix(in srgb,var(--primary,#2563c9) 5%,var(--surface,#fff));color:var(--primary,#2563c9);font:inherit;font-size:12px;cursor:pointer}
#appScreen .mi-dash-add-tile .mi-dash-plus{font-size:24px;line-height:1}
#appScreen .mi-dash-ghost{position:absolute;pointer-events:none;z-index:5;border:2px dashed var(--primary,#2563c9);border-radius:11px;background:color-mix(in srgb,var(--primary,#2563c9) 13%,transparent)}
#appScreen .mi-dash-ghost.mi-dash-invalid{border-color:#c33c47;background:rgba(195,60,71,.1)}
#appScreen .mi-dash-catalog-search{width:100%;padding:11px;margin:0 0 12px;border:1px solid var(--border,#d7e1ed);border-radius:9px;background:var(--surface,#fff);color:inherit;font:inherit;font-size:13px}
#appScreen .mi-dash-catalog-option span:first-child{display:flex;align-items:center;gap:9px;min-width:0}
#appScreen .mi-dash-catalog-option strong{font-size:12px}
#appScreen .mi-dash-catalog-option small{color:var(--muted,#718299);font-size:11px}
#appScreen .mi-dash-card.mi-dash-dragging{opacity:.7;box-shadow:0 9px 24px rgba(10,35,65,.18)}

#appScreen .mi-dash-mobile-order{display:none;flex:none;width:27px;height:30px;border:1px solid var(--border,#d7e1ed);border-radius:7px;background:transparent;color:var(--primary,#2563c9);cursor:pointer}
/* Step 4.91: responsive editor uses the same drag/resize UI at all widths. */
@media(max-width:1100px){
  #appScreen .mi-dash-grid.mi-dash-editing .mi-dash-card-header{cursor:grab;touch-action:none}
  #appScreen .mi-dash-grid.mi-dash-editing .mi-dash-resize{display:block!important;touch-action:none}
  #appScreen .mi-dash-mobile-order{display:none!important}
}
@media(max-width:620px){
  #appScreen .mi-dash-grid.mi-dash-editing .mi-dash-card-header{min-height:40px}
  #appScreen .mi-dash-grid.mi-dash-editing .mi-dash-resize{width:34px;height:34px;right:3px;bottom:3px}
  #appScreen .mi-dash-grid.mi-dash-editing .mi-dash-select{width:28px;height:28px}
}

/* Step 4.89 — Live widget collision reflow. No layout change outside edit mode. */
#appScreen .mi-dash-grid.mi-dash-editing .mi-dash-card:not(.mi-dash-dragging){
  transition:transform 200ms cubic-bezier(.2,.75,.25,1), box-shadow 180ms ease;
}
#appScreen .mi-dash-grid.mi-dash-editing .mi-dash-card.mi-dash-dragging{
  transition:none!important;z-index:6;box-shadow:0 14px 30px rgba(15,40,80,.17);
}
#appScreen .mi-dash-grid.mi-dash-preview-active .mi-dash-card.mi-dash-preview-shift{
  box-shadow:0 7px 19px rgba(15,40,80,.1);
}
#appScreen .mi-dash-grid .mi-dash-ghost{z-index:4;transition:left 130ms ease,top 130ms ease,width 130ms ease,height 130ms ease;}
@media(prefers-reduced-motion:reduce){
  #appScreen .mi-dash-grid.mi-dash-editing .mi-dash-card,
  #appScreen .mi-dash-grid .mi-dash-ghost{transition:none!important}
}
[data-mi-reduced-motion="true"] #appScreen .mi-dash-grid.mi-dash-editing .mi-dash-card,
[data-mi-reduced-motion="true"] #appScreen .mi-dash-grid .mi-dash-ghost{transition:none!important}

/* STEP 4.94 - CLEAN SINGLE-LABEL GROUP PRESENTATION */
/* One subtle shared frame; members keep their normal card visuals. */
#appScreen .mi-dash-grid .mi-dash-group-frame {
  position: absolute;
  z-index: 2;
  box-sizing: border-box;
  pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--mi-group-accent, #2a70d6) 55%, transparent);
  border-radius: 15px;
  background: color-mix(in srgb, var(--mi-group-accent, #2a70d6) 3%, transparent);
  box-shadow: none;
}
#appScreen .mi-dash-grid .mi-dash-card { z-index: 1; }
#appScreen .mi-dash-grid .mi-dash-card.mi-dash-grouped {
  border-color: var(--border, #d7e1ed);
}
#appScreen .mi-dash-card.mi-dash-grouped::before { content: none !important; }
#appScreen .mi-dash-group-name {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: calc(100% - 18px);
  padding: 3px 11px;
  border: 1px solid color-mix(in srgb, var(--mi-group-accent, #2a70d6) 35%, var(--border, #d7e1ed));
  border-radius: 999px;
  background: var(--surface, #fff);
  color: var(--mi-group-accent, #2a70d6);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Member content is balanced and centered inside the card. */
#appScreen .mi-dash-grid .mi-dash-card.mi-dash-grouped .mi-dash-card-body {
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}
#appScreen .mi-dash-grid .mi-dash-card.mi-dash-grouped .mi-dash-metric,
#appScreen .mi-dash-grid .mi-dash-card.mi-dash-grouped .mi-dash-caption {
  max-width: 100%;
  text-align: center;
}
#appScreen .mi-dash-grid .mi-dash-card.mi-dash-grouped .mi-dash-caption {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
#appScreen .mi-dash-grid.mi-dash-preview-active .mi-dash-group-frame { opacity: .55; }
#appScreen .mi-dash-status:empty { display: none; }
@media (max-width:620px) {
  #appScreen .mi-dash-group-name { font-size: 10px; padding: 2px 8px; }
  #appScreen .mi-dash-grid .mi-dash-card.mi-dash-grouped .mi-dash-card-body { padding: 3px 5px 7px; }
}
@media (prefers-reduced-motion: reduce) {
  #appScreen .mi-dash-grid .mi-dash-group-frame { transition: none !important; }
}


/* STEP 4.96 - EMPTY CELL ADD BUTTONS */
/* One unobtrusive + in each available square while Customize is active. */
#appScreen .mi-dash-grid.mi-dash-editing .mi-dash-cell-add {
  min-width:0;
  min-height:0;
  border:1px dashed color-mix(in srgb,var(--primary,#2563c9) 24%,transparent);
  border-radius:10px;
  background:color-mix(in srgb,var(--primary,#2563c9) 2%,var(--surface,#fff));
  color:var(--primary,#2563c9);
  opacity:.38;
  transition:opacity 140ms ease,background-color 140ms ease,border-color 140ms ease;
}
#appScreen .mi-dash-grid.mi-dash-editing .mi-dash-cell-add:hover,
#appScreen .mi-dash-grid.mi-dash-editing .mi-dash-cell-add:focus-visible {
  opacity:1;
  border-color:var(--primary,#2563c9);
  background:color-mix(in srgb,var(--primary,#2563c9) 10%,var(--surface,#fff));
}
#appScreen .mi-dash-grid.mi-dash-editing .mi-dash-cell-add .mi-dash-plus {
  font-size:23px;
}
@media (pointer:coarse) {
  #appScreen .mi-dash-grid.mi-dash-editing .mi-dash-cell-add {
    opacity:.68;
    border-color:color-mix(in srgb,var(--primary,#2563c9) 36%,transparent);
  }
}
@media(prefers-reduced-motion:reduce){
  #appScreen .mi-dash-grid.mi-dash-editing .mi-dash-cell-add {transition:none!important}
}
[data-mi-reduced-motion="true"] #appScreen .mi-dash-grid.mi-dash-editing .mi-dash-cell-add {transition:none!important}


/* STEP 4.97 - BALANCED GROUP TILES */
/* Alignment is performed by the layout engine, not by visual-only CSS offsets. */
#appScreen .mi-dash-card.mi-dash-grouped .mi-dash-card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}
#appScreen .mi-dash-card.mi-dash-grouped .mi-dash-metric,
#appScreen .mi-dash-card.mi-dash-grouped .mi-dash-caption {
  text-align: center;
  max-width: 100%;
}
#appScreen #miDashAlignGroup:disabled { opacity: .45; cursor: not-allowed; }


/* STEP 5.00 - SMART SELECTION */

#appScreen .mi-dash-selection-toggle[aria-pressed="true"] {
    border-color: var(--primary, #2563c9);
    background: color-mix(
        in srgb,
        var(--primary, #2563c9) 13%,
        var(--surface, #fff)
    );
    color: var(--primary, #2563c9);
}

#appScreen .mi-dash-grid.mi-dash-selection-mode
.mi-dash-card {
    cursor: pointer;
    touch-action: manipulation;
}

#appScreen .mi-dash-grid.mi-dash-selection-mode
.mi-dash-card-header {
    cursor: pointer;
    touch-action: manipulation;
}

#appScreen .mi-dash-grid.mi-dash-selection-mode
.mi-dash-select,
#appScreen .mi-dash-grid.mi-dash-selection-mode
.mi-dash-resize {
    display: none !important;
}

#appScreen .mi-dash-grid.mi-dash-selection-mode
.mi-dash-card.mi-dash-selected {
    outline: 2px solid var(--primary, #2563c9);
    outline-offset: -3px;
    background: color-mix(
        in srgb,
        var(--primary, #2563c9) 5%,
        var(--surface, #fff)
    );
}

#appScreen .mi-dash-grid.mi-dash-selection-mode
.mi-dash-card.mi-dash-selected::after {
    content: "?";
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background: var(--primary, #2563c9);
    color: #fff;
    font-size: 12px;
    pointer-events: none;
}

#appScreen .mi-dash-grid.mi-dash-selection-mode
.mi-dash-card:focus-visible {
    outline: 3px solid var(--primary, #2563c9);
    outline-offset: -3px;
}

@media (max-width: 620px) {
    #appScreen .mi-dash-selection-toggle,
    #appScreen .mi-dash-selection-extra {
        min-height: 40px;
    }
}


/* STEP 5.01R - EXPLICIT GROUP HANDLE */

/* The frame does not intercept member-widget dragging. */
#appScreen .mi-dash-grid .mi-dash-group-frame {
    pointer-events: none;
}

/* Only the group name can initiate whole-group movement. */
#appScreen .mi-dash-grid.mi-dash-editing
.mi-dash-group-name:not(:disabled) {
    pointer-events: auto;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

#appScreen .mi-dash-grid.mi-dash-editing
.mi-dash-group-name:not(:disabled):active {
    cursor: grabbing;
}

#appScreen .mi-dash-group-name {
    appearance: none;
    font-family: inherit;
}

#appScreen .mi-dash-group-name:disabled {
    pointer-events: none;
    cursor: default;
}

#appScreen .mi-dash-group-name:focus-visible {
    outline: 2px solid var(--primary, #2563c9);
    outline-offset: 3px;
}

/* A grouped widget is still independently resizable. */
#appScreen .mi-dash-grid.mi-dash-editing
.mi-dash-card-header {
    touch-action: none;
}


/* STEP 5.02 - SMART DASHBOARD EDITOR */

#appScreen .mi-smart-editor {
    gap: 12px;
    border-style: solid;
    padding: 10px 12px;
}

#appScreen .mi-smart-editor .mi-dash-editor-actions {
    flex: 1;
    justify-content: flex-end;
    min-width: 0;
    gap: 8px;
}

#appScreen .mi-smart-primary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
}

#appScreen .mi-smart-editor [hidden],
#appScreen .mi-smart-context[hidden] {
    display: none !important;
}

#appScreen .mi-smart-more-wrap {
    position: relative;
}

#appScreen .mi-smart-more-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 7px);
    z-index: 80;
    display: grid;
    gap: 4px;
    min-width: 200px;
    max-width: calc(100vw - 30px);
    padding: 7px;
    border: 1px solid var(--border, #d5deec);
    border-radius: 12px;
    background: var(--surface, #fff);
    box-shadow: 0 12px 32px rgba(14, 40, 78, .18);
}

#appScreen .mi-smart-more-panel .mi-dash-button {
    width: 100%;
    text-align: left;
    border: 0;
    border-radius: 7px;
    background: transparent;
}

#appScreen .mi-smart-more-panel .mi-dash-button:hover:not(:disabled) {
    background: color-mix(
        in srgb,
        var(--primary, #2463c8) 8%,
        var(--surface, #fff)
    );
}

#appScreen .mi-smart-context {
    position: fixed;
    z-index: 1100;
    min-width: 190px;
    max-width: calc(100vw - 16px);
    padding: 6px;
    border: 1px solid var(--border, #d5deec);
    border-radius: 12px;
    background: var(--surface, #fff);
    box-shadow: 0 15px 45px rgba(10, 30, 60, .23);
}

#appScreen .mi-smart-context-action {
    display: block;
    width: 100%;
    min-height: 38px;
    padding: 9px 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text, #162d4c);
    text-align: left;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

#appScreen .mi-smart-context-action:hover,
#appScreen .mi-smart-context-action:focus-visible {
    background: color-mix(
        in srgb,
        var(--primary, #2463c8) 10%,
        var(--surface, #fff)
    );
    outline: none;
}

@media (max-width: 750px) {
    #appScreen .mi-smart-editor {
        align-items: flex-start;
    }

    #appScreen .mi-smart-editor .mi-dash-editor-actions {
        width: 100%;
        justify-content: space-between;
    }

    #appScreen .mi-smart-primary-actions {
        gap: 5px;
    }

    #appScreen .mi-smart-more-panel {
        right: auto;
        left: 0;
    }
}


/* STEP 5.03 - WIDGET ICON AND REPLACE UI */

/* More button: CSS chevron, no unsupported glyph. */
#appScreen .mi-smart-more-trigger {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

#appScreen .mi-smart-more-trigger::after {
    content: "" !important;
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 1.7px solid currentColor;
    border-bottom: 1.7px solid currentColor;
    transform: rotate(45deg);
    margin-top: -3px;
}

#appScreen .mi-smart-more-trigger[aria-expanded="true"]::after {
    transform: rotate(225deg);
    margin-top: 3px;
}

/*
 * Selected widget indicator:
 * Draw a blue circle and white check using CSS.
 * No text glyph, so no '?' font fallback.
 */
#appScreen .mi-dash-grid.mi-dash-selection-mode
.mi-dash-card.mi-dash-selected::before {
    content: "" !important;
    position: absolute;
    top: 5px;
    right: 5px;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background: #2563c9;
    z-index: 8;
    pointer-events: none;
}

#appScreen .mi-dash-grid.mi-dash-selection-mode
.mi-dash-card.mi-dash-selected::after {
    content: "" !important;
    position: absolute;
    top: 10px;
    right: 11px;
    width: 9px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    border-right: 0;
    border-top: 0;
    border-radius: 0;
    background: transparent !important;
    transform: rotate(-45deg);
    z-index: 9;
    pointer-events: none;
}

/* Replace dialog */
#appScreen .mi-dash-replace-dialog {
    width: min(440px, calc(100vw - 24px));
    max-height: 82vh;
    overflow-y: auto;
    padding: 19px;
}

#appScreen .mi-dash-replace-dialog h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

#appScreen .mi-dash-replace-description {
    margin: 0 0 15px;
    color: var(--muted, #728096);
    font-size: 12px;
    line-height: 1.6;
}

#appScreen .mi-dash-replace-options {
    display: grid;
    gap: 8px;
    margin-bottom: 15px;
}

#appScreen .mi-dash-replace-option {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 51px;
    padding: 9px 12px;
    border: 1px solid var(--border, #d7e1ed);
    border-radius: 10px;
    background: var(--surface, #fff);
    color: var(--text, #172b49);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

#appScreen .mi-dash-replace-option strong {
    flex: 1;
    font-size: 12px;
}

#appScreen .mi-dash-replace-option small {
    color: var(--muted, #728096);
    font-size: 11px;
}

#appScreen .mi-dash-replace-option:hover,
#appScreen .mi-dash-replace-option:focus-visible {
    border-color: var(--primary, #2563c9);
    background: color-mix(
        in srgb,
        var(--primary, #2563c9) 7%,
        var(--surface, #fff)
    );
}

#appScreen .mi-smart-replace[hidden] {
    display: none !important;
}

@media (max-width: 620px) {
    #appScreen .mi-dash-replace-option {
        min-height: 48px;
    }
}


/* STEP 5.04 - TOUCH HOLD FEEDBACK */

/* Only the content area receives long-press feedback.
   Drag headers and resize handles retain their behavior. */

#appScreen .mi-dash-grid.mi-dash-editing
.mi-dash-card-body {
    -webkit-touch-callout: none;
}

#appScreen .mi-dash-grid
.mi-dash-card.mi-dash-touch-holding {
    outline: 2px solid var(--primary, #2563c9);
    outline-offset: -2px;
    box-shadow: 0 7px 23px rgba(20, 65, 130, .16);
}

@media (prefers-reduced-motion: reduce) {
    #appScreen .mi-dash-card.mi-dash-touch-holding {
        transition: none !important;
    }
}


/* STEP 5.07 - SMART DRAG GROUP PREVIEW */

#appScreen .mi-dash-card.mi-dash-group-drop-target {
    outline: 2px dashed #5b9cf0;
    outline-offset: -3px;
}

#appScreen .mi-dash-card.mi-dash-group-drop-ready {
    outline: 3px solid #2563c9;
    outline-offset: -3px;
    box-shadow:
        0 0 0 4px rgba(37,99,201,.12),
        0 10px 25px rgba(37,99,201,.14);
}

#appScreen .mi-dash-card.mi-dash-group-drop-target::selection {
    background: transparent;
}

@media (prefers-reduced-motion: reduce) {
    #appScreen .mi-dash-card.mi-dash-group-drop-target,
    #appScreen .mi-dash-card.mi-dash-group-drop-ready {
        transition: none !important;
        animation: none !important;
    }
}


/* STEP 5.08 - SMART SPACE MANAGER */

#appScreen .mi-dash-space-manager {
    display: flex;
    flex-direction: column;
    gap: 9px;
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--border, #d8e2ee);
    border-radius: 12px;
    background: color-mix(
        in srgb,
        var(--surface, #fff) 96%,
        var(--primary, #2563c9)
    );
}

#appScreen .mi-dash-space-summary {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 5px 12px;
    align-items: center;
}

#appScreen .mi-dash-space-summary strong {
    font-size: 12px;
    font-weight: 650;
}

#appScreen .mi-dash-space-help {
    font-size: 11px;
    color: var(--muted, #718096);
}

#appScreen .mi-dash-space-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

#appScreen .mi-dash-space-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 11px;
    border: 1px solid var(--border, #d8e2ee);
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text, #19304e);
    font: inherit;
    font-size: 11px;
    font-weight: 550;
    cursor: pointer;
}

#appScreen .mi-dash-space-button:hover:not(:disabled),
#appScreen .mi-dash-space-button:focus-visible {
    border-color: var(--primary, #2563c9);
    outline-offset: 2px;
}

#appScreen .mi-dash-space-button:disabled {
    opacity: .42;
    cursor: not-allowed;
}

@media (max-width: 620px) {
    #appScreen .mi-dash-space-controls {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #appScreen .mi-dash-space-button {
        min-width: 0;
        min-height: 39px;
        padding: 7px 5px;
    }
}


/* STEP 5.09 - COMPACT SPACE ACTIONS */

/* Show space controls only when the subsection opens. */
#appScreen .mi-smart-space-submenu {
    min-width: 0;
    border-top: 1px solid var(--border, #d7e0eb);
    padding-top: 5px;
}

#appScreen .mi-smart-space-trigger,
#appScreen .mi-smart-context-space-heading {
    position: relative;
    padding: 10px 28px 10px 11px;
    border-radius: 8px;
    color: var(--text, #172b49);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

#appScreen .mi-smart-space-trigger::-webkit-details-marker,
#appScreen .mi-smart-context-space-heading::-webkit-details-marker {
    display: none;
}

#appScreen .mi-smart-space-trigger::after,
#appScreen .mi-smart-context-space-heading::after {
    content: "";
    position: absolute;
    right: 13px;
    top: calc(50% - 4px);
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
}

#appScreen .mi-smart-space-submenu[open]
.mi-smart-space-trigger::after,
#appScreen .mi-smart-context-space[open]
.mi-smart-context-space-heading::after {
    transform: rotate(45deg);
}

#appScreen .mi-smart-space-trigger:hover,
#appScreen .mi-smart-context-space-heading:hover {
    background: color-mix(
        in srgb,
        var(--primary, #2563c9) 8%,
        var(--surface, #fff)
    );
}

/* Existing controls become a compact menu section. */
#appScreen .mi-smart-more-panel {
    width: min(310px, calc(100vw - 25px));
    max-height: min(75vh, 520px);
    overflow-y: auto;
}

#appScreen .mi-smart-space-submenu
.mi-dash-space-manager {
    width: 100%;
    margin: 4px 0 0;
    padding: 7px;
    border: 0;
    box-shadow: none;
    background: transparent;
}

#appScreen .mi-smart-space-submenu
.mi-dash-space-summary {
    display: none;
}

#appScreen .mi-smart-space-submenu
.mi-dash-space-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
}

#appScreen .mi-smart-space-submenu
.mi-dash-space-button {
    width: 100%;
    min-height: 36px;
    justify-content: flex-start;
    padding: 8px 10px;
    border: 0;
    background: transparent;
    text-align: left;
}

#appScreen .mi-smart-context-space {
    border-top: 1px solid var(--border, #d7e0eb);
    margin-top: 4px;
    padding-top: 4px;
}

#appScreen .mi-smart-context-space-items {
    display: grid;
    gap: 2px;
    padding-left: 8px;
}

#appScreen .mi-smart-context-space-items
button:disabled {
    opacity: .38;
    cursor: not-allowed;
}

@media (max-width: 620px) {
    #appScreen .mi-smart-more-panel {
        max-width: calc(100vw - 24px);
    }

    #appScreen .mi-smart-space-submenu
    .mi-dash-space-controls {
        grid-template-columns: 1fr;
    }
}


/* STEP 5.09R - VIEWPORT SAFE CONTEXT MENU */

/* The complete floating menu always stays on-screen. */
#appScreen .mi-smart-context {
    box-sizing: border-box;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    max-width: calc(100vw - 16px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

/* Expanded actions stay within the scrolling parent. */
#appScreen .mi-smart-context-space {
    max-width: 100%;
    min-width: 0;
}

#appScreen .mi-smart-context-space-items {
    min-width: 0;
}

#appScreen .mi-smart-context-space-items
.mi-smart-context-action {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Menus remain usable on short laptop/mobile screens. */
@media (max-height: 480px) {
    #appScreen .mi-smart-context {
        max-height: calc(100dvh - 12px);
    }
}


/* STEP 5.09S - WINDOWS STYLE SPACE FLYOUT */

#appScreen .mi-smart-space-flyout {
    position: fixed;
    box-sizing: border-box;
    z-index: 1200;
    min-width: 0;
    padding: 6px;
    border: 1px solid var(--border, #d7e0eb);
    border-radius: 11px;
    background: var(--surface, #fff);
    color: var(--text, #172b49);
    box-shadow: 0 14px 38px rgba(15, 37, 68, .2);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

#appScreen .mi-smart-space-flyout[hidden] {
    display: none !important;
}

#appScreen .mi-smart-space-flyout
.mi-smart-context-space-items {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 0;
}

#appScreen .mi-smart-space-flyout
.mi-smart-context-action {
    width: 100%;
    min-height: 37px;
    padding: 9px 11px;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
}

#appScreen .mi-smart-space-flyout
.mi-smart-context-action:disabled {
    opacity: .4;
    cursor: not-allowed;
}

#appScreen .mi-smart-context-space-heading {
    white-space: nowrap;
}

/* Narrow screen fallback: separate panel, not a
   long accordion attached to the parent menu. */
#appScreen .mi-smart-space-sheet {
    box-shadow: 0 17px 48px rgba(10, 30, 60, .28);
}

#appScreen .mi-smart-space-back {
    display: block;
    width: 100%;
    margin-bottom: 5px;
    padding: 9px 11px;
    border: 0;
    border-radius: 7px;
    background: var(--surface-secondary, #f1f5f9);
    color: inherit;
    text-align: left;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

#appScreen .mi-smart-space-back[hidden] {
    display: none !important;
}



/* STEP 5.10 - COMPACT KEYBOARD HINT CONTROL */

#appScreen .mi-shortcut-control {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    align-self: flex-start;
}

#appScreen .mi-shortcut-trigger {
    padding: 7px 11px;
    min-height: 33px;
    border: 1px solid var(--border, #d7e0eb);
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text, #19304e);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}

#appScreen .mi-shortcut-trigger::before {
    content: "\2328";
    margin-right: 7px;
}

#appScreen .mi-shortcut-menu {
    position: absolute;
    z-index: 100;
    left: 0;
    top: calc(100% + 6px);
    box-sizing: border-box;
    width: min(265px, calc(100vw - 30px));
    padding: 12px;
    border: 1px solid var(--border, #d7e0eb);
    border-radius: 12px;
    background: var(--surface, #fff);
    color: var(--text, #19304e);
    box-shadow: 0 13px 35px rgba(15, 35, 70, .16);
}

#appScreen .mi-shortcut-menu[hidden] {
    display: none !important;
}

#appScreen .mi-shortcut-menu strong {
    display: block;
    margin-bottom: 10px;
    font-size: 12px;
}

#appScreen .mi-shortcut-choices {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
}

#appScreen .mi-shortcut-choices button,
#appScreen .mi-shortcut-help-open {
    padding: 8px 5px;
    border: 1px solid var(--border, #d7e0eb);
    border-radius: 7px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}

#appScreen .mi-shortcut-choices
button[aria-pressed="true"] {
    border-color: var(--primary, #2563c9);
    background: color-mix(
        in srgb, var(--primary, #2563c9) 9%, transparent
    );
}

#appScreen .mi-shortcut-help-open {
    margin-top: 9px;
    width: 100%;
    text-align: left;
}

#appScreen .mi-shortcut-note {
    margin: 9px 0 0;
    color: var(--muted, #718096);
    font-size: 10px;
    line-height: 1.5;
}

#appScreen [data-shortcut-hints="show"]
.mi-dash-selection-toggle[data-shortcut-hint]::after {
    content: attr(data-shortcut-hint);
    display: inline-block;
    margin-left: 7px;
    padding: 2px 4px;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-size: 9px;
    opacity: .7;
}

.mi-shortcut-help-dialog {
    box-sizing: border-box;
    width: min(420px, calc(100vw - 25px));
    padding: 19px;
    border: 1px solid #ccd7e5;
    border-radius: 14px;
    background: var(--surface, #fff);
    color: var(--text, #19304e);
}

.mi-shortcut-help-dialog::backdrop {
    background: rgba(8, 22, 44, .45);
}

.mi-shortcut-help-dialog h2 {
    margin: 0 0 15px;
    font-size: 17px;
}

.mi-shortcut-help-list > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid #e1e6ef;
    font-size: 12px;
}

.mi-shortcut-help-list kbd {
    padding: 4px 7px;
    border: 1px solid #c5d0df;
    border-radius: 5px;
    font: inherit;
    font-size: 11px;
    white-space: nowrap;
}

.mi-shortcut-help-dialog > button {
    margin-top: 15px;
    padding: 8px 15px;
    border: 1px solid #c5d0df;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

@media (pointer: coarse) {
    #appScreen [data-shortcut-hints="show"]
    .mi-dash-selection-toggle[data-shortcut-hint]::after {
        display: none;
    }
}



/* STEP 5.10R - SHORTCUT SETTINGS DIALOG */

.mi-shortcut-settings-dialog {
    box-sizing: border-box;
    width: min(445px, calc(100vw - 24px));
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    padding: 20px;
    border: 1px solid var(--border, #ced8e6);
    border-radius: 15px;
    background: var(--surface, #fff);
    color: var(--text, #172b49);
    box-shadow: 0 22px 65px rgba(12, 30, 60, .24);
}

.mi-shortcut-settings-dialog::backdrop {
    background: rgba(10, 23, 46, .46);
}

.mi-shortcut-settings-dialog h2 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 650;
}

.mi-shortcut-settings-dialog > p {
    margin: 0 0 15px;
    color: var(--muted, #738098);
    font-size: 12px;
    line-height: 1.6;
}

.mi-shortcut-settings-choices {
    display: grid;
    gap: 9px;
}

.mi-shortcut-setting-card {
    display: grid;
    gap: 5px;
    width: 100%;
    min-height: 67px;
    padding: 12px 14px;
    border: 1px solid var(--border, #d4ddea);
    border-radius: 11px;
    background: var(--surface, #fff);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.mi-shortcut-setting-card strong {
    font-size: 13px;
}

.mi-shortcut-setting-card span {
    color: var(--muted, #738098);
    font-size: 11px;
    line-height: 1.5;
}

.mi-shortcut-setting-card[aria-pressed="true"] {
    border-color: var(--primary, #2563c9);
    background: color-mix(
        in srgb,
        var(--primary, #2563c9) 7%,
        var(--surface, #fff)
    );
}

.mi-shortcut-setting-card:hover,
.mi-shortcut-setting-card:focus-visible {
    border-color: var(--primary, #2563c9);
}

.mi-shortcut-settings-help,
.mi-shortcut-settings-close {
    margin-top: 13px;
    min-height: 37px;
    padding: 8px 12px;
    border: 1px solid var(--border, #d4ddea);
    border-radius: 8px;
    background: var(--surface, #fff);
    color: inherit;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.mi-shortcut-settings-help {
    margin-right: 8px;
}

#appScreen .mi-shortcut-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

#appScreen .mi-shortcut-trigger::before {
    content: "";
    width: 15px;
    height: 11px;
    margin: 0;
    border: 1.5px solid currentColor;
    border-radius: 3px;
    background:
        repeating-linear-gradient(
            90deg,
            transparent 0 3px,
            currentColor 3px 4px,
            transparent 4px 6px
        );
    opacity: .75;
}

@media (max-width: 620px) {
    .mi-shortcut-settings-dialog {
        padding: 16px;
    }
}


/* STEP 5.10S - DIRECT SHORTCUT TOGGLE */

#appScreen .mi-shortcut-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 35px;
    padding: 7px 12px;
    border-radius: 9px;
    transition: background-color .15s, border-color .15s;
}

/* Draw an eye using CSS, avoiding unsupported text glyphs. */
#appScreen .mi-shortcut-trigger::before {
    content: "" !important;
    display: inline-block;
    width: 15px;
    height: 10px;
    margin: 0;
    border: 1.7px solid currentColor;
    border-radius: 75% 20% / 75% 20%;
    transform: rotate(45deg);
    background: transparent;
}

#appScreen .mi-shortcut-trigger::after {
    content: "";
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    pointer-events: none;
}

/* Visible indicator for active shortcut hints. */
#appScreen .mi-shortcut-trigger[data-mode="show"] {
    border-color: var(--primary, #2563c9);
    background: color-mix(
        in srgb,
        var(--primary, #2563c9) 10%,
        var(--surface, #fff)
    );
}

/* The Hide state stays visually quiet. */
#appScreen .mi-shortcut-trigger[data-mode="hide"] {
    opacity: .85;
}

#appScreen .mi-shortcut-trigger[data-mode="hide"]::before {
    border-style: dashed;
}

/* Inline hints display only when explicitly enabled. */
#appScreen [data-shortcut-hints="show"]
.mi-dash-selection-toggle[data-shortcut-hint]::after {
    content: attr(data-shortcut-hint);
    display: inline-block;
    margin-left: 7px;
    padding: 2px 5px;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-size: 9px;
    opacity: .75;
}

#appScreen [data-shortcut-hints="hide"]
.mi-dash-selection-toggle[data-shortcut-hint]::after {
    display: none !important;
}

/* No permanent keyboard badges on touch-only screens. */
@media (hover: none) {
    #appScreen [data-shortcut-hints="show"]
    .mi-dash-selection-toggle[data-shortcut-hint]::after {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #appScreen .mi-shortcut-trigger {
        transition: none;
    }
}

/* Settings-first dashboard V11: scoped tiles, no legacy KPI styles or hardcoded theme. */
#appScreen #miDashboardView .mi-dash-heading-copy {display:flex;flex-direction:column;gap:4px;min-width:0}
#appScreen #miDashboardView .mi-dash-heading-copy p {margin:0;color:var(--muted,var(--text-muted,#718299));font-size:12px;line-height:1.4}
/* Adaptive Settings card styles are in dashboard-setting-widgets.css. */
