
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}
img, video, canvas, iframe, svg { max-width: 100%; }
img, video { height: auto; }
pre, code, kbd { overflow-wrap: anywhere; }
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

@media (max-width: 900px) {
  .table-wrap > .table:not(.fm-table) { min-width: 560px; }
  body .table:not(.fm-table) th, body .table:not(.fm-table) td { padding-left: 10px; padding-right: 10px; }
}

@media (max-width: 720px) {

  body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="hidden"]),
  body select,
  body textarea {
    font-size: 16px !important;
    max-width: 100%;
  }
  body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="hidden"]),
  body select {
    min-height: 38px;
  }

  body:has(header.hk-bar) .c,
  body .c,
  body .c-wide {
    width: calc(100% - 24px) !important;
    max-width: 100%;
    box-sizing: border-box;
  }
  body .layout > * { min-width: 0; }
  body .analytics-layout, body .grid-2, body .grid-3, body .stat-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  body .head { flex-wrap: wrap; gap: 10px; }
  body .head h1 { overflow-wrap: anywhere; }

  body .card-title-row, body .card-head { flex-wrap: wrap; gap: 8px; }

  body .form-grid { grid-template-columns: minmax(0, 1fr) !important; }
  body .setting-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  body .setting-row > * { max-width: 100%; }
  body .btn-row, body .actions, body .form-actions { flex-wrap: wrap; gap: 8px; }
  body .filter-bar { flex-wrap: wrap; gap: 8px; }
  body .filter-bar > * { flex: 1 1 100%; min-width: 0; }

  body .btn, body .btn-dark, body .btn-primary {
    min-height: 38px;
  }

  .table-wrap > .table:not(.fm-table) { min-width: 520px; }
  body .table:not(.fm-table) th, body .table:not(.fm-table) td { font-size: 13px; padding: 10px 8px; }

  body .dropdown {
    max-width: calc(100vw - 24px);
    right: 0;
  }

  body .modal-overlay { padding: 12px; align-items: center; }
  body .modal-box {
    max-width: 100%;
    width: 100%;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }
  body .modal-foot { flex-wrap: wrap; gap: 8px; }
  body .modal-foot > .btn, body .modal-foot > button { flex: 1 1 140px; justify-content: center; }
  body .fm-modal { max-width: calc(100vw - 24px); }
  body #fm-editor-textarea { height: 55vh; height: 55dvh; }

  body .toast-wrap {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
  }
  body .toast { max-width: 100%; }

  body #cookieBanner {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: 12px;
    max-width: none;
    padding: 16px;
  }

  body .term-shell-wrap { height: 55vh; height: 55dvh; min-height: 260px; }

  body .stat .val, body .kv-val, body .mono { overflow-wrap: anywhere; }
}

@media (max-width: 480px) {
  body .modal-box { border-radius: 10px; }
  body .modal-foot > .btn, body .modal-foot > button { flex: 1 1 100%; }
  .table-wrap > .table:not(.fm-table) { min-width: 480px; }
}

@media (hover: none) and (pointer: coarse) {
  body .nav-link, body .hk-rail-link, body .dropdown-item { min-height: 38px; }
  body .hk-rail-link { padding-top: 8px; padding-bottom: 8px; }
}

@supports (padding: max(0px)) {
  @media (max-width: 720px) {
    body .hk-bar-in {
      padding-left: max(0px, env(safe-area-inset-left, 0px));
      padding-right: max(0px, env(safe-area-inset-right, 0px));
    }
  }
}

@media (max-width: 900px) {
  body.adm-body .tka-grid { grid-template-columns: minmax(0, 1fr) !important; }
  body.adm-body .table-wrap > .table:not(.fm-table) { min-width: 640px; }
}
@media (max-width: 720px) {
  body.adm-body .filter-bar > *,
  body.adm-body .filter-bar .filter-select { min-width: 0; flex: 1 1 100%; }
  body.adm-body .hk-modal .form-grid,
  body.adm-body .hk-modal .form-grid.hk-grid-3,
  body.adm-body .hk-modal .plan-grid-row { grid-template-columns: minmax(0, 1fr) !important; }
  body.adm-body .hk-modal { max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  body.adm-body .users-table .cell-user,
  body.adm-body .srv-table .cell-srv { min-width: 160px; }
  body.adm-body .tka-compose .tka-bar > div,
  body.adm-body .tka-bar .tka-selwrap { min-width: 0; flex: 1 1 100%; }
}

@media (max-width: 720px) {
  body .side { padding-top: calc(var(--hk-bar-h, 64px) + 4px); }
}

@media (max-width: 720px) {

  body .head { align-items: flex-start; margin-bottom: 14px; }
  body .head > h1 { flex: 1 1 100%; min-width: 0; line-height: 1.3; }
  body .head > h1 > span { display: block; margin: 4px 0 0; }
  body .head > .tk-head-acts, body .head > .head-acts { flex: 1 1 100%; }
  body .pager { flex-wrap: wrap; justify-content: center; gap: 10px; }
  

  body #app-content[style*="padding:28px 0"] { padding: 14px 0 !important; }

  .tk-head-acts { width: 100%; }
  .tk-head-acts .tk-btn { flex: 1 1 140px; }

  .tk-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin-bottom: 12px; padding-bottom: 2px; }
  .tk-tabs::-webkit-scrollbar { display: none; }
  .tk-tab { flex: none; min-height: 34px; }
  .tk-tabs .tk-search { flex: 0 0 100%; margin-left: 0; order: 5; }
  .tk-search input, .tk-search .tk-in { width: 100%; }
  .tk-tabs:has(.tk-search) { flex-wrap: wrap; overflow-x: visible; }
  .tk-tabs:has(.tk-search) .tk-tab { flex: 1 1 auto; justify-content: center; }

  .tk-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 4px; }
  .tk-row .tk-subj { order: 1; flex: 1 1 0; min-width: 0; }
  .tk-row > span:nth-child(4) { order: 2; flex: none; }
  .tk-row::after { content: ""; order: 3; flex: 1 0 100%; height: 0; }
  .tk-row .tk-c-dept, .tk-row .tk-c-prio, .tk-row .tk-c-upd { order: 4; flex: none; grid-column: auto; font-size: 12px; max-width: 100%; }
  .tk-row .tk-c-prio .tk-pr { font-size: 12px; }
  .tk-subj b { font-size: 14px; }

  .tk-grid, .tk-new { gap: 12px; }
  .tk-mh { padding: 10px 12px; gap: 6px 8px; }
  .tk-mh time { margin-left: 0; flex: 1 0 100%; white-space: normal; }
  .tk-mb { padding: 12px; font-size: 14px; }
  .tk-att { padding: 0 12px 12px; }
  .tk-metarow { margin: 0 0 12px; gap: 6px 10px; }
  .tk-compose .tk-ta, .tk-ta { min-height: 140px; }
  .tk-foot { gap: 8px; }
  .tk-foot .tk-sp { display: none; }
  .tk-foot .tk-btn { flex: 1 1 140px; }
  .tk-drop .tk-drop-row { gap: 8px; }
  .tk-drop .tk-drop-row .tk-btn { flex: 1 1 100%; }
  .tk-side .tk-acts { gap: 8px; }
  .tk-closed-card { flex-direction: column; gap: 10px; }
  .tk-star { width: 34px; height: 34px; }

  .pf-top { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .pf-bill-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  body .field { margin-bottom: 12px; }
  body .field input, body .field select { width: 100%; box-sizing: border-box; }
  body .field label { font-size: 11px; }
  body .field input[disabled] { overflow: hidden; text-overflow: ellipsis; }
  body #pf-billing-form .rowbtns { justify-content: stretch !important; }
  body #pf-billing-form .rowbtns .btn-sm { flex: 1 1 100%; }
  .table-wrap > .table.history-table { min-width: 0; }
  body .history-table td, body .history-table th { padding: 10px 8px; }
  body .history-table td.mono { white-space: nowrap; font-size: 12px; }
  body .hist-action { display: inline-flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }

  body .wizard-steps { margin-bottom: 12px; }
  body .server-grid { gap: 10px; }
  body .server-card { padding: 14px; min-height: 64px; }
  body .server-name { overflow-wrap: anywhere; }
  

  body .plan-pick-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 10px; }
  body .plan-pick-card { padding: 16px; }
  body .plan-pick-card .plan-pick-title { font-size: 14px; }
  body .plan-pick-card .pp-price b { font-size: 24px; }
  body .plan-pick-card .pp-price small, body .plan-pick-card .pp-sub { font-size: 12px; }
  body .plan-pick-card .pp-row { font-size: 13px; padding: 8px 0; }
  body .plan-pick-card .pp-row span { font-size: 11px; }
  body .plan-pick-card .pp-btn { min-height: 36px; font-size: 13px; width: 100%; justify-content: center; }
  body .plan-pick-card .pp-tag { font-size: 10px; }

  .co-grid { gap: 12px; }
  .co-item, .co-name, .co-pay-card, .co-summary { padding: 14px; }
  .co-item-top { flex-wrap: wrap; gap: 10px; }
  .co-item-price { order: 4; width: 100%; padding-left: 0; text-align: left; display: flex; align-items: baseline; gap: 8px; }
  .co-item-price small { margin-top: 0; }
  .co-item-title b { font-size: 16px; overflow-wrap: anywhere; }
  .co-item-chip { max-width: 100%; }
  .co-specs { grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 8px 12px; }
  .co-name .deploy-name-input { padding: 0 40px; }
  .name-suggestions { justify-content: flex-start; }
  .name-chip { padding: 5px 12px; }
  .co-method { padding: 12px; gap: 10px; }
  .co-pay { min-height: 40px; font-size: 14px; padding-top: 9px; padding-bottom: 9px; }
  .co-remove { width: 30px; height: 30px; }
  .co-edit { height: 26px; padding: 0 12px; }
  .co-due strong { font-size: 26px; }
  .co-summary { position: static; }
}

@media (max-width: 380px) {
  .tk-tabs:has(.tk-search) .tk-tab { flex: 1 1 45%; }
}

@media (max-width: 720px) {

  body .inline-form { max-width: 100%; gap: 10px; }
  body .inline-form .field { flex: 1 1 100%; min-width: 0; }
  body .inline-form .inline-form-btn { flex: 1 1 0; min-width: 0; }
  body .inline-form .inline-form-btn label { display: none; }
  body .inline-form .inline-form-btn button { width: 100%; justify-content: center; }

  body #env-list { display: flex; flex-direction: column; gap: 8px; }
  body #env-list .domain-item { padding: 12px; gap: 10px; }
  body #env-list .domain-item > span {
    min-width: 0;
    font-family: var(--mono, ui-monospace, monospace);
    font-size: 13px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-all;
  }
  body #env-list .domain-item > div { display: flex; gap: 8px; width: 100%; }
  body #env-list .domain-item > div .btn-sm { flex: 1 1 0; justify-content: center; }
  body #env-list .domain-item input { width: 100% !important; flex: 1 1 100% !important; box-sizing: border-box; }
  body #env-import-wrap .rowbtns .btn-dark { width: 100%; justify-content: center; }
  body #env-import-input { font-size: 14px !important; }

  body .as-capacity {
    height: auto;
    width: 100%;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 12px 14px;
    box-sizing: border-box;
  }
  body .as-capacity-track { flex: 1 1 100%; order: 3; min-width: 0; gap: 4px; }
  body .as-capacity-seg { flex: 1 1 0; min-width: 0; height: 6px; }
  body .as-capacity-label { order: 1; }
  body .as-capacity-count { order: 2; margin-left: auto; }
  body .head .as-capacity-count { margin-left: auto; }

  body #wizard-step-1 .server-grid,
  body #sfCatCard .server-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  body #wizard-step-1 .server-card,
  body #sfCatCard .server-card { padding: 14px; gap: 14px; min-height: 68px; align-items: center; }
  body #wizard-step-1 .server-card:active,
  body #sfCatCard .server-card:active { background: var(--hk-c-1c1c1f); border-color: var(--hk-c-3a3a3c); }
  body #wizard-step-1 .server-icon,
  body #sfCatCard .server-icon { width: 44px; height: 44px; flex: none; object-fit: contain; border-radius: 10px; }
  body #wizard-step-1 .server-info,
  body #sfCatCard .server-info { min-width: 0; flex: 1 1 auto; }
  body #wizard-step-1 .server-name,
  body #sfCatCard .server-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
  body #wizard-step-1 .server-desc,
  body #sfCatCard .server-desc {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  body #wizard-step-1 .server-card.disabled,
  body #sfCatCard .server-card.disabled { opacity: .55; }

  body .ms-stats { grid-template-columns: minmax(0, 1fr); gap: 8px; margin-bottom: 12px; }
  body .ms-stat { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; }
  body .ms-stat .v { margin-top: 0; }
  body .ms-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  body .ms-tabs::-webkit-scrollbar { display: none; }
  body .ms-tab { flex: none; min-height: 34px; }
  
  body .head > .ms-btn { flex: 1 1 100%; justify-content: center; }

  .ms-table { display: block; min-width: 0 !important; width: 100%; }
  .table-wrap > .ms-table { min-width: 0 !important; }
  .ms-table thead { display: none; }
  .ms-table tbody { display: flex; flex-direction: column; gap: 10px; }
  .ms-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px 12px;
    padding: 14px;
    border: 1px solid var(--hk-c-232324);
    border-radius: 8px;
    background: var(--hk-c-0f0f10);
  }
  .ms-table td { display: block; padding: 0 !important; border: 0 !important; min-width: 0; overflow-wrap: anywhere; }
  .ms-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--hk-c-6e6e72);
  }
  .ms-table td.ms-plan { grid-column: 1 / -1; padding-bottom: 10px !important; border-bottom: 1px solid var(--hk-c-1e1e1f) !important; }
  .ms-table td.ms-plan::before { display: none; }
  .ms-table td.ms-plan b { font-size: 15px; }
  .ms-table td.ms-acts-cell { grid-column: 1 / -1; padding-top: 10px !important; border-top: 1px solid var(--hk-c-1e1e1f) !important; white-space: normal !important; }
  .ms-table .ms-acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ms-table .ms-acts .btn-sm { justify-content: center; text-align: center; }

  body .tke .tke-foot { display: none; }
}

@media (max-width: 720px) {
  #fm-editor-modal.modal-overlay { padding: 0; align-items: stretch; justify-content: stretch; }
  #fm-editor-modal .fm-editor-box {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    padding: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    box-sizing: border-box;
  }

  #fm-editor-modal .modal-head {
    flex: none;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px 12px;
    gap: 8px;
  }
  #fm-editor-modal .fm-modal-title { flex: 1 1 auto; min-width: 0; gap: 8px; }
  #fm-editor-modal .fm-modal-title > svg { display: none; }
  #fm-editor-modal .fm-editor-filename {
    flex: 0 1 auto;
    min-width: 0;
    max-width: none;
    font-size: 13px;
  }
  #fm-editor-modal .fm-editor-badge { flex: none; }
  #fm-editor-modal .modal-close-btn { flex: none; width: 32px; height: 32px; }

  #fm-editor-modal .fm-editor-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
  }
  #fm-editor-modal .fm-editor-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
  #fm-editor-modal #fm-editor-textarea {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    border: 0;
    border-radius: 0;
    resize: none;
    padding: 10px 12px;
    font-size: 14px !important;
    line-height: 1.55;
  }
  #fm-editor-modal .CodeMirror {
    flex: 1 1 auto;
    height: 100% !important;
    min-height: 0;
    font-size: 13px;
    line-height: 1.55;
  }
  #fm-editor-modal .CodeMirror-scroll { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  #fm-editor-modal .CodeMirror-gutters { background: var(--hk-c-0d0d0e); }

  #fm-editor-modal .fm-editor-status {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 12px;
    border-top: 1px solid var(--hk-c-1e1e1f);
    background: var(--hk-c-0e0e0f);
    font-size: 11px;
  }
  #fm-editor-modal .fm-editor-kbd { display: none; }

  #fm-editor-modal .modal-foot {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--hk-c-1e1e1f);
    background: var(--hk-c-0e0e0f);
  }
  #fm-editor-modal .fm-editor-foot-msg { flex: 1 1 100%; order: -1; min-height: 0; }
  #fm-editor-modal .fm-editor-foot-msg:empty { display: none !important; }
  #fm-editor-modal .modal-foot .fm-btn { flex: 1 1 0; min-height: 34px; padding: 6px 14px; }
}
