/* Shared layout contract, loaded after feature and theme styles.
   Every route fills the same workspace; only tables/boards scroll horizontally.
   Colors remain owned by design-system.css. */
.app-shell { grid-template-columns:236px minmax(0,1fr); height:100vh; height:100dvh; min-height:0; }
.app-shell > main { min-width:0; min-height:0; }
#content { width:100%; max-width:none; min-width:0; margin:0; align-self:stretch; }
#content > * { min-width:0; max-width:100%; }
.workspace-error { max-width:none; }
.sidebar { min-width:0; min-height:0; height:100vh; height:100dvh; }
#nav { min-height:0; overflow-y:auto; }
.topbar { height:auto; flex-shrink:0; flex-wrap:wrap; }
.topbar > div { min-width:0; }
.top-actions { min-width:0; max-width:100%; flex-wrap:wrap; }
.topbar h1 { white-space:normal; overflow:visible; overflow-wrap:anywhere; }
.grid > *, .form-grid > *, .filter-grid > *, .integration-grid > *,
.card-grid > *, .major-grid > *, .report-kpi > *, .product-grid > *,
.detail-grid > *, .event > *, .ticket-card dl > * { min-width:0; }
.grid.split { grid-template-columns:minmax(0,1.45fr) minmax(0,1fr); }
.grid.split > :only-child { grid-column:1 / -1; }
.detail-grid { grid-template-columns:minmax(0,1fr) minmax(260px,310px); }
.form-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
.filter-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,200px),1fr)); }
.card-grid { grid-template-columns:repeat(auto-fill,minmax(min(100%,250px),1fr)); }
.product-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr)); }
.integration-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr)); }
.report-kpi, .kpis { grid-template-columns:repeat(auto-fit,minmax(min(100%,160px),1fr)); }
.major-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,140px),1fr)); }
.toolbar, .search-form, .view-bar, .row-actions, .modal-actions,
.section-head, .ticket-head, .major-top, .integration-title, .integration-row,
.device-head, .problem, .onboarding-step-head, .hero-strip { flex-wrap:wrap; }
.row-actions { display:flex; gap:8px; align-items:center; }
.toolbar > *, .search-form > *, .section-head > *, .ticket-head > *,
.problem > *, .integration-row > *, .hero-strip > *, .workflow-help > * { min-width:0; max-width:100%; }
.toolbar .search, .search-form .search { min-width:0; flex:1 1 240px; max-width:none; }
input, select, textarea, fieldset { min-width:0; max-width:100%; }
fieldset { margin-inline:0; }
button, .row-actions .btn, .primary, .ghost, .soft, .badge, .pill {
  max-width:100%; white-space:normal; overflow-wrap:anywhere;
}
.card, .ticket-card, .kanban-card, .notice, .workflow-help, .modal {
  overflow-wrap:anywhere;
}
.ticket-card dl { grid-template-columns:repeat(2,minmax(0,1fr)); }
.ticket-card dd { overflow-wrap:anywhere; }
.workflow-help .row-actions { flex-shrink:1; }
.row-side { min-width:0; max-width:100%; flex-wrap:wrap; }
/* Data retains every column and its own scrolling area, not a hidden page edge. */
.table-scroll, .table-wrap, .kanban { min-width:0; max-width:100%; overflow-x:auto; overscroll-behavior-x:contain; }
.table-card { min-width:0; max-width:100%; }
.table-scroll > table, .table-wrap > table { width:100%; min-width:640px; border-collapse:collapse; }
.table-scroll th, .table-scroll td, .table-wrap th, .table-wrap td { overflow-wrap:anywhere; }
.table-scroll td .row-actions { min-width:160px; }
.table-tickets th:nth-child(2), .table-tickets td:nth-child(2),
.table-tickets th:nth-child(6), .table-tickets td:nth-child(6) { display:table-cell; }
/* A wide sticky title can cover the entire phone. Scroll all columns together. */
.table-scroll .table th:first-child, .table-scroll .table td:first-child { position:static; box-shadow:none; }
.kanban-col { min-width:0; flex:1 0 240px; }
.gantt-row { grid-template-columns:minmax(0,260px) minmax(0,1fr) 56px; }
.bars-row { grid-template-columns:minmax(0,220px) minmax(0,1fr) 62px; }
.team-row { grid-template-columns:minmax(0,1fr) 70px 70px 64px; }
.bar-row { grid-template-columns:minmax(0,110px) minmax(0,1fr) 38px; }
/* Dialogs remain bounded and scrollable even on a short or zoomed viewport. */
.modal-backdrop { z-index:100; padding:16px; align-items:start; overflow:auto; }
.modal { min-width:0; width:100%; max-width:680px; max-height:calc(100dvh - 64px); margin:16px auto; overflow:auto; }
.modal-head { min-width:0; gap:12px; }
.modal-head h2 { min-width:0; overflow-wrap:anywhere; }
.modal-head .x { flex:none; min-width:44px; min-height:44px; }
.modal-card { max-width:calc(100% - 32px); max-height:calc(100dvh - 32px); margin:0; z-index:101; }
.requester-card { width:min(920px,calc(100% - 32px)); }
.toast { overflow-wrap:anywhere; }
@media (min-width:781px) {
  .brand > div:last-child, .sidebar-footer { display:block; }
  .sidebar #nav { flex:1 1 auto; }
  .sidebar-footer { flex:none; }
}
@media (max-width:1100px) {
  .app-shell { grid-template-columns:210px minmax(0,1fr); }
  .grid.split, .detail-grid { grid-template-columns:minmax(0,1fr); }
  .top-actions #demo-role { max-width:100%; overflow:visible; white-space:normal; }
}
@media (max-width:780px) {
  html, body { max-width:none; overflow-x:visible; }
  body.nav-lock { overflow:hidden; }
  .app-shell { display:block; height:auto; min-height:100dvh; overflow:visible; }
  .app-shell > main { overflow:visible; }
  #content { overflow:visible; padding:16px 15px calc(28px + env(safe-area-inset-bottom)); }
  /* One drawer model across 360–780px; replaces the conflicting old top strip. */
  .sidebar { position:fixed; inset:0 auto 0 0; width:260px; max-width:calc(100% - 48px); height:100dvh; min-height:0; padding:18px 14px; display:flex; flex-direction:column; flex-wrap:nowrap; align-items:stretch; gap:16px; overflow:visible; z-index:80; transform:translateX(-100%); }
  .app-shell.nav-open .sidebar { transform:translateX(0); }
  .sidebar .brand { order:0; flex:none; justify-content:flex-start; }
  .sidebar .brand > div:last-child { display:block!important; }
  .sidebar .brand strong { white-space:normal; }
  .sidebar #nav { position:static; display:flex!important; flex-direction:column; flex:1 1 auto; width:auto; max-height:none; min-height:0; padding:0; margin:0; overflow-y:auto; border:0; border-radius:0; box-shadow:none; }
  #nav .nav-btn { flex:none; display:flex; align-items:center; gap:8px; min-height:44px; text-align:left; white-space:normal; }
  #nav .nav-label { overflow:visible; }
  .sidebar-footer { display:none!important; }
  .sidebar .nav-toggle { display:flex!important; position:absolute; top:16px; left:calc(100% + 15px); transform:none; margin:0; width:44px; height:44px; min-height:44px; flex:none; align-items:center; justify-content:center; z-index:81; }
  .nav-open .sidebar .nav-toggle { position:static; align-self:flex-end; }
  .nav-backdrop { z-index:70; }
  .app-shell.nav-open .nav-backdrop { display:block; }
  .topbar { padding:16px 15px 16px 67px; min-height:72px; gap:12px; }
  .top-actions { width:100%; flex-direction:row; flex-wrap:wrap; }
  .top-actions .ghost, .top-actions #demo-role { display:inline-flex!important; }
  .top-actions .primary { margin-left:0; }
  .primary, .ghost, .soft, .btn, .view-btn { min-height:44px; }
  input, select, textarea { font-size:16px; }
  .grid.split, .detail-grid, .form-grid { grid-template-columns:minmax(0,1fr); }
  .section-head, .section-body { padding:12px 0; }
  .toolbar { flex-direction:row; align-items:center; }
  .toolbar > *, .search-form > * { flex:1 1 150px; }
  .ticket-row { flex-wrap:wrap; }
  .team-row { grid-template-columns:minmax(0,1fr) repeat(3,minmax(0,60px)); gap:6px; }
  .gantt-row, .bars-row { grid-template-columns:minmax(0,1fr) 56px; row-gap:4px; }
  .gantt-label, .bars-label { grid-column:1 / -1; white-space:normal; }
  .modal-backdrop { padding:8px; }
  .modal { margin:8px auto; padding:18px 16px; max-height:calc(100dvh - 32px); }
  .modal-head { position:static; margin:0 0 14px; padding:0 0 12px; }
  .modal-actions > button { flex:1 1 130px; }
}
@media (prefers-reduced-motion:reduce) { .sidebar { transition:none; } }

/* Daily work: consistent rhythm, readable titles, reachable actions. */
.topbar { align-items:flex-start; gap:12px 20px; padding-block:18px; }
.topbar > div:first-child { flex:1 1 220px; }
.top-actions { flex:0 1 auto; gap:8px; }
.topbar #page-subtitle { max-width:55ch; margin-bottom:0; }
.daily-queue { padding:20px; margin-bottom:16px; }
.daily-queue .section-head { padding:0; }
.queue-item { display:flex; align-items:center; justify-content:space-between; gap:16px; width:100%; padding:14px 0; text-align:left; border:0; border-top:1px solid var(--line); }
.queue-item > span { min-width:0; }
.queue-item small { display:block; margin-top:5px; }
.queue-item b,.row-main > b { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; overflow-wrap:anywhere; }
.grid.split,.detail-grid { align-items:start; }
.detail-grid > .detail-side { grid-column:2; grid-row:1 / span 2; }
.detail-grid > .ticket-conversation { grid-column:1; grid-row:2; }
.detail-grid > .ticket-result { grid-column:2; grid-row:3; }
.ticket-result > .card + .card { margin-top:16px; }
.detail-grid > .ticket-extras { grid-column:1 / -1; padding:16px 20px; }
.ticket-extras > summary,.timeline > summary { cursor:pointer; font-weight:650; padding:8px 0; }
.ticket-extras .workflow-ticket { margin-top:16px; }
.timeline:not([open]) { margin-top:14px; }
.ticket-conversation .section-card { margin:0; }
.ticket-extras:not([open]) > :not(summary) { display:none; }
.dialog-open { overflow:hidden; }
.modal-error:empty { min-height:0; }
:focus-visible { outline:3px solid var(--accent); outline-offset:3px; }
.ticket-head { align-items:start; }
.ticket-head > div:first-child { flex:1 1 240px; }
@media (max-width:1100px) {
  .detail-grid > .detail-side,.detail-grid > .ticket-conversation,.detail-grid > .ticket-result { grid-column:1; grid-row:auto; }
  .detail-side { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px 16px; }
  .detail-side .ticket-actions { grid-column:1 / -1; margin-top:0; }
  .detail-side .field { margin-bottom:0; }
  .top-actions { flex:1 1 100%; }
}
@media (max-width:780px) {
  .topbar { padding:16px 15px 12px 67px; }
  .topbar > div:first-child { flex-basis:100%; }
  .top-actions { display:flex; width:100%; }
  .top-actions #new-ticket { width:100%; }
  .top-actions > button { width:100%; min-width:0; margin:0; }
  .daily-queue { padding:16px; }
  .queue-item { align-items:start; flex-wrap:wrap; gap:8px; }
  .queue-item > span:first-child { flex:1 1 100%; }
  .queue-item > span:last-child { display:flex; align-items:center; flex-wrap:wrap; gap:6px; }
  .queue-item small { margin:0; }
  .row-main { flex:1 1 100%; }
  .row-side { width:100%; justify-content:flex-start; gap:8px; }
  .ticket-row { gap:8px; padding:14px 10px; }
  .detail-main,.detail-side { padding:16px; }
  .ticket-head > div:first-child { flex-basis:100%; }
  .detail-side .ticket-actions { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .detail-side .ticket-actions > .primary { grid-column:1 / -1; }
  .modal-backdrop { padding:8px; }
  .modal { width:100%; max-height:calc(100dvh - 16px); margin:0 auto; }
  .modal-actions { flex-wrap:wrap; }
  .modal input,.modal textarea,.modal select { font-size:16px; }
  .rate-star { min-width:44px; min-height:44px; }
}
@media (max-height:500px) and (max-width:780px) {
  .modal { max-height:calc(100dvh - 16px); }
  .modal-head { margin-bottom:8px; }
}

.mobile-view-label { display:none; }
#mobile-tools:empty { display:none; }
@media (max-width:780px) {
  #mobile-tools { display:flex; flex-direction:column; gap:8px; flex:none; max-height:40dvh; overflow-y:auto; }
  #mobile-tools > button { flex:none; min-height:44px; width:100%; text-align:left; }
  #mobile-tools #demo-role { font-size:12px; }
  .mobile-view-label { display:flex; align-items:center; gap:12px; margin-bottom:14px; }
  .mobile-view-label select { flex:1; }
  .view-bar,.view-hint { display:none; }
}

/* Appearance belongs with workspace identity, above Bitrix24. */
.sidebar-appearance { flex:none; padding:0 9px 12px; }
.sidebar-appearance:empty { display:none; }
.sidebar-appearance .theme-toggle { width:100%; min-height:44px; text-align:left; }
