/* Phone layer shared by the Studio (style.css) and the modules (shell.css). Loaded last on every page.
   Header: one row (logo, module name, icon buttons). Module sections: one "current section" button
   instead of a sideways-scrolling tab strip. Wide tables and boards: fade + "Przesuń w bok" bar. */

/* No bluish box over tapped elements on Android; keyboard focus outlines stay. */
html {
  -webkit-tap-highlight-color: transparent;
}

.module-nav-toggle,
.phone-only {
  display: none !important;
}
.scroll-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted, #767676);
}
.scroll-hint-buttons {
  display: flex;
  gap: 6px;
  flex: none;
}
.scroll-hint button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--line, #ddd);
  border-radius: 50%;
  background: var(--surface, #fff);
  color: inherit;
  font-size: 22px;
  line-height: 1;
}
.scroll-hint button svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.scroll-hint button:disabled {
  opacity: 0.35;
  cursor: default;
}
.sx.sx-r:not(.sx-l) {
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent);
}
.sx.sx-l:not(.sx-r) {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 40px);
  mask-image: linear-gradient(90deg, transparent, #000 40px);
}
.sx.sx-l.sx-r {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent);
}

/* "Moduły" menu: the Studio uses the same bordered items as the other modules; the current
   module has a soft background (desktop and phone). */
.topbar .module-menu .help-menu-items a {
  display: flex;
  align-items: center;
  margin: 4px 0;
  padding: 11px 16px;
  border: 1px solid var(--line, #e2e2e2);
  border-radius: 9px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.4;
}
.module-menu-links a[aria-current='page'],
.topbar .module-menu .help-menu-items a[aria-current='page'] {
  background: var(--soft, var(--panel-gray-f1f1f1, #f0f0f0));
  border-color: transparent;
}

/* Simple view components (phones), app style: icon tiles two per row, a title bar with a back arrow. */
.app-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 6px 0 20px;
}
.app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 138px;
  padding: 16px 10px 14px;
  border: 1px solid var(--line, #e2e2e2);
  border-radius: 22px;
  background: var(--surface, var(--panel-gray-ffffff, #fff));
  color: inherit;
  font: inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.app-tile:active {
  transform: scale(0.97);
}
.app-tile-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin-bottom: 6px;
  border-radius: 18px;
  background: var(--soft, var(--panel-gray-f1f1f1, #f0f0f0));
}
.app-tile-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app-tile strong {
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.app-tile-meta {
  font-size: 12px;
  color: var(--muted, #767676);
}
.app-tile.is-muted {
  opacity: 0.55;
}
.app-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 2px 0 16px;
}
.app-top > h1 {
  /* Same size and no margins in every module (Makieta has its own heading styles). */
  margin: 0 !important;
  padding: 0 !important;
  font-size: 24px !important;
  line-height: 1.15 !important;
  overflow-wrap: anywhere;
}
.app-top > .btn {
  flex: none;
  margin-left: auto;
}
.app-back {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line, #e2e2e2);
  border-radius: 14px;
  background: var(--surface, #fff);
  color: inherit;
  cursor: pointer;
}
.app-back svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app-meter {
  height: 8px;
  margin: 4px 0 2px;
  border-radius: 8px;
  background: var(--soft, #f0f0f0);
  overflow: hidden;
}
.app-meter > span {
  display: block;
  height: 100%;
  border-radius: 8px;
  background: var(--accent, #252525);
}
.app-meter.is-over > span {
  background: #c44949;
}
/* Simple view: no status line in Makieta (saves still show a notice); calendar without the source picker. */
html[data-view-mode='simple'] .global-status,
html[data-view-mode='simple'] .calendar-modes select {
  display: none !important;
}
html[data-view-mode='simple'] .calendar-modes {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 8px;
}
html[data-view-mode='simple'] .calendar-modes > .btn {
  width: 100%;
  min-width: 0;
  justify-content: center;
}
/* Makieta in the simple view: only status and price on the cards. */
html[data-view-mode='simple'] .quick-card .quick-extra,
html[data-view-mode='simple'] .quick-card .row-location {
  display: none !important;
}
html[data-view-mode='simple'] #globalMenuToggle,
html[data-view-mode='simple'] .topbar .mode-switch,
html[data-view-mode='simple'] #floatingPreview {
  display: none !important;
}
.simple-tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 18px 0;
}
.simple-tiles-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.simple-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 6px;
  min-height: 108px;
  padding: 16px;
  border: 1px solid var(--line, #e2e2e2);
  border-radius: 16px;
  background: var(--surface, var(--panel-gray-ffffff, #fff));
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.simple-tile:active {
  transform: scale(0.98);
}
.simple-tile svg {
  width: 26px;
  height: 26px;
  margin-bottom: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.simple-tile strong {
  font-size: 17px;
  line-height: 1.25;
}
.simple-tile span {
  font-size: 13px;
  color: var(--muted, #767676);
}
.simple-back {
  margin: 0 0 8px;
}
.simple-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}
.simple-tabs > button {
  min-height: 46px;
  justify-content: center;
}
.simple-search {
  width: 100%;
  min-height: 48px;
  margin: 4px 0 12px;
  padding: 10px 14px;
  border: 1px solid var(--line, #e2e2e2);
  border-radius: 12px;
  font: inherit;
  font-size: 16px;
  background: var(--surface, var(--panel-gray-ffffff, #fff));
  color: inherit;
}
.simple-list {
  display: grid;
  gap: 8px;
}
.simple-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  min-height: 60px;
  padding: 12px 14px;
  border: 1px solid var(--line, #e2e2e2);
  border-radius: 12px;
  background: var(--surface, #fff);
  color: inherit;
  font: inherit;
  text-align: left;
}
.simple-row span {
  font-size: 13px;
  color: var(--muted, #767676);
}
.simple-section {
  margin: 22px 0 8px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #767676);
}
.simple-task {
  display: grid;
  gap: 6px;
  margin: 0 0 10px;
  padding: 14px;
  border: 1px solid var(--line, #e2e2e2);
  border-radius: 12px;
  background: var(--surface, #fff);
}
.simple-task .btn,
.simple-task button {
  min-height: 46px;
}
.simple-task input[type='range'] {
  width: 100%;
  accent-color: var(--accent, #252525);
}
.simple-actions {
  display: grid;
  gap: 10px;
  margin: 12px 0 18px;
}
.simple-actions .btn {
  min-height: 52px;
  justify-content: center;
  white-space: normal;
}
.simple-history {
  display: grid;
  gap: 2px;
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--soft, #f0f0f0);
}
.simple-history small {
  color: var(--muted, #767676);
}

/* Bottom app bar (phones): mode switch, start screen, conversations. */
.app-bar {
  display: none;
}
.simple-note {
  margin: 18px 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--soft, var(--panel-gray-f1f1f1, #f0f0f0));
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 760px) {
  body {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }
  /* With viewport-fit=cover the page reaches the screen edge (Chrome on Android draws it under the
     navigation bar, without the light divider line); the bar pads itself by the safe area. */
  .app-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 950;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 0 10px env(safe-area-inset-bottom);
    border-top: 1px solid var(--line, #e2e2e2);
    background: var(--surface, var(--panel-gray-ffffff, #fff));
    box-shadow: 0 -4px 18px #0000000d;
  }
  .app-bar > * {
    justify-self: center;
  }
  .app-bar-switch,
  .app-bar-home {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 72px;
    min-height: 52px;
    padding: 4px 8px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 11px;
    font-weight: 650;
    text-decoration: none;
  }
  .app-bar svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  /* The conversations button looks like the other bar items: outline icon with a caption. */
  .app-bar .communication-fab {
    position: relative !important;
    right: auto;
    bottom: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px !important;
    width: auto;
    min-width: 72px;
    height: auto;
    min-height: 52px;
    padding: 4px 8px !important;
    border: 0 !important;
    border-radius: 12px !important;
    background: none !important;
    color: inherit !important;
    box-shadow: none;
    font-size: 11px;
    font-weight: 650;
    line-height: 1.2;
  }
  .app-bar .communication-fab > svg {
    width: 24px;
    height: 24px;
    transform: none;
  }
  .app-bar .communication-fab .communication-count {
    right: 12px;
    top: -2px;
    min-width: 16px;
    height: 16px;
    padding: 1px 4px;
    font-size: 10px;
    line-height: 14px;
  }
  .app-bar-chat:empty {
    display: none;
  }
  .toast {
    bottom: calc(84px + env(safe-area-inset-bottom)) !important;
  }

  .phone-only {
    display: revert !important;
  }
  .phone-hide {
    display: none !important;
  }

  /* One-row header. */
  .shell-header,
  .topbar {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 0;
    padding: 10px 12px !important;
  }
  .shell-header .studio-identity,
  .topbar .studio-identity {
    flex: 1 1 0;
    min-width: 0;
    gap: 10px;
  }
  .topbar .brand-block {
    grid-column: auto;
    max-width: none;
    width: auto;
  }
  /* Makieta: logo and module name start at the left edge like in the other modules. */
  .topbar .studio-identity {
    justify-content: flex-start;
  }
  .topbar .studio-identity > .brand {
    flex: none;
    justify-content: center;
    width: 46px !important;
    min-width: 46px !important;
    padding: 0 !important;
  }
  .studio-identity-copy {
    display: none !important;
  }
  .studio-identity .studio-module-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    align-self: center;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 15px;
    font-weight: 650;
    line-height: 1.25;
    /* Two lines by default ("Makieta / inwestycji"), so every module looks the same. */
    max-width: 11ch;
    margin-right: 8px;
    text-align: left;
  }
  .studio-identity .brand svg {
    width: 38px;
    height: 38px;
    padding: 8px;
  }
  .topbar .file-actions {
    display: flex;
    gap: 6px;
    margin: 0;
    width: auto;
  }
  .shell-header .module-menu,
  .topbar .module-menu {
    margin-left: 0;
  }
  .shell-header .module-menu > summary,
  .topbar .module-menu > summary,
  .shell-header .theme,
  .topbar #panelTheme,
  .topbar #globalMenuToggle,
  .studio-help > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    margin: 0;
    padding: 0 !important;
    font-size: 0 !important;
    border-radius: 10px;
  }
  .shell-header .module-menu > summary::after,
  .shell-header .module-menu > summary > *,
  .topbar #panelTheme > span,
  .studio-help > summary > span,
  .topbar .module-menu > summary::after {
    display: none !important;
  }
  .topbar #panelTheme .button-icon {
    width: 20px;
    height: 20px;
  }
  .shell-header .module-menu > summary::before,
  .topbar .module-menu > summary::before {
    content: '';
    width: 20px;
    height: 20px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8'%3E%3Cpath d='M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z'/%3E%3C/svg%3E")
      center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8'%3E%3Cpath d='M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z'/%3E%3C/svg%3E")
      center / contain no-repeat;
  }
  .studio-help > summary::before {
    width: 22px;
    height: 22px;
    margin: 0;
  }
  .topbar #globalMenuToggle::before {
    content: '☰';
    font-size: 20px;
    line-height: 1;
  }
  .topbar #globalMenuToggle {
    order: 5;
  }
  .topbar .mode-switch:not([hidden]) {
    order: 10;
    flex: 0 0 100%;
  }
  .topbar .global-nav {
    right: 12px;
  }
  /* Drop-down menus hang from the header edge to edge, never off the left side of the screen. */
  .shell-header,
  .topbar {
    position: relative;
  }
  .shell-header .module-menu,
  .shell-header .studio-help,
  .topbar .module-menu,
  .topbar .studio-help,
  .topbar .file-actions {
    position: static !important;
  }
  .module-menu-links,
  .topbar .module-menu .help-menu-items,
  .studio-help-items {
    position: absolute !important;
    top: calc(100% + 6px) !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    min-width: 0 !important;
    max-height: calc(100dvh - 100px);
    overflow-y: auto;
    z-index: 200;
  }
  .module-menu-links a,
  .topbar .module-menu .help-menu-items a {
    display: flex !important;
    justify-content: flex-start !important;
    text-align: left !important;
    min-height: 46px;
    margin: 2px 0 !important;
  }

  /* Summary tiles: two equal columns, number at the bottom, no overflow; a lone last tile spans both. */
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  .stats > .stat {
    justify-content: flex-start;
    min-width: 0;
    padding: 14px !important;
    gap: 8px;
  }
  .stats > .stat:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  .stat > span {
    font-size: 13px;
    line-height: 1.35;
    min-height: 2.7em;
  }
  .stat strong {
    /* Amounts such as "6 200 000 zł" stay on one line at 360 px; long ones still wrap as a last resort. */
    font-size: clamp(16px, 5vw, 21px) !important;
    line-height: 1.2;
    letter-spacing: -0.4px !important;
    overflow-wrap: anywhere;
  }

  /* Planner investment cards: compact figure lines, the budget bar and the buttons close together. */
  .planner-click-card > h2 {
    margin: 0 0 8px;
  }
  .planner-click-card > h2 + p {
    margin: 0 0 14px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--muted);
  }
  .planner-click-card .planner-fact {
    gap: 10px;
    font-size: 14px;
    line-height: 1.4;
  }
  .planner-click-card .planner-fact svg {
    width: 30px;
    height: 30px;
    padding: 6px;
  }
  .planner-click-card .budget-meter {
    margin: 14px 0 0;
  }
  .planner-click-card .budget-meter p {
    margin: 0 0 8px;
    font-size: 14px;
  }
  .planner-click-card .budget-meter .budget-track + p {
    margin: 8px 0 0;
  }

  /* Task rows: title on top, "Wykonane" and the other actions in one even row. */
  .crm-task-row {
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 10px !important;
  }
  .crm-task-row > div:first-child {
    grid-column: 1 / -1;
  }
  .crm-task-row > .btn {
    width: auto !important;
  }
  .crm-row-actions {
    display: flex;
    gap: 8px;
  }

  /* Calendar controls: month row, then actions; view switch in equal thirds. */
  .calendar-toolbar {
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr) 44px;
    gap: 8px !important;
    align-items: stretch;
  }
  .calendar-toolbar > * {
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
  }
  .calendar-toolbar > .btn:nth-of-type(1),
  .calendar-toolbar > .btn:nth-of-type(2) {
    padding: 0;
  }
  .calendar-toolbar input {
    grid-column: 2 / 4;
  }
  .calendar-toolbar > .btn:nth-of-type(3) {
    grid-column: 1 / 3;
  }
  .calendar-toolbar > .btn:nth-of-type(4) {
    grid-column: 3 / 5;
  }
  .calendar-ical {
    width: 100%;
    margin-top: 16px;
  }
  .calendar-toolbar input {
    height: 44px;
    padding: 0 10px;
  }
  .calendar-modes {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px !important;
  }
  .calendar-modes select {
    grid-column: 1 / -1;
    height: 44px;
  }

  /* Studio: investment bar without sideways scrolling (desktop-only sections are hidden). */
  #projectNav {
    flex-wrap: wrap !important;
    overflow: visible !important;
    min-height: 0 !important;
    gap: 6px !important;
    padding: 8px 12px !important;
  }
  #projectNav > button:first-child {
    font-size: 13px;
    min-height: 38px;
    padding: 6px 10px;
  }
  #projectNav > strong {
    display: none !important;
  }
  #projectNav > button:first-child {
    flex: 0 0 100%;
    justify-content: flex-start;
  }
  #projectNav .nav-item {
    flex: 1 1 auto;
    white-space: nowrap !important;
    min-width: 0;
    min-height: 42px !important;
    padding: 6px 10px;
    text-align: center;
    justify-content: center;
    font-size: 13px;
  }

  /* Studio: quick status and price cards. */
  .quick-list {
    display: grid;
    gap: 12px;
    margin: 8px 0 16px;
  }
  .quick-card {
    display: grid;
    gap: 6px;
    padding: 16px;
    border: 1px solid var(--line, #e2e2e2);
    border-radius: 14px;
    background: var(--panel-gray-ffffff, #fff);
  }
  .quick-card.is-dirty {
    border-color: var(--green, #262626);
    box-shadow: 0 0 0 1px var(--green, #262626);
  }
  .quick-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .quick-card-head strong {
    font-size: 17px;
  }
  .quick-card-head .status-pill {
    margin: 0;
    flex: none;
  }
  .quick-card-fact {
    margin: 0;
    font-size: 13px;
    color: var(--muted, #767676);
  }
  .quick-card-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    margin-top: 8px;
  }
  .quick-card-form label {
    display: grid;
    gap: 4px;
    margin: 0;
    font-size: 12px;
    color: var(--muted, #767676);
  }
  .quick-card-form select,
  .quick-card-form input {
    width: 100%;
    min-width: 0;
    height: 46px;
    margin: 0;
    font-size: 16px;
  }
  .quick-card-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
  }
  .quick-card-actions .quick-save {
    flex: 1;
    min-height: 46px;
  }
  .quick-card-actions .quick-save:disabled {
    opacity: 0.45;
  }
  .quick-card-actions button {
    min-height: 46px;
  }
  .phone-note {
    margin: 4px 0 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--panel-gray-f1f1f1, #f0f0f0);
    font-size: 13px;
    line-height: 1.5;
  }
  .context-plan-layout {
    display: block !important;
  }
  .context-view-rail {
    display: none !important;
  }

  /* Wide tables (4+ columns) keep readable columns and scroll sideways (with the hint above);
     small tables (e.g. cost | amount) fit the screen. */
  .table-wrap > table:has(th:nth-child(4)) {
    min-width: 620px;
  }
  .table-wrap th,
  .table-wrap td {
    padding: 12px 12px;
  }
  .table-wrap td .detail-actions,
  .table-wrap td .row-actions,
  .table-wrap td .planner-list-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 6px;
    margin: 0 !important;
  }
  .table-wrap td .detail-actions .btn,
  .table-wrap td .row-actions .btn {
    width: auto !important;
    white-space: nowrap;
  }
  .board {
    scroll-snap-type: x mandatory;
  }
  .board > * {
    scroll-snap-align: start;
  }

  /* Calendar month on a phone: events as colour markers; a tap on a day opens its agenda. */
  .calendar-grid {
    gap: 3px !important;
  }
  .calendar-grid .calendar-weekday {
    font-size: 11px;
  }
  .calendar-grid .calendar-day,
  .calendar-grid .calendar-empty {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: 1 / 1.05;
    padding: 3px !important;
    overflow: hidden !important;
    border-radius: 8px;
    cursor: pointer;
  }
  .calendar-grid .calendar-day .calendar-date {
    position: static;
    width: 100%;
    min-height: 0 !important;
    height: auto;
    padding: 2px 0 !important;
    border: 0;
    background: none;
    font-size: 13px !important;
    line-height: 1.2;
  }
  .calendar-grid .calendar-event-with-delete {
    display: block;
  }
  .calendar-grid .calendar-event-with-delete > .delete-icon {
    display: none !important;
  }
  .calendar-grid .calendar-event {
    display: block;
    height: 6px;
    min-height: 0 !important;
    margin: 3px 0 0 !important;
    padding: 0 !important;
    overflow: hidden;
    font-size: 0 !important;
    border-radius: 3px;
    pointer-events: none;
  }

  /* Module sections: one button with the current section; the list opens below it. */
  .module-sidebar {
    padding: 8px 12px !important;
  }
  .module-nav-toggle {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    font-size: 15px;
  }
  .module-nav-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.15s;
  }
  .module-sidebar.nav-open .module-nav-toggle svg {
    transform: rotate(180deg);
  }
  .module-sidebar nav {
    display: none !important;
  }
  .module-sidebar.nav-open nav {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px;
    margin-top: 8px;
    max-height: calc(100dvh - 160px);
    overflow-y: auto !important;
  }
  .module-sidebar.nav-open nav .btn {
    justify-content: flex-start;
    width: 100%;
    min-height: 46px;
  }
}

/* Small laptops: "Szukaj lokalu" shows only its icon (the label stays as the button's accessible name) and the
   investment bar may wrap instead of hiding "Podgląd projektu" behind a sideways scroll. */
@media (min-width: 1101px) and (max-width: 1400px) {
  #projectNav {
    flex-wrap: wrap !important;
    overflow: visible !important;
    row-gap: 6px !important;
  }
  #projectNav > .project-search-button {
    margin-left: auto;
    gap: 0 !important;
    font-size: 0 !important;
  }
  #projectNav > .project-search-button svg {
    width: 18px;
    height: 18px;
  }
  #projectNav > .nav-item {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}

/* Tablets (portrait and small landscape): compact header, investment bar wraps instead of overflowing. */
@media (min-width: 761px) and (max-width: 1100px) {
  .shell-header,
  .topbar {
    gap: 10px !important;
    padding-left: 18px !important;
    padding-right: 18px !important;
  }
  .studio-identity-copy small,
  .studio-identity #brandDeveloper {
    display: none !important;
  }
  .shell-header .theme,
  .topbar #panelTheme {
    font-size: 0 !important;
    gap: 0 !important;
    padding: 10px !important;
    min-width: 43px;
  }
  .shell-header .theme span,
  .topbar #panelTheme > span {
    display: none !important;
  }
  .studio-help > summary {
    padding: 10px 14px !important;
    gap: 10px;
  }
  #projectNav {
    flex-wrap: wrap !important;
    overflow: visible !important;
    row-gap: 6px !important;
  }
  #projectNav > .project-search-button {
    margin-left: auto;
  }
}

/* CRM full view on a phone: contact cards instead of the wide table (modules/crm.js). */
.crm-contact-cards {
  display: grid;
  gap: 10px;
}
.crm-contact-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.crm-contact-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.crm-contact-card-head .crm-contact-identity {
  min-width: 0;
}
.crm-contact-card p {
  margin: 0;
  font-size: 13px;
}
.crm-contact-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.crm-contact-card-actions .btn:not(.delete-icon) {
  flex: 1;
  justify-content: center;
  min-height: 44px;
}
