/* =========================================================
   Control Finques — Shell crític
   Este fitxer concentra l'esquelet visual del primer render perquè
   la base siga robusta sense JS, sense Pico remot i amb viewport mòbil.
========================================================= */

:root {
  --shell-gap: clamp(.75rem, 1vw + .5rem, 1rem);
  --shell-padding-inline: clamp(.8rem, 2vw, 1rem);
  --shell-safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Escala responsive base: 1400 ample, 980 compacte, 640 mòbil i 420 ultraestret. */
  --cf-radius-panel-xxl: 24px;
  --cf-radius-panel-xl: 22px;
  --cf-radius-panel-lg: 20px;
  --cf-radius-panel-md: 18px;
  --cf-radius-panel-sm: 16px;
  --cf-panel-max-compact: 640px;
  --cf-map-height-home: clamp(360px, 65vh, 760px);
  --cf-map-height-detail: clamp(320px, 52vh, 520px);
  --cf-map-height-shell: clamp(340px, 48vh, 520px);
  --cf-map-height-form: clamp(420px, 68vh, 760px);
  --cf-map-height-form-narrow: min(58vh, 560px);
  --cf-map-height-form-mobile: clamp(340px, 52vh, 460px);
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  text-rendering: optimizeLegibility;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

main.container {
  width: min(100%, 1200px);
}

main.container.cf-container-wide {
  width: min(100%, 1480px);
}

.cf-topbar-wrap {
  position: sticky;
  top: 0;
  z-index: 1100;
  padding-top: max(.4rem, env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, rgba(15, 20, 26, .92), rgba(15, 20, 26, 0));
  backdrop-filter: blur(14px);
}

.cf-topbar {
  min-width: 0;
}

.cf-topbar ul {
  min-width: 0;
  flex-wrap: wrap;
}

.cf-nav-left,
.cf-nav-center,
.cf-nav-right {
  min-width: 0;
}

.cf-nav-right {
  row-gap: .4rem;
}

.cf-nav-right > li,
.cf-nav-center > li,
.cf-nav-left > li {
  min-width: 0;
}

.cf-nav-right a,
.cf-nav-right button,
.cf-nav-center a,
.cf-nav-left a {
  white-space: nowrap;
}

.cf-notify {
  position: relative;
}

.cf-notify summary {
  list-style: none;
}

.cf-notify summary::-webkit-details-marker {
  display: none;
}

.cf-notify__trigger {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 40px;
  padding: .5rem .8rem;
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.04);
  cursor: pointer;
}

.cf-notify[open] .cf-notify__trigger {
  background: rgba(14,165,233,.12);
  border-color: rgba(14,165,233,.28);
}

.cf-notify__icon {
  font-size: 1rem;
}

.cf-notify__count,
.cf-notify__state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  min-height: 1.35rem;
  padding: 0 .38rem;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 700;
}

.cf-notify__count {
  background: #dc2626;
  color: #fff;
}

.cf-notify__state {
  background: rgba(148,163,184,.18);
  color: var(--text);
}

.cf-notify__panel {
  position: absolute;
  right: 0;
  z-index: 50;
  width: min(400px, calc(100vw - 2rem));
  margin-top: .6rem;
  padding: 1rem;
  border: 1px solid rgba(148,163,184,.2);
  border-radius: var(--cf-radius-panel-md);
  background:
    radial-gradient(circle at top right, rgba(14,165,233,.12), transparent 32%),
    rgba(15,20,26,.98);
  box-shadow: 0 24px 48px rgba(15,23,42,.35);
}

.cf-notify__header,
.cf-notify__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
}

.cf-notify__list {
  display: grid;
  gap: .55rem;
  padding: 0;
  margin: .8rem 0;
  list-style: none;
}

.cf-notify__list--dropdown {
  max-height: 18rem;
  overflow: auto;
  padding-right: .2rem;
}

.cf-notify__entry {
  border: 1px solid rgba(148,163,184,.14);
  border-radius: 14px;
  background: rgba(255,255,255,.03);
}

.cf-notify__entry.is-unread {
  border-color: rgba(14,165,233,.28);
  background: rgba(14,165,233,.08);
}

.cf-notify__item {
  display: grid;
  gap: .24rem;
  padding: .72rem .78rem;
  text-decoration: none;
  color: inherit;
}

.cf-notify__item-title {
  font-weight: 700;
  line-height: 1.2;
}

.cf-notify__item-meta,
.cf-notify__item-copy,
.cf-notify__empty {
  color: var(--muted);
  font-size: .84rem;
}

.cf-notify__item-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cf-notify__item-copy {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.cf-notify__footnote {
  margin: -.1rem 0 .7rem;
  color: var(--muted);
  font-size: .8rem;
}

.cf-notify__actions {
  flex-wrap: wrap;
  padding-top: .75rem;
  border-top: 1px solid rgba(148,163,184,.12);
}

.cf-user-pill {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.cf-soft-inline--topbar {
  width: 100%;
}

.cf-soft-inline--topbar button {
  width: 100%;
}

label {
  display: grid;
  gap: .35rem;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

input,
select,
textarea,
button {
  font: inherit;
}

.cf-card,
.cf-shell-panel,
.notice {
  overflow: clip;
}

.cf-inline-actions,
.cf-toolbar,
.cf-page-header,
.cf-page-header__aside,
.cf-parcella-header-actions {
  min-width: 0;
}

.cf-bottom-nav {
  display: none;
}

@media (max-width: 980px) {
  body.cf-has-bottom-nav main.container {
    padding-bottom: calc(76px + var(--shell-safe-bottom) + 1rem);
  }

  .cf-topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: .45rem;
    padding: .7rem;
  }

  .cf-nav-left,
  .cf-nav-center,
  .cf-nav-right {
    justify-content: flex-start;
  }

  .cf-nav-left a,
  .cf-nav-center a,
  .cf-nav-right a,
  .cf-nav-right button {
    min-height: 44px;
  }

  .cf-nav-right {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .cf-nav-right__user {
    grid-column: 1 / -1;
  }

  .cf-nav-right__sync,
  .cf-nav-right__install,
  .cf-nav-right__mode,
  .cf-nav-right__notifications,
  .cf-nav-right__profile,
  .cf-nav-right__logout {
    min-width: 0;
  }

  .cf-notify__panel {
    position: static;
    width: 100%;
  }

  .cf-notify__list--dropdown {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .cf-page-header,
  .cf-page-header--parcelles {
    flex-direction: column;
    align-items: stretch;
  }

  .cf-page-header__aside {
    justify-items: stretch;
  }

  .cf-parcella-header-actions,
  .cf-inline-actions,
  .cf-toolbar {
    flex-wrap: wrap;
  }

  .cf-inline-actions > *,
  .cf-toolbar > * {
    min-width: min(100%, 15rem);
  }

  .cf-bottom-nav {
    display: grid;
  }
}

@media (max-width: 640px) {
  .container,
  main.container {
    padding-left: var(--shell-padding-inline);
    padding-right: var(--shell-padding-inline);
  }

  .cf-topbar-wrap {
    margin-bottom: .35rem;
  }

  .cf-topbar {
    border-radius: 18px;
  }

  .cf-nav-right {
    grid-template-columns: 1fr;
  }

  .cf-nav-right a,
  .cf-nav-right button,
  .cf-nav-center a,
  .cf-nav-left a {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .cf-user-pill {
    justify-content: center;
  }
}

@media (min-width: 981px) {
  .cf-bottom-nav,
  .cf-app-shell-spacer {
    display: none !important;
  }
}