/* Ops 162: whole-product visual alignment and responsive rhythm. */
:root{
  --align-1:4px;
  --align-2:8px;
  --align-3:12px;
  --align-4:16px;
  --align-5:20px;
  --align-6:24px;
  --align-8:32px;
  --align-control:44px;
  --align-content:1420px;
}

html{scrollbar-color:#9db8b1 #eef2ef}
body{line-height:1.5}
::selection{background:#bcebdd;color:#103c38}

/* One frame: app chrome and work surfaces share the same horizontal anchors. */
.topbar{padding-inline:42px}
.workspace{
  width:100%;
  max-width:var(--align-content);
  margin-inline:auto;
  padding:var(--align-8) 42px 58px;
}
.page-heading{
  align-items:flex-end;
  gap:var(--align-4) var(--align-6);
  margin-bottom:var(--align-6);
  min-width:0;
  flex-wrap:wrap;
}
.page-heading>div:first-child{min-width:min(100%,420px);margin-right:auto}
.page-heading .eyebrow{margin-bottom:var(--align-2)}
.page-heading h1{margin:0;line-height:1.18}
.page-heading p{max-width:72ch;margin:var(--align-2) 0 0;line-height:1.6}
.page-heading>:is(button,a,.actions,.toolbar,.device-import){align-self:flex-end}

/* Consistent vertical rhythm for sections and cards. */
.workspace :is(.card,.kdb-library,.kdb-approval-filter-card,.kdb-approval-queue,.device-cmdb,.notification-settings){scroll-margin-top:78px}
.card{padding:var(--align-6)}
.card-title,
.section-heading,
.ledger-heading,
.ticket-ledger-heading,
.kdb-approval-filter-heading,
.kdb-approval-queue-heading{
  align-items:flex-start;
  gap:var(--align-4);
  margin-bottom:var(--align-4);
}
.card-title :is(h2,h3,p),
.section-heading :is(h2,h3,p),
.ledger-heading :is(h2,h3,p),
.ticket-ledger-heading :is(h2,h3,p){margin-top:0}
.workspace :is(.card,.ticket-command-modern,.ticket-ledger,.kdb-approval-workspace,.device-cmdb)+:is(.card,.ticket-command-modern,.ticket-ledger,.kdb-approval-workspace,.device-cmdb){margin-top:var(--align-5)}

/* Labels, controls and actions sit on a shared component grid. */
.workspace :is(input:not([type="checkbox"]):not([type="radio"]),select){
  height:var(--align-control);
  min-height:var(--align-control);
  padding-block:0;
  line-height:1.35;
}
.workspace textarea{padding:12px 14px;line-height:1.65}
.workspace :is(.field,.form-grid>label,.form-grid>.field,.filter-grid>label,.filter-grid>.field){min-width:0;margin:0}
.workspace :is(.field>label,.filter-field>label,.device-form-grid label>span){
  display:block;
  min-height:18px;
  margin:0 0 var(--align-2);
  line-height:18px;
}
.workspace label:has(>input:not([type="checkbox"]):not([type="radio"])),
.workspace label:has(>select),
.workspace label:has(>textarea){
  display:grid;
  align-content:start;
  gap:var(--align-2);
  margin:0;
  line-height:18px;
}
.workspace :is(.form-grid,.filter-grid,.ticket-time-grid,.ticket-identity-core,.notification-group-fields,.device-form-grid){align-items:start}
.workspace :is(button,.button-like){line-height:1.25}
.workspace .toolbar,
.workspace .actions,
.workspace .filter-actions{align-items:center;gap:var(--align-2)}
.workspace button svg{flex:0 0 auto;width:18px;height:18px}
.badge{align-items:center;min-height:26px;line-height:1.2}
.personnel-add :is(input,button){height:38px;min-height:38px}
.workspace .personnel-row label:has(>input){gap:0}
.personnel-row input,.personnel-row-actions button{height:36px;min-height:36px}
.ticket-personnel-panel .personnel-field select{height:36px;min-height:36px}

/* Tabs align their first label with the content underneath. */
.ticket-status-tabs{
  align-items:flex-end;
  gap:28px;
  padding-inline:16px;
}
.ticket-status-tabs button{
  min-height:48px;
  padding:11px 0;
}
.ticket-status-tabs button:after{right:0;left:0}
.admin-tabs{
  align-items:flex-end;
  gap:28px;
  margin-bottom:var(--align-6);
}
.admin-tabs button{min-height:44px;padding:10px 0;line-height:22px}

/* Tables and repeated records use stable baselines and predictable numeric widths. */
.workspace :is(table,.ticket-list-v2,.ticket-list-v3,.audit-table){font-variant-numeric:tabular-nums}
.workspace :is(th,td){vertical-align:top}
.workspace th{height:44px;padding-block:12px;line-height:20px}
.workspace td{padding-block:14px;line-height:1.55}
.detail-line{align-items:baseline}
.ticket-list-head,.ticket-list-row{column-gap:var(--align-4)}

/* Side navigation uses a fixed number column so every label begins on one line. */
.nav button{
  display:grid;
  grid-template-columns:30px minmax(0,1fr);
  align-items:center;
  column-gap:12px;
}
.nav button span{width:auto;text-align:left;font-variant-numeric:tabular-nums}

/* Drawers and editors preserve the same content edge. */
.sheet{padding:var(--align-6) clamp(20px,2.4vw,36px)}
.sheet-header{align-items:flex-start;margin-bottom:var(--align-6)}
.sheet-header>button:last-child{flex:0 0 44px;width:44px;height:44px;min-height:44px;padding:0}
.kdb-editor{gap:var(--align-5)}
.rich-toolbar-row{min-height:48px}

/* Responsive alignment: structural reflow with full-width touch controls. */
@media(max-width:1100px){
  .topbar{padding-inline:25px}
  .workspace{padding-inline:25px}
}

@media(max-width:720px){
  :root{--align-control:48px}
  .topbar{padding-inline:16px}
  .workspace{padding:20px 16px 96px}
  .page-heading{display:flex;align-items:flex-start;gap:var(--align-4);margin-bottom:var(--align-5)}
  .page-heading>div:first-child{flex:1 1 100%;min-width:0;margin:0}
  .page-heading>:is(button,a,.actions,.toolbar,.device-import){align-self:stretch}
  .page-heading>button{flex:1 1 auto;min-height:44px}
  .page-heading .eyebrow{margin-bottom:6px}
  .page-heading p{margin-top:6px}
  .card{padding:var(--align-4)}
  .card-title,.section-heading,.ledger-heading,.ticket-ledger-heading{margin-bottom:var(--align-3)}
  .ticket-status-tabs{gap:24px;padding-inline:16px;scroll-padding-inline:16px}
  .ticket-status-tabs{
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:0;
    overflow:visible;
  }
  .ticket-status-tabs button{justify-content:center;min-width:0;min-height:52px;padding-inline:2px;gap:4px;font-size:11px}
  .ticket-status-tabs button span{min-width:22px;height:22px;padding-inline:5px}
  .admin-tabs{gap:24px;margin-inline:0;margin-bottom:var(--align-5);scroll-padding-inline:0}
  .admin-tabs button{min-height:48px}
  .workspace :is(.toolbar,.actions,.filter-actions){gap:var(--align-2)}
  .workspace :is(.toolbar,.actions,.filter-actions)>button{min-height:44px}
  .sheet{padding:20px 16px}
  .sheet-header{margin-bottom:var(--align-5)}
  .form-grid{row-gap:var(--align-4)}
  .ticket-list-head,.ticket-list-row{column-gap:var(--align-3)}
  .personnel-add :is(input,button),
  .personnel-row input,.personnel-row-actions button,
  .ticket-personnel-panel .personnel-field select{height:44px;min-height:44px}
}

@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}
}
