/*
 * Mobile specific stylesheet for FireDoorApp
 *
 * This file contains mobile-only overrides for smaller screens. Base/shared
 * styles live in style.css and are loaded separately by the layout.
 *
 * The design emphasises a
 * simplified, app‑like experience with a bottom navigation bar,
 * compact spacing and consistent branding. The palette matches the
 * desktop version for a cohesive feel across devices.
 */

:root {
  --mobile-select-border: rgba(203, 213, 225, 0.92);
  --mobile-select-bg: #ffffff;
  --mobile-select-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  --mobile-menu-surface: rgba(255, 255, 255, 0.99);
  --mobile-menu-border: rgba(203, 213, 225, 0.92);
  --mobile-menu-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
  --mobile-menu-radius: 16px;
}

/* === Mobile base overrides (<= 768px) === */
@media (max-width: 768px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  :where(html, body) {
    overflow-x: hidden;
  }

  body {
    /* Mobile Safari struggles with fixed background attachments (jank/paint). */
    background-attachment: scroll;
  }

  /*
   * Safari/Chrome treat `backdrop-filter` (and `filter`) as creating a containing
   * block for `position: fixed` descendants. Our hamburger lives inside `.top-bar`,
   * so leaving the blur enabled makes the "fixed" button scroll away with the header.
   */
  .top-bar {
    backdrop-filter: none;
  }

  :where(img, svg, video, canvas) {
    max-inline-size: 100%;
    block-size: auto;
  }

  /* Prevent iOS Safari form-field zoom (must be >= 16px). */
  :where(input, select, textarea) {
    font-size: 16px;
  }

  :where(.u-minw-220, .u-minw-180, .u-maxw-180) {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  :where(.content, .admin-shell) {
    overflow-wrap: anywhere;
  }

  :where(.content, .admin-shell, .modal__dialog) :where(input, select, textarea) {
    max-inline-size: 100%;
  }

  :where(
    .content,
    .admin-shell,
    .modal__dialog
  ) select:not([multiple]):not([size]) {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    min-height: 46px;
    padding: 10px 42px 10px 14px;
    border: 1px solid var(--mobile-select-border);
    border-radius: 12px;
    background-color: var(--mobile-select-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%2364758b' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-position: right 14px center;
    background-repeat: no-repeat;
    background-size: 18px 18px;
    box-shadow: var(--mobile-select-shadow);
    color: #0f172a;
    line-height: 1.3;
  }

  html[data-theme="dark"] :where(
    .content,
    .admin-shell,
    .modal__dialog
  ) select:not([multiple]):not([size]) {
    border-color: rgba(71, 85, 105, 0.95);
    background-color: rgba(15, 23, 42, 0.98);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%23cbd5e1' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    color: #e2e8f0;
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.22);
  }

  :where(
    .content,
    .admin-shell,
    .modal__dialog
  ) select:not([multiple]):not([size]):focus-visible {
    border-color: color-mix(in srgb, var(--brand) 72%, white);
    box-shadow:
      0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent),
      var(--mobile-select-shadow);
  }

  :where(.top-bar-search, .component-search) {
    width: 100%;
  }

  :where(.top-bar-search input, .component-search input) {
    min-width: 0;
    width: 100%;
    font-size: 16px;
  }

  /*
   * Tables: avoid sideways scrolling on mobile by stacking
   * `.table-stack-mobile` rows into cards up to 768px.
   */
  .table-stack-mobile thead {
    display: none;
  }

  .table-stack-mobile tbody,
  .table-stack-mobile tr,
  .table-stack-mobile td {
    display: block;
    width: 100%;
  }

		  .table-stack-mobile tr {
		    margin-bottom: 12px;
		    border-radius: 12px;
		    background: var(--card);
		    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
		    overflow: visible;
		  }

  .table-stack-mobile td {
    border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
    padding: 8px 14px;
    position: relative;
    font-size: 0.9rem;
  }

  .table-stack-mobile td:last-child {
    border-bottom: none;
  }

  .table-stack-mobile td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted, #9ca3af);
    margin-bottom: 2px;
  }

  .table-stack-mobile td:not([data-label])::before,
  .table-stack-mobile td[data-label=""]::before {
    display: none;
  }

  .table-stack-mobile td[data-label="Actions"]::before {
    display: none;
  }

  .table-stack-mobile td[data-label="Actions"],
  .table-stack-mobile td[data-label=""] {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
  }

  /*
   * On mobile we stack tables into "cards". The desktop action menu uses
   * absolute positioning which can feel detached/off-table on small screens.
   * Render the menu inline within the Actions block so it stays anchored to
   * the row/card and remains fully visible.
   */
  .table-stack-mobile .table-actions__more {
    display: inline-flex;
    align-items: center;
  }

  .table-stack-mobile .table-actions__more[open] {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
  }

  .table-stack-mobile .table-actions__menu {
    position: static;
    top: auto;
    right: auto;
    margin-top: 8px;
    width: 100%;
    min-width: 0;
    align-self: stretch;
  }

  :where(
    .top-bar-user-menu__dropdown,
    .table-actions__menu,
    .guided-tour__menu-panel,
    .admin-body .admin-dropdown__menu
  ) {
    border-radius: var(--mobile-menu-radius);
    border: 1px solid var(--mobile-menu-border);
    background: var(--mobile-menu-surface);
    box-shadow: var(--mobile-menu-shadow);
    backdrop-filter: none;
  }

  html[data-theme="dark"] :where(
    .top-bar-user-menu__dropdown,
    .table-actions__menu,
    .guided-tour__menu-panel,
    .admin-body .admin-dropdown__menu
  ) {
    background: rgba(15, 23, 42, 0.98);
    border-color: rgba(71, 85, 105, 0.9);
    box-shadow: 0 16px 36px rgba(2, 6, 23, 0.34);
  }

  :where(
    .top-bar-user-menu__item,
    .table-actions__menu-item,
    .guided-tour__menu-item,
    .admin-body .admin-dropdown__item
  ) {
    min-height: 44px;
    border-radius: 12px;
  }

  /* Account menu: compact sheet aligned to the trigger, still ≥44px rows */
  .top-bar-user-menu__dropdown {
    min-width: min(272px, calc(100vw - 20px));
    max-width: calc(100vw - 14px);
    padding: 5px;
    top: calc(100% + 5px);
    border-radius: 14px;
  }

  .top-bar-user-menu__header {
    padding: 5px 7px 7px;
    margin-bottom: 1px;
  }

  .top-bar-user-menu__name {
    font-size: 0.8rem;
  }

  .top-bar-user-menu__email {
    font-size: 0.6875rem;
  }

  .top-bar-user-menu__items {
    padding-top: 2px;
    gap: 1px;
  }

  .top-bar-user-menu__item {
    padding: 9px 7px;
    border-radius: 11px;
  }

  .top-bar-user-menu__label {
    font-size: 0.8rem;
  }

  .top-bar-user-menu__hint {
    -webkit-line-clamp: 1;
    line-clamp: 1;
  }

  .top-bar-user-menu__icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  .top-bar-user-menu__icon svg {
    width: 17px;
    height: 17px;
  }


  :where(
    .quick-fill-dropdown,
    .table-actions__more > summary
  ) {
    border-radius: 12px;
  }

  :where(
    .quick-fill-dropdown summary,
    .table-actions__more > summary,
    .guided-tour__menu summary
  ) {
    min-height: 40px;
    display: flex;
    align-items: center;
  }

  .table--compact.table-stack-mobile td {
    padding: 8px 12px;
  }

  .mobile-nav-trigger {
    display: flex;
    border-radius: 10px;
    border: 1px solid var(--rule-strong);
    background: var(--surface-card);
    box-shadow: var(--shadow-sm);
    z-index: 1650;
  }

  .mobile-nav-trigger span {
    background: var(--ink-2);
  }

  .sidebar {
    --sidebar-link-padding: 8px 10px;
    --sidebar-padding-x: 12px;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: min(84vw, 320px);
    padding: 18px 12px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-110%);
    transition: transform 0.3s ease;
    z-index: 1150;
    overflow-y: auto;
    border-right: 1px solid var(--rule);
    background: var(--surface-card);
    color: var(--ink-2);
    box-shadow: 0 24px 40px rgba(26, 24, 21, 0.14);
  }

  body.mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-brand {
    margin-bottom: 24px;
  }

  .sidebar-nav {
    gap: 12px;
  }

	  .sidebar-nav__list {
	    gap: 8px;
	  }

	  .sidebar-nav__item--mobile-only {
	    display: list-item;
	  }

  .sidebar-nav__section-heading {
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .sidebar-nav__section-bell {
    display: inline-flex !important;
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 0;
    padding: 0;
  }

	  .sidebar-nav__link,
	  .sb-item {
	    font-size: 0.96rem;
	    border-radius: 10px;
	    min-block-size: 42px;
	  }

  .sidebar-nav__link::before {
    left: 0;
    top: 10px;
    bottom: 10px;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    min-height: 56px;
  }

  .logo {
    margin-right: 0;
  }

  .logo-image {
    max-width: 112px;
  }

  .tb-divider,
  .tb-btn,
  .topbar-breadcrumb {
    display: none;
  }

  /* Notification badge — larger with count on mobile */
  .tb-notif-dot,
  .topbar .top-bar-notifications__badge {
    width: auto;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    top: 4px;
    right: 2px;
  }

  /* Guided tour stays in the top bar on phones (text labels hidden; button keeps aria-label). */
  .tb-btn.top-bar-guided-tour {
    display: inline-flex !important;
    flex-shrink: 0;
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 0;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid color-mix(in srgb, var(--success, #1e7a45) 26%, transparent);
    background: var(--success-soft, rgba(30, 122, 69, 0.1));
    color: color-mix(in srgb, var(--success, #1e7a45) 78%, var(--ink-3, #6b6458) 22%);
    box-shadow: 0 1px 2px rgba(26, 24, 21, 0.05);
  }

  .tb-btn.top-bar-guided-tour:focus-visible {
    outline: none;
    border-color: color-mix(in srgb, var(--success, #1e7a45) 44%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--success, #1e7a45) 16%, transparent);
  }

  .tb-btn.top-bar-guided-tour .top-bar-link__label {
    display: none;
  }

  .tb-btn.top-bar-guided-tour .shell-icon {
    width: 15px;
    height: 15px;
    color: inherit;
  }

  html[data-theme='dark'] .tb-btn.top-bar-guided-tour {
    border-color: rgba(110, 180, 140, 0.35);
    background: rgba(52, 120, 90, 0.22);
    color: rgba(170, 210, 185, 0.92);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  }

  html[data-theme='dark'] .tb-btn.top-bar-guided-tour:focus-visible {
    border-color: rgba(140, 200, 165, 0.55);
    box-shadow: 0 0 0 3px rgba(52, 120, 90, 0.35);
  }

  @media (hover: hover) and (pointer: fine) {
    .tb-btn.top-bar-guided-tour:hover {
      border-color: color-mix(in srgb, var(--success, #1e7a45) 34%, transparent);
      background: color-mix(
        in srgb,
        var(--success-soft, rgba(30, 122, 69, 0.1)) 90%,
        var(--surface-subtle, #f2efe9) 10%
      );
      color: color-mix(in srgb, var(--success, #1e7a45) 86%, var(--ink-2, #3d3a34) 14%);
    }

    html[data-theme='dark'] .tb-btn.top-bar-guided-tour:hover {
      background: rgba(58, 128, 96, 0.34);
      border-color: rgba(125, 188, 152, 0.45);
      color: rgba(198, 228, 208, 0.96);
    }
  }

  .tb-search {
    display: none;
  }

  .tb-nav {
    gap: 6px;
    margin-left: auto;
  }

  .tb-user {
    margin-left: 0;
  }

  .tb-uname {
    display: none;
  }

  .top-bar-user-menu__mobile-only {
    display: block;
  }

  .top-bar-user-menu__item--theme-picker {
    display: flex !important;
  }

  .content {
    padding: 16px;
  }

  .global-search-drawer {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: flex-end;
    align-items: flex-start;
    z-index: 2120;
  }

  .global-search-drawer.is-open {
    display: flex;
  }

  .global-search-drawer .modal__overlay {
    display: block;
  }

  /* Height follows content — avoids empty column below the form */
  .global-search-drawer .drawer__panel {
    width: min(420px, 100%);
    height: auto;
    max-height: min(100vh, 100dvh);
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 0;
    border: none;
    margin-top: 0;
    box-shadow: -18px 0 40px rgba(15, 23, 42, 0.35);
    padding-top: env(safe-area-inset-top, 0px);
    -webkit-overflow-scrolling: touch;
  }

  .global-search-drawer .drawer__header,
  .global-search-drawer .global-search-drawer__header {
    padding: 12px 14px 10px;
    gap: 8px;
    flex-shrink: 0;
    align-items: flex-start;
  }

  .global-search-drawer .global-search-drawer__eyebrow {
    margin-bottom: 4px;
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    color: color-mix(in srgb, var(--brand, #c49510) 88%, var(--ink-4, #64748b));
  }

  .global-search-drawer .global-search-drawer__title {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--ink, #0f172a);
  }

  .global-search-drawer .global-search-drawer__close {
    flex-shrink: 0;
    margin-top: -2px;
    font-size: 1.35rem;
    line-height: 1;
    padding: 4px 8px;
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: var(--ink-3, #475569);
  }

  .global-search-drawer .global-search-drawer__close:hover,
  .global-search-drawer .global-search-drawer__close:focus-visible {
    background: var(--surface-subtle, #f1f5f9);
    color: var(--ink, #0f172a);
    outline: none;
  }

  /* Do not let the body flex-grow and swallow the viewport */
  .global-search-drawer .drawer__body {
    flex: 0 0 auto;
    padding: 10px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    overflow-y: visible;
  }

  .global-search-drawer__form {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .global-search-drawer .global-search-drawer__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
  }

  .global-search-drawer .global-search-drawer__label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink-3, #475569);
    letter-spacing: 0.02em;
  }

  .global-search-drawer .global-search-drawer__field input[type='search'] {
    width: 100%;
    min-height: 48px;
    padding: 12px 44px 12px 14px;
    font-size: 16px;
    line-height: 1.3;
    border-radius: 12px;
    border: 1px solid var(--rule-strong, #cbd5e1);
    background: var(--surface-card, #fff);
    color: var(--ink, #0f172a);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  }

  .global-search-drawer .global-search-drawer__field input[type='search']:focus-visible {
    outline: none;
    border-color: color-mix(in srgb, var(--brand, #c49510) 55%, var(--rule-strong, #cbd5e1));
    box-shadow:
      0 0 0 3px color-mix(in srgb, var(--brand, #c49510) 22%, transparent),
      0 1px 2px rgba(15, 23, 42, 0.06);
  }

  .global-search-drawer__actions {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .global-search-drawer__actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-weight: 600;
    border-radius: 12px;
  }

  html[data-theme='dark'] .global-search-drawer .drawer__panel {
    background: var(--surface-card, rgba(15, 23, 42, 0.98));
    box-shadow: -20px 0 56px rgba(0, 0, 0, 0.55);
  }

  html[data-theme='dark'] .global-search-drawer .drawer__header,
  html[data-theme='dark'] .global-search-drawer .global-search-drawer__header {
    border-bottom-color: rgba(148, 163, 184, 0.2);
  }

  html[data-theme='dark'] .global-search-drawer .global-search-drawer__title {
    color: var(--text, #e2e8f0);
  }

  html[data-theme='dark'] .global-search-drawer .global-search-drawer__label {
    color: var(--text-muted, #94a3b8);
  }

  html[data-theme='dark'] .global-search-drawer .global-search-drawer__field input[type='search'] {
    background: rgba(15, 23, 42, 0.75);
    border-color: rgba(148, 163, 184, 0.35);
    color: var(--text, #e2e8f0);
  }

  html[data-theme='dark'] .global-search-drawer .global-search-drawer__close:hover,
  html[data-theme='dark'] .global-search-drawer .global-search-drawer__close:focus-visible {
    background: rgba(30, 41, 59, 0.9);
    color: var(--text, #e2e8f0);
  }

  /* Hero KPI consistency: always stack copy + KPIs on mobile so KPI cards
     take the full hero width (avoids per-page drift). */
  :where(
    .rem-hero,
    .quote-hero,
    .properties-hero
  ) {
    flex-direction: column;
    align-items: stretch;
  }

  :where(
    .rem-hero__stats,
    .quote-hero__stats,
    .properties-hero__stats
  ) {
    width: 100%;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
  }

  :where(
    .rem-hero__stats,
    .quote-hero__stats,
    .properties-hero__stats
  ) > div {
    color: var(--hero-stat-text, #0f172a);
    background: var(--hero-stat-surface, color-mix(in srgb, currentColor 10%, transparent));
    border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
    border-radius: 16px;
    padding: 12px;
    text-align: center;
  }

  :where(
    .rem-hero__stats,
    .quote-hero__stats,
    .properties-hero__stats
  ) dt {
    margin: 0 0 4px 0;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--hero-stat-label, color-mix(in srgb, currentColor 72%, transparent));
  }

  :where(
    .rem-hero__stats,
    .quote-hero__stats,
    .properties-hero__stats
  ) dd {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--hero-stat-value, currentColor);
  }

  /* Top bar: keep one-row and minimal on mobile (avoid icon-grid wrap). */
  .top-bar {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    row-gap: 0;
    padding: 10px 12px;
    margin: -16px -16px 14px;
  }

  .top-bar-left {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-start;
    align-items: center;
  }

  .top-bar-logo img {
    max-height: 34px;
  }

  .top-bar-right {
    width: auto;
    min-width: 0;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .top-bar-actions {
    width: auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .top-bar-brand__name {
    font-size: 0.92rem;
  }

  .top-bar-actions > :not(.top-bar-search-trigger) {
    display: none !important;
  }

  .top-bar-link,
  .top-bar-offline {
    display: none !important;
  }
  .top-bar-actions .btn,
  .top-bar-actions .btn-primary-modern,
  .top-bar-actions .btn-secondary-outline {
    min-height: 44px;
  }
  /* Cards on mobile should mirror the desktop appearance. Use the same 
     spacing and shadows as the base styles, and avoid alternating 
     backgrounds so lists of cards appear consistent. */
  .card {
    border-radius: 12px;
    margin: 0;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--panel-shadow);
    background: var(--card);
  }

  :where(.content, .admin-shell) .card:last-child {
    margin-bottom: 0;
  }

  /* prevent alternating card backgrounds on mobile */
  .card:nth-of-type(even) {
    background: var(--card);
  }

	  /* keep wizard sections consistent with base style background */
	  .card--wizard .form-section {
	    background: #f5f7ff;
	  }

	  html[data-theme="dark"] .card--wizard .form-section {
	    background: rgba(15, 23, 42, 0.7);
	  }

	  .form-progress {
	    gap: 12px;
	  }

	  .form-progress__step span {
	    background: #fff;
	    color: var(--brand);
	  }

	  html[data-theme="dark"] .form-progress__step span {
	    background: rgba(15, 23, 42, 0.85);
	    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.28);
	    color: #93c5fd;
	  }

	  .card h3 {
	    font-size: 1rem;
	  }

  /* restore the top border and spacing for door sections on mobile. Matching 
     the desktop styling ensures the component checklist header stands out 
     consistently across devices. */
  .door-card__section {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
  }

  /* component rows should not alternate background colours on mobile; 
     align with base styling for clarity */
  .component-row {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    padding: 12px;
    margin-bottom: 10px;
  }

  .component-row:nth-of-type(even) {
    background: var(--card);
  }

  .timeline {
    padding-left: 48px;
    gap: 14px;
  }

  .timeline::before {
    left: 20px;
  }

  .timeline-item {
    padding: 16px;
  }

  .timeline-item__icon {
    left: -18px;
    top: 14px;
    width: 32px;
    height: 32px;
  }

  .timeline-item__meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .timeline-item__summary,
  .timeline-item__delta {
    flex-direction: column;
    gap: 6px;
  }

  /*
   * Responsive tables
   *
   * On narrow screens data tables can exceed the viewport width. Making
   * tables scrollable prevents layout breakage while preserving readability.
   */
  :where(
    .ipi-table-wrap,
    .table-wrapper,
    .table-responsive,
    .asset-door-table-wrapper,
    .asset-component-table-wrapper,
    .rem-board-table-wrapper
    
  ) {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-inline-size: 100%;
  }

  /* Avoid nested vertical scrolling on mobile; allow the page to flow. */

  /*
   * Table action menus (the "⋯" buttons) use absolutely-positioned dropdowns.
   * Mobile wrappers scroll horizontally via `overflow-x: auto` which also clips
   * vertical overflow in many browsers, hiding the dropdown. A small JS hook
   * toggles this class while a menu is open so the dropdown can escape.
   */
  :where(
    .ipi-table-wrap,
    .table-wrapper,
    .table-responsive,
    .asset-door-table-wrapper,
    .asset-component-table-wrapper,
    .rem-board-table-wrapper
    
  ).table-actions-menu-open {
    overflow: visible;
  }

  /* Hint that horizontal scrolling is available (iOS often hides scrollbars). */
  :where(
    .table-wrapper,
    .table-responsive,
    .asset-door-table-wrapper,
    .asset-component-table-wrapper,
    .rem-board-table-wrapper
    
  )::before,
  :where(
    .table-wrapper,
    .table-responsive,
    .asset-door-table-wrapper,
    .asset-component-table-wrapper,
    .rem-board-table-wrapper
    
  )::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 18px;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  :where(
    .table-wrapper,
    .table-responsive,
    .asset-door-table-wrapper,
    .asset-component-table-wrapper,
    .rem-board-table-wrapper
    
  )::before {
    left: 0;
    background: linear-gradient(90deg, rgba(15, 23, 42, 0.14), rgba(15, 23, 42, 0));
  }

  :where(
    .table-wrapper,
    .table-responsive,
    .asset-door-table-wrapper,
    .asset-component-table-wrapper,
    .rem-board-table-wrapper
    
  )::after {
    right: 0;
    background: linear-gradient(270deg, rgba(15, 23, 42, 0.14), rgba(15, 23, 42, 0));
  }

  :where(
    .table-wrapper,
    .table-responsive,
    .asset-door-table-wrapper,
    .asset-component-table-wrapper,
    .rem-board-table-wrapper
    
  ).table-scroll-hints--left::before {
    opacity: 0.9;
  }

  :where(
    .table-wrapper,
    .table-responsive,
    .asset-door-table-wrapper,
    .asset-component-table-wrapper,
    .rem-board-table-wrapper
    
  ).table-scroll-hints--right::after {
    opacity: 0.9;
  }

  :where(
    .table-wrapper table,
    .table-responsive table,
    .asset-door-table-wrapper table,
    .asset-component-table-wrapper table,
    .rem-board-table-wrapper table
  ) {
    inline-size: max-content;
    min-inline-size: 100%;
    max-inline-size: none;
  }

  /* Denser table rhythm reads better on phones. */
  :where(table th, table td) {
    padding: 10px 12px;
  }
}

/* === Mobile component/layout overrides (<= 768px) === */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .page-header__actions > * {
    width: 100%;
  }

  .page-header__actions .u-inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .page-header__actions .u-inline-form input,
  .page-header__actions .u-inline-form select,
  .page-header__actions .u-inline-form textarea {
    flex: 1 1 180px;
    min-width: 0;
  }

  .page-header__actions .u-inline-form button,
  .page-header__actions .u-inline-form .btn-primary-modern,
  .page-header__actions .u-inline-form .btn-secondary-outline,
  .page-header__actions .u-inline-form .btn-ghost {
    flex: 0 0 auto;
  }

body.modal-open {
		    overflow: hidden;
		}

.modal {
			    position: fixed;
			    inset: 0;
			    z-index: 2130;
			    display: flex;
			    align-items: center;
			    justify-content: center;
			    padding: 16px;
			    padding-top: calc(16px + env(safe-area-inset-top, 0px));
			    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
			}

.modal[hidden] {
    display: none;
}

.modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.modal__dialog {
					    position: relative;
					    z-index: 1;
					    background: var(--card);
					    border-radius: 16px;
					    width: min(560px, 100%);
					    max-block-size: 100%;
					    overflow: hidden;
					    display: flex;
					    flex-direction: column;
					    box-shadow: 0 25px 65px rgba(9, 41, 57, 0.18);
					}

  /* Component inspection guide modal (opened via the "i" buttons). */
  .component-guide-modal {
    align-items: center;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .component-guide-modal__dialog {
    border-radius: 16px;
    width: min(560px, 100%);
    max-height: 100%;
    box-shadow: 0 25px 65px rgba(9, 41, 57, 0.18);
  }

  .component-guide-modal__header {
    padding: 14px 16px 12px;
  }

  .component-guide-modal__body {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .component-guide-modal__close {
    top: 10px;
    right: 10px;
    inline-size: 44px;
    block-size: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

.modal__header {
	    display: flex;
	    align-items: center;
	    justify-content: space-between;
	    gap: 0.75rem;
	    padding: 14px 16px;
	    margin: 0;
		    border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
		    background: var(--card);
		    position: sticky;
		    top: 0;
		    z-index: 2;
}

.modal__close {
		    border: none;
		    background: transparent;
		    font-size: 1.5rem;
		    inline-size: 44px;
		    block-size: 44px;
		    display: inline-flex;
		    align-items: center;
		    justify-content: center;
		}

.modal__body {
	    padding: 16px;
	    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	    overflow-y: auto;
	    -webkit-overflow-scrolling: touch;
	    flex: 1 1 auto;
	    min-block-size: 0;
}

.modal__body:not(form) {
	    display: flex;
	    flex-direction: column;
	    gap: 1rem;
}

.modal__footer {
		    padding: 12px 16px;
		    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
			    border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
			    background: var(--card);
			    flex: 0 0 auto;
	}

  /* Modal sizing, animation, and bottom-sheet alignment on mobile are owned
     by the canonical full-screen rule in style.css
     (`@media (max-width: 900px) .modal.modal--sheet {...}`). Page-specific
     mobile.css blocks for guided-tour-picker, modal--sheet generic, and
     theme-picker have been removed — all modals are now full-screen on
     mobile. Content layout (theme tiles, grid columns, etc.) lives in the
     owning page's CSS. */

  /* Theme picker: content layout only (single-column tiles at mobile). */
  .modal.theme-picker-modal .theme-picker-modal__grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .modal.theme-picker-modal .theme-picker-modal__tile {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    min-height: 56px;
    padding: 12px 14px;
    border-radius: 14px;
  }

  .modal.theme-picker-modal .theme-picker-modal__swatch {
    width: 40px;
    height: 40px;
    min-width: 40px;
    flex-shrink: 0;
  }

  .modal.theme-picker-modal .theme-picker-modal__tile-label {
    font-size: 0.95rem;
  }

  .modal.theme-picker-modal .theme-picker-modal__tile-hint {
    font-size: 0.8rem;
  }

  .modal.guided-tour-picker-modal .guided-tour-picker__advanced {
    margin-top: 12px;
  }

  /* When a modal is open, prevent fixed mobile shortcuts from stealing taps. */
	body.modal-open .mobile-nav-trigger,
	body.modal-open .mobile-nav-overlay {
  pointer-events: none;
  opacity: 0;
}

/* Make checkbox/radio targets easier to hit inside modals on touch devices. */
.modal :where(input[type="checkbox"], input[type="radio"]) {
  inline-size: 20px;
  block-size: 20px;
  min-inline-size: 20px;
  min-block-size: 20px;
  accent-color: var(--brand, #0052cc);
}

.modal :where(label > input[type="checkbox"], label > input[type="radio"]) {
  vertical-align: middle;
  margin-right: 10px;
}

  .pricing-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.pricing-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pricing-table__actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-small {
    font-size: 12px;
    padding: 6px 12px;
    min-height: 34px;
}

.text-danger {
    color: #b42318;
}

.pricing-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pricing-form__footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pricing-reason-add {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.pricing-import-label {
    position: relative;
    overflow: hidden;
}

.pricing-import-label input {
    position: absolute;
    inset: 0;
    opacity: 0;
}

.modal__actions {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    margin-top: 1rem;
}

.status-pill--success {
    background: rgba(10, 135, 84, 0.15);
    color: var(--success);
}

	.status-pill--muted {
	    background: #f3f4f6;
	    color: #475467;
	}

	html[data-theme="dark"] .status-pill--muted {
	    background: rgba(148, 163, 184, 0.14);
	    color: var(--text-muted);
	}
.color-chip {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: var(--chip-color, #cbd5f5);
}

.btn-reset {
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    align-self: flex-start;
}



	}

/* Responsive rules migrated from style.css (mobile-only). */
@media (max-width: 1024px) {
  .layout-columns-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .layout-columns-2,
  .layout-columns-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .hide-on-mobile {
    display: none !important;
  }

  .show-on-mobile {
    display: block !important;
  }

  .show-on-mobile.btn,
  .show-on-mobile.btn-primary-modern,
  .show-on-mobile.btn-secondary-outline,
  .show-on-mobile.btn-sm-modern,
  .show-on-mobile.btn-small {
    display: inline-flex !important;
  }

  .order-mobile-first {
    order: -1;
  }

  .sidebar-brand img {
    max-width: 80px;
    max-height: 48px;
    width: auto;
    height: auto;
  }

  .sidebar-brand {
    display: none;
  }

  .top-bar {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    row-gap: 0;
    margin: -16px -16px 14px;
  }

  .top-bar-left {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-start;
  }

  .top-bar-right {
    width: auto;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 8px;
    row-gap: 0;
  }

  .top-bar-search {
    width: 100%;
  }

  /* Top bar: avoid a full-width search field on mobile; use a drawer instead. */
  .top-bar-search {
    display: none;
  }

  .top-bar-actions {
    gap: 8px;
  }

  .top-bar-search-trigger {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  .top-bar-user {
    max-width: 100%;
  }

  @media (max-width: 480px) {
    .top-bar-user {
      max-width: none;
      padding: 0 8px;
    }

    .top-bar-user-meta {
      display: none;
    }

    .top-bar-user-name::after {
      display: none;
    }

    .top-bar-brand__name {
      font-size: 0.88rem;
    }

    .top-bar-user::after {
      content: '';
      display: inline-block;
      border-width: 5px 5px 0 5px;
      border-style: solid;
      border-color: rgba(148, 163, 184, 0.9) transparent transparent transparent;
      transform: translateY(1px);
      margin-left: 6px;
    }
  }

  .app-notifications {
    align-items: flex-end;
  }

  .app-notifications__panel {
    width: 100%;
    max-width: none;
    max-height: min(78vh, 640px);
    margin: 0;
    border-radius: 16px 16px 0 0;
  }

  .component-checklist-header,
  .components-modal__header,
  .component-checklist-meta,
  .component-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .component-checklist-actions,
  .components-modal__header-actions {
    justify-content: flex-start;
  }

  .component-controls {
    width: 100%;
  }

  .component-search {
    width: 100%;
  }

  .component-search input {
    width: 100%;
  }




.guided-tour {
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px) + var(--guided-tour-offset-bottom, 0px));
  width: auto;
}

.guided-tour.guided-tour--top {
  top: calc(12px + env(safe-area-inset-top, 0px));
  bottom: auto;
  left: 12px;
  right: auto;
  width: min(420px, calc(100vw - 24px));
}

.guided-tour__menu-panel {
  left: 0;
  right: auto;
  width: min(220px, calc(100vw - 24px));
}

.guided-tour__eyebrow {
  letter-spacing: 0.06em;
}

  /* Touch-friendly tour chrome: ~44px targets; manipulation avoids double-tap zoom delay. */
  .guided-tour .guided-tour__icon-btn {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    touch-action: manipulation;
  }

  .guided-tour .guided-tour__pill-btn {
    min-height: 44px;
    touch-action: manipulation;
  }

/* Minimised: one compact row — summary + controls (inherits row layout from style.css). */
.guided-tour.guided-tour--min {
  left: auto;
  right: 12px;
  width: auto;
  max-width: calc(100vw - 24px);
  min-width: 0;
  padding: 6px 6px 6px 8px;
  border-radius: 14px;
  gap: 4px;
}

.guided-tour.guided-tour--min .guided-tour__meta {
  display: none;
}

.guided-tour.guided-tour--min .guided-tour__header {
  justify-content: flex-end;
  gap: 4px;
}

.guided-tour.guided-tour--min .guided-tour__header-actions {
  gap: 4px;
}

.guided-tour.guided-tour--min .guided-tour__icon-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 10px;
}

.guided-tour.guided-tour--min .guided-tour__pill {
  margin-top: 0 !important;
}

.guided-tour.guided-tour--min .guided-tour__pill-btn {
  min-height: 40px;
  padding: 6px 8px;
  gap: 6px;
}

.guided-tour.guided-tour--min .guided-tour__pill-title {
  font-size: 0.8rem;
  line-height: 1.25;
}

.guided-tour.guided-tour--min .guided-tour__pill-progress {
  font-size: 0.72rem;
}

  /* Beat flex/display rules on small screens so minimise actually collapses the panel. */
  .guided-tour.guided-tour--min .guided-tour__content,
  .guided-tour.guided-tour--min .guided-tour__footer,
  .guided-tour.guided-tour--min .guided-tour__hint {
    display: none !important;
  }

  .guided-tour.guided-tour--min .guided-tour__pill {
    display: block !important;
  }

.guided-tour__actions {
  flex-direction: column;
  align-items: stretch;
}

.guided-tour__nav {
  width: 100%;
}

.guided-tour__nav :where(.btn, .btn-secondary-outline, .btn-primary-modern) {
  flex: 1;
}

.guided-tour__actions > :where(.btn, .btn-secondary-outline, .btn-primary-modern),
.guided-tour__actions > :where(a.btn, a.btn-secondary-outline, a.btn-primary-modern) {
  width: 100%;
}

.guided-tour--first-win {
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  width: auto;
  max-height: min(78vh, 640px);
  padding: 0;
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.guided-tour--first-win .guided-tour__content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  flex: 1 1 auto;
}

.guided-tour--first-win .guided-tour__header {
  align-items: flex-start;
}

.guided-tour--first-win .guided-tour__header-actions {
  flex: 0 0 auto;
}

.guided-tour--first-win .guided-tour__step {
  font-size: 0.95rem;
  line-height: 1.5;
}

.guided-tour--first-win .guided-tour__nav {
  grid-template-columns: 1fr;
}

.guided-tour--first-win .guided-tour__close-btn {
  width: 38px;
  height: 38px;
}

.modal.guided-tour-modal--first-win {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

.modal.guided-tour-modal--first-win .modal__dialog {
  width: 100%;
  height: 100%;
  max-block-size: 100%;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

.modal.guided-tour-modal--first-win .modal__header {
  padding: calc(14px + env(safe-area-inset-top, 0px)) 14px 10px;
  flex: 0 0 auto;
}

.modal.guided-tour-modal--first-win .modal__header h3 {
  font-size: 1.2rem;
  line-height: 1.25;
}

.modal.guided-tour-modal--first-win .modal__body {
  flex: 1 1 auto;
  min-block-size: 0;
  padding: 10px 14px 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal.guided-tour-modal--first-win .modal__footer {
  position: static;
  flex: 0 0 auto;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--card, #ffffff) 98%, rgba(239, 246, 255, 0.3));
}

.modal.guided-tour-modal--first-win .modal__footer .btn-primary-modern,
.modal.guided-tour-modal--first-win .modal__footer .btn-secondary-outline {
  width: 100%;
}

.guided-tour-first-win__hero {
  padding: 14px;
  border-radius: 18px;
}

.guided-tour-first-win__eyebrow {
  margin-bottom: 4px;
}

.guided-tour-first-win__hero h4 {
  font-size: 1rem;
  line-height: 1.3;
}

.guided-tour-first-win__copy {
  font-size: 0.9rem;
  line-height: 1.45;
}

.guided-tour-first-win__meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.guided-tour-first-win__meta-pill {
  justify-content: flex-start;
  min-height: 30px;
  padding: 5px 10px;
  text-align: left;
}

.guided-tour-first-win__options {
  gap: 10px;
}

.guided-tour-first-win-card {
  padding: 14px;
  border-radius: 16px;
}

.guided-tour-first-win-card::after {
  top: 12px;
  right: 12px;
}

.guided-tour-first-win-card__title {
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 5px;
}

.guided-tour-first-win-card__icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
}

.guided-tour-first-win-card__icon svg {
  width: 16px;
  height: 16px;
}

.guided-tour-first-win-card__meta,
.guided-tour-first-win-card__steps {
  font-size: 0.82rem;
}

.gu
