/* App frame — core/shell.js and the ⌘K palette (core/palette.js).
   Design: docs/research/design-language.md §3.1 shell · §3.2 palette · §3.5 components · §6 touch · §8 motion;
   navigation: docs/ARCHITECTURE.md §10 (core/hubs.js: one flat row per tool of this app — Café or Roastery —
   grouped by hairlines, Settings at the bottom; no sections or chips).
   Desktop ≥ 1024: 232px sidebar on --bg-sunken (no border), collapsible to a 56px rail · tablet 768–1023:
   rail (expands over the content) · phones < 768: 48px top bar + 56px bottom tabs + "More" sheet.
   The sidebar header stacks the wordmark (or the business's name) over a quiet app label; phones put the app's
   name under the page title.
   core/shell.js sets on .shell: data-layout (app | focus | bare), data-viewport (desktop | tablet | mobile),
   data-side (full | rail | overlay | none) and data-app (cafe | roastery); on <html>: data-layout,
   data-palette-open, data-shell-lock.
   Ink & Jade (PRD §7): primary actions are ink (--primary); jade is the active item's 1px "cut" line under the
   current sidebar/rail row and phone tab, the dots and links.
   For views and overlays: --shell-top (sticky header height) and --shell-bottom (bottom tab bar, 0 when
   hidden). Layout 'focus': .shell-view is a flex column that fills the space under the header — give the
   view's root flex: 1 (or height: 100%). Logical properties only (RTL). Colours come from tokens.css. */

:root {
  --shell-head: var(--topbar-h, 52px);
  --shell-top: var(--shell-head);
  --shell-bottom: 0px;
  --shell-scrim: var(--scrim);
  --shell-scrim-soft: color-mix(in srgb, var(--scrim) 30%, transparent);
}
:root[data-layout="focus"] { --shell-head: 48px; }
:root[data-layout="bare"] { --shell-top: 0px; }

@media (max-width: 767px) {
  :root {
    --shell-head: 48px;
    --shell-top: calc(var(--shell-head) + env(safe-area-inset-top, 0px));
    --shell-bottom: calc(var(--tabbar-h, 56px) + env(safe-area-inset-bottom, 0px));
  }
  :root[data-layout="focus"] { --shell-bottom: 0px; }
  :root[data-layout="bare"] { --shell-top: 0px; --shell-bottom: 0px; }
  :root[data-palette-open], :root[data-shell-lock] { overflow: hidden; }
}

/* ------------------------------------------------------------------ frame */

.shell {
  --shell-pad: 32px;
  --shell-side: var(--sidebar-w, 232px);
  --shell-font: var(--font-sans, "Inter", system-ui, sans-serif);
  display: grid;
  grid-template-columns: var(--shell-side) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
}
.shell[data-side="rail"],
.shell[data-side="overlay"] { --shell-side: var(--rail-w, 56px); }
.shell[data-side="none"] { grid-template-columns: minmax(0, 1fr); }
.shell[data-viewport="tablet"] { --shell-pad: 24px; }
.shell[data-viewport="mobile"] { --shell-pad: 16px; }

.shell-column {
  grid-column: -2 / -1;
  grid-row: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.shell-content {
  flex: 1 0 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.shell-content:focus { outline: none; }
.shell-view { flex: 1 0 auto; min-width: 0; }

.shell[data-layout="app"] .shell-view {
  width: 100%;
  max-width: calc(var(--content-max, 1120px) + 2 * var(--shell-pad));
  margin-inline: auto;
  padding: 32px var(--shell-pad) calc(64px + var(--shell-bottom));
}
.shell[data-layout="app"][data-viewport="mobile"] .shell-view { padding-block-start: 20px; }

/* focus (POS, KDS): the frame is the viewport; the view fills what the header leaves */
.shell[data-layout="focus"] { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.shell[data-layout="focus"] .shell-column { height: 100vh; height: 100dvh; }
.shell[data-layout="focus"] .shell-content { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.shell[data-layout="focus"] .shell-view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* bare (welcome, sign-in, demo): no chrome at all */
.shell[data-layout="bare"] { display: block; }
.shell[data-layout="bare"] :is(.shell-sidebar, .shell-topbar, .shell-banners, .shell-tabbar, .shell-scrim) { display: none; }

/* ------------------------------------------------------------------ shared bits */

.shell-sr,
.shell[data-side="rail"] :is(.shell-brand-text, .shell-nav-label, .shell-account-name, .shell-account-cta),
.shell[data-viewport="mobile"] .shell-primary-label,
.shell[data-layout="focus"] .shell-primary-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.shell :focus-visible,
.shell-layer :focus-visible,
.shell-palette :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Chrome links never underline (base.css underlines a:hover for running text). Hover tints apply only
   where a pointer can hover: on touch screens a tap would leave them stuck on. */
:is(.shell-sidebar, .shell-topbar, .shell-banners, .shell-tabbar, .shell-layer) a:hover { text-decoration-line: none; }
[dir="rtl"] :is(.shell, .shell-layer, .shell-palette) [data-rtl="flip"] { transform: scaleX(-1); }

.shell-icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--r-md, 8px);
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  transition: background-color var(--dur-1, 100ms) var(--ease-standard, ease), color var(--dur-1, 100ms) var(--ease-standard, ease);
}
@media (hover: hover) { .shell-icon-btn:hover { background: var(--bg-hover); color: var(--text); } }
.shell-icon-btn:active { background: var(--bg-active); }

.shell-kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-xs, 4px);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--text-subtle);
  font: 500 11px/16px var(--shell-font);
  letter-spacing: 0;
  white-space: nowrap;
}

:lang(ar) .shell-palette-heading { font: 600 12px/16px var(--shell-font); letter-spacing: 0; text-transform: none; }

/* ------------------------------------------------------------------ sidebar */

.shell-sidebar {
  grid-column: 1;
  grid-row: 1;
  position: sticky;
  inset-block-start: 0;
  z-index: var(--z-nav, 20);
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  padding-block-start: env(safe-area-inset-top, 0px);
  background: var(--bg-sunken);
}
.shell[data-side="none"] .shell-sidebar { display: none; }

.shell-brand {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  height: var(--topbar-h, 52px);
  padding-inline: 10px 8px;
}
.shell-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding-inline: 8px;
  border-radius: var(--r-md, 8px);
  color: var(--text);
  font: 600 var(--fs-body, 14px)/var(--lh-body, 20px) var(--shell-font);
  letter-spacing: var(--tr-body, -0.005em);
  text-decoration: none;
}
@media (hover: hover) { .shell-brand-link:hover { background: var(--bg-hover); } }
/* The wordmark (or the business's name) over the app, quietly: "coffeegx / Roastery", "Moda Kahve / CoffeeGX Café". */
.shell-brand-text { display: grid; justify-items: start; gap: 2px; min-width: 0; }
.shell-brand-name { max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-brand-text > .wordmark { display: block; }
.shell-brand-app {
  max-width: 100%;
  overflow: hidden;
  color: var(--text-subtle);
  font: 500 var(--fs-caption, 12px)/var(--lh-caption, 16px) var(--shell-font);
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: var(--r-sm, 6px);
  background: var(--primary, var(--accent));
  color: var(--on-primary, var(--on-accent));
  font: 600 12px/1 var(--shell-font);
  letter-spacing: 0;
  overflow: hidden;
}
.shell-mark-img { object-fit: cover; background: var(--bg-raised); box-shadow: inset 0 0 0 1px var(--line); }
.shell-mark-brand { background: transparent; } /* logo() draws the cut in its fixed brand colours */

.shell-nav { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.shell-nav-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 10px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.shell-nav-system { flex: none; padding: 4px 10px 8px; }
.shell-nav-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
/* groups (core/hubs.js): the daily tools, then the rest — a hairline between them, never an eyebrow */
.shell-nav-scroll > .shell-nav-list + .shell-nav-list { margin-block-start: 9px; padding-block-start: 9px; border-block-start: 1px solid var(--line); }
.shell[data-side="rail"] .shell-nav-scroll > .shell-nav-list + .shell-nav-list { margin-inline: 6px; }

.shell-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding-inline: 8px;
  border-radius: var(--r-md, 8px);
  color: var(--text-muted);
  font: 500 var(--fs-body, 14px)/var(--lh-body, 20px) var(--shell-font);
  letter-spacing: var(--tr-body, -0.005em);
  text-decoration: none;
  transition: background-color var(--dur-1, 100ms) var(--ease-standard, ease), color var(--dur-1, 100ms) var(--ease-standard, ease);
}
.shell-nav-item > .icon { flex: none; color: var(--text-subtle); }
.shell-nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) { .shell-nav-item:hover { background: var(--bg-hover); color: var(--text); } }
@media (hover: hover) { .shell-nav-item:hover > .icon { color: var(--text-muted); } }
.shell-nav-item[aria-current="page"] { background: var(--bg-active); color: var(--text); }
.shell-nav-item[aria-current="page"] > .icon { color: var(--text); }
/* the cut (PRD §7.1): a 1px jade line under the active row */
.shell-nav-item[aria-current="page"]::after {
  content: "";
  position: absolute;
  inset-inline: 8px;
  inset-block-end: 0;
  height: 1px;
  background: var(--accent-line, var(--accent));
  pointer-events: none;
}

.shell-nav-badge {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full, 999px);
  background: var(--bg-active);
  color: var(--text-muted);
  font: 500 11px/18px var(--font-num, var(--shell-font));
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.shell-nav-item[aria-current="page"] .shell-nav-badge { background: var(--bg-raised); }
.shell-nav-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.shell-nav-lock { display: inline-flex; flex: none; color: var(--text-subtle); }

/* footer: plan chip + sync · account + lock + Switch app */
.shell-foot {
  flex: none;
  display: grid;
  gap: 2px;
  padding: 8px 10px 10px;
  border-block-start: 1px solid var(--line);
}
.shell-foot-plan { display: flex; align-items: center; gap: 2px; min-width: 0; }
.shell-foot-plan .shell-sync { margin-inline-start: auto; }
.shell-foot-row { display: flex; align-items: center; gap: 2px; min-width: 0; }

.shell-plan {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  min-height: 28px;
  padding-inline: 8px;
  border-radius: var(--r-md, 8px);
  color: var(--text-muted);
  font: 500 var(--fs-caption, 12px)/var(--lh-caption, 16px) var(--shell-font);
  text-decoration: none;
}
@media (hover: hover) { a.shell-plan:hover { background: var(--bg-hover); color: var(--text); } }
.shell-plan-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--text-subtle); }
.shell-plan:is([data-plan="trial"], [data-plan="pro"], [data-plan="business"]) .shell-plan-dot { background: var(--accent); }
.shell-plan-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-plan-cta { flex: none; color: var(--accent-text); }
.shell-plan-cta::before { content: "·"; margin-inline-end: 6px; color: var(--text-subtle); }

.shell-account {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding-inline: 6px 8px;
  border-radius: var(--r-md, 8px);
  color: var(--text);
  font: 500 var(--fs-body-sm, 13px)/var(--lh-body-sm, 18px) var(--shell-font);
  text-decoration: none;
}
@media (hover: hover) { .shell-account:hover { background: var(--bg-hover); } }
.shell-avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-active);
  color: var(--text);
  font: 600 11px/1 var(--shell-font);
}
.shell-avatar-guest { color: var(--text-subtle); }
.shell-account-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-account-cta { flex: none; margin-inline-start: auto; color: var(--accent-text); font-size: var(--fs-caption, 12px); }

.shell-sync[data-sync="error"] { color: var(--danger-text); }
.shell-sync[data-sync="offline"] { color: var(--warning-text); }
.shell-sync[data-sync="synced"] { color: var(--success-text); }
.shell-sync[data-sync="syncing"] .icon { animation: shell-spin 1s linear infinite; }
.shell-collapse-rail { display: none; }

/* rail: icons only (labels stay for screen readers and show as tooltips) */
.shell[data-side="rail"] .shell-brand { justify-content: center; padding-inline: 0; }
.shell[data-side="rail"] .shell-brand-link { flex: none; width: 40px; padding: 0; justify-content: center; }
.shell[data-side="rail"] .shell-brand .shell-collapse { display: none; }
.shell[data-side="rail"] :is(.shell-nav-scroll, .shell-nav-system) { padding-inline: 8px; }
.shell[data-side="rail"] .shell-nav-item { justify-content: center; height: 36px; padding: 0; }
.shell[data-side="rail"] .shell-nav-item[aria-current="page"]::after { inset-inline: 10px; }
.shell[data-side="rail"] .shell-nav-badge {
  position: absolute;
  inset-block-start: 1px;
  inset-inline-end: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  line-height: 16px;
}
.shell[data-side="rail"] .shell-nav-dot { position: absolute; inset-block-start: 7px; inset-inline-end: 8px; }
.shell[data-side="rail"] .shell-nav-lock { display: none; }
.shell[data-side="rail"] .shell-foot { justify-items: center; padding-inline: 8px; }
.shell[data-side="rail"] .shell-foot-plan { justify-content: center; }
.shell[data-side="rail"] .shell-foot-plan .shell-plan { display: none; }
.shell[data-side="rail"] .shell-foot-plan .shell-sync { margin: 0; }
.shell[data-side="rail"] .shell-foot-row { order: -1; flex-direction: column; gap: 2px; }
.shell[data-side="rail"] .shell-account { flex: none; justify-content: center; width: 36px; height: 36px; padding: 0; }
.shell[data-side="rail"] .shell-collapse-rail { display: inline-grid; }

/* rail expanded over the content (tablet, focus layout) */
.shell[data-side="overlay"] .shell-sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: var(--z-dropdown, 40);
  width: var(--sidebar-w, 232px);
  box-shadow: var(--shadow-sheet);
  animation: shell-fade var(--dur-2, 160ms) var(--ease-standard, ease);
}
.shell-scrim { display: none; }
.shell[data-side="overlay"] .shell-scrim {
  display: block;
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-dropdown, 40) - 1);
  background: var(--shell-scrim-soft);
  animation: shell-fade var(--dur-2, 160ms) var(--ease-standard, ease);
}

/* ------------------------------------------------------------------ top bar */

.shell-topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: var(--z-topbar, 30);
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  height: calc(var(--shell-head) + env(safe-area-inset-top, 0px));
  padding-block-start: env(safe-area-inset-top, 0px);
  padding-inline: var(--shell-pad);
  background: var(--bg);
  border-block-end: 1px solid var(--line);
}
/* glass (PRD §4.2, §7.3 --glass): the page shows through, softly, as it scrolls under the sticky top bar */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .shell[data-layout="app"] .shell-topbar {
    background: var(--glass);
    -webkit-backdrop-filter: var(--glass-filter);
    backdrop-filter: var(--glass-filter);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .shell[data-layout="app"] .shell-topbar { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
.shell-back,
.shell-top-brand,
.shell-title,
.shell-offline-chip { display: none; }
.shell-top-spacer { flex: 1; min-width: 0; }

.shell-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 360px;
  min-width: 0;
  height: 32px;
  padding-inline: 10px 6px;
  border: 0;
  border-radius: var(--r-md, 8px);
  background: var(--bg-hover);
  color: var(--text-subtle);
  font: 400 var(--fs-body, 14px)/var(--lh-body, 20px) var(--shell-font);
  letter-spacing: var(--tr-body, -0.005em);
  cursor: pointer;
  transition: background-color var(--dur-1, 100ms) var(--ease-standard, ease);
}
@media (hover: hover) { .shell-search:hover { background: var(--bg-active); color: var(--text-muted); } }
.shell-search > .icon { flex: none; }
.shell-search-text { flex: 1; min-width: 0; overflow: hidden; text-align: start; text-overflow: ellipsis; white-space: nowrap; }

.shell-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  height: 32px;
  padding-inline: 12px;
  border: 0;
  border-radius: var(--r-md, 8px);
  background: var(--primary, var(--accent));
  color: var(--on-primary, var(--on-accent));
  font: 500 var(--fs-body, 14px)/1 var(--shell-font);
  letter-spacing: var(--tr-body, -0.005em);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-1, 100ms) var(--ease-standard, ease);
}
@media (hover: hover) { .shell-primary:hover { background: var(--primary-hover, var(--accent-hover)); } }
.shell-primary:active { background: var(--primary-active, var(--accent-active)); }
.shell-primary > .icon { flex: none; }

.shell-offline-chip {
  align-items: center;
  gap: 6px;
  flex: none;
  height: 24px;
  padding-inline: 8px;
  border-radius: var(--r-full, 999px);
  background: var(--warning-bg);
  color: var(--warning-text);
  font: 500 var(--fs-caption, 12px)/1 var(--shell-font);
}

.shell-title {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font: 600 var(--fs-heading-sm, 15px)/var(--lh-heading-sm, 22px) var(--shell-font);
  letter-spacing: var(--tr-heading-sm, -0.006em);
  white-space: nowrap;
}
.shell-title-page, .shell-title-app { display: block; overflow: hidden; text-overflow: ellipsis; }
/* phones: the app's name under the page title, quietly ("Today" over "CoffeeGX Café"); never in the focus layout */
.shell-title-app { display: none; color: var(--text-subtle); font: 500 11px/14px var(--shell-font); letter-spacing: 0; }
.shell[data-viewport="mobile"][data-layout="app"] .shell-title-page { line-height: 20px; }
.shell[data-viewport="mobile"][data-layout="app"] .shell-title-app { display: block; }

/* focus layout: slim header — back · title · … · offline · search · action · theme */
.shell[data-layout="focus"] .shell-topbar { position: relative; padding-inline: 12px; }
.shell[data-layout="focus"] .shell-back {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md, 8px);
  color: var(--text-muted);
}
@media (hover: hover) { .shell[data-layout="focus"] .shell-back:hover { background: var(--bg-hover); color: var(--text); } }
.shell[data-layout="focus"] .shell-title { display: block; }
.shell[data-layout="focus"] .shell-offline-chip { display: inline-flex; }

/* focus layout and phones: the title takes the free space, so search · action · theme sit at the end */
:is(.shell[data-layout="focus"], .shell[data-viewport="mobile"]) .shell-title { flex: 1 1 auto; }
:is(.shell[data-layout="focus"], .shell[data-viewport="mobile"]) .shell-top-spacer { display: none; }

/* compact search (focus layout, phones): an icon button */
:is(.shell[data-layout="focus"], .shell[data-viewport="mobile"]) .shell-search {
  flex: none;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
}
@media (hover: hover) { :is(.shell[data-layout="focus"], .shell[data-viewport="mobile"]) .shell-search:hover { background: var(--bg-hover); } }
:is(.shell[data-layout="focus"], .shell[data-viewport="mobile"]) :is(.shell-search-text, .shell-search-kbd) { display: none; }
:is(.shell[data-layout="focus"], .shell[data-viewport="mobile"]) .shell-search > .icon { width: 18px; height: 18px; }
:is(.shell[data-layout="focus"], .shell[data-viewport="mobile"]) .shell-primary { width: 36px; height: 36px; padding: 0; }

/* phones: mark · page title · search · action (theme lives in More) */
.shell[data-viewport="mobile"] .shell-topbar { gap: 4px; padding-inline: 12px 8px; }
.shell[data-viewport="mobile"][data-layout="app"] .shell-top-brand {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  margin-inline-end: 2px;
  border-radius: var(--r-md, 8px);
}
.shell[data-viewport="mobile"] .shell-top-brand .shell-mark { width: 26px; height: 26px; font-size: 13px; border-radius: 7px; }
.shell[data-viewport="mobile"] .shell-title { display: block; }
.shell[data-viewport="mobile"][data-layout="app"] .shell-theme { display: none; }

/* ------------------------------------------------------------------ banners */

.shell-banners:empty { display: none; }
.shell-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  min-height: 40px;
  padding: 8px var(--shell-pad);
  background: var(--info-bg);
  color: var(--text);
  font: 400 var(--fs-body-sm, 13px)/var(--lh-body-sm, 18px) var(--shell-font);
}
.shell-banner + .shell-banner { box-shadow: inset 0 1px 0 var(--line); }
.shell-banner-icon { display: inline-flex; flex: none; color: var(--info-text); }
.shell-banner[data-tone="warning"] { background: var(--warning-bg); }
.shell-banner[data-tone="warning"] .shell-banner-icon { color: var(--warning-text); }
.shell-banner[data-tone="danger"] { background: var(--danger-bg); }
.shell-banner[data-tone="danger"] .shell-banner-icon { color: var(--danger-text); }
.shell-banner[data-tone="success"] { background: var(--success-bg); }
.shell-banner[data-tone="success"] .shell-banner-icon { color: var(--success-text); }
.shell-banner-text { flex: 1 1 220px; min-width: 0; }
.shell-banner-text p { margin: 0; }
.shell-banner-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: none; }
.shell-banner-btn {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding-inline: 10px;
  border: 0;
  border-radius: var(--r-md, 8px);
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--text);
  font: 500 var(--fs-body-sm, 13px)/1 var(--shell-font);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
@media (hover: hover) { .shell-banner-btn:hover { background: var(--bg-hover); } }
.shell-banner-close { width: 28px; height: 28px; margin-inline-end: -6px; color: var(--text-muted); }
.shell[data-layout="focus"] .shell-banner { min-height: 36px; padding-block: 4px; padding-inline: 16px; }
/* phones: the message wraps beside a text action instead of stacking a boxed button under it */
.shell[data-viewport="mobile"] .shell-banner { flex-wrap: nowrap; gap: 10px; padding-block: 4px; }
.shell[data-viewport="mobile"] .shell-banner-text { flex: 1 1 auto; padding-block: 6px; }
.shell[data-viewport="mobile"] .shell-banner-btn {
  height: 44px;
  padding-inline: 4px;
  background: none;
  box-shadow: none;
  font-weight: 600;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  white-space: normal;
  text-align: end;
}
@media (hover: hover) { .shell[data-viewport="mobile"] .shell-banner-btn:hover { background: none; } }
.shell[data-viewport="mobile"] .shell-banner-actions { flex-wrap: nowrap; max-inline-size: 45%; }
/* The live demo's bar: its action is a sentence ("Kendi kavurmahanenizi kurun →"). When it does not fit beside the
   message it moves under it, at the end, instead of folding into a narrow column of its own. */
.shell[data-viewport="mobile"] .shell-banner[data-banner="demo"] { flex-wrap: wrap; row-gap: 0; }
.shell[data-viewport="mobile"] .shell-banner[data-banner="demo"] .shell-banner-text { flex: 1 1 12em; }
.shell[data-viewport="mobile"] .shell-banner[data-banner="demo"] .shell-banner-actions { flex: 0 1 auto; max-inline-size: 100%; margin-inline-start: auto; }
.shell[data-viewport="mobile"] .shell-banner[data-banner="demo"] .shell-banner-btn { white-space: nowrap; }

/* ------------------------------------------------------------------ bottom tab bar (phones) */

.shell-tabbar { display: none; }
.shell[data-viewport="mobile"][data-layout="app"] .shell-tabbar {
  display: block;
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: var(--z-nav, 20);
  padding-block-end: env(safe-area-inset-bottom, 0px);
  padding-inline: max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  background: var(--bg);
  border-block-start: 1px solid var(--line);
}
.shell-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  height: var(--tabbar-h, 56px);
  margin: 0;
  padding: 0;
  list-style: none;
}
.shell-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  height: 100%;
  padding: 6px 0 4px; /* the label may use the tab's full width: "Green coffee" fits a 72 px tab at 360 px (ui L4) */
  border: 0;
  background: none;
  color: var(--text-subtle);
  font: 500 11px/14px var(--shell-font);
  letter-spacing: 0;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.shell-tab:focus-visible { outline-offset: -4px; border-radius: var(--r-lg, 12px); }
.shell-tab-icon { position: relative; display: inline-grid; place-items: center; width: 44px; height: 26px; border-radius: var(--r-full, 999px); transition: background-color var(--dur-1, 100ms) var(--ease-standard, ease); }
.shell-tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-tab:is([aria-current="page"], [data-active]) { color: var(--text); }
.shell-tab:is([aria-current="page"], [data-active]) .shell-tab-icon { background: var(--bg-active); color: var(--text); }
.shell-tab:is([aria-current="page"], [data-active]) .shell-tab-icon::after {
  content: "";
  position: absolute;
  inset-inline: 12px;
  inset-block-end: -1px;
  height: 1px;
  background: var(--accent-line, var(--accent));
}
.shell-tab:active .shell-tab-icon { background: var(--bg-active); }
.shell-tab-dot {
  position: absolute;
  inset-block-start: 1px;
  inset-inline-end: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
}

/* ------------------------------------------------------------------ More sheet (phones) */

.shell-sheet { position: fixed; inset: 0; z-index: var(--z-sheet, 50); }
.shell-sheet[hidden] { display: none; }
.shell-sheet-scrim { position: absolute; inset: 0; background: var(--shell-scrim); animation: shell-fade var(--dur-3, 240ms) var(--ease-standard, ease); }
.shell-sheet-panel {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  display: flex;
  flex-direction: column;
  max-height: 92vh;
  max-height: 92dvh;
  padding-block-end: env(safe-area-inset-bottom, 0px);
  padding-inline: max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  border-start-start-radius: var(--r-xl, 16px);
  border-start-end-radius: var(--r-xl, 16px);
  background: var(--bg-raised);
  box-shadow: var(--shadow-sheet);
  outline: none;
  animation: shell-rise var(--dur-4, 320ms) var(--ease-standard, ease);
}
.shell-sheet-grabber { flex: none; width: 36px; height: 5px; margin: 8px auto 0; border-radius: 3px; background: var(--line-strong); }
.shell-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; padding-block: 6px 2px; padding-inline: 20px 8px; }
.shell-sheet-title {
  margin: 0;
  font: 600 var(--fs-heading-md, 18px)/var(--lh-heading-md, 26px) var(--shell-font);
  letter-spacing: var(--tr-heading-md, -0.011em);
}
.shell-sheet-head .shell-icon-btn { width: 44px; height: 44px; }
.shell-sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 12px 12px; }
.shell-sheet-group + .shell-sheet-group { margin-block-start: 10px; padding-block-start: 10px; border-block-start: 1px solid var(--line); }
.shell-sheet-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 4px; margin: 0; padding: 0; list-style: none; }
.shell-sheet-meta .shell-sheet-list { grid-template-columns: minmax(0, 1fr); }
.shell-sheet-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 4px 8px;
  border: 0;
  border-radius: var(--r-md, 8px);
  background: none;
  color: var(--text);
  font: 500 15px/20px var(--shell-font);
  letter-spacing: var(--tr-body, -0.005em);
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}
:lang(ar) .shell-sheet-item { font-size: 16px; line-height: 24px; }
.shell-sheet-item > .icon { flex: none; color: var(--text-subtle); }
/* Two lines for long labels ("Закрытие дня", "Maliyet ve kâr"); a single long word breaks only as a last resort. */
.shell-sheet-label {
  flex: 1;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.shell-sheet-note { flex: none; color: var(--text-subtle); font: 400 var(--fs-body-sm, 13px)/var(--lh-body-sm, 18px) var(--shell-font); }
@media (hover: hover) { .shell-sheet-item:hover { background: var(--bg-hover); } }
.shell-sheet-item[aria-current="page"] { background: var(--bg-active); }
.shell-sheet-item[aria-current="page"] > .icon { color: var(--text); }
.shell-sheet-meta .shell-account { min-height: 48px; padding-inline: 8px; gap: 12px; font-size: var(--fs-body, 14px); }
.shell-sheet-meta .shell-avatar { width: 24px; height: 24px; }
.shell-sheet-status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 6px 8px 0; }
.shell-sheet-sync {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font: 400 var(--fs-body-sm, 13px)/var(--lh-body-sm, 18px) var(--shell-font);
  text-align: start;
  cursor: pointer;
}
.shell-sheet-sync[data-sync="synced"] > .icon { color: var(--success-text); }
.shell-sheet-sync[data-sync="error"] > .icon { color: var(--danger-text); }
.shell-sheet-sync[data-sync="offline"] > .icon { color: var(--warning-text); }
.shell-sheet-status .shell-plan { min-height: 44px; padding-inline: 4px; }

/* ------------------------------------------------------------------ rail tooltip */

.shell-tip {
  position: fixed;
  z-index: var(--z-toast, 70);
  max-width: 240px;
  padding: 4px 8px;
  border-radius: var(--r-sm, 6px);
  background: var(--ink);
  color: var(--on-ink, var(--bg));
  font: 500 12px/16px var(--shell-font);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-pop);
  animation: shell-fade var(--dur-2, 160ms) var(--ease-standard, ease);
}
.shell-tip[hidden] { display: none; }

/* ------------------------------------------------------------------ plan gate */

.shell-gate { max-width: 440px; margin: 12vh auto 0; padding-inline: 16px; text-align: center; }
.shell-gate-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--bg-hover); color: var(--text-muted); }
.shell-gate-title { margin: 16px 0 6px; color: var(--text); font: 600 20px/28px var(--shell-font); letter-spacing: -0.011em; }
.shell-gate-body { margin: 0; color: var(--text-muted); }
.shell-gate-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 24px 0 0; }
.shell-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding-inline: 14px;
  border: 0;
  border-radius: var(--r-md, 8px);
  background: var(--bg-raised);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--text);
  font: 500 var(--fs-body, 14px)/1 var(--shell-font);
  text-decoration: none;
  cursor: pointer;
}
@media (hover: hover) { .shell-btn:hover { background: var(--bg-hover); } }
.shell-btn-primary { background: var(--primary, var(--accent)); color: var(--on-primary, var(--on-accent)); box-shadow: none; }
@media (hover: hover) { .shell-btn-primary:hover { background: var(--primary-hover, var(--accent-hover)); } }

/* ------------------------------------------------------------------ skip link */

.shell-skip {
  position: fixed;
  inset-block-start: 8px;
  inset-inline-start: 8px;
  z-index: calc(var(--z-palette, 80) + 1);
  padding: 8px 12px;
  border-radius: var(--r-md, 8px);
  background: var(--ink);
  color: var(--on-ink, var(--bg));
  font: 500 var(--fs-body, 14px)/var(--lh-body, 20px) var(--shell-font);
  text-decoration: none;
  transform: translateY(-200%);
}
.shell-skip:focus { transform: none; }
/* A touch screen gets a 44px target when the link shows (keyboard focus on a tablet with a keyboard). */
@media (pointer: coarse) {
  .shell-skip { display: inline-flex; align-items: center; min-block-size: 44px; }
}

/* ------------------------------------------------------------------ ⌘K palette */

.shell-palette { position: fixed; inset: 0; z-index: var(--z-palette, 80); }
.shell-palette[hidden] { display: none; }
.shell-palette-scrim { position: absolute; inset: 0; background: var(--shell-scrim-soft); animation: shell-fade var(--dur-2, 160ms) var(--ease-standard, ease); }
.shell-palette-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100% - 32px));
  max-height: min(560px, 70vh);
  margin: 15vh auto 0;
  overflow: hidden;
  border-radius: var(--r-lg, 12px);
  background: var(--bg-raised);
  box-shadow: var(--shadow-pop);
  animation: shell-pop var(--dur-3, 240ms) var(--ease-standard, ease);
}
.shell-palette-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  height: 52px;
  padding-inline: 16px 12px;
  border-block-end: 1px solid var(--line);
}
.shell-palette-glass { display: inline-flex; flex: none; color: var(--text-subtle); }
.shell-palette-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 400 var(--fs-body-md, 16px)/var(--lh-body-md, 24px) var(--shell-font);
  letter-spacing: var(--tr-body-md, -0.009em);
}
.shell-palette-input::placeholder { color: var(--text-subtle); opacity: 1; }
.shell-palette-input:focus,
.shell-palette-input:focus-visible { outline: none; }
.shell-palette-cancel { display: none; }

.shell-palette-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 8px; scroll-padding-block: 8px; }
.shell-palette-group + .shell-palette-group { margin-block-start: 4px; }
.shell-palette-heading {
  padding: 10px 16px 4px;
  color: var(--text-subtle);
  font: 500 var(--fs-eyebrow, 11px)/var(--lh-eyebrow, 16px) var(--font-mono, "JetBrains Mono", ui-monospace, monospace);
  letter-spacing: var(--tr-eyebrow, 0.08em);
  text-transform: uppercase;
}
.shell-palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  margin-inline: 6px;
  padding-inline: 10px;
  border-radius: var(--r-md, 8px);
  color: var(--text);
  font: 400 var(--fs-body, 14px)/var(--lh-body, 20px) var(--shell-font);
  letter-spacing: var(--tr-body, -0.005em);
  cursor: pointer;
  user-select: none;
}
.shell-palette-item[aria-selected="true"] { background: var(--bg-hover); }
.shell-palette-icon { display: inline-flex; flex: none; color: var(--text-subtle); }
.shell-palette-item[aria-selected="true"] .shell-palette-icon { color: var(--text-muted); }
.shell-palette-text { display: flex; align-items: baseline; gap: 8px; flex: 1; min-width: 0; overflow: hidden; }
.shell-palette-label { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-palette-sub {
  flex: 0 100 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--text-subtle);
  font-size: var(--fs-body-sm, 13px);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shell-palette-keys { display: inline-flex; gap: 4px; flex: none; }
.shell-palette-go { display: inline-flex; flex: none; color: var(--text-subtle); visibility: hidden; }
.shell-palette-item[aria-selected="true"] .shell-palette-go { visibility: visible; }
.shell-palette-empty { padding: 28px 24px 32px; text-align: center; }
.shell-palette-empty-title { margin: 0; color: var(--text); font: 500 var(--fs-body, 14px)/var(--lh-body, 20px) var(--shell-font); overflow-wrap: anywhere; }
.shell-palette-empty-hint { margin: 4px 0 0; color: var(--text-subtle); font: 400 var(--fs-body-sm, 13px)/var(--lh-body-sm, 18px) var(--shell-font); }
.shell-palette-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: none;
  height: 36px;
  padding-inline: 16px;
  border-block-start: 1px solid var(--line);
  color: var(--text-subtle);
  font: 400 var(--fs-caption, 12px)/var(--lh-caption, 16px) var(--shell-font);
}
.shell-palette-foot > span { display: inline-flex; align-items: center; gap: 4px; }

@media (max-width: 767px) {
  .shell-palette-scrim { display: none; }
  .shell-palette-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    margin: 0;
    padding-block-start: env(safe-area-inset-top, 0px);
    padding-block-end: env(safe-area-inset-bottom, 0px);
    border-radius: 0;
    box-shadow: none;
    animation-name: shell-fade;
  }
  .shell-palette-head { height: 56px; padding-inline: 16px 6px; }
  .shell-palette-esc, .shell-palette-foot { display: none; }
  .shell-palette-cancel {
    display: inline-flex;
    align-items: center;
    flex: none;
    height: 44px;
    padding-inline: 10px;
    border: 0;
    border-radius: var(--r-md, 8px);
    background: none;
    color: var(--accent-text);
    font: 500 var(--fs-body-md, 16px)/1 var(--shell-font);
    cursor: pointer;
  }
  .shell-palette-item { min-height: 48px; }
}

/* ------------------------------------------------------------------ touch */

@media (pointer: coarse) {
  .shell-nav-item { min-height: 44px; }
  .shell[data-side="rail"] .shell-nav-item { height: 44px; }
  .shell-icon-btn,
  .shell[data-layout="focus"] .shell-back,
  :is(.shell[data-layout="focus"], .shell[data-viewport="mobile"]) :is(.shell-search, .shell-primary) { width: 44px; height: 44px; }
  .shell-search, .shell-primary { height: 44px; }
  .shell-primary { padding-inline: 16px; }
  /* compact primary: a 44px target that draws a 36px jade square, so it never fills the slim header */
  :is(.shell[data-layout="focus"], .shell[data-viewport="mobile"]) .shell-primary { padding: 4px; border-radius: 12px; background-clip: content-box; }
  .shell-brand-link, .shell-plan, .shell-account { min-height: 44px; }
  .shell[data-side="rail"] .shell-account { width: 44px; height: 44px; }
  .shell[data-viewport="mobile"][data-layout="app"] .shell-top-brand { width: 44px; height: 44px; }
  .shell-banner-btn { height: 44px; padding-inline: 14px; }
  .shell-banner-close { width: 44px; height: 44px; }
  .shell-palette-item, .shell-sheet-item { min-height: 48px; }
}

/* ------------------------------------------------------------------ motion */

@keyframes shell-fade { from { opacity: 0; } }
@keyframes shell-pop { from { opacity: 0; transform: scale(0.98); } }
@keyframes shell-rise { from { opacity: 0; transform: translateY(24px); } }
@keyframes shell-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  :is(.shell, .shell-layer, .shell-palette) *,
  :is(.shell, .shell-layer, .shell-palette) *::before { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

@media (forced-colors: active) {
  .shell-nav-item[aria-current="page"], .shell-tab[aria-current="page"], .shell-palette-item[aria-selected="true"],
  .shell-sheet-item[aria-current="page"] { outline: 2px solid Highlight; outline-offset: -2px; }
}

/* ------------------------------------------------------------------ print

   With no print job (Ctrl+P on a report; core/print.js jobs print #print-root alone, app/css/print.css)
   the page prints as the content alone: no sidebar, bars, banners, sheets or palette. */

@media print {
  .shell, .shell[data-layout="focus"] { display: block; height: auto; min-height: 0; overflow: visible; background: none; }
  .shell[data-layout="focus"] :is(.shell-column, .shell-content) { height: auto; overflow: visible; }
  :is(.shell-sidebar, .shell-scrim, .shell-topbar, .shell-banners, .shell-tabbar, .shell-skip),
  :is(.shell-layer, .shell-palette, .shell-tip) { display: none !important; }
  .shell .shell-view { max-width: none; margin: 0; padding: 0; }
  :root[data-shell-lock], :root[data-palette-open] { overflow: visible; }
}
