

button,
.nav-item,
.pill,
.tbl-action,
.toggle,
.checkbox,
a[role=button],
[onclick] {
  touch-action: manipulation
}

button,
a {
  -webkit-tap-highlight-color: transparent
}

@supports (-webkit-touch-callout:none) {
  .app {
    height: -webkit-fill-available
  }

  .sidebar {
    height: -webkit-fill-available
  }
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain
}

.table-scroll::-webkit-scrollbar {
  height: 4px
}

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg2);
  border: 1px solid var(--bd);
  border-radius: 9px;
  color: var(--ts);
  cursor: pointer;
  flex-shrink: 0
}

.mobile-menu-btn:active {
  background: var(--bg3)
}

.sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--bg3);
  border: 1px solid var(--bd);
  border-radius: 9px;
  color: var(--ts);
  cursor: pointer;
  flex-shrink: 0
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(2px);
  z-index: 1190;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease
}

body.nav-open {
  overflow: hidden
}

.modal-overlay {
  z-index: 2000
}

@media (max-width:1200px) {

  .grid-4,
  .g4 {
    grid-template-columns: repeat(2, 1fr)
  }

  .view-panel,
  .view-panel--flex {
    padding: 24px
  }
}

@media (max-width:980px) {
  .grid-3 {
    grid-template-columns: repeat(2, 1fr)
  }

  .clients-grid,
  .team-grid,
  .tg {
    grid-template-columns: repeat(2, 1fr)
  }

  [style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important
  }
}

@media (max-width:900px) {
  .cal-l {
    grid-template-columns: 1fr
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1200;
    width: min(284px, 84vw);
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 0 0 40px rgba(0, 0, 0, .5);
    padding-left: env(safe-area-inset-left);
    will-change: transform
  }

  body.nav-open .sidebar {
    transform: translateX(0)
  }

  body.nav-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto
  }

  .sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px
  }

  .sidebar-close {
    display: flex
  }

  .nav {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom))
  }

  .nav-item {
    padding: 11px 12px;
    font-size: 13px;
    gap: 11px;
    margin-bottom: 3px
  }

  .sidebar-user {
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom))
  }

  .mobile-menu-btn {
    display: flex
  }

  .main {
    width: 100%
  }

  .header {
    padding: 0 14px;
    padding-left: calc(14px + env(safe-area-inset-left));
    padding-right: calc(14px + env(safe-area-inset-right));
    gap: 10px
  }

  .breadcrumb {
    overflow: hidden
  }

  .breadcrumb>span:first-child,
  .breadcrumb>svg {
    display: none
  }

  .breadcrumb .breadcrumb-active {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--tx);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
  }

  .header-actions {
    gap: 8px
  }

  .search-wrapper input {
    width: 132px
  }

  .view-panel,
  .view-panel--flex {
    padding: 18px 14px calc(24px + env(safe-area-inset-bottom));
    padding-left: calc(14px + env(safe-area-inset-left));
    padding-right: calc(14px + env(safe-area-inset-right))
  }

  .form-input,
  .form-select,
  .form-field input,
  .form-field select,
  .form-field textarea,
  .filter-input-wrapper input,
  .chat-input,
  .ai-key-input,
  input[type=text],
  input[type=email],
  input[type=password],
  input[type=number],
  input[type=date],
  input[type=time],
  input[type=datetime-local],
  input[type=search],
  input[type=tel],
  input[type=url],
  select,
  textarea {
    font-size: 16px
  }

  input[type=date],
  input[type=time],
  input[type=datetime-local] {
    min-height: 42px
  }

  .modal-overlay {
    align-items: flex-start;
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch
  }

  .modal {
    width: 100% !important;
    max-width: 560px;
    margin: auto;
    padding: 20px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto
  }

  .access-profile-modal {
    width: 100% !important;
    max-width: 100%;
    max-height: calc(100dvh - 32px)
  }

  .access-profile-modal .access-profile-permissions {
    max-height: none
  }

  .modal-footer {
    flex-wrap: wrap
  }

  .kanban-board {
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    gap: 12px;
    margin-right: -14px;
    padding-right: 14px
  }

  .kanban-column,
  .task-board .task-column {
    min-width: 264px;
    flex: 0 0 264px;
    scroll-snap-align: start
  }

  .kanban-add-column {
    min-width: 264px;
    flex: 0 0 264px;
    scroll-snap-align: start;
    padding: 18px
  }

  .kanban-col-btn {
    padding: 6px
  }

  .kanban-card {
    cursor: pointer
  }

  .kanban-touch-ghost {
    pointer-events: none
  }

  .notif-panel {
    width: min(340px, calc(100vw - 24px));
    right: -4px
  }
}

@media (max-width:760px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 18px
  }

  .page-title {
    font-size: 18px
  }

  .grid-4,
  .g4,
  .grid-3,
  .grid-2,
  .clients-grid,
  .team-grid,
  .tg {
    grid-template-columns: 1fr
  }

  .task-metrics,
  .admin-metrics,
  .subscription-metrics {
    grid-template-columns: 1fr 1fr
  }

  .metric-card,
  .mc {
    padding: 16px 18px
  }

  .metric-value,
  .mv {
    font-size: 20px
  }

  .metric-icon,
  .mix {
    top: 14px;
    right: 16px;
    padding: 7px
  }

  .chart-card {
    padding: 16px
  }

  [style*="grid-template-columns"]:not([style*="auto-fit"]):not([style*="auto-fill"]) {
    grid-template-columns: minmax(0, 1fr) !important
  }

  .filter-bar {
    gap: 8px;
    margin-bottom: 16px
  }

  .filter-input-wrapper {
    min-width: 100%
  }

  .filter-pills {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none
  }

  .filter-pills::-webkit-scrollbar {
    display: none
  }

  .pill {
    padding: 9px 13px;
    flex-shrink: 0
  }

  .contract-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px 0
  }

  .contract-row>*:first-child {
    grid-column: 1/-1
  }

  .table-scroll .data-table,
  .fin-table-wrap .data-table,
  .subscription-table .data-table {
    min-width: 600px
  }

  .fin-table-wrap,
  .subscription-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch
  }

  .cal-day {
    min-height: 44px;
    padding: 3px 2px
  }

  .cal-day-number {
    font-size: 10px
  }

  .cal-event-label {
    font-size: 7px
  }

  .message-bubble {
    max-width: 88%
  }

  .ai-suggestions {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px
  }

  .ai-suggestions::-webkit-scrollbar {
    display: none
  }

  .ai-key-row {
    flex-direction: column
  }

  .ai-key-btn {
    padding: 12px 20px
  }

  .settings-row,
  .permissions-row,
  .origin-item,
  .transaction-item {
    gap: 10px
  }

  .team-tab-btn {
    padding: 9px 12px;
    font-size: 11px
  }

  .search-wrapper {
    display: none
  }
}

@media (max-width:560px) {
  .btn-quick-action {
    padding: 8px 10px;
    font-size: 0;
    gap: 0
  }

  .btn-quick-action svg {
    width: 14px;
    height: 14px
  }

  .db-badge {
    font-size: 0;
    padding: 5px;
    gap: 0
  }

  .view-panel,
  .view-panel--flex {
    padding: 16px 12px calc(20px + env(safe-area-inset-bottom))
  }

  .modal {
    padding: 18px 16px;
    border-radius: 14px
  }

  .modal-t {
    font-size: 15px
  }

  .modal-footer {
    flex-direction: column-reverse
  }

  .modal-footer>* {
    width: 100%;
    justify-content: center
  }

  .btn-primary,
  .btn-secondary,
  .btn-danger {
    padding: 11px 14px;
    justify-content: center
  }

  .kanban-column,
  .task-board .task-column {
    min-width: 84vw;
    flex: 0 0 84vw
  }

  .kanban-add-column {
    min-width: 84vw;
    flex: 0 0 84vw
  }

  .task-metrics,
  .admin-metrics,
  .subscription-metrics {
    grid-template-columns: 1fr
  }

  .contract-row {
    grid-template-columns: 1fr
  }

  .table-scroll .data-table,
  .fin-table-wrap .data-table,
  .subscription-table .data-table {
    min-width: 520px
  }

  .transaction-item-icon {
    width: 32px;
    height: 32px
  }
}

@media (max-height:480px) and (orientation:landscape) {
  .view-panel--flex {
    height: auto;
    min-height: calc(100dvh - 52px)
  }

  .modal-overlay {
    align-items: flex-start
  }

  .modal {
    max-height: calc(100dvh - 24px)
  }
}

@media (prefers-reduced-motion:reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important
  }
}