/* Mobile layout for the published React build. Keep this file after hpanel.css. */
@media (max-width: 1023px) {
  html,
  body,
  #root {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  body {
    overflow-x: hidden;
  }

  .mobile-nav-bar {
    background: #1a2a2e !important;
    border-bottom: 1px solid rgba(255, 255, 255, .1) !important;
    box-shadow: 0 3px 14px rgba(20, 40, 44, .13) !important;
    color: #fff;
    backdrop-filter: none;
  }

  html.dark .mobile-nav-bar {
    background: #111a1c !important;
  }

  .mobile-nav-bar > div {
    max-width: 960px !important;
  }

  .mobile-nav-bar h1 {
    color: #fff !important;
  }

  .mobile-nav-bar p {
    color: rgba(255, 255, 255, .7) !important;
  }

  .mobile-nav-bar [role="toolbar"] > a,
  .mobile-nav-bar [role="toolbar"] > button {
    color: #eaf5f6 !important;
  }

  .mobile-app-main {
    min-width: 0;
    background: var(--canvas);
    scroll-padding-top: 12px;
  }

  .mobile-app-main > div {
    box-sizing: border-box;
    max-width: 960px !important;
    padding: 12px clamp(12px, 3.5vw, 24px) calc(5rem + env(safe-area-inset-bottom)) !important;
  }

  .mobile-app-main .page-container-mobile {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: auto !important;
  }

  /* Keep page wrappers visible; do NOT force the mobile date/stats lead cards. */
  .mobile-app-main .shrink-0:has(.lg\:mb-5),
  .mobile-app-main .shrink-0:has(h1.text-2xl) {
    display: block !important;
  }

  /* Hide mobile date + kayıtlı hasta (and similar) lead cards on every page */
  .mobile-app-main .lg\:hidden.rounded-2xl.border.bg-white,
  .mobile-app-main .page-container-mobile .lg\:hidden.rounded-2xl {
    display: none !important;
  }

  .mobile-app-main .page-container-mobile > .flex.flex-col.h-full,
  .mobile-app-main .page-container-mobile > .flex.flex-col.h-full.min-h-0 {
    height: auto !important;
    min-height: 0;
  }

  .mobile-app-main .page-container-mobile > .flex.flex-col.h-full > .flex.flex-col.flex-1.min-h-0,
  .mobile-app-main .page-container-mobile .flex.flex-col.flex-1.min-h-0.overflow-hidden,
  .mobile-app-main .page-container-mobile .flex.flex-col.flex-1.min-h-0.overflow-y-auto {
    flex: 0 0 auto;
    height: auto !important;
    overflow: visible !important;
  }

  .mobile-app-main .page-container-mobile .flex-1.min-h-0.overflow-hidden,
  .mobile-app-main .page-container-mobile .flex-1.min-h-0.overflow-y-auto,
  .mobile-app-main .page-container-mobile .flex-1.overflow-y-auto.min-h-0 {
    height: auto !important;
    overflow: visible !important;
  }

  .mobile-app-main .page-container-mobile .rounded-2xl:has(.clinic-calendar) {
    min-height: 600px;
    overflow: hidden !important;
  }

  .mobile-app-main .page-container-mobile .rounded-2xl {
    min-width: 0;
    border-radius: 18px !important;
  }

  .mobile-app-main .page-container-mobile :is(.grid, .flex) > * {
    min-width: 0;
  }

  .mobile-app-main :is(.overflow-x-auto, .admin-table-wrap) {
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-app-main :is(input, select, textarea) {
    max-width: 100%;
    box-sizing: border-box;
  }

  .mobile-app-main :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    min-height: 44px;
  }

  input[type="date"] {
    width: 100%;
    min-width: 0 !important;
  }

  [role="dialog"] [role="document"] {
    max-width: 100%;
    max-height: 100dvh;
  }

  [role="dialog"] [role="document"] :is(.grid, .flex) > * {
    min-width: 0;
  }

  [role="dialog"] [role="document"] :is(input, select, textarea) {
    max-width: 100%;
    box-sizing: border-box;
  }

  .mobile-app-main :is(button.bg-primary, a.bg-primary, .app-filter, .campaign-filter, .admin-tabs button) {
    min-height: 44px;
  }

  .mobile-app-main :is(.app-filter-group, .admin-tabs, .campaign-modes) {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-app-main :is(.campaign-panel, .admin-panel, .kys-fx) {
    min-width: 0;
    max-width: 100%;
  }

  nav[aria-label="Ana navigasyon"] {
    background: #e9e9eb !important;
    border-top: 1px solid #d5d9da !important;
    box-shadow: 0 -5px 20px rgba(26, 42, 46, .07);
  }

  html.dark nav[aria-label="Ana navigasyon"] {
    background: #151a1b !important;
    border-top-color: #354044 !important;
  }

  nav[aria-label="Ana navigasyon"] ul {
    box-sizing: border-box;
    max-width: 960px;
    height: 58px;
    padding: 4px 8px;
    gap: 4px;
  }

  nav[aria-label="Ana navigasyon"] :is(a, button) {
    border-radius: 12px;
    min-height: 48px;
    line-height: 1.1;
  }

  nav[aria-label="Ana navigasyon"] :is(a[aria-current="page"], button[aria-expanded="true"]) {
    background: #fff;
    color: #1a2a2e !important;
    box-shadow: 0 1px 3px rgba(26, 42, 46, .12);
  }

  html.dark nav[aria-label="Ana navigasyon"] :is(a[aria-current="page"], button[aria-expanded="true"]) {
    background: #2a3639;
    color: #a4dce3 !important;
  }

  nav[aria-label="Ana navigasyon"] span {
    font-size: 11px;
  }

  nav[aria-label="Ana navigasyon"] svg {
    width: 21px;
    height: 21px;
  }

  .mobile-app-main :is(button, a, input, select, textarea):focus-visible,
  nav[aria-label="Ana navigasyon"] :is(a, button):focus-visible {
    outline: 2px solid #4f97a1;
    outline-offset: 2px;
  }

  .clinic-calendar {
    min-height: 520px;
    max-width: 100%;
  }

  .clinic-calendar .rbc-month-row {
    min-height: 76px !important;
  }

  .clinic-calendar .rbc-time-view,
  .clinic-calendar .rbc-agenda-view {
    min-height: 520px;
  }

  .clinic-calendar .rbc-agenda-view {
    overflow-x: auto !important;
  }

  .clinic-calendar .rbc-agenda-table {
    min-width: 530px;
  }
}

@media (max-width: 640px) {
  .mobile-app-main > div {
    padding-inline: 12px !important;
  }

  .mobile-app-main .page-container-mobile > .flex.flex-col.h-full > .flex.flex-col.flex-1.min-h-0 {
    gap: 16px;
  }

  .mobile-app-main .page-container-mobile :is(.p-6, .p-5) {
    padding: 16px;
  }

  .mobile-app-main .page-container-mobile :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    font-size: 16px;
  }

  [role="dialog"] [role="document"] :is(.px-6, .p-6) {
    padding-inline: 16px;
  }

  [role="dialog"] [role="document"] form .grid.grid-cols-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-app-main form .grid.grid-cols-2,
  [role="dialog"] [class*="grid-cols-[minmax(11.5rem"] {
    grid-template-columns: minmax(0, 1fr);
  }

  [role="dialog"] [role="document"] .border-t.flex.justify-end {
    flex-wrap: wrap;
  }

  .mobile-app-main .page-container-mobile .grid.grid-cols-12 {
    gap: 12px;
  }

  .mobile-app-main :is(.campaign-heading, .campaign-section-header, .campaign-issues-header, .admin-card-head) {
    flex-wrap: wrap;
  }

  .mobile-app-main .campaign-stats {
    gap: 8px;
  }

  .mobile-app-main .campaign-stat {
    padding: 11px 12px;
  }

  .mobile-app-main .kys-fx__rates {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mobile-app-main .kys-fx__rate {
    padding: 9px 7px;
  }

  .clinic-calendar .rbc-month-row {
    min-height: 64px !important;
  }

  .clinic-calendar .rbc-header {
    padding: 9px 2px !important;
    font-size: 10px !important;
  }

  .clinic-calendar .rbc-date-cell {
    padding: 4px 5px !important;
    font-size: 11px !important;
  }

  .clinic-calendar .rbc-event {
    min-height: 18px !important;
    margin: 1px 2px !important;
    padding: 2px 3px !important;
    border-radius: 6px !important;
  }

  .clinic-calendar .rbc-event-content {
    font-size: 10px !important;
  }
}

@media (max-width: 380px) {
  .mobile-nav-bar > div {
    padding-inline: 10px !important;
  }

  nav[aria-label="Ana navigasyon"] ul {
    padding-inline: 4px;
    gap: 2px;
  }

  nav[aria-label="Ana navigasyon"] span {
    font-size: 10px;
  }
}

/* Branded mobile dashboard header and raised content surface. */
@media (max-width: 1023px) {
  .mobile-nav-bar,
  html.dark .mobile-nav-bar {
    background: #172b2e !important;
    border: 0 !important;
    box-shadow: none !important;
    position: relative;
    z-index: 0 !important;
  }

  html.dark .mobile-nav-bar {
    background: #102024 !important;
  }

  .mobile-nav-inner {
    box-sizing: border-box;
    padding: 18px clamp(12px, 3.5vw, 24px) 40px;
  }

  .mobile-nav-content,
  .mobile-nav-actions,
  .mobile-profile-pill {
    display: flex;
    align-items: center;
  }

  .mobile-nav-content {
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
  }

  .mobile-brand-link {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    min-width: 0;
    background: transparent !important;
  }

  .mobile-brand-logo {
    display: block;
    width: clamp(122px, 37vw, 166px);
    height: auto;
  }

  .mobile-nav-actions {
    gap: 7px;
    min-width: 0;
  }

  .mobile-nav-actions:has(> button:not(.mobile-theme-button)) .mobile-profile-text {
    display: none;
  }

  .mobile-nav-actions:has(> button:not(.mobile-theme-button)) .mobile-profile-pill {
    padding-right: 4px;
  }

  .mobile-theme-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    width: 36px;
    height: 40px;
    color: #e6f5f6;
    border-radius: 11px;
    transition: background-color .18s ease;
  }

  .mobile-theme-button:hover,
  .mobile-theme-button:focus-visible {
    background: rgba(255, 255, 255, .11);
  }

  .mobile-profile-pill {
    box-sizing: border-box;
    flex: 0 1 auto;
    gap: 7px;
    max-width: 204px;
    min-width: 0;
    min-height: 45px;
    padding: 4px 10px 4px 4px;
    border: 1px solid rgba(211, 239, 242, .2);
    border-radius: 999px;
    background: rgba(255, 255, 255, .065);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .035);
    color: #fff;
    text-decoration: none;
  }

  .mobile-profile-pill:hover,
  .mobile-profile-pill:focus-visible {
    background: rgba(255, 255, 255, .13);
  }

  .mobile-profile-avatar {
    width: 35px;
    height: 35px;
    color: #d7eef1;
  }

  .mobile-profile-avatar-ring {
    border: 2px solid rgba(169, 219, 224, .52);
  }

  .mobile-profile-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.12;
  }

  .mobile-profile-name,
  .mobile-profile-caption {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-profile-name {
    font-size: 12px;
    font-weight: 650;
  }

  .mobile-profile-caption {
    margin-top: 2px;
    color: rgba(230, 242, 243, .69);
    font-size: 11px;
  }

  .mobile-nav-page-title {
    display: none !important;
  }

  .mobile-app-main {
    position: relative;
    z-index: 1;
    margin-top: -35px;
    /* Keep scrollport above fixed bottom nav so it cannot steal taps (iOS/WebKit). */
    margin-bottom: calc(3.25rem + env(safe-area-inset-bottom, 0px));
    border-radius: 30px 30px 0 0;
    background: #f7f7f8 !important;
    scroll-padding-top: 20px;
  }

  html.dark .mobile-app-main {
    background: #171d1f !important;
  }

  .mobile-app-main > div {
    padding-top: 24px !important;
    /* Nav clearance is on main; keep only a short content gap. */
    padding-bottom: 1rem !important;
  }

  /* Bottom quick-nav must always win over page content / FABs */
  nav[aria-label="Ana navigasyon"] {
    z-index: 1100 !important;
    pointer-events: auto !important;
  }

  nav[aria-label="Ana navigasyon"] :is(a, button) {
    pointer-events: auto !important;
    position: relative;
    z-index: 1;
  }

  /* Hide mobile date / kayıtlı hasta lead cards (all pages) */
  .mobile-app-main .page-container-mobile .dashboard-mobile-greeting > .lg\:hidden,
  .mobile-app-main .page-container-mobile .hastalar-mobile-lead > .lg\:hidden,
  .mobile-app-main .page-container-mobile .shrink-0 > .lg\:hidden.rounded-2xl {
    display: none !important;
  }

  /* Notes sheet: keep above bottom nav; show composer */
  .dashboard-notes-overlay {
    z-index: 10010 !important;
  }

  .dashboard-notes-sheet {
    max-height: min(88dvh, calc(100dvh - env(safe-area-inset-bottom))) !important;
  }

  .dashboard-notes-composer {
    position: relative;
    z-index: 2;
    background: #f5f5f7 !important;
    box-shadow: 0 -6px 18px rgba(25, 39, 43, .06);
  }

  html.dark .dashboard-notes-composer {
    background: #1c1c1e !important;
  }

  .dashboard-notes-composer input {
    font-size: 16px !important;
    min-height: 48px;
  }

  /* Dashboard overview stats: true 2-column grid (no horizontal carousel) */
  .mobile-app-main .page-container-mobile .dashboard-overview-stats,
  .mobile-app-main .page-container-mobile .dashboard-mobile-greeting + .grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 10px !important;
    overflow: visible !important;
    width: 100%;
    max-width: 100%;
  }

  .mobile-app-main .page-container-mobile .dashboard-overview-stats > :is(div, a),
  .mobile-app-main .page-container-mobile .dashboard-mobile-greeting + .grid > :is(div, a) {
    flex: none !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    border-color: #e3e6e8 !important;
    border-radius: 18px !important;
    box-shadow: 0 1px 3px rgba(25, 39, 43, .04);
    padding: 12px !important;
    min-height: 92px !important;
    box-sizing: border-box;
  }

  .mobile-app-main .page-container-mobile .dashboard-overview-stats > :is(div, a) > div:first-child,
  .mobile-app-main .page-container-mobile .dashboard-mobile-greeting + .grid > :is(div, a) > div:first-child {
    gap: 8px;
    align-items: flex-start;
  }

  .mobile-app-main .page-container-mobile .dashboard-overview-stats > :is(div, a) > div:first-child > span,
  .mobile-app-main .page-container-mobile .dashboard-mobile-greeting + .grid > :is(div, a) > div:first-child > span {
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 4px;
    font-size: 12px !important;
    line-height: 1.25 !important;
    overflow-wrap: anywhere;
  }

  .mobile-app-main .page-container-mobile .dashboard-overview-stats > :is(div, a) > div:first-child > div,
  .mobile-app-main .page-container-mobile .dashboard-mobile-greeting + .grid > :is(div, a) > div:first-child > div {
    flex-shrink: 0 !important;
    width: 28px !important;
    height: 28px !important;
  }

  html.dark .dashboard-overview-stats > :is(div, a),
  html.dark .dashboard-mobile-greeting + .grid > :is(div, a) {
    border-color: rgba(255, 255, 255, .09) !important;
  }
}

@media (max-width: 380px) {
  .mobile-nav-inner {
    padding-inline: 10px;
  }

  .mobile-brand-logo {
    width: 116px;
  }

  .mobile-nav-actions {
    gap: 3px;
  }

  .mobile-theme-button {
    flex-basis: 32px;
    width: 32px;
  }

  .mobile-profile-pill {
    padding-right: 7px;
  }

  .mobile-profile-name {
    font-size: 11px;
  }
}

/* Patient card: one scroll area, a compact identity section, and reachable actions. */
@media (min-width: 1024px) {
  .patient-identity-toggle {
    display: none;
  }
}

@media (max-width: 1023px) {
  .patient-detail-modal {
    height: 100dvh !important;
    max-height: 100dvh;
    min-width: 0;
  }

  .patient-modal-header {
    gap: 8px;
    min-height: 68px;
    padding: max(10px, env(safe-area-inset-top)) 14px 11px !important;
  }

  .patient-modal-header > div:first-child {
    gap: 10px;
  }

  .patient-modal-header > div:first-child > div.rounded-full {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .patient-modal-header h2 {
    font-size: 17px;
    line-height: 1.2;
  }

  .patient-modal-header p {
    font-size: 12px;
  }

  .patient-modal-header button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
  }

  .patient-modal-body {
    display: block !important;
    min-height: 0;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    background: #f7f7f8;
  }

  html.dark .patient-modal-body {
    background: #171d1f;
  }

  .patient-identity {
    box-sizing: border-box;
    width: 100% !important;
    max-height: none !important;
    padding: 12px 14px 0 !important;
    overflow: visible !important;
    border: 0 !important;
    background: transparent !important;
  }

  .patient-identity-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 21;
    gap: 12px;
    width: 100%;
    min-height: 58px;
    padding: 10px 14px;
    border: 1px solid #e2e6e8;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(25, 39, 43, .04);
    text-align: left;
  }

  html.dark .patient-identity-toggle {
    border-color: rgba(255, 255, 255, .1);
    background: #242b2d;
    color: #f4f7f7;
  }

  .patient-identity-summary {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
  }

  .patient-identity-summary strong,
  .patient-identity-summary span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .patient-identity-summary strong {
    color: #1e3035;
    font-size: 14px;
    font-weight: 650;
  }

  html.dark .patient-identity-summary strong {
    color: #f4f7f7;
  }

  .patient-identity-summary span {
    color: #6b7581;
    font-size: 12px;
  }

  .patient-identity-toggle-action {
    flex: 0 0 auto;
    color: #4d99a4;
    font-size: 13px;
    font-weight: 650;
  }

  .patient-identity:not(.is-open) > div {
    display: none;
  }

  .patient-identity.is-open > div {
    margin-top: 12px !important;
  }

  .patient-identity > div > div:last-child {
    border-color: #e2e6e8;
    border-radius: 16px;
  }

  .patient-identity > div > div:last-child > .px-4 {
    padding-inline: 14px !important;
  }

  .patient-identity-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .patient-identity-form > div {
    min-width: 0;
    margin: 0 !important;
  }

  .patient-birth-row {
    grid-template-columns: minmax(0, 1.7fr) minmax(72px, .8fr) !important;
  }

  .patient-birth-row input {
    min-width: 0 !important;
  }

  .patient-identity :is(input:not([type="checkbox"]), select, textarea) {
    box-sizing: border-box;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }

  .patient-main-content {
    flex: none !important;
    min-height: auto !important;
    overflow: visible !important;
    background: transparent !important;
  }

  .patient-modal-tabs {
    position: sticky !important;
    top: 0;
    z-index: 20;
    margin-top: 10px;
    background: #f7f7f8 !important;
    box-shadow: 0 4px 9px rgba(25, 39, 43, .035);
  }

  html.dark .patient-modal-tabs {
    background: #171d1f !important;
  }

  .patient-modal-tabs > div {
    padding: 7px 14px 9px !important;
    border: 0 !important;
    background: transparent !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .patient-modal-tabs > div::-webkit-scrollbar {
    display: none;
  }

  .patient-modal-tabs button {
    min-height: 42px;
  }

  .patient-tab-panel {
    flex: none !important;
    min-height: auto !important;
    padding: 14px 14px 28px !important;
    overflow: visible !important;
    background: #f7f7f8;
  }

  html.dark .patient-tab-panel {
    background: #171d1f;
  }

  .patient-tab-panel .space-y-6 > :not(:last-child) {
    margin-bottom: 16px !important;
  }

  .patient-tab-panel :is(input:not([type="checkbox"]), select, textarea) {
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }

  .patient-tab-panel :is(.patient-med-form, .patient-med-edit-form, .patient-followup-form) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .patient-tab-panel :is(.patient-med-form, .patient-med-edit-form, .patient-followup-form) > * {
    grid-column: auto !important;
    min-width: 0;
  }

  .patient-tab-panel :is(.patient-med-form, .patient-med-edit-form) > :first-child,
  .patient-tab-panel .patient-followup-form > :nth-child(3),
  .patient-tab-panel .patient-followup-form > :last-child {
    grid-column: 1 / -1 !important;
  }

  .patient-tab-panel .patient-followup-form > :last-child > button {
    min-height: 44px;
  }

  .patient-tab-panel .patient-anamnez-form {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .patient-tab-panel .patient-anamnez-form > * {
    grid-column: 1 / -1 !important;
    min-width: 0;
  }

  .patient-tab-panel .patient-anamnez-form label:has(input[type="file"]) {
    min-height: 44px;
  }

  .patient-modal-footer {
    gap: 8px;
    min-height: 66px;
    padding: 10px 14px max(10px, env(safe-area-inset-bottom)) !important;
    background: #fff !important;
    box-shadow: 0 -5px 18px rgba(25, 39, 43, .055);
  }

  html.dark .patient-modal-footer {
    background: #202729 !important;
  }

  .patient-modal-footer > div:last-child {
    min-width: 0;
  }

  .patient-modal-footer button {
    min-height: 44px;
    white-space: nowrap;
  }

  .patient-detail-modal :is(button, a, input, select, textarea):focus-visible {
    outline: 2px solid #4f97a1;
    outline-offset: 2px;
  }
}

@media (max-width: 380px) {
  .patient-birth-row {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .patient-modal-footer {
    padding-inline: 10px !important;
  }

  .patient-modal-footer > div:last-child {
    gap: 4px;
  }

  .patient-modal-footer button {
    padding-inline: 10px;
  }
}

/* Compact calendar views for appointments on phones and tablets. */
@media (max-width: 1023px) {
  .mobile-calendar-toolbar { display: grid; gap: 12px; margin-bottom: 14px; }
  .mobile-calendar-toolbar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
  .mobile-calendar-toolbar-top > div:last-child { min-width: 0; max-width: 56%; }
  .mobile-calendar-toolbar > div:last-child { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; padding: 4px; }
  .mobile-calendar-toolbar > div:last-child button { min-width: 0; min-height: 44px; padding: 6px 2px; font-size: 12px; }
  .mobile-calendar-month, .mobile-calendar-year { min-width: 0; }
  .mobile-calendar-weekdays, .mobile-calendar-month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .mobile-calendar-weekdays { margin-bottom: 7px; color: #89949a; font-size: 11px; font-weight: 700; text-align: center; }
  .mobile-calendar-month-grid { gap: 5px; }
  .mobile-calendar-date { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; min-width: 0; min-height: 52px; padding: 7px 2px 5px; border: 1px solid #e7ecee; border-radius: 12px; background: #fff; color: #28343c; font: inherit; cursor: pointer; }
  .mobile-calendar-date.is-outside { color: #b3bdc2; background: #f8f9fa; }
  .mobile-calendar-date.is-today { border-color: #8ac5cd; }
  .mobile-calendar-date.is-selected { border-color: #5aa9b4; background: #eaf6f8; color: #266f79; box-shadow: inset 0 0 0 1px #5aa9b4; }
  .mobile-calendar-date-number { font-size: 13px; font-weight: 700; line-height: 1.1; }
  .mobile-calendar-date-activity { display: flex; align-items: center; justify-content: center; gap: 2px; max-width: 100%; }
  .mobile-calendar-date-count { display: grid; place-items: center; min-width: 17px; height: 17px; padding: 0 3px; border-radius: 999px; background: #70b0ba; color: white; font-size: 10px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
  .mobile-calendar-event-dots { display: inline-flex; align-items: center; justify-content: center; gap: 2px; min-width: 0; }
  .mobile-calendar-event-dot { display: block; flex: none; width: 6px; height: 6px; border: 1px solid rgba(0, 0, 0, 0.16); border-radius: 50%; }
  .mobile-calendar-day-list { margin-top: 18px; padding: 16px; border: 1px solid #e8ecee; border-radius: 16px; background: #fafbfb; }
  .mobile-calendar-day-list-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
  .mobile-calendar-day-list-head strong { color: #26323a; font-size: 14px; text-transform: capitalize; }
  .mobile-calendar-day-list-head span { color: #718087; font-size: 12px; white-space: nowrap; }
  .mobile-calendar-appointments { display: grid; gap: 8px; margin-top: 13px; }
  .mobile-calendar-appointment { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #e7ecee; border-left: 3px solid #70b0ba; border-radius: 10px; background: #fff; color: #27343b; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
  .mobile-calendar-appointment time { color: #3c8994; font-weight: 750; font-variant-numeric: tabular-nums; }
  .mobile-calendar-appointment span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-calendar-appointment-detail { flex: 1; min-width: 0; }
  .mobile-calendar-appointment-detail > div { padding: 0; }
  .mobile-calendar-appointment-detail span { white-space: normal; }
  .mobile-calendar-no-appointments { margin: 13px 0 0; color: #8a969c; font-size: 13px; }
  .mobile-calendar-add { margin-top: 13px; padding: 8px 0; border: 0; background: none; color: #347e88; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
  .mobile-calendar-week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 12px; }
  .mobile-calendar-week-date { display: grid; justify-items: center; align-content: start; gap: 3px; min-width: 0; min-height: 75px; padding: 8px 2px; border: 1px solid #e7ecee; border-radius: 12px; background: #fff; color: #64717a; font: inherit; cursor: pointer; }
  .mobile-calendar-week-date span { font-size: 10px; }
  .mobile-calendar-week-date strong { font-size: 15px; line-height: 1; }
  .mobile-calendar-week-date small { display: grid; place-items: center; min-width: 16px; height: 16px; padding: 0 2px; border-radius: 999px; color: #4f97a1; font-size: 10px; font-weight: 800; font-variant-numeric: tabular-nums; }
  .mobile-calendar-week-date .mobile-calendar-event-dots { min-height: 6px; }
  .mobile-calendar-week-date.is-selected { border-color: #5aa9b4; background: #eaf6f8; color: #266f79; }
  .mobile-calendar-week-date.is-today:not(.is-selected) { border-color: #8ac5cd; }
  .mobile-calendar-year { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
  .mobile-calendar-year-month { display: flex; flex-direction: column; align-items: flex-start; min-height: 88px; padding: 12px; border: 1px solid #e7ecee; border-radius: 14px; background: #fff; color: #35434a; font: inherit; text-align: left; cursor: pointer; }
  .mobile-calendar-year-month span { font-size: 12px; font-weight: 700; }
  .mobile-calendar-year-month strong { margin-top: 9px; color: #3c8994; font-size: 20px; line-height: 1; font-variant-numeric: tabular-nums; }
  .mobile-calendar-year-month small { color: #8a969c; font-size: 10px; }
  .mobile-calendar-year-month .mobile-calendar-event-dots { justify-content: flex-start; gap: 4px; margin-top: auto; padding-top: 7px; }
  .mobile-calendar-year-month .mobile-calendar-event-dot { width: 9px; height: 9px; }
  .mobile-calendar-year-month.is-selected { border-color: #5aa9b4; background: #eaf6f8; }
  .mobile-calendar-week-layout { min-height: 580px; }
  .mobile-calendar-week-layout > .clinic-calendar { min-height: 520px; }
  .mobile-calendar-time-layout { display: flex; flex-direction: column; min-height: 0; }
  .mobile-calendar-time-layout > .clinic-calendar { min-height: 520px; }
  .mobile-calendar-time-layout > .mobile-calendar-add, .mobile-calendar-week-layout > .mobile-calendar-add { align-self: flex-start; }
  .clinic-calendar .rbc-time-gutter { font-size: 11px; }
  .clinic-calendar .rbc-time-view .rbc-event { padding: 3px 5px !important; }
  .dark .mobile-calendar-date, .dark .mobile-calendar-week-date, .dark .mobile-calendar-year-month, .dark .mobile-calendar-appointment { border-color: #394346; background: #242b2d; color: #e5edef; }
  .dark .mobile-calendar-date.is-outside { background: #1f2527; color: #718087; }
  .dark .mobile-calendar-date.is-selected, .dark .mobile-calendar-week-date.is-selected, .dark .mobile-calendar-year-month.is-selected { border-color: #6eb0ba; background: #193439; color: #b4e2e8; }
  .dark .mobile-calendar-day-list { border-color: #394346; background: #202729; }
  .dark .mobile-calendar-day-list-head strong { color: #e5edef; }
  .mobile-calendar-date:focus-visible, .mobile-calendar-week-date:focus-visible, .mobile-calendar-year-month:focus-visible, .mobile-calendar-appointment:focus-visible, .mobile-calendar-add:focus-visible { outline: 2px solid #4f97a1; outline-offset: 2px; }
}

@media (max-width: 380px) {
  .mobile-calendar-month-grid { gap: 3px; }
  .mobile-calendar-date { min-height: 46px; padding-inline: 1px; }
  .mobile-calendar-year { gap: 6px; }
  .mobile-calendar-year-month { min-height: 80px; padding: 9px; }
}

@media (max-width: 640px) {
  .mobile-calendar-time-layout .rbc-agenda-view { overflow-x: hidden !important; }
  .mobile-calendar-time-layout .rbc-agenda-table { min-width: 0; width: 100%; table-layout: fixed; }
  .mobile-calendar-time-layout .rbc-agenda-table :is(th, td) { padding: 7px 4px !important; font-size: 11px; }
  .mobile-calendar-time-layout .rbc-agenda-table :is(th, td):first-child { width: 76px; }
  .mobile-calendar-time-layout .rbc-agenda-table :is(th, td):nth-child(2) { width: 69px; }
  .mobile-calendar-time-layout .rbc-agenda-date-cell, .mobile-calendar-time-layout .rbc-agenda-time-cell { white-space: normal; overflow-wrap: anywhere; }
  .mobile-calendar-time-layout .rbc-agenda-event-cell { min-width: 0; overflow-wrap: anywhere; }
}

/* Patient creation and profile settings share the mobile viewport with the app shell. */
@media (max-width: 1023px) {
  .patient-create-wizard {
    box-sizing: border-box;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh;
    overflow: hidden;
  }

  .patient-create-header {
    gap: 10px;
    min-height: 68px;
    padding: max(10px, env(safe-area-inset-top)) 16px 11px !important;
  }

  .patient-create-header > div:first-child { gap: 10px; }
  .patient-create-header > div:first-child > div:first-child { width: 40px; height: 40px; font-size: 16px; }
  .patient-create-header h2 { font-size: 17px; line-height: 1.2; }
  .patient-create-header p { font-size: 12px; }
  .patient-create-header > button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; }

  .patient-create-body {
    display: flex !important;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  .patient-create-steps {
    box-sizing: border-box;
    display: block !important;
    flex: none;
    width: 100% !important;
    padding: 10px 14px !important;
    border-right: 0 !important;
    border-bottom: 1px solid rgba(30, 48, 53, .08);
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none;
  }

  .patient-create-steps::-webkit-scrollbar { display: none; }
  .patient-create-steps > p, .patient-create-steps > .mt-auto { display: none; }
  .patient-create-steps > .space-y-2 { display: flex; gap: 6px; width: 100%; }
  .patient-create-steps > .space-y-2 > div {
    box-sizing: border-box;
    display: flex;
    flex: 1 1 0;
    align-items: center;
    gap: 6px;
    min-width: 0;
    min-height: 44px;
    margin: 0 !important;
    padding: 7px 8px !important;
  }

  .patient-create-steps > .space-y-2 > div > div:first-child { width: 24px; height: 24px; font-size: 11px; }
  .patient-create-steps > .space-y-2 > div > div:last-child p:first-child { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
  .patient-create-steps > .space-y-2 > div > div:last-child p:last-child { display: none; }

  .patient-create-main { flex: 1 1 auto; width: 100%; min-width: 0; min-height: 0; overflow: hidden; }
  .patient-create-scroll { min-height: 0; padding: 16px !important; overflow-x: hidden !important; overflow-y: auto !important; overscroll-behavior-y: contain; scroll-padding-bottom: 80px; -webkit-overflow-scrolling: touch; }
  .patient-create-form { box-sizing: border-box; width: 100%; max-width: 100%; min-width: 0; }
  .patient-create-form :is(input, select, textarea) { box-sizing: border-box; max-width: 100%; min-width: 0; font-size: 16px; }
  .patient-create-birth-row input[type="date"] { min-width: 0 !important; }
  .patient-create-conversion-banner { margin: 12px 16px 0 !important; }
  .patient-create-footer { gap: 10px; padding: 10px 16px max(10px, env(safe-area-inset-bottom)) !important; background: #fff; box-shadow: 0 -4px 14px rgba(25, 39, 43, .06); }
  .patient-create-footer button { min-height: 44px; white-space: nowrap; }
  html.dark .patient-create-footer { background: #1c1c1e; }

  .profile-mobile-layout { display: flex !important; flex-direction: column !important; align-items: stretch; height: auto !important; overflow: visible !important; }
  .profile-summary-card { box-sizing: border-box; flex: none !important; width: 100% !important; max-width: 100% !important; max-height: none !important; overflow: visible !important; }
  .profile-summary-card > div:first-child { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; column-gap: 12px; padding: 16px 16px 12px !important; }
  .profile-summary-card > div:first-child > div:first-child { width: 64px; height: 64px; }
  .profile-summary-card > div:first-child > div:first-child > div:first-child { width: 64px; height: 64px; }
  .profile-summary-card > div:first-child > div:nth-child(2) { width: auto; min-width: 0; margin-top: 0; text-align: left; }
  .profile-summary-card > div:first-child > div:nth-child(2) h2 { overflow-wrap: anywhere; }
  .profile-summary-card > div:first-child > div:nth-child(3) { grid-column: 1 / -1; margin-top: 12px; }
  .profile-summary-card > div:nth-child(2) { padding-inline: 16px; }
  .profile-summary-card > div:nth-child(3) { padding: 14px 16px 16px !important; }
  /* Text/full-width actions only — not circular icon buttons */
  .profile-summary-card > div:nth-child(3) button,
  .profile-summary-card .flex.gap-2 > button {
    min-height: 44px;
  }

  /* Only the profile avatar camera badge — NOT FAB / randevu ekle */
  .profile-summary-card .relative > button.absolute.rounded-full.bg-primary {
    box-sizing: border-box !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 9999px !important;
    flex-shrink: 0 !important;
    aspect-ratio: 1 / 1 !important;
  }

  /* Restore mobile FAB (Randevu Ekle etc.) if previously crushed */
  .mobile-app-main button.fixed.bg-primary,
  .mobile-app-main button.fixed.right-4 {
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 44px !important;
    max-width: min(16rem, calc(100vw - 2rem)) !important;
    max-height: none !important;
    padding: 12px 16px !important;
    border-radius: 9999px !important;
    aspect-ratio: auto !important;
    gap: 8px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    /* Stay above nav bar; never stretch across the tab strip */
    bottom: calc(3.25rem + 0.75rem + env(safe-area-inset-bottom, 0px)) !important;
    left: auto !important;
    right: 1rem !important;
    z-index: 1090 !important;
  }

  @media (max-width: 380px) {
    .mobile-app-main button.fixed.bg-primary,
    .mobile-app-main button.fixed.right-4 {
      padding: 12px 14px !important;
    }
  }

  .profile-settings-panel { box-sizing: border-box; flex: none !important; width: 100%; max-width: 100%; height: auto !important; overflow: visible !important; }
  .profile-settings-content { flex: none !important; min-height: 0; padding: 16px !important; overflow: visible !important; }
  .profile-summary-card p, .profile-settings-content p { overflow-wrap: anywhere; }
  .profile-settings-panel :is(input, select, textarea) { box-sizing: border-box; max-width: 100%; font-size: 16px; }
  .profile-settings-panel :is(button, a):not([role="switch"]):not(.kys-switch):not(.rounded-full) { min-height: 44px; }

  /* SMS toggles: do not stretch into circles via min-height:44 */
  .profile-settings-panel button.kys-switch,
  .profile-settings-panel button[role="switch"] {
    box-sizing: border-box !important;
    width: 44px !important;
    height: 24px !important;
    min-width: 44px !important;
    min-height: 24px !important;
    max-width: 44px !important;
    max-height: 24px !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    border-radius: 999px !important;
    align-self: center;
  }
  .profile-settings-panel button.kys-switch .kys-switch__knob,
  .profile-settings-panel button[role="switch"] > span:not(.sr-only) {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
  }
  .profile-settings-content {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)) !important;
  }
  .profile-settings-content .flex.items-center.justify-between {
    gap: 12px !important;
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .patient-create-form .grid.grid-cols-2 { grid-template-columns: minmax(0, 1fr) !important; }
  .patient-create-form .grid.grid-cols-2 > .col-span-2 { grid-column: 1 / -1 !important; }
  .patient-create-form .patient-create-birth-row { grid-template-columns: minmax(0, 1.7fr) minmax(76px, .8fr) !important; }
  .patient-create-form .patient-create-birth-row > * { grid-column: auto !important; }
  .patient-create-footer > div:last-child { min-width: 0; }
}

@media (max-width: 380px) {
  .patient-create-steps > .space-y-2 > div { padding-inline: 5px !important; }
  .patient-create-form .patient-create-birth-row { grid-template-columns: minmax(0, 1fr) !important; }
  .patient-create-footer { padding-inline: 10px !important; }
  .profile-settings-content .grid.grid-cols-2 { grid-template-columns: minmax(0, 1fr) !important; }
}

/* Give the clinic assistant a dedicated mobile screen and an easy-to-find menu entry. */
@media (max-width: 1023px) {
  .clinic-mobile-menu-content { display: flex; flex-direction: column; }
  .clinic-assistant-menu-entry {
    order: -1;
    margin: 4px 0 12px !important;
    padding: 12px !important;
    border: 1px solid rgba(104, 178, 190, .28) !important;
    border-radius: 18px;
    background: rgba(104, 178, 190, .09);
  }
  .clinic-assistant-menu-entry > p { margin-bottom: 4px !important; color: #438b97 !important; }
  .clinic-assistant-menu-entry > div { padding: 0 !important; }
  .clinic-assistant-trigger {
    min-height: 60px;
    padding: 8px 10px !important;
    border: 1px solid rgba(104, 178, 190, .23);
    background: #fff;
  }
  html.dark .clinic-assistant-menu-entry { background: rgba(104, 178, 190, .12); }
  html.dark .clinic-assistant-trigger { background: #242b2d; }

  .clinic-assistant-panel {
    box-sizing: border-box;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh;
    min-height: 0;
    border: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  .clinic-assistant-header {
    min-height: 72px;
    padding: max(12px, env(safe-area-inset-top)) 16px 12px !important;
  }
  .clinic-assistant-header h3 { font-size: 17px; }
  .clinic-assistant-header button { display: grid; place-items: center; min-width: 44px; min-height: 44px; }
  .clinic-assistant-chat {
    min-height: 0;
    padding: 18px 16px !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }
  .clinic-assistant-chat > div > div { max-width: 100%; }
  .clinic-assistant-footer {
    padding: 10px 12px max(12px, env(safe-area-inset-bottom)) !important;
    box-shadow: 0 -4px 16px rgba(25, 39, 43, .06);
  }
  .clinic-assistant-prompt-grid {
    display: flex !important;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    margin-bottom: 10px !important;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .clinic-assistant-prompt-grid::-webkit-scrollbar { display: none; }
  .clinic-assistant-prompt-grid > button {
    flex: 0 0 auto;
    grid-column: auto !important;
    min-height: 38px;
    padding: 8px 12px !important;
    white-space: nowrap;
  }
  .clinic-assistant-composer { min-width: 0; }
  .clinic-assistant-composer input {
    min-width: 0;
    min-height: 46px;
    font-size: 16px !important;
  }
  .clinic-assistant-composer button { min-width: 46px; min-height: 46px; }
}


/* Finans mobilde aynı toplamları iki kez göstermesin; yatay özet tek bakışta yeterli. */
@media (max-width: 1023px) {
  .finance-detailed-summary {
    display: none !important;
  }
}

/* Ana gezinme, her sayfanın içerik katmanından bağımsız tıklanabilir kalır. */
nav[aria-label="Ana navigasyon"] {
  position: fixed !important;
  inset-inline: 0 !important;
  bottom: 0 !important;
  z-index: 1100 !important;
  pointer-events: auto !important;
  touch-action: manipulation;
}


/* Finans filtreleri dar ekranda birbirinin üstüne binmesin. */
@media (max-width: 1023px) {
  .finance-transaction-toolbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px !important;
    overflow: visible !important;
  }

  .finance-transaction-toolbar > div:first-child,
  .finance-transaction-toolbar > .app-filter-group {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .finance-transaction-toolbar > .app-filter-group {
    display: flex;
  }

  .finance-transaction-toolbar > .app-filter-group > button {
    flex: 1 1 0;
    justify-content: center;
  }

  .finance-transaction-toolbar > select {
    width: 100% !important;
    min-width: 0;
  }
}

/* Appointment dialogs cover navigation and stay inside the iPhone's visible viewport. */
@media (max-width: 1023px) {
  [role="dialog"]:has(> .appointment-dialog) {
    box-sizing: border-box;
    align-items: center !important;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)) !important;
    height: 100dvh;
    z-index: 10020 !important;
  }
  [role="dialog"] > .appointment-dialog {
    width: 100%;
    min-height: 0;
    max-width: 480px;
    max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom))) !important;
    border-radius: 20px !important;
  }
  .appointment-dialog > div { min-width: 0; flex-shrink: 0; }
  .appointment-dialog > div:first-child { gap: 10px; padding: 18px !important; }
  .appointment-dialog > div:first-child > div { min-width: 0; }
  .appointment-dialog > div:first-child > button { flex-shrink: 0; min-width: 40px; min-height: 40px; }
  .appointment-dialog > .overflow-y-auto {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0 18px 18px !important;
  }
  .appointment-dialog > div:last-child:not(.overflow-y-auto) { padding: 14px 18px !important; }
  .appointment-dialog :is(input:not([type="checkbox"]), select, textarea) { min-width: 0; max-width: 100%; font-size: 16px; }
  .appointment-dialog button { min-height: 44px; }
}

/* Hasta kartı > Takip ekleme formu: iOS tarih alanı taşması ve hizalama */
.patient-followup-add-label { display:none; }
@media (max-width: 767px) {
  .patient-tab-panel .patient-followup-form { align-items:start !important; }
  .patient-tab-panel .patient-followup-form input[type="date"] {
    -webkit-appearance:none; appearance:none; display:block; width:100%; max-width:100%; min-width:0;
    height:44px; line-height:44px; padding-top:0; padding-bottom:0; text-align:left;
  }
  .patient-tab-panel .patient-followup-form input[type="date"]::-webkit-date-and-time-value { text-align:left; margin:0; }
  .patient-tab-panel .patient-followup-form input[type="date"]::-webkit-calendar-picker-indicator { margin-left:auto; }
  .patient-tab-panel .patient-followup-form .patient-followup-add { display:inline-flex; align-items:center; justify-content:center; gap:8px; border-radius:12px; font-size:15px; font-weight:600; }
  .patient-tab-panel .patient-followup-form .patient-followup-add-label { display:inline; }
}
