/* Global NephScola mobile shell. Desktop and tablet layouts remain unchanged. */
.mobile-sidebar-close,
.mobile-sidebar-backdrop,
.mobile-header-action,
.mobile-header-welcome,
.mobile-search-close,
.mobile-bottom-nav,
.mobile-plus-layer {
  display: none;
}

@media screen and (max-width: 768px) {
  :root {
    --mobile-header-height: 72px;
    --mobile-bottom-nav-height: 70px;
  }

  body.mobile-drawer-open,
  body.mobile-sheet-open {
    overflow: hidden;
  }

  .app-shell {
    height: 100dvh;
    min-height: 100dvh;
  }

  .main {
    height: 100dvh;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 70;
    width: 100%;
    min-height: var(--mobile-header-height) !important;
    height: var(--mobile-header-height) !important;
    display: flex;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 4px;
    padding: 8px 10px !important;
    color: #fff !important;
    border: 0 !important;
    background: var(--color-sidebar-bg) !important;
    box-shadow: 0 8px 24px color-mix(in srgb, var(--color-sidebar-bg) 28%, transparent) !important;
  }

  .menu-toggle,
  .mobile-header-action {
    width: 42px;
    height: 44px;
    min-width: 42px;
    display: grid;
    place-items: center;
    padding: 0;
    color: #fff !important;
    border: 0 !important;
    border-radius: 7px;
    background: transparent !important;
    box-shadow: none !important;
  }

  .menu-toggle:hover,
  .menu-toggle:focus-visible,
  .mobile-header-action:hover,
  .mobile-header-action:focus-visible {
    color: #fff !important;
    background: color-mix(in srgb, white 14%, transparent) !important;
    outline: 2px solid color-mix(in srgb, white 48%, transparent);
    outline-offset: -2px;
  }

  .menu-toggle svg,
  .mobile-header-action svg,
  .mobile-sidebar-close svg,
  .mobile-search-close svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .top-school-identity {
    flex: 1 1 auto;
    min-width: 0 !important;
    gap: 9px;
    overflow: hidden;
  }

  .top-school-logo {
    width: 42px !important;
    height: 48px !important;
    flex: 0 0 42px;
    padding: 3px;
    object-fit: contain;
    border: 1px solid color-mix(in srgb, white 68%, transparent) !important;
    border-radius: 7px !important;
    background: #fff !important;
  }

  .top-school-identity > div {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  .top-school-identity strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: #fff !important;
    font-size: 14px !important;
    font-weight: 750;
    line-height: 1.18;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-school-identity #topSchoolMotto {
    display: none;
  }

  .mobile-header-welcome {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: rgba(255,255,255,.76) !important;
    font-size: 10.5px !important;
    font-weight: 500;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-search-toggle {
    display: grid;
  }

  .header-tools {
    width: auto !important;
    margin: 0 !important;
    display: flex;
    flex: 0 0 auto;
    flex-wrap: nowrap !important;
    justify-content: flex-end !important;
    gap: 2px;
  }

  .header-tools > .appearance-switcher,
  .header-tools > .language-selector,
  .header-tools > .header-dropdown-wrap:has(.mail-trigger),
  .header-tools > .header-dropdown-wrap:has(.help-trigger) {
    display: none !important;
  }

  .header-tools .header-icon-button,
  .header-tools .profile-trigger {
    min-width: 40px;
    width: 40px;
    height: 44px;
    min-height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    color: #fff !important;
    border: 0 !important;
    border-radius: 7px;
    background: transparent !important;
    box-shadow: none !important;
  }

  .header-tools .header-icon-button:hover,
  .header-tools .header-icon-button:focus-visible,
  .header-tools .profile-trigger:hover,
  .header-tools .profile-trigger:focus-visible {
    color: #fff !important;
    background: color-mix(in srgb, white 14%, transparent) !important;
    outline: 2px solid color-mix(in srgb, white 48%, transparent);
    outline-offset: -2px;
  }

  .header-tools .header-icon-svg {
    width: 23px;
    height: 23px;
  }

  .header-tools .profile-trigger > span,
  .header-tools .profile-chevron {
    display: none !important;
  }

  .header-tools .profile-avatar {
    width: 34px;
    height: 34px;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,.72);
    background: color-mix(in srgb, white 12%, transparent) !important;
  }

  .header-tools .profile-avatar svg {
    width: 21px;
    height: 21px;
  }

  .header-tools .header-icon-button > span {
    top: 0;
    right: -1px;
    min-width: 18px;
    height: 18px;
    border: 2px solid var(--color-sidebar-bg);
    background: #f97316;
    font-size: 9px;
  }

  .master-search {
    position: fixed !important;
    z-index: 69;
    top: calc(var(--mobile-header-height) + 8px);
    right: 10px;
    left: 10px;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    display: none;
    padding: 8px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    box-shadow: var(--shadow-dropdown);
  }

  .topbar.mobile-search-open .master-search {
    display: block;
    animation: none;
  }

  .master-search .search-box {
    width: 100%;
    min-width: 0;
    max-width: none;
    padding: 0 4px 0 11px;
    border-color: var(--color-border-strong) !important;
    border-radius: 6px;
    background: var(--color-input-bg) !important;
  }

  .master-search .search-box:focus-within {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent) !important;
  }

  .master-search #globalSearch {
    min-width: 0;
    height: 40px;
    min-height: 40px;
  }

  .master-search-button {
    width: 38px;
    height: 36px;
    flex-basis: 38px;
  }

  .mobile-search-close {
    width: 38px;
    height: 38px;
    display: grid;
    flex: 0 0 38px;
    place-items: center;
    padding: 0;
    color: var(--color-text-secondary);
    border: 0;
    border-radius: 6px;
    background: transparent;
  }

  .mobile-search-close:hover,
  .mobile-search-close:focus-visible {
    color: var(--color-primary);
    background: var(--color-primary-soft);
  }

  .global-search-dropdown {
    position: absolute !important;
    top: calc(100% + 6px) !important;
    right: 0 !important;
    left: 0 !important;
    max-height: calc(100dvh - 154px) !important;
  }

  .header-dropdown {
    position: fixed !important;
    z-index: 85;
    top: calc(var(--mobile-header-height) + 7px) !important;
    right: 8px !important;
    left: 8px !important;
    width: auto !important;
    max-height: calc(100dvh - var(--mobile-header-height) - var(--mobile-bottom-nav-height) - 22px);
    overflow-y: auto;
    border-radius: 8px;
  }

  .sidebar {
    z-index: 95 !important;
    width: min(86vw, 330px) !important;
    height: 100dvh !important;
    transition: transform 210ms ease-out !important;
  }

  .sidebar .brand {
    grid-template-columns: auto minmax(0, 1fr) auto !important;
  }

  .sidebar-collapse {
    display: none !important;
  }

  .mobile-sidebar-close {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    padding: 0;
    color: #fff;
    border: 1px solid color-mix(in srgb, white 28%, transparent);
    border-radius: 7px;
    background: color-mix(in srgb, white 12%, transparent);
  }

  .mobile-sidebar-backdrop {
    position: fixed;
    z-index: 90;
    inset: 0;
    display: block;
    padding: 0;
    border: 0;
    background: rgba(7, 20, 35, .52);
    backdrop-filter: blur(2px);
  }

  .mobile-sidebar-backdrop.hidden {
    display: none !important;
  }

  .page-content {
    padding: 14px 12px calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 24px) !important;
    scroll-padding-bottom: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 24px);
  }

  .floating-action,
  .floating-action-button,
  .fab,
  .global-quick-actions {
    bottom: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 14px) !important;
  }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 60;
    right: 0;
    bottom: 0;
    left: 0;
    min-height: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-columns: repeat(var(--mobile-nav-count, 4), minmax(0, 1fr));
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--color-border);
    background: color-mix(in srgb, var(--color-surface) 96%, var(--color-primary-soft));
    box-shadow: 0 -8px 28px color-mix(in srgb, var(--color-text-primary) 11%, transparent);
  }

  .mobile-bottom-nav:empty,
  .app-shell.hidden + .mobile-bottom-nav {
    display: none;
  }

  .mobile-bottom-nav button {
    position: relative;
    min-width: 0;
    min-height: 64px;
    display: grid;
    grid-template-rows: 28px auto;
    align-content: center;
    justify-items: center;
    gap: 3px;
    padding: 5px 2px 3px;
    color: var(--color-text-secondary);
    border: 0;
    background: transparent;
    font-size: 10px;
    font-weight: 650;
    line-height: 1.08;
  }

  .mobile-bottom-nav button::before {
    content: "";
    position: absolute;
    top: 0;
    width: 38px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: transparent;
  }

  .mobile-bottom-nav button svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-bottom-nav button span {
    max-width: 100%;
    overflow: hidden;
    text-align: center;
    display: -webkit-box;
    line-height: 1.05;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .mobile-bottom-nav button.active {
    color: var(--color-primary);
  }

  .mobile-bottom-nav button.active::before {
    background: var(--color-primary);
  }

  .mobile-plus-layer {
    position: fixed;
    z-index: 110;
    inset: 0;
    display: grid;
    align-items: end;
  }

  .mobile-plus-layer.hidden {
    display: none !important;
  }

  .mobile-plus-backdrop {
    position: absolute;
    inset: 0;
    padding: 0;
    border: 0;
    background: rgba(7, 20, 35, .54);
    backdrop-filter: blur(2px);
  }

  .mobile-plus-sheet {
    position: relative;
    z-index: 1;
    max-height: min(78dvh, 720px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    color: var(--color-text-primary);
    border-radius: 16px 16px 0 0;
    background: var(--color-surface-raised);
    box-shadow: 0 -24px 70px rgba(7, 20, 35, .3);
    animation: mobile-sheet-rise 190ms ease-out;
  }

  .mobile-plus-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 22px 18px 13px;
    border-bottom: 1px solid var(--color-border);
  }

  .mobile-plus-head::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: var(--color-border-strong);
    transform: translateX(-50%);
  }

  .mobile-plus-head h2 {
    margin: 0;
    color: var(--color-text-primary);
    font-size: 19px;
  }

  .mobile-plus-head small {
    display: block;
    margin-top: 3px;
    color: var(--color-text-secondary);
    font-size: 11px;
  }

  .mobile-plus-head button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: 7px;
    background: var(--color-surface);
  }

  .mobile-plus-head svg,
  .mobile-sheet-card svg,
  .mobile-sheet-full-menu svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-plus-content {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 15px 16px 20px;
  }

  .mobile-plus-section + .mobile-plus-section {
    margin-top: 20px;
    padding-top: 17px;
    border-top: 1px solid var(--color-border);
  }

  .mobile-plus-section h3 {
    margin: 0 0 10px;
    color: var(--color-text-secondary);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .mobile-sheet-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
  }

  .mobile-sheet-card {
    min-width: 0;
    min-height: 88px;
    display: grid;
    align-content: center;
    justify-items: start;
    gap: 8px;
    padding: 11px 9px;
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
  }

  .mobile-sheet-card svg {
    color: var(--color-primary);
  }

  .mobile-sheet-card:focus-visible,
  .mobile-sheet-card:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
    outline: 0;
  }

  .mobile-sheet-full-menu {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    color: var(--color-primary);
    border: 1px solid var(--color-border-strong);
    border-radius: 8px;
    background: var(--color-surface);
    font-weight: 750;
  }

  @keyframes mobile-search-reveal {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  @keyframes mobile-sheet-rise {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

@media screen and (max-width: 360px) {
  .topbar {
    gap: 1px;
    padding-inline: 6px !important;
  }

  .menu-toggle,
  .mobile-header-action {
    width: 36px;
    min-width: 36px;
  }

  .top-school-logo {
    width: 36px !important;
    height: 43px !important;
    flex-basis: 36px;
  }

  .top-school-identity {
    gap: 6px;
  }

  .top-school-identity strong {
    font-size: 12.5px !important;
  }

  .mobile-header-welcome {
    font-size: 9.5px !important;
  }

  .header-tools .header-icon-button,
  .header-tools .profile-trigger {
    width: 36px;
    min-width: 36px;
  }

  .header-tools .profile-avatar {
    width: 31px;
    height: 31px;
  }

  .mobile-sheet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  .mobile-bottom-nav,
  .mobile-plus-layer,
  .mobile-sidebar-backdrop {
    display: none !important;
  }
}
