/* AKDV Mobile v1: responsive presentation ONLY.
   No JavaScript, observers, API changes, role changes or calendar data changes.
   Loaded after existing styles, including native calendar v7. */

@media (max-width: 950px) {
  .workspace, .main, .main > *, .panel, .surface { min-width: 0; }
  .topbar { gap: 8px; }
  .topright { min-width: 0; }
  .overview-top { grid-template-columns: minmax(0, 1fr); }
  .overview-intro { min-width: 0; }
  .lineitem .grow { min-width: 0; }
  .lineitem b, .lineitem p { overflow-wrap: anywhere; }
  .scrolltable, .gantt-scroll, .akdv7-scroll { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .dialog-body { -webkit-overflow-scrolling: touch; }
}

@media (max-width: 680px) {
  :root { --akdv-mobile-navigation-height: 80px; }
  html { scroll-padding-top: 74px; scrollbar-gutter: auto; }
  body { overflow-x: clip; }
  .shell { display: block; min-height: 100dvh; }
  .workspace { width: 100%; padding-bottom: 0; }

  /* Accessible bottom navigation; all sections remain reachable by swiping. */
  .sidebar {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0;
    display: block; width: 100%; height: auto; min-height: 0;
    padding: 7px 0 calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--canvas); border-top: 1px solid var(--line-strong);
    border-right: 0; box-shadow: 0 -10px 36px rgba(20, 28, 43, .09);
    z-index: 30;
  }
  .sidebar .brand, .sidebar .smalllabel, .sidebar .sidebar-foot { display: none; }
  .sidebar-content {
    display: block; width: 100%; overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  }
  .sidebar-content::-webkit-scrollbar { display: none; }
  .nav { display: flex; flex-direction: row; justify-content: flex-start; align-items: stretch;
         gap: 2px; width: max-content; min-width: 100%; padding: 0 7px; }
  .nav button {
    display: flex; flex: 0 0 88px; flex-direction: column; justify-content: center;
    align-items: center; gap: 4px; width: 88px; min-width: 88px; height: 65px;
    padding: 5px 3px 3px; border-radius: 12px;
    font-size: 11px; font-weight: 630; line-height: 1.15; white-space: normal;
    text-align: center; scroll-snap-align: start;
  }
  .nav button span { display: block; width: 100%; white-space: nowrap; }
  .nav button svg { flex: none; width: 21px; height: 21px; }
  .nav button:hover { transform: none; }
  .nav button.active {
    color: var(--accent); background: var(--accentsoft); font-weight: 750;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 14%, transparent);
  }
  .nav button.active svg { color: var(--accent); }
  .nav-active-marker { display: none; }

  /* Compact, fixed workspace header. */
  .topbar {
    position: sticky; top: 0; z-index: 20; height: 61px;
    padding: 0 13px 0 17px; background: var(--canvas);
    box-shadow: 0 3px 15px rgba(20, 28, 43, .035);
  }
  .crumb { min-width: 0; gap: 0; }
  .crumb > span, .crumb > svg { display: none; }
  .crumb strong { display: block; max-width: 142px; overflow: hidden;
                 white-space: nowrap; text-overflow: ellipsis; color: var(--ink);
                 font-size: 15px; font-weight: 790; letter-spacing: -.2px; }
  .crumb strong::before { content: 'АКДВ · '; color: var(--accent); }
  .topright { gap: 5px; flex: 0 0 auto; }
  .topbar .btn.icon-button { width: 42px; min-width: 42px; height: 42px; border-radius: 11px; }
  .user-chip { padding-left: 7px; margin-left: 1px; border-left: 1px solid var(--line); }
  .user-copy { display: none; }
  .avatar { width: 35px; height: 35px; border-radius: 11px; }

  /* Reading order: clean intro, compact indicators and stacked task lists. */
  .main {
    max-width: none; width: 100%;
    padding: 23px 14px calc(var(--akdv-mobile-navigation-height) + env(safe-area-inset-bottom, 0px) + 36px);
  }
  .main:has(.calendar-panel), .main:has(#request-list), .main:has(#team-list) {
    max-width: none;
  }
  .pagehead { display: flex; flex-direction: column; gap: 11px; margin-bottom: 16px; }
  .pagehead h1 { font-size: 26px; letter-spacing: -.8px; line-height: 1.16; }
  .pagehead .lead { margin-top: 6px; font-size: 13px; line-height: 1.5; }
  .pagehead .actions { display: flex; flex-wrap: wrap; width: 100%; gap: 8px; margin-top: 1px; }
  .pagehead .actions > .btn { min-height: 44px; }
  .pagehead .actions > .btn.primary { flex: 1 1 auto; }

  .overview-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: 11px; margin-bottom: 12px; }
  .overview-intro { border-radius: 17px; padding: 21px 19px 18px; }
  .overview-intro .eyebrow { font-size: 9.5px; letter-spacing: .7px; }
  .overview-intro h2 { font-size: 22px; line-height: 1.23; margin: 8px 0 6px; }
  .overview-intro p { line-height: 1.55; font-size: 12.5px; }
  .intro-shortcuts { margin-top: 14px; gap: 9px; }
  .intro-shortcuts .btn { min-height: 44px; flex: 1 1 115px; }
  .clock-card { min-height: 100px; padding: 15px 20px; border-radius: 16px; }
  .clock-card:after { transform: scale(.65); transform-origin: right top; }
  .clock-digits { font-size: 34px; margin: 3px 0; letter-spacing: -1.2px; }
  .clock-label { font-size: 10px; }
  .grid4, .overview-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .overview-metrics { margin-bottom: 13px; }
  .metric { padding: 14px; min-height: 119px; border-radius: 15px; gap: 3px; }
  .metric-copy { min-width: 0; }
  .metric-label { font-size: 11px; line-height: 1.32; max-width: 110px; }
  .metric strong { font-size: 30px; margin: 6px 0 4px; }
  .metric-icon { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 10px; }
  .metric-icon svg { width: 15px; height: 15px; }
  .metric-foot { font-size: 10px; line-height: 1.3; }
  .split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 13px; margin-top: 13px; }
  .surface { border-radius: 16px; }
  .panel { padding: 17px 16px; }
  .panelhead, .controlrow { flex-wrap: wrap; align-items: flex-start; gap: 10px; }
  .panelhead h2 { font-size: 16px; }
  .panelhead .btn { min-height: 42px; }
  .lineitem { padding: 13px 0; gap: 9px; align-items: center; }
  .lineitem .grow { flex: 1 1 calc(100% - 53px); }
  .lineitem b { font-size: 12.5px; line-height: 1.38; }
  .lineitem p { font-size: 11px; line-height: 1.45; }
  .lineitem .initials { width: 37px; height: 37px; }
  .lineitem > .pill { margin-left: 46px; font-size: 10px; }
  .lineitem > .btn { min-height: 42px; margin-left: auto; }
  .pill { max-width: 100%; }
  .main-footer { margin-top: 24px; font-size: 10px; }

  /* Forms: no iOS zoom, comfortable spacing and visible dialog actions. */
  .btn { min-height: 44px; }
  .btn.min, .btn.icon-button { min-height: 42px; height: 42px; min-width: 42px; }
  .input, .field input, .field select, .field textarea { min-height: 46px; font-size: 16px; }
  .field textarea { min-height: 110px; }
  .fields2, .fields3, .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .filterbar { gap: 9px; }
  .filterbar .input { flex: 1 1 100%; width: 100%; max-width: none; }
  .filterbar .field { min-width: min(100%, 160px); }
  .overlay { padding: 8px; align-items: end; }
  .dialog-panel, .dialog-panel:has(.request-summary), .dialog-panel:has(.position-form),
  .dialog-panel:has(#request-delete-form), .dialog-panel:has(#transitionform) {
    width: 100%; max-height: calc(100dvh - 16px); border-radius: 20px 20px 14px 14px;
  }
  .dialog-head { padding: 18px 18px 14px; }
  .dialog-head h2 { font-size: 19px; line-height: 1.26; }
  .dialog-body { padding: 17px 18px 22px; }
  .dialog-footer { gap: 9px; padding: 12px 15px calc(13px + env(safe-area-inset-bottom, 0px)); }
  .dialog-footer .btn { min-height: 45px; }
  .request-summary { padding: 15px; }
  .request-summary-line { flex-wrap: wrap; }
  .approval-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 16px; column-gap: 10px; }
  .approval-step:before { display: none; }
  .upload-target { min-height: 46px; }
  .skill-choice { min-height: 43px; }
  .login-bg { min-height: 100dvh; padding: 16px; }
  .login-card { padding: 24px 20px; border-radius: 19px; }

  /* Preserve all table columns and calendar information via horizontal scrolling. */
  .scrolltable { max-width: 100%; overflow-x: auto; }
  .scrolltable .table { min-width: 680px; }
  .calendar-panel { padding: 14px 11px; }
  .calendar-workbar { flex-wrap: wrap; gap: 10px; }
  .calendar-period-title h2 { font-size: 20px; }
  .calendar-date-arrows { gap: 6px; }
  .calendar-date-arrows .btn { min-height: 42px; }
  .calendar-toolbar { gap: 11px; padding: 13px 0; }
  .calendar-toolbar > .seg { display: flex; max-width: 100%; overflow-x: auto; justify-content: flex-start; }
  .calendar-toolbar > .seg button { flex: 0 0 auto; min-height: 42px; font-size: 11px; }
  .calendar-filterbar { gap: 9px; }
  .calendar-filterbar label { min-width: 0; }
  .calendar-filterbar .input { min-height: 44px; font-size: 14px; }
  .cal-grid { gap: 3px; }
  .cal-day { min-height: 69px; padding: 4px; border-radius: 7px; }
  .cal-click { padding: 4px; min-height: 68px; }
  .cal-day .daynumber { font-size: 11px; }
  .cal-event { font-size: 9px; overflow-wrap: anywhere; }
  .month-collection { grid-template-columns: minmax(0, 1fr); }
  .month-day { min-height: 36px; }
  .gantt-scroll, .akdv7-scroll { max-width: 100%; }
  .akdv7-table .akdv7-name-col, .akdv7-table .akdv7-person-col {
    width: 148px; min-width: 148px; max-width: 148px;
  }
  .akdv7-table .akdv7-person-col { padding-left: 7px; padding-right: 7px; }
  .akdv7-table .akdv7-person-col strong, .akdv7-table .akdv7-person-col small { max-width: 132px; }
  .akdv7-conflict-card { padding: 13px; }
  .akdv7-conflict-body { gap: 5px; }
  .akdv7-conflict-actions { flex-wrap: wrap; }
  #toasts { left: 12px; right: 12px; bottom: calc(91px + env(safe-area-inset-bottom, 0px)); }
  .toast { max-width: none; }
}

@media (max-width: 380px) {
  .nav button { flex-basis: 81px; width: 81px; min-width: 81px; font-size: 10.5px; }
  .topbar { padding-right: 8px; padding-left: 12px; }
  .topbar .btn.icon-button { width: 39px; min-width: 39px; height: 39px; }
  .crumb strong { max-width: 110px; font-size: 14px; }
  .main { padding-right: 11px; padding-left: 11px; }
  .panel { padding: 15px 13px; }
  .metric { padding: 12px 11px; }
  .metric-icon { width: 27px; flex-basis: 27px; height: 27px; }
  .metric strong { font-size: 29px; }
  .calendar-panel { padding-left: 8px; padding-right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-content { scroll-behavior: auto; }
}
