/* =========================================================
   Control Finques — "Mini Pico" (CSS propi)
   Objectiu: look net tipus Pico, sense dependències.

  Guia ràpida de manteniment:
  - Aquest fitxer defineix l'estil global de tota l'app.
  - Les variables :root (colors/espais) són la font de veritat visual.
  - Evita hardcodejar colors en plantilles: usa variables aquí.
========================================================= */

/* --- Reset suau --- */
*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.25;
}

/* --- Tema base (fosc suau) --- */
:root{
  --bg: #0f141a;
  --panel: rgba(255,255,255,.03);
  --border: rgba(255,255,255,.10);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.70);
  --accent: #0ea5e9;
  --accent2: rgba(14,165,233,.18);

  --radius: 12px;
  --shadow: 0 1px 0 rgba(0,0,0,.2);
  --font: 14px;   /* mida global */
  --gap: 10px;    /* espai base */
  --pad: 10px;    /* padding base */
}

body{
  background: var(--bg);
  color: var(--text);
  font-size: var(--font);
  overflow-x: hidden;
}

body.cf-has-bottom-nav {
  padding-bottom: 0;
}

main.container{
  padding-top: 12px;
  padding-bottom: 22px;
}

/* --- Container --- */
.container{
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px;
}
@media (min-width: 1400px){
  .container{ max-width: 1360px; }
}

/* --- Tipografia --- */
h1,h2,h3{ margin: 6px 0 10px; line-height: 1.1; }
h1{ font-size: 22px; }
h2{ font-size: 18px; }
h3{ font-size: 15px; }
p{ margin: 6px 0 10px; color: var(--muted); }

/* --- Links --- */
a{ color: var(--accent); text-decoration: none; }
a:hover{ text-decoration: underline; }

/* --- Navbar --- */
header{ padding: 6px 0; }
nav{
  display:flex; align-items:center; justify-content: space-between; gap: 12px;
}
nav ul{
  list-style:none; padding:0; margin:0; display:flex; align-items:center; gap: 10px;
}
nav a{ padding: 6px 8px; border-radius: 10px; }
nav a:hover{ background: rgba(255,255,255,.04); text-decoration:none; }

.cf-topbar-wrap{ padding-top: 10px; }

.cf-topbar{
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 7px 9px;
  gap: 8px;
}

.cf-topbar a.active{
  color: var(--text);
  background: var(--accent2);
  border: 1px solid rgba(14,165,233,.38);
}

.cf-nav-center{
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

.cf-nav-right{
  justify-content: flex-end;
  gap: 6px;
}

.cf-user-pill{
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--muted);
}

.cf-sync-pill{
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, .35);
  background: rgba(245, 158, 11, .12);
  color: #fbbf24;
}

.cf-sync-pill__count{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 .35rem;
  border-radius: 999px;
  background: rgba(15, 20, 26, .55);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
}

.cf-brand-link{
  color: var(--text);
  font-weight: 700;
  letter-spacing: .01em;
}

.cf-brand-link:hover{
  background: rgba(255,255,255,.06);
}

.cf-brand-link:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px var(--accent2);
}

.cf-page-header {
  display: flex;
  justify-content: space-between;
  gap: .8rem;
  align-items: flex-start;
  margin-bottom: .8rem;
}

.cf-page-header__text h2,
.cf-page-header__text h3,
.cf-page-header__text p {
  margin-top: 0;
}

.cf-soft-inline {
  margin: 0;
}

.cf-soft-inline--topbar{
  display: flex;
}

.cf-soft-inline--profile{
  display: flex;
}

.cf-muted {
  color: var(--muted);
}

.cf-map-activation {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 650;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(15,20,26,.88);
  color: #fff;
  backdrop-filter: blur(10px);
}

.cf-shell-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.cf-card{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.cf-card h3,
.cf-card h4{
  margin-top: 0;
}

.cf-detail-shell{
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  margin-bottom: 12px;
}

.cf-detail-side,
.cf-detail-map-card{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.cf-photo-box{
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 170px;
  background: rgba(255,255,255,.02);
}

.cf-photo-box img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cf-photo-empty{
  min-height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.cf-detail-title{
  margin: 0 0 .35rem;
}

.cf-detail-list{
  margin: 0;
  padding-left: 1.1rem;
}

.cf-detail-list li + li{
  margin-top: .2rem;
}

.cf-detail-meta-action{
  margin-left: .5rem;
  min-height: 30px;
  padding: .25rem .55rem;
  font-size: .85rem;
}

.cf-detail-meta-action--warn{
  background: #ff9800;
  border-color: #ff9800;
  color: #fff;
}

.cf-detail-primary-action{
  font-weight: 600;
}

.cf-detail-hero__actions{
  margin-top: .9rem;
  flex-wrap: wrap;
}

.cf-detail-danger-zone{
  gap: .5rem;
}

.cf-detail-danger-zone .cf-plan-meta{
  margin: 0;
}

.cf-section-title{
  margin-top: 0;
}

.cf-hidden-form{
  display: none;
}

.cf-color-chip{
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  background: var(--cf-chip-color, #3388ff);
  border: 1px solid #888;
  border-radius: .2rem;
}

.cf-map-legend{
  background: #fff;
  padding: .5rem .6rem;
  border: 1px solid #ccc;
  border-radius: .5rem;
  line-height: 1.4;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  color: #111;
}

.cf-map-legend__row{
  display: flex;
  align-items: center;
  gap: .4rem;
}

.cf-map-legend__row + .cf-map-legend__row{
  margin-top: .14rem;
}

.cf-map-legend__swatch{
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid #999;
}

.cf-map-legend__swatch--dark{
  border-color: #111;
}

.cf-map-legend hr{
  margin: .4rem 0;
  border: 0;
  border-top: 1px solid #ddd;
}

.cf-map-legend--compact{
  padding: .38rem .45rem;
  border-radius: .6rem;
  font-size: .82rem;
  line-height: 1.2;
  max-width: 220px;
}

.cf-map-legend--compact .cf-map-legend__row{
  gap: .32rem;
}

.cf-map-legend--compact .cf-map-legend__row + .cf-map-legend__row{
  margin-top: .12rem;
}

.cf-map-legend--compact .cf-map-legend__swatch{
  width: 10px;
  height: 10px;
}

.cf-map-legend--compact hr{
  margin: .28rem 0;
}

.cf-modal{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0,0,0,.5);
  z-index: 1000;
}

.cf-modal[hidden]{
  display: none;
}

.cf-detail-hero{
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
  gap: 14px;
  align-items: start;
}

.cf-detail-eyebrow{
  margin: 0 0 .35rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .74rem;
  color: var(--muted);
}

.cf-detail-kpis{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.cf-kpi-card,
.cf-detail-meta-card{
  display: grid;
  gap: .32rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.02);
  padding: .85rem .95rem;
}

.cf-kpi-card__label,
.cf-detail-meta-card__label{
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}

.cf-kpi-card__value,
.cf-detail-meta-card__value{
  font-size: 1rem;
  line-height: 1.25;
}

.cf-detail-meta-grid{
  display: grid;
  gap: 10px;
}

.cf-detail-section-head{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .8rem;
  margin-bottom: .75rem;
}

.cf-detail-section-head > *{
  margin-top: 0;
}

.cf-detail-section-head__actions{
  flex: 0 0 auto;
}

.cf-detail-map-actions{
  margin-top: 0;
}

.cf-detail-map-note{
  margin: -.1rem 0 .8rem;
}

.cf-plan-grid--detail{
  align-items: start;
}

.cf-detail-table{
  margin-top: .65rem;
}

.cf-mobile-card-list--detail{
  margin-top: .75rem;
}

.cf-bancal-card__head,
.cf-order-mini-card__head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  margin-bottom: .4rem;
}

.cf-bancal-card__head h4,
.cf-order-mini-card__head h4{
  margin: 0;
}

.cf-order-mini-card__status{
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .8rem;
}

.cf-bancal-card p,
.cf-order-mini-card p{
  margin: 0 0 .25rem;
}

.cf-map--detail{
  height: 60vh;
  margin: 0;
}

.bancal-label{
  background: rgba(255,255,255,.85);
  color:#111;
  border:1px solid #bbb;
  padding:.1rem .3rem;
  border-radius:.25rem;
  font-size:.85rem;
}

.pou-marker-square {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 2px solid #111;
  box-shadow: 0 0 0 1px rgba(255,255,255,.35);
}

.pou-sortida { background: #2b9cff; }
.pou-final-linia { background: #ffd27a; }
.pou-partidor { background: #e45756; }
.pou-ullal { background: #ffffff; }

.cf-map-legend__swatch--limit { background: #ff7f0e; }
.cf-map-legend__swatch--bancal { background: #3388ff; }
.cf-map-legend__swatch--sortida { background: #2b9cff; }
.cf-map-legend__swatch--final-linia { background: #ffd27a; }
.cf-map-legend__swatch--partidor { background: #e45756; }
.cf-map-legend__swatch--ullal { background: #ffffff; }

.cf-modal{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0,0,0,.5);
  z-index: 1000;
}

.cf-modal[hidden]{
  display: none;
}

body.cf-modal-open{
  overflow: hidden;
}

.cf-modal__dialog{
  width: min(100%, 450px);
  max-height: min(86vh, 760px);
  overflow: auto;
  background: #fff;
  color: #333;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 8px 16px rgba(0,0,0,.2);
}

.cf-modal__dialog--shell{
  max-width: 520px;
}

.cf-modal__dialog--wide{
  max-width: 720px;
}

.cf-modal__header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
}

.cf-modal__header-copy{
  display: grid;
  gap: .25rem;
}

.cf-modal__close{
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.cf-modal__subtitle{
  margin: 0;
  color: #667085;
  font-size: .92rem;
}

.cf-modal__title{
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
  color: #333;
}

.cf-modal__body{
  margin-bottom: 1.25rem;
}

.cf-modal__field{
  margin-bottom: 1rem;
}

.cf-modal__label{
  display: block;
  margin-bottom: .5rem;
  font-weight: 600;
  color: #333;
  font-size: .95rem;
}

.cf-modal__textarea,
.cf-modal__select,
.cf-modal__input{
  width: 100%;
  padding: .75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #111;
  font-family: inherit;
  font-size: .95rem;
}

.cf-modal__note{
  color: #666;
  font-size: .9rem;
  margin: 0;
}

#cf-dialog-message:empty{
  display: none;
}

.cf-modal__actions{
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.cf-modal__danger{
  background: #ff6b6b;
  border-color: #ff6b6b;
  color: #fff;
}

.cf-inline-actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.parcella-list-map-shell{
  margin-bottom: .75rem;
}

.parcella-list-map-frame{
  margin: 0;
}

.cf-parcella-card{
  display: grid;
  gap: .7rem;
}

.cf-parcella-card__meta{
  display: grid;
  gap: .22rem;
}

.cf-parcella-card__meta p{
  margin: 0;
}

.cf-parcella-card__coords span{
  overflow-wrap: anywhere;
}

.cf-parcella-card__actions{
  margin-top: .15rem;
}

.cf-profile-actions{
  margin: 0 0 .85rem;
}

.cf-profile-actions .cf-soft-inline--profile{
  flex: 1 1 220px;
}

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

.cf-profile-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .85rem;
}

.cf-table-desktop-only{
  display: table;
}

/* --- Formulari: base global --- */
label{
  display:block; margin: 0 0 4px;
  font-weight: 600; font-size: 12px; color: var(--muted);
}
input, select, textarea{
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 9px;
  min-height: 34px;
  outline: none;
}
input:focus, select:focus, textarea:focus{
  border-color: rgba(14,165,233,.55);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}

/* Selects i desplegables en tema fosc (evita text/fons blancs) */
select{
  color-scheme: dark;
}
select option,
select optgroup{
  background: #18212b;
  color: #eaf1ff;
}

/* Scrollbars globals (coherents amb el tema) */
*{
  scrollbar-width: thin;
  scrollbar-color: #3a4a5f #111925;
}
*::-webkit-scrollbar{
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track{
  background: #111925;
}
*::-webkit-scrollbar-thumb{
  background: #3a4a5f;
  border-radius: 10px;
  border: 2px solid #111925;
}
*::-webkit-scrollbar-thumb:hover{
  background: #4f637d;
}

/* --- Botons --- */
button, [type="submit"], a[role="button"]{
  display:inline-flex; align-items:center; justify-content:center; gap: 8px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 10px;
  min-height: 34px;
  cursor:pointer; text-decoration:none;
}
button:hover, [type="submit"]:hover, a[role="button"]:hover{
  background: rgba(255,255,255,.09);
  text-decoration:none;
}
a[role="button"]{ color: var(--text); }

button.primary,
a[role="button"].primary,
[type="submit"].primary{
  background: var(--accent2);
  border-color: rgba(14,165,233,.45);
}

button.primary:hover,
a[role="button"].primary:hover,
[type="submit"].primary:hover{
  background: rgba(14,165,233,.28);
}

button.danger,
a[role="button"].danger,
[type="submit"].danger{
  background: rgba(220, 38, 38, .24);
  border-color: rgba(248, 113, 113, .5);
  color: #ffd7d7;
}

button.danger:hover,
a[role="button"].danger:hover,
[type="submit"].danger:hover{
  background: rgba(220, 38, 38, .34);
}

/* --- Taules --- */
table{
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow:hidden;
  font-size: .95rem; /* densitat lleu */
}
th, td{
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align:left; vertical-align: middle;
}
thead th{
  color: var(--muted);
  font-size: 12px;
}
tbody tr:hover{ background: rgba(255,255,255,.03); }

/* =========================================================
   Components ControlFinques (els que ja estàs usant)
========================================================= */

.cf-toolbar{ display:flex; gap: 10px; align-items:center; margin: 6px 0 10px; }

.cf-map{
  height: 46vh;
  width: 100%;
  margin: 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow:hidden;
  background: rgba(255,255,255,.02);
}

.cf-map-shell{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: .7rem;
}

.cf-map-shell > h3,
.cf-map-shell > h4{
  margin: .15rem .2rem .6rem;
}

.cf-map-theme .leaflet-control-zoom a,
.cf-map-theme .leaflet-control-layers-toggle,
.cf-map-theme .leaflet-draw-toolbar a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background-color: #18212b;
  color: #eaf1ff;
  border-color: rgba(255,255,255,.14);
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.22);
}

.cf-map-theme .leaflet-control-zoom a:hover,
.cf-map-theme .leaflet-control-layers-toggle:hover,
.cf-map-theme .leaflet-draw-toolbar a:hover {
  background: #213042;
  color: #eaf1ff;
}

.cf-map-theme .leaflet-control-zoom,
.cf-map-theme .leaflet-control-layers,
.cf-map-theme .leaflet-draw {
  margin-top: 10px;
}

@media (max-width: 720px){
  .cf-detail-hero__actions{
    width: 100%;
  }

  .cf-detail-hero__actions > *{
    flex: 1 1 160px;
  }

  .cf-detail-section-head{
    flex-direction: column;
  }

  .cf-detail-section-head__actions{
    width: 100%;
  }

  .cf-detail-section-head__actions > *{
    width: 100%;
  }

  .cf-map-legend--compact{
    max-width: 180px;
    font-size: .76rem;
  }
}

.cf-map-theme .leaflet-bar,
.cf-map-theme .leaflet-control-layers {
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(0,0,0,.24);
}

.cf-map-theme .leaflet-control-layers-toggle {
  background-color: #18212b;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%23eaf1ff' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8'%3E%3Cpath d='M12 3 4 7l8 4 8-4-8-4Z'/%3E%3Cpath d='m4 12 8 4 8-4'/%3E%3Cpath d='m4 17 8 4 8-4'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 22px 22px;
}

.cf-map-theme .leaflet-control-zoom a {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.cf-map-theme .leaflet-touch .leaflet-bar a {
  width: 44px;
  height: 44px;
  line-height: 44px;
}

.cf-map-theme .leaflet-control-layers-expanded {
  background: #18212b;
  color: #eaf1ff;
  border: 1px solid rgba(255,255,255,.14);
  padding: 12px 14px;
  min-width: 170px;
}

.cf-map-theme .leaflet-control-layers-list {
  display: grid;
  gap: 8px;
}

.cf-map-theme .leaflet-control-layers-base,
.cf-map-theme .leaflet-control-layers-overlays {
  display: grid;
  gap: 8px;
}

.cf-map-theme .leaflet-control-layers-separator {
  margin: 2px 0;
  border-top-color: rgba(255,255,255,.12);
}

.cf-map-theme .leaflet-control-layers-expanded label,
.cf-map-theme .leaflet-control-layers label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: #eaf1ff;
  font-size: .92rem;
  font-weight: 600;
  line-height: 1.25;
}

.cf-map-theme .leaflet-control-layers input,
.cf-map-theme .leaflet-control-layers-selector {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  padding: 0;
  flex: 0 0 18px;
  appearance: auto;
  accent-color: #38bdf8;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.cf-map-theme .leaflet-control-layers input:focus,
.cf-map-theme .leaflet-control-layers-selector:focus {
  box-shadow: none;
}

.cf-map-theme .leaflet-control a,
.cf-map-theme .leaflet-control label {
  text-decoration: none;
}

.cf-map-theme .leaflet-popup-content-wrapper,
.cf-map-theme .leaflet-popup-tip {
  background: #18212b;
  color: #eaf1ff;
}

.cf-map-theme .leaflet-popup-content a {
  color: #7cc7ff;
}

.cf-map-control-group + .cf-map-control-group{
  margin-top: 6px;
}

.cf-map-control-button{
  font-weight: 700;
  min-width: 40px;
  min-height: 40px;
  text-align: center;
  font-size: 1rem;
}

@media (max-width: 980px){
  .cf-map-theme .leaflet-top.leaflet-right {
    top: 4px;
    right: 4px;
  }

  .cf-map-theme .leaflet-control-zoom a,
  .cf-map-theme .leaflet-control-layers-toggle,
  .cf-map-theme .leaflet-draw-toolbar a,
  .cf-map-control-button {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
  }

  .cf-map-theme .leaflet-control-layers-toggle {
    background-size: 24px 24px;
  }

  .cf-map-theme .leaflet-control-layers {
    max-width: 56px;
  }
}

.cf-plan-card{
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
}

.cf-plan-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.cf-plan-meta{
  color: var(--muted);
  font-size: .92rem;
}

.cf-panel-table{
  width: 100%;
  border-collapse: collapse;
}

.cf-panel-table th,
.cf-panel-table td{
  padding: .6rem .7rem;
}

.cf-mobile-card-list{
  display: none;
}

/* Atribució Leaflet/tiles: mínima però visible */
.leaflet-control-attribution {
  font-size: 9px !important;
  line-height: 1.05 !important;
  padding: 1px 4px !important;
  opacity: .28;
  background: rgba(15, 20, 26, 0.25) !important;
  border-radius: 6px 0 0 0;
}

.leaflet-control-attribution:hover {
  opacity: .75;
}

.leaflet-control-attribution a {
  color: rgba(234, 241, 255, 0.78) !important;
}

/* Filtres en grid */
form.cf-filters{
  display:grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px; align-items:end;
  margin: 8px 0 10px; padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
form.cf-filters .cf-col-2{ grid-column: span 2; }
form.cf-filters .cf-col-3{ grid-column: span 3; }
form.cf-filters .cf-col-4{ grid-column: span 4; }
form.cf-filters .cf-col-6{ grid-column: span 6; }

form.cf-filters .cf-actions{
  grid-column: span 12;
  display:flex; gap: 10px; align-items:center;
}

@media (max-width: 980px){
  form.cf-filters{ grid-template-columns: 1fr; }
  form.cf-filters .cf-col-2,
  form.cf-filters .cf-col-3,
  form.cf-filters .cf-col-4,
  form.cf-filters .cf-col-6{ grid-column: span 1; }
  form.cf-filters .cf-actions{ grid-column: span 1; flex-wrap:wrap; }
}

/* Paginació */
.cf-pagination ul{
  display:flex; gap: 10px; list-style:none; padding:0; margin: 8px 0 0; align-items:center;
}
.cf-pageinfo{ color: var(--muted); }

.cf-notice-stack{
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.notice{
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  border-radius: 10px;
  padding: 10px 12px;
}

.notice.success{
  border-color: rgba(16,185,129,.45);
  background: rgba(16,185,129,.12);
}

.notice.error{
  border-color: rgba(228,87,86,.45);
  background: rgba(228,87,86,.12);
}

.notice.warning{
  border-color: rgba(251,191,36,.45);
  background: rgba(251,191,36,.12);
}

.notice.info{
  border-color: rgba(14,165,233,.45);
  background: rgba(14,165,233,.12);
}

/* =========================================================
   Layout 2 columnes: formulari + mapa (Nova Parcella)
========================================================= */

.cf-split{
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  font-size: 0.9rem; /* densitat lleu a tota la vista */
}
.cf-split-left{ position: sticky; top: 10px; height: fit-content; }

.cf-panel{
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px;
  padding: 10px;
}

.cf-muted{ display:block; margin: .35rem 0 .5rem; opacity: .85; }

/* Grid del formulari (2 columnes) */
.cf-form-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px; align-items: end;
}
.cf-form-grid .cf-col-full{ grid-column: 1 / -1; }

/* Inputs/selects compactes NOMÉS dins la vista .cf-split */
.cf-split label{ font-size: 0.75rem; margin-bottom: 2px; opacity: .85; }
.cf-split input, .cf-split select{
  height: 34px; padding: 4px 8px; font-size: 0.85rem;
}
.cf-split input[readonly]{ opacity: .7; }

/* Mapa alt a la dreta (versió compacta) */
.cf-map--tall{
  height: calc(100vh - 300px);
  min-height: 420px;
}

/* Responsive */
@media (max-width: 980px){
  .cf-split{ grid-template-columns: 1fr; }
  .cf-split-left{ position: static; }
  .cf-form-grid{ grid-template-columns: 1fr; }
  .cf-map--tall{ height: 50vh; min-height: 380px; }
}

/* --- Botons més baixos dins toolbars de la vista --- */
.cf-toolbar button, .cf-toolbar a[role="button"]{
  padding: 6px 12px; font-size: 0.85rem;
}

/* --- Títols compactes dins la vista --- */
.cf-split h3{ font-size: 1rem; margin: 4px 0 6px; }
.cf-muted{ font-size: 0.75rem; margin-bottom: 4px; }

/* =========================================================
   (Opcional) Overrides per Pico si encara el carregues
   -> S'apliquen només si Pico està present.
========================================================= */
:root{
  --pico-form-element-spacing-vertical: .40rem;
  --pico-form-element-spacing-horizontal: .60rem;
  --pico-line-height: 1.25;
  --pico-border-radius: .55rem;
  --pico-typography-spacing-vertical: .75rem;
}
select{ background-position: right .55rem center; }


/* 1) Aplana els wrappers dels camps (evita que afegeixin alçada extra) */
.cf-form-grid > div,
.cf-form-grid fieldset {
  display: grid;            /* label a dalt, input a sota */
  gap: 4px;                 /* espai mínim entre label i input */
  align-content: start;     /* NO centrar verticalment */
  padding: 0;
  margin: 0;
  border: 0;
  min-height: 0;
}

/* 2) Neutralitza qualsevol estil de fieldset que vingui de Pico */
.cf-panel fieldset {
  all: unset;               /* treu padding/border/legend per defecte */
  display: grid;
  gap: 4px;
}

/* 3) Inputs/selects REALMENT baixos dins de la vista de formulari */
.cf-split input,
.cf-split select,
.cf-split textarea {
  height: 44px;
  min-height: 44px;
  padding: 8px 10px;
  font-size: 0.9rem;
  line-height: 1.1;
}

/* 4) Botons també compactes a la zona del formulari */
.cf-split button,
.cf-split [role="button"] {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 0.9rem;
  line-height: 1.1;
}

@media (max-width: 980px){
  .cf-page-header{
    flex-direction: column;
    align-items: stretch;
  }

  main.container{
    padding-top: 6px;
    padding-bottom: 10px;
  }

  .container{
    padding: 7px;
  }

  .cf-topbar-wrap{
    padding-top: 4px;
  }

  .cf-topbar{
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    gap: 8px;
  }

  .cf-topbar ul{
    gap: 4px;
  }

  .cf-nav-left,
  .cf-nav-center,
  .cf-nav-right{
    width: 100%;
  }

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

  .cf-nav-center{
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
  }

  .cf-nav-center li,
  .cf-nav-right li{
    flex: 0 0 auto;
  }

  .cf-nav-center li a{
    display: inline-flex;
    text-align: center;
    padding: 8px 12px;
    min-height: 44px;
    font-size: .9rem;
  }

  .cf-nav-right{
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 6px;
  }

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

  .cf-nav-right li{
    min-width: 0;
  }

  .cf-nav-right__mode,
  .cf-nav-right__sync{
    grid-column: 1 / -1;
  }

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

  .cf-nav-right__profile,
  .cf-nav-right__logout,
  .cf-nav-right__install{
    grid-column: span 1;
  }

  .cf-nav-right__user,
  .cf-nav-right__profile,
  .cf-nav-right__logout,
  .cf-nav-right__mode,
  .cf-nav-right__install,
  .cf-nav-right__sync,
  .cf-nav-right__logout .cf-soft-inline{
    display: flex;
  }

  .cf-nav-right button,
  .cf-nav-right a,
  .cf-nav-right .cf-user-pill,
  .cf-nav-right .cf-soft-inline button{
    width: 100%;
    justify-content: center;
  }

  body.cf-has-bottom-nav .cf-nav-right__user,
  body.cf-has-bottom-nav .cf-nav-right__profile,
  body.cf-has-bottom-nav .cf-nav-right__logout,
  body.cf-has-bottom-nav .cf-nav-right__install,
  body.cf-has-bottom-nav .cf-nav-right__mode{
    display: none;
  }

  body.cf-has-bottom-nav .cf-topbar{
    padding: .75rem;
  }

  body.cf-has-bottom-nav .cf-nav-right__mode,
  body.cf-has-bottom-nav .cf-nav-right__sync{
    grid-column: 1 / -1;
  }

  .cf-user-pill{
    padding: 2px 7px;
    font-size: .82rem;
  }

  .cf-detail-shell{
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .cf-detail-side,
  .cf-detail-map-card{
    padding: 9px;
  }

  .cf-detail-side ul{
    margin: 0;
    padding-left: 1rem;
  }

  .cf-detail-side li{
    margin-bottom: .35rem;
  }

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

  .cf-table-desktop-only{
    display: none;
  }
}

@media (max-width: 520px){
  .cf-topbar-wrap{ padding-top: 4px; }

  body{ line-height: 1.16; }

  h1{ font-size: 1.2rem; margin: 4px 0 8px; }
  h2{ font-size: 1.05rem; margin: 4px 0 8px; }
  h3{ font-size: .94rem; margin: 3px 0 7px; }

  p{ margin: 4px 0 8px; }

  .cf-topbar{
    border-radius: 12px;
    padding: .75rem;
  }

  .cf-nav-center{
    gap: 3px;
  }

  nav a{
    padding: 8px 12px;
    font-size: .84rem;
    min-height: 44px;
  }

  .cf-page-header{
    gap: .6rem;
  }

  .cf-page-header__text p{
    font-size: .94rem;
  }

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

  body.cf-has-bottom-nav .cf-topbar{
    gap: .65rem;
  }

  body.cf-has-bottom-nav .cf-nav-left{
    justify-content: center;
  }

  body.cf-has-bottom-nav .cf-brand-link{
    display: inline-flex;
    justify-content: center;
    width: 100%;
  }

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

  .cf-nav-right__mode,
  .cf-nav-right__sync,
  .cf-nav-right__install{
    grid-column: 1 / -1;
  }

  .cf-inline-actions{
    width: 100%;
    gap: 6px;
  }

  .cf-inline-actions > *{
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }

  .cf-map{
    height: 39vh;
  }

  .cf-nav-right button,
  .cf-nav-right a[role="button"]{
    min-height: 44px;
    padding: 8px 12px;
    font-size: .84rem;
  }

  .cf-parcella-card{
    gap: .55rem;
  }

  .cf-parcella-card__actions > *{
    flex: 1 1 100%;
  }

  .cf-card,
  .notice,
  .cf-plan-card,
  .cf-map-shell,
  .cf-panel,
  .cf-detail-side,
  .cf-detail-map-card{
    padding: .7rem;
    border-radius: 10px;
  }

  .cf-mobile-card-list{
    display: grid;
    gap: .55rem;
  }

  .cf-profile-grid{
    grid-template-columns: 1fr;
    gap: .55rem;
  }

  .cf-profile-actions > *,
  .cf-profile-actions .cf-soft-inline--profile{
    flex: 1 1 100%;
  }

  .cf-mobile-card{
    border: 1px solid var(--border);
    background: rgba(255,255,255,.03);
    border-radius: 10px;
    padding: .65rem;
  }

  .cf-mobile-card h4{
    margin: 0 0 .25rem;
  }

  .cf-mobile-card p{
    margin: 0 0 .25rem;
  }

  .cf-detail-side ul,
  .cf-detail-map-card ul{
    margin: 0;
    padding-left: .95rem;
  }

  .cf-detail-side li,
  .cf-detail-map-card li{
    margin-bottom: .2rem;
  }

  .cf-modal{
    padding: .75rem;
  }

  .cf-modal__dialog{
    padding: 1rem;
    border-radius: 12px;
  }

  .cf-modal__actions > *{
    flex: 1 1 calc(50% - 6px);
  }
}