/* App shell — sidebar desktop (≥861px), bottom nav mobile (Emil: fast, minimal chrome) */

:root{
  --sidebar-w:264px;
  --sidebar-w-collapsed:48px;
  --ease-shell:cubic-bezier(0.23,1,0.32,1);
  --ease-drawer:cubic-bezier(0.32,0.72,0,1);
}

.app-layout{
  display:flex;
  flex-direction:column;
  min-height:100dvh;
}

.app-sidebar{
  display:none;
}

.app-main{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
}

.app-header .topbar{
  border-bottom:1px solid var(--bd);
  background:color-mix(in srgb,var(--bg2) 92%,transparent);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
  display:grid!important;
  grid-template-columns:auto minmax(0,1fr) auto;
  grid-template-rows:auto auto;
  column-gap:12px;
  row-gap:1px;
  align-items:center;
  height:auto;
  min-height:56px;
  padding:8px 20px 10px;
}

.app-header .topbar .tbr{
  grid-column:3;
  grid-row:1 / -1;
  align-self:center;
  margin-left:0;
}

.app-sidebar-toggle--bar{
  grid-column:1;
  grid-row:1 / -1;
  align-self:center;
  flex-shrink:0;
}

.app-sidebar-logo-row{
  display:flex;
  align-items:center;
  gap:10px;
}

.app-sidebar-head{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  flex-shrink:0;
  padding:2px 4px 10px;
}

.app-sidebar-logo-stack{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  width:100%;
  padding:4px 6px 2px;
}

.app-sidebar-logo-box{
  position:relative;
  width:min(100%,112px);
  aspect-ratio:1;
  flex-shrink:0;
  background:transparent;
}

.app-sidebar-logo-box.has-custom-logo .app-sidebar-logo-mark{
  display:none!important;
}

.app-sidebar-logo-mark{
  width:100%;
  height:100%;
  border-radius:14px;
  background:var(--acc);
  display:flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
}

.app-sidebar-logo-mark[hidden],
.app-sidebar-logo-img[hidden]{display:none!important;}

.app-sidebar-logo-img{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:contain;
  border-radius:0;
  border:none;
  background:transparent;
  padding:2px;
}

.app-sidebar-empresa{
  font-size:12px;
  font-weight:500;
  color:var(--tx2);
  line-height:1.35;
  text-align:center;
  text-wrap:balance;
  max-width:100%;
  padding:0 4px;
}

.app-sidebar-logo-text{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:2px;
}

.branding-sync-hint{
  margin:-2px 0 10px;
  font-size:12px;
  color:var(--tx3);
  line-height:1.45;
}

.field-row .field,
.field-row .modal-field{
  flex:1;
  min-width:0;
  margin-bottom:0;
}

.field label,
.modal-field label{
  font-size:12px;
  font-weight:500;
  color:var(--tx2);
  display:block;
  margin-bottom:4px;
}

.modal-title i.ti{
  font-size:16px;
  vertical-align:-2px;
  margin-right:6px;
  color:var(--acc);
}

.preset-io-row{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-bottom:10px;
  align-items:center;
}

.worker-drag-tray{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px;
  padding:10px 12px;
  margin-bottom:12px;
  background:var(--bg2);
  border:1px solid var(--bd);
  border-radius:12px;
}

.worker-drag-tray[hidden]{display:none!important;}

.worker-drag-tray-label{
  font-size:11px;
  font-weight:600;
  color:var(--tx3);
  display:inline-flex;
  align-items:center;
  gap:5px;
  margin-right:4px;
}

.worker-drag-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:5px 12px 5px 5px;
  border-radius:999px;
  border:1px solid var(--bd);
  background:var(--bg3);
  cursor:grab;
  font-family:inherit;
  color:var(--tx);
  transition:transform 100ms var(--ease-shell),box-shadow 160ms var(--ease-shell),border-color 160ms var(--ease-shell);
}

@media(hover:hover) and (pointer:fine){
  .worker-drag-pill:hover{border-color:color-mix(in srgb,var(--acc) 35%,var(--bd));}
}

.worker-drag-pill:active:not(.ptr-dragging){transform:scale(0.98);}

.worker-drag-pill__avatar--img img{width:100%;height:100%;object-fit:cover;border-radius:50%;display:block;}

.worker-drag-pill--busy{
  opacity:.58;
  filter:grayscale(.4);
  border-style:dashed;
}

.worker-drag-tray-sep{
  flex:0 0 100%;
  font-size:11px;
  font-weight:600;
  color:var(--tx3);
  display:inline-flex;
  align-items:center;
  gap:5px;
  margin:6px 4px 2px;
}

.obra-drag-pill__icon i{font-size:13px;color:#fff;}

.herr-obra-global-bar{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  padding:10px 12px;
  border-radius:10px;
  background:var(--bg3);
  border:1px solid var(--bd);
  margin-top:8px;
}

.herr-obra-global-bar label{font-size:12px;color:var(--tx3);font-weight:500;white-space:nowrap;}

.herr-obra-global-bar .fsel{flex:1;min-width:160px;max-width:360px;}

.herr-obra-global-hint{font-size:11px;color:var(--tx3);flex:1 1 180px;min-width:140px;}

.worker-drag-pill__avatar{
  width:28px;
  height:28px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:10px;
  font-weight:700;
  color:#fff;
  flex-shrink:0;
}

.worker-drag-pill__text{
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:1px;
  min-width:0;
  text-align:left;
}

.worker-drag-pill__text strong{
  font-size:12px;
  font-weight:600;
  line-height:1.2;
  max-width:140px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.worker-drag-pill__text span{
  font-size:10px;
  color:var(--tx2);
  max-width:140px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.ni-b i{font-size:20px;line-height:1;display:flex;align-items:center;justify-content:center;width:24px;height:24px;}

.asig-worker-hero{
  display:flex;align-items:center;gap:12px;
  padding:12px 14px;margin:0 0 14px;
  border-radius:12px;border:1px solid var(--bd);
  background:var(--bg3);
}
.asig-worker-hero__avatar{
  width:44px;height:44px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  font-size:14px;font-weight:700;color:#fff;flex-shrink:0;
}
.asig-worker-hero__text{display:flex;flex-direction:column;gap:2px;min-width:0;}
.asig-worker-hero__text strong{font-size:14px;color:var(--tx);font-weight:600;}
.asig-worker-hero__text span{font-size:12px;color:var(--tx2);}
.obra-sort-hint{font-size:11px;color:var(--tx2);margin:0 0 8px;}

.gantt-cell-drop-target{
  outline:2px solid var(--acc);
  outline-offset:-2px;
  background:color-mix(in srgb,var(--acc2) 55%,var(--bg2))!important;
}

.gantt-obra-drop-target{
  outline:2px solid var(--acc);
  outline-offset:-2px;
  background:color-mix(in srgb,var(--acc2) 40%,var(--bg2))!important;
}

.worker-drag-pill__avatar--img{background-color:var(--bg3);}
.worker-drag-pill__avatar--emoji{display:flex;align-items:center;justify-content:center;}

/* Topbar: logo + contexto de sección */
.topbar-brand{
  grid-column:2;
  grid-row:1 / -1;
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
  flex-shrink:1;
}

.topbar-brand-text{
  display:flex;
  align-items:stretch;
  gap:8px;
  min-width:0;
  flex:1;
}

.topbar-brand-lines{
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:1px;
  min-width:0;
  flex:1;
}

.topbar-lead-accent{
  width:3px;
  border-radius:99px;
  background:linear-gradient(180deg,var(--acc),color-mix(in srgb,var(--acc) 55%,var(--accl)));
  flex-shrink:0;
  opacity:.9;
  align-self:stretch;
  min-height:26px;
}

.topbar-section-title{
  margin:0;
  font-size:16px;
  font-weight:650;
  color:var(--tx);
  letter-spacing:-.03em;
  line-height:1.15;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.topbar-app-name{
  margin:0;
  font-size:11px;
  font-weight:500;
  color:var(--tx3);
  letter-spacing:.01em;
  line-height:1.2;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.topbar-lead,
.topbar-app-band{display:none;}

.topbar-title,
.app-header .topbar .topbar-app-title{display:none!important;}

.app-sidebar-backdrop{
  display:none;
  position:fixed;
  inset:0;
  z-index:360;
  background:color-mix(in srgb,var(--bg) 62%,transparent);
  backdrop-filter:blur(3px);
  -webkit-backdrop-filter:blur(3px);
  opacity:0;
  transition:none;
  cursor:pointer;
}

.app-layout.sidebar-drawer-animate .app-sidebar-backdrop{
  transition:opacity 180ms var(--ease-shell);
}

.app-sidebar-backdrop.is-open{
  display:block;
  opacity:1;
}

/* Sin animación al cruzar breakpoint desktop ↔ móvil */
.app-layout.sidebar-mode-switching .app-sidebar,
.app-layout.sidebar-mode-switching .app-sidebar-backdrop{
  transition:none!important;
}

.app-sidebar-head{display:none!important;}

.app-sidebar-toggle--bar{
  display:inline-flex;
}

.app-sidebar-toggle .sr-only{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

.app-sidebar-toggle{
  width:36px;
  height:36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  border-radius:9px;
  border:1px solid var(--bd);
  background:transparent;
  color:var(--tx2);
  font-family:inherit;
  cursor:pointer;
  flex-shrink:0;
  transition:
    background 160ms var(--ease-shell),
    border-color 160ms var(--ease-shell),
    color 160ms var(--ease-shell),
    transform 100ms var(--ease-shell);
}

.app-sidebar-toggle-glyph{
  display:flex;
  align-items:center;
  justify-content:center;
  line-height:0;
  flex-shrink:0;
}

.app-sidebar-toggle-icon{
  display:block;
  width:18px;
  height:18px;
}

.app-sidebar-toggle i{font-size:18px;line-height:1;}

@media(hover:hover) and (pointer:fine){
  .app-sidebar-toggle:hover{
    background:var(--bg3);
    color:var(--tx);
    border-color:var(--bd2);
  }
}

.app-sidebar-toggle:active{transform:scale(0.97);}

.app-sidebar-toggle:focus-visible{
  outline:2px solid var(--acc);
  outline-offset:2px;
}

/* Desktop: sidebar + compact topbar (aligned with app.css @861px) */
@media(min-width:861px){
  .app-layout{
    flex-direction:row;
    align-items:stretch;
  }

  .app-sidebar{
    display:flex;
    flex-direction:column;
    width:var(--sidebar-w);
    flex-shrink:0;
    position:sticky;
    top:0;
    height:100dvh;
    padding:12px 14px 18px;
    border-right:1px solid var(--bd);
    background:var(--bg2);
    z-index:380;
    overflow:hidden;
    transition:none;
  }

  .app-layout.sidebar-desktop-animate .app-sidebar{
    transition:
      width 200ms var(--ease-shell),
      padding 200ms var(--ease-shell),
      border-color 200ms var(--ease-shell),
      opacity 160ms var(--ease-shell);
  }

  .app-sidebar-brand{
    padding:4px 4px 16px;
    margin-bottom:4px;
    border-bottom:1px solid var(--bd);
  }

  .app-sidebar-nav{
    display:flex;
    flex-direction:column;
    gap:6px;
    flex:1;
    overflow-y:auto;
    padding:10px 0 20px;
  }

  .app-sidebar-nav .ni,
  .app-sidebar-nav .ni-b{
    width:100%;
    justify-content:flex-start;
    padding:11px 14px;
    border-radius:10px;
    font-size:13px;
    transition:background 160ms var(--ease-shell),color 160ms var(--ease-shell),transform 100ms var(--ease-shell);
  }

  .app-sidebar-nav .ni:active,
  .app-sidebar-nav .ni-b:active{
    transform:scale(0.98);
  }

  .app-sidebar-nav .ni.on,
  .app-sidebar-nav .ni-b.on{
    background:color-mix(in srgb,var(--acc2) 88%,var(--bg3));
    font-weight:600;
  }

  .app-sidebar-nav .ni.on::after{display:none;}

  .app-sidebar-toggle--bar{display:inline-flex!important;}

  .sidebar-collapsed{--sidebar-w:0;}

  .sidebar-collapsed .app-sidebar{
    width:0;
    min-width:0;
    padding:0;
    border-right-color:transparent;
    opacity:0;
    pointer-events:none;
  }

  .sidebar-collapsed .app-sidebar-brand,
  .sidebar-collapsed .app-sidebar-nav{
    display:none;
  }

  .app-main{
    flex:1;
    min-width:0;
  }

  .app-header > .nav,
  .app-header > .nav-mobile,
  .nav-bottom,
  .hamburger{display:none!important;}

  .app-header .topbar{
    gap:12px;
    align-items:center;
    min-height:56px;
    padding-top:10px;
    padding-bottom:10px;
  }

  .body{
    max-width:none;
    margin:0;
    padding:24px 28px 32px;
  }
}

/* Topbar estrecha (tablet / ventana reducida): iconos antes que texto cortado */
@media(min-width:861px) and (max-width:1280px){
  .app-header .topbar{
    column-gap:10px;
    padding-left:16px;
    padding-right:16px;
  }
  .topbar-brand{min-width:0;}
  .topbar-brand-text{min-width:0;}
  .topbar-section-title{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    min-width:0;
  }
  .kronzen-wordmark-img--topbar{max-width:min(168px,20vw);}
  .app-header .topbar .tbr{
    gap:6px;
    min-width:0;
    flex-shrink:1;
  }
  .topbar-user{
    min-width:0;
    max-width:min(210px,26vw);
    padding:6px 10px;
    gap:6px;
  }
  .topbar-user-greet{display:none;}
  .topbar-user-name{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    min-width:0;
  }
  .topbar-notif-btn{padding:6px 10px!important;gap:6px!important;min-height:38px!important;}
  .gt-wrap:not(.gt-wrap-login) .gt-picker-label{display:none;}
  .gt-wrap:not(.gt-wrap-login) .gt-picker-btn{
    max-width:58px;
    padding:5px 8px!important;
    justify-content:center;
  }
  .gt-wrap:not(.gt-wrap-login) .gt-picker-chevron{display:none;}
}

@media(min-width:861px) and (max-width:1080px){
  .kronzen-wordmark-img--topbar{max-width:min(120px,16vw);}
  .topbar-section-title{max-width:18vw;}
  .app-header .topbar .tbr .topbar-logout-text{display:none!important;}
  .topbar-notif-btn .topbar-logout-text{display:none!important;}
  .topbar-logout,
  .topbar-notif-btn{
    min-width:36px!important;
    padding:6px 8px!important;
    justify-content:center;
    gap:0!important;
  }
  .topbar-user{
    max-width:40px;
    padding:4px!important;
    gap:0!important;
  }
  .topbar-user-name,
  .topbar-user-greet{display:none!important;}
  .app-header .topbar .tbr .theme-switch{width:46px;height:28px;}
}

@media(max-width:860px){
  .app-sidebar-toggle--bar{display:inline-flex!important;}

  .app-header > .nav{display:none!important;}
  .nav-bottom{display:none!important;}
  .nav-mobile{display:none!important;}
  .hamburger{display:none!important;}

  .app-sidebar{
    display:flex;
    flex-direction:column;
    position:fixed;
    top:0;
    left:0;
    bottom:0;
    z-index:360;
    width:min(288px,88vw);
    max-width:100%;
    padding:12px 14px 20px;
    border-right:1px solid transparent;
    background:var(--bg2);
    transform:translate3d(-105%,0,0);
    transition:none;
    box-shadow:none;
    visibility:hidden;
    pointer-events:none;
  }

  .app-layout.sidebar-drawer-animate .app-sidebar{
    transition:transform 240ms var(--ease-drawer),visibility 0s linear 240ms;
  }

  .sidebar-mobile-open .app-sidebar{
    transform:translate3d(0,0,0);
    border-right-color:var(--bd);
    box-shadow:8px 0 32px color-mix(in srgb,var(--bg) 40%,transparent);
    visibility:visible;
    pointer-events:auto;
  }

  .app-layout.sidebar-drawer-animate.sidebar-mobile-open .app-sidebar{
    transition:transform 240ms var(--ease-drawer),visibility 0s;
  }

  .sidebar-collapsed .app-sidebar{
    transform:translate3d(-105%,0,0);
    visibility:hidden;
    pointer-events:none;
  }

  .sidebar-collapsed .app-sidebar-brand,
  .sidebar-collapsed .app-sidebar-nav{
    display:flex;
  }

  .sidebar-collapsed .app-sidebar-brand{display:flex;}
  .sidebar-collapsed .app-sidebar-nav{display:flex;}

  .app-sidebar-brand{
    padding:8px 4px 16px;
    margin-bottom:8px;
    border-bottom:1px solid var(--bd);
  }

  .app-sidebar-nav{
    display:flex;
    flex-direction:column;
    gap:4px;
    flex:1;
    overflow-y:auto;
    padding:8px 0 16px;
  }

  .app-sidebar-nav .ni,
  .app-sidebar-nav .ni-b{
    width:100%;
    justify-content:flex-start;
    padding:12px 14px;
    border-radius:10px;
    font-size:14px;
  }

  .app-sidebar-nav .ni.on,
  .app-sidebar-nav .ni-b.on{
    background:color-mix(in srgb,var(--acc2) 88%,var(--bg3));
    font-weight:600;
  }

  .app-sidebar-nav .ni.on::after{display:none;}

  .body{
    padding:16px 14px 24px;
    padding-bottom:calc(24px + env(safe-area-inset-bottom,0px));
  }

  body.sidebar-drawer-open{overflow:hidden;}

  .app-header .topbar{
    grid-template-rows:auto;
    grid-template-columns:auto minmax(0,1fr) auto;
    column-gap:8px;
    row-gap:0;
    padding:6px 10px;
    min-height:50px;
    align-items:center;
  }

  .app-sidebar-toggle--bar{
    grid-column:1;
    grid-row:1;
    width:34px;
    height:34px;
    border-radius:8px;
  }

  .app-sidebar-toggle--bar i{font-size:16px;}
  .app-sidebar-toggle--bar .app-sidebar-toggle-icon{width:16px;height:16px;}

  .topbar-brand{
    grid-column:2;
    grid-row:1;
    gap:8px;
    align-items:center;
    min-width:0;
  }

  .app-header .topbar .tbr{
    grid-column:3;
    grid-row:1;
  }

  .topbar-brand-text{gap:6px;}

  .topbar-lead-accent{display:none;}

  .topbar-section-title{font-size:15px;}

  .topbar-app-name{font-size:10px;}

  .app-header .topbar .tbr{
    flex-wrap:nowrap;
    gap:2px;
    max-width:none;
    min-width:0;
    flex-shrink:0;
    justify-content:flex-end;
  }

  .app-header .topbar .tbr .topbar-logout-text{
    display:none!important;
  }

  .app-header .topbar .tbr #status-pill{display:none!important;}

  .app-header .topbar .tbr .topbar-user{
    padding:2px!important;
    min-height:34px!important;
    max-width:none;
    border-radius:999px;
    gap:0!important;
  }

  .app-header .topbar .tbr .topbar-user-greet,
  .app-header .topbar .tbr .topbar-user-name{display:none!important;}

  .app-header .topbar .tbr .topbar-user-avatar{
    width:30px!important;
    height:30px!important;
    min-width:30px!important;
    font-size:11px!important;
  }

  .app-header .topbar .tbr .topbar-notif-btn{
    padding:5px 7px!important;
    min-height:34px!important;
    gap:0!important;
  }

  .app-header .topbar .tbr .topbar-logout{
    padding:5px 7px!important;
    min-width:34px!important;
    min-height:34px!important;
  }

  .app-header .topbar .tbr .theme-switch{
    width:50px;
    height:30px;
    flex-shrink:0;
  }

  .app-header .topbar .tbr .gt-wrap:not(.gt-wrap-login) .gt-picker-btn{
    min-height:34px;
    padding:4px 6px!important;
    max-width:52px;
  }

  @media(prefers-reduced-motion:reduce){
    .app-sidebar{transition:none;}
    .app-sidebar-backdrop{transition:none;}
  }
}

.login-prefs-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:14px;
  padding-bottom:14px;
  border-bottom:1px solid var(--bd);
}

.login-prefs-row .login-lang-row{
  margin:0;
  padding:0;
  border:none;
  flex:0 0 auto;
  min-width:0;
  justify-content:flex-end;
}

.ptr-dragging{
  cursor:grabbing!important;
  opacity:.92;
}

.ptr-dragging--anchored{
  opacity:.88;
  box-shadow:0 10px 24px rgba(0,0,0,.16)!important;
  outline:2px solid color-mix(in srgb,var(--acc) 55%,transparent);
  outline-offset:0;
}

.ptr-sort-placeholder{
  border:2px dashed var(--acc);
  border-radius:12px;
  background:color-mix(in srgb,var(--acc2) 40%,transparent);
  margin:0;
  box-sizing:border-box;
  pointer-events:none;
}

.ptr-sort-placeholder--grid{
  width:100%!important;
  max-width:none!important;
  min-width:0;
  height:auto!important;
}

.obras-grid .ptr-sort-placeholder{
  border-radius:14px;
  min-height:80px;
}

.preset-subgrid .ptr-sort-placeholder{
  margin:0;
  min-width:0;
  width:100%!important;
  max-width:none;
  border-radius:12px;
}

.preset-card[data-user-idx]{
  user-select:none;
}

.ptr-drop-over{
  border-color:var(--acc)!important;
  background:color-mix(in srgb,var(--acc2) 50%,var(--bg3))!important;
}

@media(prefers-reduced-motion:reduce){
  .ptr-dragging{transition:none!important;}
  .app-sidebar-nav .ni:active,
  .worker-drag-pill:active{transform:none;}
  .ptr-sort-placeholder{transition:none;}
}
