/* Cello Staff 5.3 — mobile experience layer */
@media (max-width: 900px) {
  :root { --mobile-nav-h: 72px; --mobile-gap: 12px; }
  html { scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
  body { min-width: 0; overflow-x: hidden; padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom)); background: #f5f7fb; }
  body, button, input, select, textarea { font-size: 16px; }
  a, button, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  input, select, textarea { width: 100%; min-height: 48px; border-radius: 12px; }
  textarea { min-height: 112px; resize: vertical; }
  label { min-width: 0; }
  .main { width: 100%; min-width: 0; padding: 10px 12px calc(24px + var(--mobile-nav-h) + env(safe-area-inset-bottom)); }
  .top { top: 0; z-index: 18; min-height: 62px; margin: -10px -12px 10px; padding: 9px 12px 12px; background: rgba(248,250,252,.94); border-bottom: 1px solid rgba(226,232,240,.9); backdrop-filter: blur(16px); }
  .top > div:first-child { gap: 9px !important; }
  .page-title { max-width: 58vw; overflow: hidden; font-size: clamp(22px,6vw,28px); line-height: 1.08; text-overflow: ellipsis; white-space: nowrap; }
  .eyebrow { font-size: 10px; }
  .mobile-menu, .top-actions .icon-action { width: 44px !important; height: 44px !important; min-height: 44px !important; border-radius: 13px !important; }
  .top-actions { flex-shrink: 0; }
  .top-actions .action-label { display: none; }
  .side { width: min(86vw,330px); padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .side .nav { overflow-y: auto; overscroll-behavior: contain; }
  .side .nav a { min-height: 50px; }
  body.menu-open { overflow: hidden; }
  .mobile-bottom-nav { position: fixed; left: 8px; right: 8px; bottom: calc(7px + env(safe-area-inset-bottom)); z-index: 80; display: grid !important; grid-template-columns: repeat(5,minmax(0,1fr)) !important; height: 64px; padding: 5px 4px; border: 1px solid rgba(226,232,240,.95); border-radius: 20px; background: rgba(255,255,255,.96); box-shadow: 0 14px 38px rgba(15,23,42,.2); backdrop-filter: blur(18px); }
  .mobile-bottom-nav a { position: relative; display: grid; place-items: center; align-content: center; gap: 2px; min-width: 0; min-height: 52px; padding: 4px 2px; border-radius: 15px; color: #64748b; }
  .mobile-bottom-nav a span { font-size: 20px; line-height: 1; }
  .mobile-bottom-nav a small { width: 100%; overflow: hidden; font-size: 9px; font-weight: 800; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-bottom-nav a.active { background: #111827; color: #fff; }
  .mobile-bottom-nav a b { position: absolute; top: 2px; right: 13px; display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border: 2px solid #fff; border-radius: 999px; background: #ef4444; color: #fff; font-size: 9px; }
  .mobile-fab { display: none !important; }
  .footer-note { padding-bottom: 12px; font-size: 10px; text-align: center; }
  .alert { left: 12px !important; right: 12px !important; top: 76px !important; z-index: 100 !important; width: auto; padding: 13px 15px; border-radius: 14px; box-shadow: 0 14px 34px rgba(15,23,42,.2); }
  .card { min-width: 0; padding: 16px; border-radius: 18px; }
  .card:hover { transform: none; }
  .card-head { gap: 10px; }
  .card-head h2 { font-size: 19px; }
  .grid2, .grid3, .formgrid, .formgrid.four, .rules-grid { grid-template-columns: 1fr !important; gap: 12px; }
  .stack { gap: 12px; }
  .btn { min-height: 48px; padding: 11px 14px; border-radius: 12px; }
  .btn.sm { min-height: 42px; }
  form > .btn:last-child:not(.sm), .card > .btn:last-child:not(.sm) { width: 100%; }
  details > summary { min-height: 50px; }
  .profile-modal, .balanced-modal, .copy-shift-modal, .upload-preview-modal { align-items: end !important; padding: 0 !important; }
  .profile-modal-card, .balanced-modal-card, .copy-shift-card, .upload-preview-card { width: 100% !important; max-height: 90dvh; overflow-y: auto; border-radius: 24px 24px 0 0 !important; padding: 22px 16px calc(20px + env(safe-area-inset-bottom)) !important; }
  .modal-close { width: 42px; height: 42px; }
  .table-wrap { position: relative; width: 100%; overflow: visible; }
  .table { min-width: 0; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { margin-bottom: 10px; padding: 12px 13px; border: 1px solid #e2e8f0; border-radius: 15px; background: #fff; box-shadow: 0 3px 12px rgba(15,23,42,.04); }
  .table td { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; min-height: 35px; padding: 7px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .table td::before { content: attr(data-label); flex: 0 0 38%; color: #64748b; font-size: 11px; font-weight: 800; text-align: left; }
  .table td[colspan] { display: block; text-align: center; }
  .table td[colspan]::before { display: none; }
  .mobile-scroll-hint { display: flex; align-items: center; gap: 6px; margin: 0 2px 8px; color: #64748b; font-size: 10px; font-weight: 700; }
  .mobile-scroll-hint::before { content: '↔'; }
  .cards { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .stat { min-height: 84px; padding: 14px; }
  .metric { font-size: 25px; }
  .dashboard-v25 { grid-template-columns: 1fr !important; }
  .today-agenda .card-head, .birthday-card .card-head { align-items: center; }
  .agenda-row, .birthday-row { min-height: 52px; }
  .schedule-card { margin-inline: -4px; padding: 13px 9px; }
  .schedule-toolbar { align-items: stretch !important; }
  .view-switch { display: grid; grid-template-columns: repeat(3,1fr); width: 100%; }
  .view-switch .btn { min-width: 0; padding-inline: 5px; }
  .schedule-nav { display: grid; grid-template-columns: 46px 1fr 46px; width: 100%; }
  .schedule-nav form, .schedule-nav input { width: 100%; }
  .auto-schedule-bar, .auto-schedule-bar form, .auto-schedule-bar .btn { width: 100%; }
  .schedule-filters { position: sticky; top: 63px; z-index: 8; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 9px; border: 1px solid #e2e8f0; border-radius: 14px; background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
  .schedule-filters label:first-child { grid-column: 1/-1; }
  .schedule-filters input[type=search] { min-height: 44px; }
  .week-board { display: grid; grid-template-columns: 1fr; gap: 10px; overflow: visible; }
  .week-day { min-height: 0; padding: 12px; }
  .week-day header { top: 63px; }
  .week-shifts .shift { min-height: 54px; }
  .shift-menu { left: 10px; right: 10px; bottom: calc(78px + env(safe-area-inset-bottom)); border-radius: 17px; }
  .schedule-matrix-panel { margin-inline: -4px; padding: 10px; border-radius: 17px; }
  .schedule-workflow { grid-template-columns: 1fr; padding: 12px; }
  .workflow-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .workflow-actions form, .workflow-actions .btn { width: 100%; }
  .matrix-head { align-items: stretch; flex-direction: column; }
  .matrix-view-toggle { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .matrix-scroll { max-height: 66dvh; border-radius: 12px; }
  .schedule-matrix thead th:first-child, .schedule-matrix tbody th.matrix-person { min-width: 138px; }
  .matrix-shift { min-width: 42px; min-height: 44px; }
  .employee-schedule-home { margin-inline: -4px; padding: 16px; }
  .employee-schedule-hero { align-items: stretch; }
  .employee-month-stats { grid-template-columns: repeat(2,1fr); }
  .employee-upcoming > div { scroll-snap-type: x mandatory; }
  .employee-shift-card { scroll-snap-align: start; }
  .attendance-tabs, .request-tabs, .profile-tabs, .notification-filters { display: flex; gap: 6px; margin-inline: -4px; padding: 5px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; scroll-snap-type: x proximity; }
  .attendance-tabs::-webkit-scrollbar, .request-tabs::-webkit-scrollbar, .profile-tabs::-webkit-scrollbar, .notification-filters::-webkit-scrollbar { display: none; }
  .attendance-tabs a, .request-tabs a, .profile-tabs a, .notification-filters button { flex: 0 0 auto; min-height: 42px; scroll-snap-align: center; }
  .attendance-today { grid-template-columns: 1fr; min-height: 0; padding: 18px; }
  .attendance-state h2 { font-size: 31px; }
  .attendance-main-button { min-height: 170px; border-radius: 25px; }
  .qr-station { grid-template-columns: 1fr; gap: 15px; padding: 16px; }
  #attendance-qr { grid-row: auto; width: min(100%,420px); margin: auto; }
  .attendance-form-actions { display: grid; grid-template-columns: 1fr; }
  .holiday-hero { align-items: flex-start; flex-direction: column; }
  .holiday-layout { grid-template-columns: 1fr; }
  .holiday-list article, .holiday-requests article { align-items: flex-start; gap: 10px; padding: 13px 0; }
  .holiday-register { width: 100%; }
  .holiday-register .btn { width: 100%; }
  .directory-grid { grid-template-columns: 1fr !important; }
  .employee-card { padding: 16px; }
  .employee-card .btn { width: 100%; }
  .employee-basic, .public-info-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .profile-hero { align-items: flex-start; flex-direction: column; gap: 14px; }
  .profile-hero-main { align-items: center; }
  .profile-hero-main img, .profile-hero-placeholder { width: 76px; height: 76px; }
  .profile-completion { width: 100%; }
  .profile-grid { grid-template-columns: 1fr; }
  .profile-fields { grid-template-columns: 1fr !important; }
  .document-upload { padding: 12px 0; }
  .file-picker { min-height: 52px; }
  .document-thumb { width: 92px; height: 92px; }
  .termination-panel summary { align-items: flex-start; }
  .termination-form .btn { width: 100%; }
  .requests-grid { grid-template-columns: 1fr; }
  .inline-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: 6px; }
  .inline-actions .btn { width: 100%; }
  .notice { min-height: 58px; padding: 13px; }
  .notification-filters { position: sticky; top: 63px; z-index: 8; background: rgba(248,250,252,.96); }
  .rules-layout { grid-template-columns: 1fr; }
  .rules-section { padding: 14px; }
  .role-overview { grid-template-columns: 1fr; }
  .role-card { padding: 15px; }
  .permission-matrix { margin-inline: -4px; padding: 12px 9px; }
  .permission-matrix .table td:not(:first-child) { align-items: center; }
  .permission-save-bar { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .account-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .account-actions select, .account-actions .btn { width: 100%; }
  .public-profile { padding: 16px; }
  .login { width: calc(100% - 24px); margin: 28px auto; padding: 22px 18px; }
  .login .logo-big { width: 84px; height: 84px; }
}

@media (max-width: 480px) {
  .main { padding-inline: 9px; }
  .top { margin-inline: -9px; padding-inline: 9px; }
  .page-title { max-width: 55vw; font-size: 23px; }
  .card { padding: 14px; border-radius: 16px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .stat { min-height: 78px; }
  .stat .small { font-size: 10px; }
  .employee-basic, .public-info-grid { grid-template-columns: 1fr; }
  .profile-hero-main { align-items: flex-start; }
  .profile-hero-main h2 { font-size: 24px; }
  .role-card { grid-template-columns: auto 1fr auto; gap: 10px; }
  .permission-matrix .table td::before { flex-basis: 48%; }
  .attendance-main-button { min-height: 155px; }
}

@media (max-width: 360px) {
  .mobile-bottom-nav { left: 4px; right: 4px; }
  .mobile-bottom-nav a small { font-size: 8px; }
  .cards { grid-template-columns: 1fr; }
  .page-title { max-width: 49vw; }
}

@media (max-width: 900px) and (orientation: landscape) {
  .profile-modal-card, .balanced-modal-card, .copy-shift-card, .upload-preview-card { max-height: 82dvh; }
  .attendance-today { grid-template-columns: 1fr 1fr; }
  .attendance-main-button { min-height: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
