/* Aurora v1.10.0 premium mobile visual system — feature locked 31 July 2026 */
:root {
  color-scheme: light;
  --background: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-blue: #eef5ff;
  --surface-amber: #fff8e7;
  --surface-green: #edf8f0;
  --surface-red: #fff0f0;
  --text: #0d1b2a;
  --text-soft: #314158;
  --muted: #68768a;
  --line: #dfe5ec;
  --line-strong: #cbd5e1;
  --primary: #1976d2;
  --primary-dark: #125ca7;
  --primary-soft: #e4f0ff;
  --primary-pressed: #0f4f91;
  --on-primary: #ffffff;
  --success: #2e7d32;
  --success-soft: #eaf6ec;
  --warning: #c66a00;
  --warning-soft: #fff3d6;
  --danger: #d32f2f;
  --danger-soft: #ffebee;
  --navy: #0d1b2a;
  --shadow-xs: 0 1px 2px rgba(13, 27, 42, .05);
  --shadow-sm: 0 3px 12px rgba(13, 27, 42, .08);
  --shadow-md: 0 10px 30px rgba(13, 27, 42, .13);
  --shadow-lg: 0 24px 70px rgba(13, 27, 42, .22);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --topbar-height: 88px;
  --nav-height: 72px;
  --content-max: 760px;
  font-family: Roboto, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; background: var(--background); color: var(--text); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overscroll-behavior-y: contain; }
button, input, textarea, select { font: inherit; }
button { touch-action: manipulation; }
a { color: var(--primary); }
h1, h2, h3, h4, p { overflow-wrap: anywhere; }
h1, h2, h3, h4 { color: var(--text); }

.hidden { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.muted { color: var(--muted); }
.fatal { max-width: 560px; margin: 48px auto; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow-md); }
#reactRoot, .react-application-root, .react-region { display: contents; }

.ui-icon { display: inline-block; flex: 0 0 auto; fill: currentColor; vertical-align: middle; }

button:focus-visible,
.button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(25, 118, 210, .32);
  outline-offset: 2px;
}

/* Installation and authentication gates */
.overlay { position: fixed; inset: 0; z-index: 100; display: grid; align-items: end; justify-items: center; padding: 16px 16px 0; background: rgba(7, 20, 38, .72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.overlay:not(.hidden) + .overlay { visibility: hidden; }
.gate-card { width: min(430px, 100%); max-height: 94dvh; overflow: auto; padding: 30px 24px calc(30px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-lg); }
.brand-mark { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; color: #fff; background: linear-gradient(145deg, #2585e8, #0d57b5); box-shadow: 0 14px 28px rgba(25, 118, 210, .28); }
.eyebrow, .section-kicker { margin: 0 0 4px; color: var(--primary); font-size: .69rem; font-weight: 800; letter-spacing: .09em; line-height: 1.2; text-transform: uppercase; }
.gate-card > .eyebrow { margin-top: 16px; }
.gate-card h1 { margin: 0; font-size: 1.72rem; line-height: 1.2; }
.supporting { color: var(--muted); font-size: .92rem; line-height: 1.55; }
.steps { padding-left: 22px; color: var(--muted); line-height: 1.65; }
.install-status { min-height: 2.5em; margin: 14px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.install-bypass-disclosure { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }
.install-bypass-disclosure summary { cursor: pointer; text-align: center; font-weight: 750; }
.install-bypass-disclosure p { text-align: center; }
.quiet-link { display: block; margin: 10px auto 0; border: 0; background: transparent; color: var(--muted); text-decoration: underline; }

/* Form system */
label { display: grid; gap: 7px; color: var(--text-soft); font-size: .86rem; font-weight: 700; }
label small { color: var(--muted); font-size: .74rem; font-weight: 500; line-height: 1.4; }
input, textarea, select { width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-md); outline: 0; background: var(--surface); color: var(--text); transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }
input::placeholder, textarea::placeholder { color: #8d99a8; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(25, 118, 210, .12); }
input:disabled, textarea:disabled, select:disabled { background: #edf1f5; color: #58687d; cursor: not-allowed; }
textarea { min-height: 104px; resize: vertical; }
fieldset { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); }
legend { padding: 0 7px; color: var(--text-soft); font-size: .8rem; font-weight: 800; }
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row input { width: 20px; min-height: 20px; }
.form-error { min-height: 1em; margin: 4px 0; color: var(--danger); font-size: .82rem; }
.field-grid { display: grid; gap: 12px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compact-label, .compact-field { min-width: 0; }

/* Buttons */
.button, .icon-button, .status-button, .clear-filter { border: 0; cursor: pointer; -webkit-user-select: none; user-select: none; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border: 1px solid transparent; border-radius: var(--radius-pill); background: var(--surface); color: var(--text); font-weight: 750; line-height: 1.15; text-align: center; text-decoration: none; transition: transform .12s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease; }
.button:active { transform: scale(.975); }
.button.primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 16px rgba(25, 118, 210, .22); }
.button.primary:hover { background: var(--primary-dark); }
.button.primary:active { background: var(--primary-pressed); }
.button.secondary { border-color: var(--line-strong); background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); }
.button.secondary:hover { background: var(--primary-soft); border-color: #bad5f1; }
.button.danger { background: var(--danger); color: #fff; }
.button.small { min-height: 40px; padding: 8px 14px; font-size: .82rem; }
.button.wide { width: 100%; margin-top: 12px; }
.load-more { width: 100%; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; height: 48px; padding: 0; border-radius: 50%; background: transparent; color: inherit; transition: transform .12s ease, background .15s ease; }
.icon-button:hover { background: rgba(255, 255, 255, .12); }
.icon-button:active { transform: scale(.92); }
.primary-icon { background: #fff; color: var(--primary); box-shadow: 0 5px 14px rgba(0, 48, 112, .22); }
.primary-icon:hover { background: #f6fbff; }

/* Application shell */
.app-shell { width: 100%; max-width: var(--content-max); min-height: 100dvh; margin: 0 auto; background: var(--background); }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: var(--topbar-height); padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 14px; color: #fff; background: linear-gradient(150deg, #1162bb 0%, #1976d2 57%, #0d56ad 100%); box-shadow: 0 6px 22px rgba(8, 63, 124, .22); }
.topbar::after { content: ""; position: absolute; inset: auto 0 0; height: 22px; pointer-events: none; opacity: .2; background: radial-gradient(120% 42px at 20% 100%, #8fc9ff 0 47%, transparent 49%), radial-gradient(90% 38px at 78% 100%, #6bb7ff 0 46%, transparent 48%); }
.topbar-brand, .header-actions { position: relative; z-index: 1; display: flex; align-items: center; }
.topbar-brand { min-width: 0; gap: 10px; }
.app-mark { display: grid; flex: 0 0 auto; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: rgba(255, 255, 255, .16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .17); }
.title-block { min-width: 0; }
.title-block .eyebrow { margin: 0 0 1px; color: rgba(255, 255, 255, .82); font-size: .68rem; }
.topbar h1 { margin: 0; color: #fff; font-size: 1.15rem; font-weight: 780; line-height: 1.1; white-space: nowrap; }
.header-actions { gap: 4px; }
.topbar-icon { color: #fff; }
.status-button { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 7px 10px; border-radius: var(--radius-pill); background: rgba(255, 255, 255, .95); color: var(--navy); font-size: .72rem; font-weight: 800; box-shadow: 0 4px 12px rgba(0, 48, 112, .18); }
.status-button .ui-icon { color: var(--primary); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #8996a6; box-shadow: 0 0 0 2px rgba(137, 150, 166, .15); }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 2px rgba(46, 125, 50, .16); }
.status-dot.syncing { background: #f5a000; animation: pulse 1s ease-in-out infinite; }
.status-dot.warning, .status-dot.error { background: var(--danger); }
.notification-badge { position: absolute; top: 1px; right: 1px; display: grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border: 2px solid var(--primary); border-radius: 10px; background: var(--danger); color: #fff; font-size: .65rem; font-weight: 800; }
@keyframes pulse { 50% { opacity: .38; transform: scale(.88); } }

main { min-width: 0; }
.view { display: none; padding: 14px 12px calc(var(--nav-height) + 24px + env(safe-area-inset-bottom, 0px)); }
.view.active { display: block; }
.view-heading, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.view-heading { margin: 4px 2px 14px; }
.view-heading h2, .section-head h2, .section-head h3 { margin: 0; }
.view-heading > span, .summary-status { color: var(--muted); font-size: .76rem; font-weight: 750; }
.section-head.flush { margin: 0 0 12px; }
.section-head { margin-top: 18px; }
.section-head h3 { font-size: 1rem; }

/* Inventory overview */
.overview-card { margin-bottom: 12px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-sm); }
.overview-card h2 { margin: 0; font-size: 1rem; }
.summary-status { padding: 5px 9px; border-radius: var(--radius-pill); background: var(--success-soft); color: var(--success); }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.summary-grid article { position: relative; min-width: 0; padding: 12px 8px; border: 1px solid #edf0f4; border-radius: var(--radius-md); background: var(--surface); text-align: center; }
.summary-grid article .ui-icon { margin-bottom: 4px; color: var(--primary); }
.summary-grid article.attention { border-color: #f6d79f; background: var(--surface-amber); }
.summary-grid article.attention .ui-icon, .summary-grid article.attention strong { color: var(--warning); }
.summary-grid article.pending { border-color: #bcd9f4; background: var(--surface-blue); }
.summary-grid strong { display: block; color: var(--text); font-size: 1.12rem; font-variant-numeric: tabular-nums; line-height: 1.15; }
.summary-grid span { display: block; margin-top: 3px; color: var(--muted); font-size: .64rem; line-height: 1.2; }

/* Search and filter controls */
.sticky-tools { position: sticky; top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px)); z-index: 20; }
.stock-search-panel { margin: 0 -2px 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(255, 255, 255, .97); box-shadow: var(--shadow-sm); }
.search-row, .filter-row, .toolbar { display: flex; align-items: center; gap: 8px; }
.search-row { margin-bottom: 9px; }
.search-field { position: relative; display: flex; flex: 1 1 auto; align-items: center; min-width: 0; }
.search-field > .ui-icon { position: absolute; left: 13px; z-index: 1; color: var(--muted); pointer-events: none; }
.search-field input { padding-left: 41px; background: var(--surface-soft); }
.scan-button { flex: 0 0 auto; min-width: 84px; padding-inline: 14px; }
.filter-row { overflow-x: auto; padding-bottom: 1px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row select { flex: 0 0 auto; width: auto; min-width: 118px; max-width: 170px; min-height: 38px; padding: 7px 30px 7px 11px; border-radius: var(--radius-pill); background-color: #f1f4f7; font-size: .74rem; }
.filter-label { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 5px; color: var(--primary); font-size: .74rem; font-weight: 800; }
.clear-filter { flex: 0 0 auto; padding: 8px 4px; background: transparent; color: var(--primary); font-size: .73rem; font-weight: 800; white-space: nowrap; }
.list-toolbar { margin-bottom: 12px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(255, 255, 255, .97); box-shadow: var(--shadow-xs); }
.list-context { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 4px 8px; color: var(--muted); font-size: .7rem; }
.result-count { margin: 0; color: var(--text-soft); font-size: .78rem; font-weight: 750; }

/* Record cards */
.card-list, .stack { display: grid; gap: 11px; }
.record-card { position: relative; overflow: hidden; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .12s ease, box-shadow .15s ease; }
.record-card:active { transform: scale(.994); }
.record-card.low { border-color: #f2cc83; box-shadow: var(--shadow-sm), inset 4px 0 0 var(--warning); }
.record-card.out { border-color: #efb4b4; box-shadow: var(--shadow-sm), inset 4px 0 0 var(--danger); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-top h2, .card-top h3 { margin: 0 0 3px; font-size: .96rem; line-height: 1.25; }
.card-subtitle { color: var(--muted); font-size: .74rem; line-height: 1.45; }
.badge-stack { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 5px; }
.badge, .status-chip { display: inline-flex; align-items: center; justify-content: center; min-height: 25px; padding: 4px 8px; border-radius: var(--radius-pill); background: var(--primary-soft); color: var(--primary); font-size: .65rem; font-weight: 800; line-height: 1.1; white-space: nowrap; }
.badge.warning-badge, .status-chip.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger-badge { background: var(--danger-soft); color: var(--danger); }
.badge.success-badge, .status-chip.success { background: var(--success-soft); color: var(--success); }
.pending-badge, .status-chip.pending { background: var(--primary-soft); color: var(--primary); }
.product-identity, .customer-identity, .quote-identity { display: flex; min-width: 0; align-items: center; gap: 10px; }
.product-thumb, .record-icon, .avatar { display: grid; flex: 0 0 auto; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--primary-soft); color: var(--primary); }
.avatar { border-radius: 50%; background: linear-gradient(145deg, #dceeff, #eef6ff); font-size: .78rem; font-weight: 900; }
.card-chevron, .menu-chevron { color: #9aa6b5; }

.stock-control { display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; align-items: center; gap: 12px; margin: 15px 0 9px; }
.stock-step { display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border: 1px solid #9ec8ee; border-radius: 50%; background: #fff; color: var(--primary); box-shadow: 0 5px 12px rgba(25, 118, 210, .12); transition: transform .12s ease, background .15s ease; }
.stock-step.plus { background: var(--primary); color: #fff; border-color: var(--primary); }
.stock-step:active { transform: scale(.9); }
.stock-number { min-width: 0; padding: 4px 8px; border: 0; background: transparent; color: var(--text); text-align: center; }
.stock-number strong { display: block; font-size: 2.15rem; font-weight: 820; font-variant-numeric: tabular-nums; line-height: .98; letter-spacing: -.04em; }
.stock-number span { display: block; margin-top: 4px; color: var(--muted); font-size: .69rem; }
.record-details { margin: 3px -2px 0; border-top: 1px solid var(--line); }
.record-details summary { display: flex; align-items: center; justify-content: space-between; min-height: 42px; padding: 8px 4px 4px; color: var(--text-soft); cursor: pointer; font-size: .75rem; font-weight: 750; list-style: none; }
.record-details summary::-webkit-details-marker { display: none; }
.record-details summary .ui-icon { transition: transform .15s ease; }
.record-details[open] summary .ui-icon { transform: rotate(90deg); }
.card-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-top: 10px; }
.compact-details { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }
.detail-cell { min-width: 0; }
.detail-cell span { display: block; margin-bottom: 2px; color: var(--muted); font-size: .66rem; }
.detail-cell b { display: block; color: var(--text-soft); font-size: .79rem; line-height: 1.35; word-break: break-word; }
.card-actions { display: flex; gap: 7px; margin-top: 12px; }
.card-actions .button { flex: 1 1 0; min-width: 0; min-height: 42px; padding: 8px 10px; font-size: .75rem; }
.quote-value { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 5px; }
.quote-value > b { color: var(--text); font-size: 1rem; font-variant-numeric: tabular-nums; }

.empty-state { padding: 68px 22px; color: var(--muted); text-align: center; }
.empty-state h2, .empty-state h3 { margin: 14px 0 5px; }
.empty-state p { margin: 0 0 16px; line-height: 1.5; }
.empty-icon { display: grid; place-items: center; width: 70px; height: 70px; margin: 0 auto; border-radius: 22px; background: var(--primary-soft); color: var(--primary); }

/* Bottom navigation */
.bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 40; display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 5px 2px calc(5px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: rgba(255, 255, 255, .98); box-shadow: 0 -5px 20px rgba(13, 27, 42, .08); }
.bottom-nav button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; padding: 5px 3px; border: 0; background: transparent; color: var(--muted); font-weight: 700; }
.bottom-nav button::before { content: ""; position: absolute; top: 5px; left: 50%; width: 52px; height: 30px; border-radius: var(--radius-pill); background: transparent; transform: translateX(-50%); transition: background .15s ease; }
.bottom-nav button .nav-icon, .bottom-nav button b { position: relative; z-index: 1; }
.bottom-nav button b { font-size: .66rem; }
.bottom-nav button.active { color: var(--primary); }
.bottom-nav button.active::before { background: var(--primary-soft); }

/* More menu */
.menu-list { display: grid; gap: 16px; }
.menu-group { display: grid; gap: 8px; }
.menu-group > h3 { margin: 0 4px 3px; color: var(--muted); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; }
.menu-group > button { display: grid; grid-template-columns: 44px minmax(0, 1fr) 22px; align-items: center; gap: 11px; min-height: 68px; padding: 10px 13px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); text-align: left; box-shadow: var(--shadow-xs); transition: transform .12s ease, background .15s ease; }
.menu-group > button:active { transform: scale(.987); background: var(--surface-soft); }
.menu-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--primary-soft); color: var(--primary); }
.menu-copy { min-width: 0; }
.menu-copy b, .menu-copy small { display: block; }
.menu-copy b { font-size: .88rem; }
.menu-copy small { margin-top: 3px; color: var(--muted); font-size: .7rem; line-height: 1.3; }

/* Tool surfaces */
.tool-area { margin-top: 14px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-sm); }
.tool-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.tool-title { display: flex; align-items: center; gap: 10px; }
.tool-title .record-icon { width: 40px; height: 40px; }
.tool-head h2 { margin: 0; font-size: 1.15rem; }
.tool-head .icon-button { color: var(--muted); }
.notice { padding: 12px 14px; border: 1px solid #cfe2f6; border-radius: var(--radius-md); background: var(--surface-blue); color: var(--text-soft); font-size: .8rem; line-height: 1.5; }
.notice.warning { border-color: #f0d399; background: var(--warning-soft); color: #805000; }
.notice.error { border-color: #efb8b8; background: var(--danger-soft); color: var(--danger); }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.metric { min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-soft); }
.metric span, .metric b { display: block; }
.metric span { color: var(--muted); font-size: .68rem; }
.metric b { margin-top: 3px; color: var(--text); font-size: .94rem; font-variant-numeric: tabular-nums; }
.composer-card, .filter-card { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.composer-card > summary, .filter-card > summary { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 12px 14px; color: var(--text); cursor: pointer; font-size: .85rem; font-weight: 800; list-style: none; }
.composer-card > summary::-webkit-details-marker, .filter-card > summary::-webkit-details-marker { display: none; }
.composer-card[open] > summary, .filter-card[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.composer-card > .stack, .filter-card > .stack { padding: 14px; }

/* CRM */
.crm-shell, .ledger-shell { display: grid; gap: 13px; }
.crm-overview { display: grid; gap: 10px; }
.crm-reminder-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.crm-reminder-grid .metric { padding: 10px 7px; text-align: center; }
.crm-reminder-grid .metric.overdue { border-color: #efb8b8; background: var(--danger-soft); }
.crm-reminder-grid .metric.due { border-color: #f0d399; background: var(--warning-soft); }
.crm-reminder-grid .metric.completed { border-color: #baddbd; background: var(--success-soft); }
.timeline { position: relative; display: grid; gap: 0; padding-left: 4px; }
.timeline::before { content: ""; position: absolute; top: 19px; bottom: 19px; left: 24px; width: 2px; background: #dbe4ee; }
.timeline-item { position: relative; display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 10px; padding: 8px 0; }
.timeline-marker { position: relative; z-index: 1; display: grid; place-items: center; width: 40px; height: 40px; border: 4px solid var(--surface); border-radius: 50%; background: var(--primary); color: #fff; box-shadow: 0 0 0 1px #c9d8e8; }
.timeline-marker.reminder { background: #cf7900; }
.timeline-marker.overdue { background: var(--danger); }
.timeline-marker.completed, .timeline-marker.purchase { background: var(--success); }
.timeline-marker.cancelled { background: #7c8795; }
.timeline-content { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-xs); }
.timeline-content .card-top h3 { font-size: .86rem; }
.timeline-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px 10px; margin-top: 8px; color: var(--muted); font-size: .67rem; }
.timeline-content p { margin: 9px 0; color: var(--text-soft); font-size: .8rem; line-height: 1.5; }

/* Ledger */
.ledger-overview { padding: 15px; border-radius: var(--radius-xl); background: linear-gradient(145deg, #f8fbff, #ffffff); border: 1px solid #cfe0f2; box-shadow: var(--shadow-sm); }
.ledger-overview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ledger-overview-head h3 { margin: 0; font-size: 1rem; }
.ledger-financial-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.financial-metric { min-width: 0; padding: 12px 8px; border-right: 1px solid var(--line); text-align: center; }
.financial-metric:last-child { border-right: 0; }
.financial-metric span { display: block; color: var(--muted); font-size: .66rem; }
.financial-metric b { display: block; margin-bottom: 4px; font-size: 1rem; font-variant-numeric: tabular-nums; }
.financial-metric.income b { color: var(--success); }
.financial-metric.cost b { color: var(--danger); }
.financial-metric.net b { color: #0b58b0; }
.balance-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.balance-row .metric { text-align: center; }
.transaction-list { display: grid; gap: 8px; }
.transaction-card { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto 20px; align-items: center; gap: 10px; min-height: 74px; padding: 10px 8px 10px 10px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-xs); }
.transaction-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--success); color: #fff; }
.transaction-icon.cost, .transaction-icon.refund { background: var(--danger); }
.transaction-main { min-width: 0; }
.transaction-main h3 { margin: 0 0 3px; font-size: .83rem; }
.transaction-amount { text-align: right; }
.transaction-amount b { display: block; font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.transaction-amount.income b { color: var(--success); }
.transaction-amount.cost b { color: var(--danger); }
.transaction-amount small { display: block; margin-top: 3px; color: var(--muted); font-size: .64rem; white-space: nowrap; }
.transaction-chevron { color: #9aa6b5; }

/* Dialogs and full-height mobile sheets */
.app-dialog { width: min(680px, 100%); max-width: 100%; max-height: 94dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.app-dialog::backdrop { background: rgba(7, 20, 38, .68); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.app-dialog > form, .app-dialog > section { max-height: 94dvh; overflow: auto; padding: 19px 17px calc(18px + env(safe-area-inset-bottom, 0px)); }
.wide-dialog { width: min(780px, 100%); }
.dialog-head { position: sticky; top: -19px; z-index: 4; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: -1px -2px 14px; padding: 7px 2px 10px; background: var(--surface); border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 1.12rem; }
.dialog-head .icon-button { color: var(--muted); }
.dialog-actions { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom, 0px)); z-index: 4; display: flex; align-items: center; gap: 8px; margin-top: 18px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: rgba(255, 255, 255, .98); }
.dialog-actions .spacer { flex: 1; }
.customer-details-card, .totals-card, .quote-line { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-soft); }
.customer-details-card { margin-top: 8px; padding: 12px; }
.quote-lines { display: grid; gap: 9px; }
.quote-line { display: grid; grid-template-columns: minmax(160px, 2fr) 78px 105px 44px; gap: 8px; align-items: end; padding: 10px; }
.quote-line label { font-size: .72rem; }
.line-total { grid-column: 1 / -1; color: var(--muted); font-size: .76rem; text-align: right; }
.remove-line { height: 48px; border: 1px solid #efb8b8; border-radius: var(--radius-md); background: var(--danger-soft); color: var(--danger); font-weight: 900; }
.totals-card { display: grid; gap: 9px; margin-top: 14px; padding: 14px; }
.totals-card > div { display: flex; align-items: center; justify-content: space-between; }
.totals-card label { grid-template-columns: 1fr 140px; align-items: center; }
.grand-total { padding-top: 10px; border-top: 1px solid var(--line); font-size: 1.08rem; }
.scanner-frame { position: relative; overflow: hidden; aspect-ratio: 4 / 3; border-radius: var(--radius-lg); background: #0b1220; }
.scanner-frame video { width: 100%; height: 100%; object-fit: cover; }
.scan-guide { position: absolute; inset: 25%; border: 2px solid #7db0ff; border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .25); }

/* Notifications, audit, imports and admin */
.notification-list { display: grid; gap: 9px; }
.notification-item { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.notification-item.unread { background: var(--surface-blue); }
.notification-item h3 { margin: 0 0 4px; font-size: .88rem; }
.notification-item p, .notification-item time { margin: 0; color: var(--muted); font-size: .75rem; }
.audit-shell { overflow: hidden; border: 1px solid #263a55; border-radius: var(--radius-lg); background: #101b2b; }
.audit-controls { display: flex; align-items: center; gap: 7px; padding: 9px; background: #17263a; }
.audit-controls b { margin-right: auto; color: #fff; }
.audit-window { height: 280px; overflow: auto; padding: 11px; color: #d7e2f0; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.audit-window.minimised { height: 0; padding: 0; }
.audit-entry { padding: 6px 0; border-bottom: 1px solid #263a55; }
.audit-entry time { color: #7da9df; }
.import-preview { max-height: 310px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-md); }
.data-table { width: 100%; border-collapse: collapse; font-size: .74rem; }
.data-table th, .data-table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.data-table th { position: sticky; top: 0; background: #f3f6fa; }
.drop-zone { padding: 24px; border: 2px dashed #b8c7db; border-radius: var(--radius-lg); background: var(--surface-soft); text-align: center; }
.admin-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding: 17px; border-radius: var(--radius-xl); background: var(--navy); color: #fff; }
.admin-banner h2, .admin-banner .eyebrow { color: #fff; }
.admin-banner h2 { margin: 0; }
.admin-grid { display: grid; gap: 12px; }
.admin-card { padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.admin-card h3 { margin-top: 0; }
.user-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.user-row small { display: block; color: var(--muted); }
.user-row .compact-label { flex: 1 1 160px; min-width: 140px; }
.user-row .compact-label select { margin-top: 4px; }
.user-row > .button { flex: 0 0 auto; }
.movement-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .75rem; padding: .75rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.movement-row small { grid-column: 1 / -1; color: var(--muted); }
pre { max-height: 320px; overflow: auto; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-soft); font-size: .72rem; white-space: pre-wrap; word-break: break-word; }

/* Toasts */
.toast-region { position: fixed; z-index: 200; bottom: calc(var(--nav-height) + 12px + env(safe-area-inset-bottom, 0px)); left: 50%; display: grid; gap: 7px; width: min(420px, calc(100% - 24px)); transform: translateX(-50%); pointer-events: none; }
.toast { padding: 13px 15px; border-radius: var(--radius-md); background: var(--navy); color: #fff; font-size: .82rem; box-shadow: var(--shadow-md); animation: toast-in .18s cubic-bezier(.2, 0, 0, 1); }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

@media (min-width: 480px) {
  .overlay { align-items: center; padding: 20px; }
  .gate-card { border-radius: var(--radius-xl); padding: 32px 28px; }
  .app-dialog { margin: auto; border-radius: var(--radius-xl); }
  .app-dialog > form, .app-dialog > section { padding: 22px; }
  .dialog-head { top: -22px; }
  .dialog-actions { bottom: -22px; }
}

@media (max-width: 640px) {
  .field-grid.two, .field-grid.three { grid-template-columns: 1fr; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions .spacer { display: none; }
  .dialog-actions .button { flex: 1 1 120px; }
  .dialog-actions .danger { flex-basis: 100%; }
  .quote-line { grid-template-columns: 1fr 72px 96px 44px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .search-field { flex-basis: 100%; }
}

@media (max-width: 430px) {
  :root { --topbar-height: 84px; }
  .topbar { padding-inline: 11px; }
  .app-mark { width: 38px; height: 38px; }
  .status-button { padding-inline: 8px; }
  .status-button .ui-icon { display: none; }
  .topbar-icon { min-width: 44px; height: 44px; }
  .primary-icon { min-width: 44px; height: 44px; }
  .view { padding-inline: 10px; }
  .summary-grid { gap: 6px; }
  .summary-grid article { padding: 10px 5px; }
  .summary-grid strong { font-size: 1rem; }
  .summary-grid span { font-size: .59rem; }
  .stock-control { grid-template-columns: 54px minmax(0, 1fr) 54px; gap: 9px; }
  .stock-step { width: 54px; height: 54px; }
  .stock-number strong { font-size: 2rem; }
  .card-actions { flex-wrap: wrap; }
  .product-actions .button { flex: 1 1 calc(33.333% - 6px); }
  .crm-reminder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger-financial-grid { grid-template-columns: 1fr; }
  .financial-metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .financial-metric:last-child { border-bottom: 0; }
  .transaction-card { grid-template-columns: 38px minmax(0, 1fr) auto; }
  .transaction-chevron { display: none; }
}

@media (max-width: 360px) {
  .app-mark { display: none; }
  .header-actions { gap: 0; }
  .status-button { min-width: 38px; justify-content: center; }
  #syncLabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .summary-grid article .ui-icon { display: none; }
  .search-row { align-items: stretch; }
  .scan-button { min-width: 62px; padding-inline: 10px; }
  .scan-button .ui-icon { display: none; }
  .quote-line { grid-template-columns: 1fr 1fr; }
  .quote-line label:first-child { grid-column: 1 / -1; }
  .remove-line { grid-column: 2; }
  .line-total { grid-column: 1; }
  .card-details { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .button:active, .icon-button:active, .stock-step:active, .record-card:active, .menu-group > button:active { transform: none; }
}

@media (forced-colors: active) {
  .button, .icon-button, .status-button, .record-card, .overview-card, .tool-area, input, textarea, select, fieldset, .menu-group > button, .transaction-card, .timeline-content { border: 1px solid ButtonText; }
  .status-dot { border: 1px solid ButtonText; }
  .topbar { background: Canvas; color: CanvasText; }
  .topbar h1, .title-block .eyebrow, .topbar-icon { color: CanvasText; }
}

@media print {
  body { background: #fff; }
  .topbar, .bottom-nav, .toolbar, .stock-search-panel { display: none !important; }
  .view { padding: 0; }
  .record-card, .overview-card, .tool-area { box-shadow: none; }
}
