/* Responsive layer for desktop-first project. Loaded after the existing styles. */
.app-body,
.out-body,
.auth-body,
.site-body,
.blog-body,
.error-body {
  min-width: 0;
}

.app-body *,
.out-body *,
.auth-body *,
.site-body *,
.blog-body *,
.error-body * {
  box-sizing: border-box;
}

img, video, iframe {
  max-width: 100%;
}

/* ===== Main authenticated application ===== */
.app-body {
  overflow: hidden;
}

.app-body .app-shell {
  overflow: hidden;
  background: #fff;
}

.app-body .app-sidebar {
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  border-right: 0;
}

/* Project cards: use a real row grid instead of floats.
   Float packing caused cards with different heights to jump into gaps. */
.app-body .project-list {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
  align-items: stretch;
  grid-auto-rows: max-content;
}

.app-body .project-list > .w20 {
  float: none !important;
  display: flex !important;
  flex-direction: column;
  align-self: stretch;
  width: auto !important;
  min-width: 0;
  min-height: 0 !important;
  height: auto !important;
  margin: 0 !important;
}

/* The original project card uses floated counters. Their height was not
   reliably included in the card/grid row, so the payment/month text could
   extend below the white background. Put those counters back into normal
   layout flow and let the card grow from its real content height. */
.app-body .project-list > .tasklist_todo > .block {
  display: block;
}

.app-body .project-list > .tasklist_todo > .block:nth-child(2) > .w.block {
  display: flex !important;
  align-items: stretch;
  gap: 10px;
}

.app-body .project-list > .tasklist_todo > .block:nth-child(2) > .w.block + .w.block {
  margin-top: 10px;
}

.app-body .project-list > .tasklist_todo > .block:nth-child(2) > .w.block > .block {
  float: none !important;
  flex: 1 1 0;
  min-width: 0;
  margin-left: 0 !important;
  margin-bottom: 0 !important;
}

.app-body .app-main {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app-body .app-topbar {
  min-height: 62px;
}

.app-body .app-content {
  height: calc(100vh - 68px);
  height: calc(100dvh - 68px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 12px 14px 0;
}

.app-menu-toggle,
.app-sidebar-overlay {
  display: none;
}

.app-body .modal,
.out-body .modal {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.app-body .modal > .bg-black,
.out-body .modal > .bg-black {
  position: fixed;
}

/* Tables stay readable: preserve columns and allow horizontal swipe. */
.app-body table.table,
.out-body table.table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}


/* Prevent long technical values from forcing the whole viewport wider. */
.app-body pre,
.app-body code,
.app-body .editor,
.app-body .ace_editor,
.out-body pre,
.out-body code {
  max-width: 100%;
}

@media (max-width: 1280px) and (min-width: 901px) {
  .app-body .app-sidebar {
    width: 220px !important;
  }

  .app-body .app-main {
    width: calc(100% - 220px) !important;
  }

  .app-body .project-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .app-body .project-list > .w20 {
    width: auto !important;
    margin: 0 !important;
  }

  .app-body .filter-modal > .w20,
  .out-body .filter-modal > .w20 {
    width: 320px !important;
  }
}

@media (max-width: 900px) {
  .app-body {
    overflow: hidden;
  }

  .app-body .app-shell {
    position: fixed;
    inset: 0;
    width: 100% !important;
    height: 100vh;
    height: 100dvh;
  }

  .app-body .app-sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(82vw, 320px) !important;
    height: 100vh !important;
    height: 100dvh !important;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,.14);
  }

  .app-body.app-menu-open .app-sidebar {
    transform: translateX(0);
  }

  .app-body .app-sidebar-overlay {
    position: fixed;
    z-index: 35;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(0,0,0,.38);
  }

  .app-body.app-menu-open .app-sidebar-overlay {
    display: block;
  }

  .app-body .app-main {
    width: 100% !important;
    height: 100vh;
    height: 100dvh;
    float: none !important;
  }

  .app-body .app-topbar {
    min-height: 60px;
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 6px 8px 4px;
    margin-bottom: 6px !important;
    background: #fff;
    border-bottom: 1px solid #eee;
  }

  .app-body .app-topbar > .w {
    display: flex !important;
    align-items: center;
    gap: 8px;
    width: 100% !important;
    margin-bottom: 0 !important;
  }

  .app-body .app-menu-toggle {
    display: inline-flex;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: #eee;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }

  .app-body .app-search-area {
    float: none !important;
    width: auto !important;
    flex: 1 1 auto;
    min-width: 0;
    display: flex !important;
    align-items: center;
    gap: 6px;
  }

  .app-body .app-search-area > input[name="search_live"] {
    flex: 1 1 auto;
    width: auto !important;
    min-width: 0;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
  }

  .app-body .app-search-area > .bn-bg-hover {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
  }

  .app-body .app-account-area {
    float: none !important;
    flex: 0 0 auto;
  }

  .app-body .app-account-area > .mt10 {
    margin: 0 !important;
    display: flex !important;
    align-items: center;
  }

  .app-body .app-account-area .menu_account {
    position: fixed !important;
    top: 58px !important;
    right: 8px !important;
    left: auto !important;
    margin: 0 !important;
    min-width: 180px;
  }

  .app-body .modal_search {
    position: fixed !important;
    top: 60px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-height: calc(100vh - 76px);
    max-height: calc(100dvh - 76px);
    overflow-y: auto;
    margin: 0 !important;
  }

  .app-body .modal-notification {
    position: fixed !important;
    top: 60px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-height: calc(100vh - 76px);
    max-height: calc(100dvh - 76px);
    overflow-y: auto;
    margin: 0 !important;
  }

  .app-body .app-content {
    height: calc(100vh - 66px);
    height: calc(100dvh - 66px);
    padding: 0 8px 18px;
  }

  .app-body .app-content > .bg-f6,
  .app-body .app-content > .w98,
  .app-body .app-content > .w99 {
    width: 100% !important;
    height: auto !important;
    min-height: calc(100vh - 82px);
    min-height: calc(100dvh - 82px);
    padding: 14px !important;
    border-radius: 10px;
  }

  .app-body .project-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .app-body .project-list > .w20 {
    width: auto !important;
    margin: 0 !important;
  }

  .app-body .search-box {
    float: none !important;
    display: flex !important;
    align-items: center;
    width: 100% !important;
    min-width: 0;
    margin: 8px 0 0 !important;
  }

  .app-body .search-box input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    width: auto !important;
  }

  .app-body .filter-modal > .w20,
  .out-body .filter-modal > .w20 {
    width: min(88vw, 360px) !important;
  }

  .app-body .tasklist {
    display: flex !important;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 10px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  /* Project kanban has an extra 80/20 desktop split around the board. */
  .app-body .app-content > .w > .bg-e.w80.h90.fleft {
    float: none !important;
    width: 100% !important;
    height: auto !important;
  }

  .app-body .app-content > .w > .bg-e.w80.h90.fleft + .fright.w20 {
    float: none !important;
    width: 100% !important;
    margin-top: 12px;
  }

  .app-body .tasklist > .w25 {
    float: none !important;
    flex: 0 0 min(78vw, 330px);
    width: min(78vw, 330px) !important;
    margin-right: 0 !important;
    scroll-snap-align: start;
  }

  .app-body .tasklist_list_box {
    height: calc(100vh - 230px);
    height: calc(100dvh - 230px);
    min-height: 360px;
  }

  .app-body .modal .w600p,
  .out-body .modal .w600p,
  .app-body .modal > .w60,
  .app-body .modal > form > .w60,
  .out-body .modal > .w60,
  .app-body .modal > .w80,
  .out-body .modal > .w80,
  .app-body .modal > .w95,
  .out-body .modal > .w95,
  .app-body .modal .form.w600p,
  .out-body .modal .form.w600p {
    width: calc(100% - 20px) !important;
    max-width: 680px;
    left: 10px !important;
    right: 10px !important;
    top: 10px !important;
    margin: 0 auto !important;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
  }

  .app-body .modal .form,
  .out-body .modal .form {
    max-width: calc(100% - 20px);
  }

  .app-body .modal .tab_item_box,
  .out-body .modal .tab_item_box {
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .app-body .modal .tab_item,
  .out-body .modal .tab_item {
    float: none !important;
    display: inline-block !important;
  }

  /* File comparison: editors are usable one under another. */
  .app-body .modal .ace_editor {
    min-height: 44vh !important;
  }

  .app-body .modal [style*="min-height:700px"] {
    min-height: 0 !important;
  }
}

@media (max-width: 700px) {
  .app-body .project-list {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .app-body .project-list > .w20 {
    width: auto !important;
    margin: 0 !important;
    min-height: 0 !important;
  }

  /* Desktop percentage columns become natural stacked blocks on phones. */
  .app-body .app-content .w70.fleft,
  .app-body .app-content .w60.fleft,
  .app-body .app-content .w50.fleft,
  .app-body .app-content .w45.fleft,
  .app-body .app-content .w40.fleft,
  .app-body .app-content .w33.fleft,
  .app-body .app-content .w30.fleft,
  .app-body .app-content .w20.fleft,
  .app-body .modal .w70.fleft,
  .app-body .modal .w60.fleft,
  .app-body .modal .w50.fleft,
  .app-body .modal .w45.fleft,
  .app-body .modal .w40.fleft,
  .app-body .modal .w30.fleft,
  .out-body .modal .w60.fleft,
  .out-body .modal .w50.fleft,
  .out-body .modal .w45.fleft,
  .out-body .modal .w40.fleft,
  .out-body .modal .w30.fleft {
    float: none !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .app-body .tasklist > .w25 {
    flex-basis: 86vw;
    width: 86vw !important;
  }

  .app-body h1 {
    font-size: 18px;
  }

  .app-body .breadcrumbs {
    overflow-x: auto;
    white-space: nowrap;
  }

  .app-body .breadcrumbs li {
    float: none !important;
    display: inline-block !important;
  }

  .app-body input[type="text"],
  .app-body input[type="number"],
  .app-body input[type="email"],
  .app-body input[type="date"],
  .app-body select,
  .app-body textarea,
  .out-body input[type="text"],
  .out-body input[type="number"],
  .out-body input[type="email"],
  .out-body input[type="date"],
  .out-body select,
  .out-body textarea {
    max-width: 100%;
  }

  .app-body .n_message_push1,
  .app-body div[class*="n_message_push"],
  .out-body div[class*="n_message_push"] {
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    min-width: 0 !important;
    margin: 10px 0 !important;
  }
}

@media (max-width: 520px) {
  .app-body .app-account-area .ml10.bold.cursor {
    max-width: 86px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-body .app-content {
    padding-left: 6px;
    padding-right: 6px;
  }

  .app-body .app-content > .bg-f6,
  .app-body .app-content > .w98,
  .app-body .app-content > .w99 {
    padding: 10px !important;
  }

  .app-body .modal .p20,
  .out-body .modal .p20 {
    padding: 14px !important;
  }
}

/* ===== Public task view / shared view ===== */
@media (max-width: 900px) {
  .out-body {
    overflow: auto;
  }

  .out-body > .block > .fixed {
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .out-body .w25.h90.fleft,
  .out-body .w75.fleft {
    float: none !important;
    width: 100% !important;
    height: auto !important;
  }

  .out-body .task-list {
    height: 52vh !important;
    min-height: 320px;
  }

  .out-body .task-json-item {
    height: auto !important;
    min-height: 420px;
  }
}

/* ===== Authentication pages ===== */
.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
}

.auth-body main > div[style*="width:400px"] {
  width: min(400px, calc(100% - 28px)) !important;
  max-width: 100%;
}

@media (max-width: 520px) {
  .auth-body {
    padding-top: 20px !important;
    padding-bottom: 40px !important;
    background-size: auto 360px;
  }

  .auth-body main > div[style*="width:400px"] {
    padding: 22px !important;
  }

  .auth-body main input.w88 {
    width: 100% !important;
  }
}

/* ===== Marketing site / help center refinements ===== */
@media (max-width: 768px) {
  .site-body .container,
  .blog-body .container,
  .error-body .container {
    width: 100%;
    max-width: 100%;
    padding-left: 16px;
    padding-right: 16px;
  }

  .site-body .header_content br {
    display: none;
  }

  .site-body .header_content h1,
  .blog-body h1,
  .error-body h1 {
    overflow-wrap: anywhere;
  }

  .blog-body header .row,
  .blog-body header .header__top_links {
    display: flex;
    flex-wrap: wrap;
  }

  .blog-body header .menu {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    justify-content: flex-start;
  }

  .blog-body header .menu a {
    margin: 0 !important;
  }
}

@media (max-width: 480px) {
  .site-body h1 {
    font-size: clamp(28px, 9vw, 40px) !important;
    line-height: 1.12 !important;
  }

  .site-body .authenticator a,
  .site-body a.sign-in {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .site-body header .menu .list {
    width: 84% !important;
    padding: 18px !important;
  }
}

/* ===== Mobile Kanban accordion =====
   On phones/tablets the four status columns become full-width accordion
   sections instead of a horizontally scrolling board. Desktop is unchanged. */
@media (max-width: 900px) {
  .app-body .tasklist.kanban-accordion {
    display: block !important;
    width: 100% !important;
    overflow: visible !important;
    padding-bottom: 0 !important;
    scroll-snap-type: none !important;
  }

  .app-body .tasklist.kanban-accordion > .w25 {
    float: none !important;
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 0 8px !important;
    padding: 0 !important;
    flex: none !important;
    scroll-snap-align: none !important;
  }

  .app-body .tasklist.kanban-accordion > .w25 > :first-child {
    position: relative;
    float: none !important;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100% !important;
    min-height: 48px;
    margin: 0 !important;
    padding: 8px 42px 8px 12px !important;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .app-body .tasklist.kanban-accordion > .w25 > :first-child::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 16px;
    width: 8px;
    height: 8px;
    margin-top: -6px;
    border-right: 2px solid #777;
    border-bottom: 2px solid #777;
    transform: rotate(45deg);
    transition: transform .18s ease, margin-top .18s ease;
  }

  .app-body .tasklist.kanban-accordion > .kanban-stage-open > :first-child::after {
    margin-top: -2px;
    transform: rotate(225deg);
  }

  .app-body .tasklist.kanban-accordion > .w25 > :first-child > .fleft,
  .app-body .tasklist.kanban-accordion > .w25 > :first-child > .fright {
    float: none !important;
    width: auto !important;
    margin: 0 !important;
  }

  .app-body .tasklist.kanban-accordion > .w25 > :first-child > .fleft {
    flex: 1 1 auto;
    min-width: 0;
  }

  .app-body .tasklist.kanban-accordion > .w25 > :first-child > .fright {
    flex: 0 0 auto;
    min-width: 42px;
    margin-left: 10px !important;
  }

  .app-body .tasklist.kanban-accordion > .w25 > :first-child .mb10 {
    margin-bottom: 0 !important;
  }

  .app-body .tasklist.kanban-accordion > .w25 > .tasklist_list_box {
    display: none;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 4px 0 8px !important;
  }

  .app-body .tasklist.kanban-accordion > .kanban-stage-open > .tasklist_list_box {
    display: block;
  }

  .app-body .tasklist.kanban-accordion .tasklist_style_box {
    width: 100% !important;
    margin: 8px 0 !important;
  }
}
