/* Mobile presentation only. Desktop markup and business flows remain unchanged. */
.mobile-menu-button,
.mobile-drawer,
.mobile-filter-disclosure > summary { display: none; }

@media (max-width: 680px) {
  html { scroll-padding-top: 66px; }
  body.app-shell { font-size: 14px; }
  body.mobile-nav-open { overflow: hidden; }
  .sidebar { height: 58px; min-height: 58px; padding: 8px 16px; }
  .side-brand { min-width: 0; }
  .mobile-menu-button { display: inline-flex; align-items: center; justify-content: center; order: 3; width: 42px; height: 42px; min-width: 42px; min-height: 42px; margin-left: auto; padding: 0; border: 1px solid rgba(255,255,255,.26); border-radius: 7px; background: transparent; color: #fff; font-size: 24px; line-height: 1; }
  .sidebar .side-foot { display: none; }
  .mobile-drawer { position: fixed; inset: 0; z-index: 200; display: none; }
  .mobile-drawer[aria-hidden="false"] { display: block; }
  .mobile-drawer-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 0; background: rgba(5,18,35,.58); }
  .mobile-drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; display: flex; flex-direction: column; width: min(320px, 88vw); padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); overflow-y: auto; background: var(--jc-sidebar); color: #fff; box-shadow: -12px 0 34px rgba(4,15,30,.22); }
  .mobile-drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 2px 18px; border-bottom: 1px solid rgba(255,255,255,.12); font-size: 16px; font-weight: 700; }
  .mobile-drawer-close { display: grid; place-items: center; width: 42px; height: 42px; min-width: 42px; min-height: 42px; padding: 0; border: 0; background: transparent; color: #fff; font-size: 30px; font-weight: 300; line-height: 1; }
  .mobile-drawer nav { display: flex; flex-direction: column; gap: 3px; padding: 16px 0; }
  .mobile-drawer nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 9px 12px; border-radius: 6px; color: #d7e5f6; text-decoration: none; }
  .mobile-drawer nav a.active { background: #195da9; color: #fff; font-weight: 700; }
  .mobile-drawer nav .nav-icon { display: inline-flex; justify-content: center; width: 20px; }
  .mobile-drawer-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.12); }
  .mobile-drawer-foot .side-user { display: flex; gap: 10px; align-items: center; }
  .mobile-drawer-foot .side-user > span:last-child { display: block; }
  .mobile-drawer-foot .logout-form { display: block; margin-top: 12px; }
  .mobile-drawer-foot .linklike { display: inline-flex; min-height: 44px; align-items: center; color: #e4efff; }

  .topbar { min-height: 42px; padding-right: 16px; }
  .topbar-actions { display: flex; align-items: center; justify-content: flex-end; width: 100%; }
  .content { padding: 0 14px calc(28px + env(safe-area-inset-bottom)); }
  .page-heading { min-height: 0; padding: 18px 0 16px; }
  .page-heading h1 { font-size: 23px; line-height: 1.25; }
  .page-heading p { font-size: 12px; line-height: 1.5; }
  .panel { padding: 16px; }
  .panel-head { gap: 12px; }
  .panel-head h2, .panel > h2 { line-height: 1.35; }
  .page-heading-actions, .panel-head .inline-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .page-heading-actions > *, .panel-head .inline-actions > * { min-width: 0; }
  .panel-head .inline-actions form { margin: 0; }
  .panel-head .inline-actions button, .page-heading-actions button { min-height: 42px; }
  .dashboard-cards, .node-overview-cards, .node-cluster-selected .node-overview-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .dashboard-cards .card, .node-overview-card { min-width: 0; padding: 13px; }
  .dashboard-cards .card b, .node-overview-card b { font-size: clamp(19px, 5.4vw, 26px); overflow-wrap: anywhere; }
  .dashboard-cards .card span, .node-overview-card span { line-height: 1.4; }
  .trend-panel .panel-head { display: block; }
  .trend-filter { margin-top: 12px; }
  .trend-filter > select { grid-column: 1 / -1; }
  .trend-chart-toolbar { align-items: flex-start; gap: 10px; }
  .trend-chart-toolbar label { min-width: 0; }
  .trend-chart-toolbar select { max-width: 100%; }
  .line-chart { min-width: 0; touch-action: manipulation; }
  .chart-tooltip { max-width: min(230px, calc(100vw - 58px)); }

  .mobile-filter-disclosure { display: block; width: 100%; margin: 12px 0; border: 1px solid var(--jc-border); border-radius: 7px; background: var(--jc-surface); }
  .mobile-filter-disclosure > summary { display: flex; align-items: center; justify-content: space-between; min-height: 46px; padding: 10px 13px; color: var(--jc-text); font-weight: 700; list-style: none; cursor: pointer; }
  .mobile-filter-disclosure > summary::-webkit-details-marker { display: none; }
  .mobile-filter-disclosure > summary::after { content: '+'; color: var(--jc-primary); font-size: 20px; font-weight: 400; }
  .mobile-filter-disclosure[open] > summary::after { content: '−'; }
  .mobile-filter-disclosure .filterbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 0; padding: 12px; border: 0; border-top: 1px solid var(--jc-border); background: transparent; }
  .mobile-filter-disclosure .filterbar > input[type="hidden"] { display: none; }
  .mobile-filter-disclosure .filterbar > input:not([type="date"]):not([type="hidden"]) { grid-column: 1 / -1; }
  .mobile-filter-disclosure .filterbar > * { min-width: 0; width: 100%; }
  .mobile-filter-disclosure .filterbar > button, .mobile-filter-disclosure .filterbar > .mini-btn { min-height: 42px; }

  .table-wrap { overflow-x: visible; }
  table.mobile-stack-table, table.mobile-stack-table tbody, table.mobile-stack-table thead { display: block; width: 100%; min-width: 0; }
  table.mobile-stack-table { border: 0; background: transparent; }
  table.mobile-stack-table tr[data-mobile-header] { display: none; }
  table.mobile-stack-table tr:not([data-mobile-header]) { display: block; width: 100%; margin: 0 0 10px; padding: 9px 13px; border: 1px solid var(--jc-border); border-radius: 8px; background: var(--jc-surface); box-shadow: 0 2px 8px rgba(7,29,56,.04); }
  table.mobile-stack-table td, table.mobile-stack-table td.actions { display: flex !important; flex-wrap: wrap; align-items: flex-start; gap: 4px 9px; width: 100%; min-width: 0; padding: 8px 0; border: 0; border-bottom: 1px solid var(--jc-border); white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
  table.mobile-stack-table tr > td:last-child { border-bottom: 0; }
  table.mobile-stack-table td::before { content: attr(data-mobile-label); flex: 0 0 74px; max-width: 74px; color: var(--jc-muted); font-size: 12px; font-weight: 600; line-height: 1.55; }
  table.mobile-stack-table td.actions::before { flex-basis: 100%; max-width: none; }
  table.mobile-stack-table td[colspan]::before { content: none; }
  table.mobile-stack-table td > pre { min-width: 0; max-width: calc(100% - 84px); margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
  table.mobile-stack-table td small { min-width: 0; overflow-wrap: anywhere; }
  table.mobile-stack-table td .domain-fold { min-width: 0; max-width: calc(100% - 84px); }
  table.mobile-stack-table td.actions > form { display: inline-flex; margin: 0; }
  table.mobile-stack-table td.actions > button, table.mobile-stack-table td.actions > a { margin: 0; }
  table.mobile-stack-table td.actions button, table.mobile-stack-table td.actions .mini-btn { min-height: 40px; }
  table.mobile-stack-table .rule-actions { min-width: 0; }
  .panel > table.mobile-stack-table { margin-top: 12px; }
  .domain-chip, .tag { max-width: 100%; overflow-wrap: anywhere; }

  dialog[open], dialog.wide[open], dialog.node-ops-dialog[open] { position: fixed; inset: 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; overflow-x: hidden; overflow-y: auto; }
  dialog[open] > .modal, dialog[open] > form.modal, dialog[open] > div.modal { min-height: 100%; padding: max(18px, env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom)); }
  dialog .modal > h2 { position: sticky; top: -18px; z-index: 2; margin: -18px -16px 12px; padding: 18px 58px 14px 16px; border-bottom: 1px solid var(--jc-border); background: var(--jc-surface); font-size: 19px; }
  dialog .modal .actions { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); z-index: 2; margin: 18px -16px calc(-18px - env(safe-area-inset-bottom)); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--jc-surface); box-shadow: 0 -7px 18px rgba(7,29,56,.05); }
  dialog .modal .actions button { min-height: 42px; }
  dialog .modal-close { position: fixed; top: max(10px, env(safe-area-inset-top)); right: 10px; z-index: 3; width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  dialog input, dialog select, dialog textarea, .filterbar input, .filterbar select, .settings-field-control input, .settings-field-control select, .settings-field-control textarea { font-size: 16px; }
  .copyline { min-width: 0; }
  .copyline input { min-width: 0; }
  .settings-savebar { position: sticky; bottom: 0; z-index: 3; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: var(--jc-surface); }
  .settings-accordion-body { overflow: visible; }
  .settings-accordion-body > label.settings-field-row, .settings-accordion-body > label.settings-switch-row { min-height: 0; }
  .settings-field-control, .settings-field-control input, .settings-field-control select, .settings-field-control textarea { min-width: 0; }
}

@media (max-width: 680px) {
  body.login-bg { display: block; min-height: 100svh; padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); }
  .login-layout { display: flex; align-items: center; justify-content: center; min-height: calc(100svh - 36px); }
  .login-showcase { display: none; }
  .login-card { width: min(430px, 100%); margin: 0; padding: 26px 20px 22px; }
  .login-card .form { margin-top: 20px; }
  .login-card input { font-size: 16px; }
  .login-card .form button { min-height: 46px; }
}
