/* The CRM login is outside .shell. The shared dialog is a sibling of #app. */
.shell,
#app:has(> .shell) ~ #modal,
#app:has(> .shell) ~ #toast {
  --ink: #202631;
  --dim: #586578;
  --line: #e1e5eb;
  --bg: #eff1f3;
  --green: #2924be;
  --light: #eeedfb;
  --ui-white: #fff;
  --ui-accent-hover: #211c9c;
  --ui-accent-line: #c9c6ed;
  --ui-soft: #f4f5f7;
  --ui-input: #d8dee7;
  --ui-danger: #a4262c;
  --ui-radius: 8px;
  color: var(--ink);
}

@media screen {
  .shell {
    grid-template-columns: 248px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
    background: radial-gradient(ellipse 475px 380px at 0 0, #bce7f5, transparent), var(--bg);
    font-variant-numeric: tabular-nums;
  }

  .shell > main, .shell:has(.ops-home) main { background: transparent; }

  .shell .side {
    top: 10px;
    height: calc(100dvh - 20px);
    padding: 0;
    border: 1px solid #ffffffbf;
    border-radius: var(--ui-radius);
    background: linear-gradient(145deg, #e1f4fb 0, #f8f9fa 55%);
    color: var(--ink);
  }

  .shell .side .brand {
    min-height: 72px;
    padding: 14px 16px;
    border-bottom: 1px solid #ffffffbd;
  }

  .shell .side .logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #edf0fd;
    color: var(--green);
  }

  .shell .side .logo .ico { width: 21px; height: 21px; }
  .shell .side .brand strong { color: var(--ink); font-size: 18px; line-height: 1.25; }
  .shell .side .brand small { color: var(--dim); font-size: 11px; }
  .shell .nav { padding: 4px 9px 14px; scrollbar-color: #b6c4d2 transparent; }
  .shell .nav p { color: var(--dim); margin: 13px 8px 5px; font-size: 12px; }

  .shell .nav > a,
  .shell .nav .menu-tree summary {
    min-height: 36px;
    padding: 7px 9px;
    border-radius: 5px;
    color: var(--ink);
    font-weight: 650;
  }

  .shell .nav > a { margin: 2px 0; }
  .shell .nav .menu-tree { margin: 2px 0; }
  .shell .nav .menu-tree summary { display: flex; align-items: center; gap: 7px; }
  .shell .nav .menu-tree summary::-webkit-details-marker { display: none; }
  .shell .nav .menu-tree summary::after {
    content: '';
    flex: none;
    width: 6px;
    height: 6px;
    margin: -3px 3px 0 auto;
    border: solid #65748a;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
  }
  .shell .nav .menu-tree details[open] > summary::after,
  .shell .nav .menu-tree[open] > summary::after { transform: rotate(225deg); margin-top: 3px; }
  .shell .nav .menu-tree details { margin-left: 12px; border-color: #d8e1eb; padding-left: 5px; }
  .shell .nav .menu-tree details > summary { min-height: 32px; color: #3f4b5d; font-weight: 600; }
  .shell .nav .menu-tree a { color: #374357; min-height: 31px; padding: 5px 8px 5px 14px; }
  .shell .nav :is(a,summary):hover { background: #e9eef5; color: var(--ink); }
  .shell .nav a.active { background: var(--green); color: white; box-shadow: none; }
  .shell .nav a.active:hover { background: var(--ui-accent-hover); }
  .shell .side footer { padding: 11px 14px; border-color: #e9edf2; color: var(--dim); font-size: 11px; text-align: center; }

  .shell .top {
    min-height: 40px;
    height: auto;
    padding: 0 4px 0 5px;
    gap: 8px;
    border: 0;
    background: transparent;
  }

  .shell .top .menu-crumb {
    flex: 0 1 auto;
    min-height: 38px;
    max-width: 100%;
    padding: 6px 13px;
    margin-inline-end: auto;
    gap: 5px 9px;
    border: 1px solid #ffffffa6;
    border-radius: 22px;
    background: #ffffffec;
    color: var(--ink);
    font-size: 13px;
  }

  .shell .menu-crumb span { color: #758195; }
  .shell .menu-crumb b { color: var(--green); }
  .shell .top .profile { gap: 7px; white-space: nowrap; }
  .shell .profile b { font-size: 13px; }
  .shell .profile small { font-size: 11px; }
  .shell .top .avatar { width: 34px; height: 34px; border-radius: 50%; background: #e8e8f8; color: var(--green); }
  .shell .top .iconbtn { flex: none; width: 38px; height: 38px; border: 1px solid #ffffffba; border-radius: 50%; background: #fff; color: var(--ink); }
  .shell .top .iconbtn:hover { background: var(--light); color: var(--green); }
  .shell .searchbox { max-width: 225px; }
  .shell .searchbox input { min-height: 38px; border-radius: 20px; border-color: #fff; background: #fff; }
  .shell .searchbox > .ico { color: var(--dim); }
  .shell .results { border-color: var(--line); border-radius: var(--ui-radius); }

  .shell .body { padding: 10px 0 15px; }
  .shell .heading {
    min-height: 59px;
    margin: 0 0 10px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: var(--ui-radius);
    background: #fff;
  }
  .shell h1 { font-size: 20px; line-height: 1.35; }
  .shell .sectionhead { gap: 8px; }
  .shell .surface {
    margin-bottom: 12px;
    border-color: var(--line);
    border-radius: var(--ui-radius);
    background: #fff;
    box-shadow: none;
  }
  .shell :is(.desk-detail,.wo,.fin-panel,.wh-page,.kb-page,.pn) { min-width: 0; }

  .shell :is(.btn,.iconbtn),
  #app:has(> .shell) ~ #modal .btn { border-radius: 5px; }
  .shell button:not(.shade) { border-color: var(--ui-input); }

  .shell :is(button,a).primary:not(:disabled),
  #app:has(> .shell) ~ #modal .primary:not(:disabled) {
    color: #fff;
    border-color: var(--green);
    background: var(--green);
  }

  .shell :is(button,a).primary:hover:not(:disabled),
  #app:has(> .shell) ~ #modal .primary:hover:not(:disabled) {
    color: #fff;
    border-color: var(--ui-accent-hover);
    background: var(--ui-accent-hover);
  }

  .shell a.link, .shell button.link { color: var(--green); }
  .shell :is(a,button,summary,input,select,textarea):focus-visible,
  #app:has(> .shell) ~ #modal :is(a,button,summary,input,select,textarea):focus-visible {
    outline: 2px solid #4b48d1;
    outline-offset: 2px;
  }
  .shell .nav a.active:focus-visible { outline-offset: -3px; outline-color: #fff; }
  .shell .field :is(input:not([type=checkbox]):not([type=radio]),select,textarea),
  #app:has(> .shell) ~ #modal .field :is(input:not([type=checkbox]):not([type=radio]),select,textarea) { border-color: var(--ui-input); border-radius: 5px; }
  .shell :is(input[type=checkbox],input[type=radio]) { accent-color: var(--green); }

  .shell .crm-filter {
    margin-bottom: 10px;
    padding: 12px 15px;
    border: 1px solid var(--line);
    border-radius: var(--ui-radius);
    background: #fff;
  }
  .shell .crm-filter-scope { border-color: var(--line); background: var(--ui-soft); color: var(--dim); }
  .shell .crm-filter-extra { border-color: var(--line); }
  .shell .crm-filter :is(.crm-filter-row,.crm-filter-extra) > .field,
  .shell .crm-filter .crm-filter-keyword > .field { color: #3d485a; }
  .shell .crm-filter :is(input:not([type=hidden]),select) { border-color: var(--ui-input); }
  .shell .crm-filter-keyword input:not([type=hidden]) { border-radius: 20px; background: #f1f3f5; padding-inline: 12px; }
  .shell .crm-filter .crm-filter-row .btn[aria-expanded=true] { border-color: var(--ui-accent-line); background: var(--light); color: var(--green); }
  .shell .quick-views { border-color: #e5e8ed; border-radius: 7px; background: #edf0f3; }
  .shell .quick-view { border-radius: 4px; }
  .shell .quick-view[aria-current=true] { border-color: #d9dbeb; background: #fff; color: var(--green); }
  .shell .quick-view[aria-current=true] .quick-count:not(.risk-count) { background: var(--light); }
  .shell .risk-count { color: var(--ui-danger); }
  .shell .quick-views .quick-count.risk-count { color: var(--ui-danger); background: #fae9ec; }

  .shell .tablewrap { border-radius: 5px; scrollbar-color: #bdc6d1 transparent; }
  .shell table th { background: #f4f5f7; color: #303949; }
  .shell table :is(th,td) { border-color: #edf0f3; }
  .shell table tbody tr:hover { background-color: #f8f9fd; }
  .shell table tr:focus-within { background-color: #f5f5fd; }

  .shell:has(.ops-home) .body { padding: 10px 0 15px; }
  .shell .ops-home {
    --ops-panel: #fff;
    --ops-edge: #e1e5eb;
    --ops-mint: #087568;
    --ops-blue: #362ccd;
    --ops-red: var(--ui-danger);
    padding: 0;
    background: transparent;
  }
  .shell .ops-head {
    align-items: center;
    margin-bottom: 10px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--ui-radius);
    background: #fff;
  }
  .shell .ops-title p, .shell .ops-title p svg { color: var(--dim); }
  .shell .ops-head h1 { margin-top: 3px; font-size: 23px; line-height: 1.3; }
  .shell .ops-context i { box-shadow: none; }
  .shell .ops-segment { border-color: transparent; border-radius: 16px; background: #eff1f3; }
  .shell .ops-segment a { border-radius: 14px; }
  .shell .ops-segment a[aria-current=true] { background: #fff; color: var(--green); }
  .shell .ops-tool { border-color: var(--ui-input); border-radius: 5px; }
  .shell :is(.ops-tool,.ops-segment a):hover { background: var(--light); color: var(--green); }
  .shell .ops-kpis { margin-bottom: 10px; }
  .shell .ops-kpis .ops-kpi { border: 1px solid var(--ops-edge); border-radius: var(--ui-radius); }
  .shell .ops-kpis .ops-kpi.ops-late:has(.risk-count) { border-color: #edc9cf; }
  .shell .ops-kpis .ops-kpi .ops-kpi-label { color: #374355; }
  .shell .ops-kpi-label > i { border: none; border-radius: 50%; background: #f2f3f6; }
  .shell .ops-kpi-value strong { font-size: 28px; }
  .shell .ops-kpi[data-metric=ar] .ops-kpi-value strong,
  .shell .ops-kpi[data-metric=ap] .ops-kpi-value strong { font-size: 24px; }
  .shell .ops-panel { border-radius: var(--ui-radius); }
  .shell .ops-cap { background: #fff; }
  .shell .ops-cap > span { color: var(--dim); border-color: var(--line); }
  .shell .ops-cap svg { color: var(--green); }
  .ops-project .shell { padding: 12px; }
  .ops-project .shell:has(.ops-home) .body { padding: 0; }

  #app:has(> .shell) ~ #modal { border-color: var(--line); border-radius: var(--ui-radius); }
  #app:has(> .shell) ~ #modal::backdrop { background: #242d4d55; }

  @media (max-width: 1000px) {
    .shell { grid-template-columns: 198px minmax(0, 1fr); }
    .shell .searchbox { max-width: 170px; }
    .shell .ops-head { align-items: flex-start; }
  }

  @media (max-width: 730px) {
    .shell { padding: 7px; }
    .shell .side { top: 7px; height: calc(100dvh - 14px); }
    .navopen .shell .side { left: 7px; }
    .shell .top { min-height: 44px; padding: 0; gap: 5px; flex-wrap: wrap; }
    .shell .top .menu-crumb { flex: 1 1 112px; margin: 0; padding: 5px 9px; min-height: 35px; font-size: 12px; }
    .shell .top .profile { margin-left: auto; }
    .shell .top .avatar { width: 30px; height: 30px; }
    .shell .top .iconbtn { width: 36px; height: 36px; min-height: 36px; }
    .shell .top .searchbox { order: 1; flex: 1 0 100%; max-width: none; margin: 0; }
    .shell .body, .shell:has(.ops-home) .body { padding: 8px 0 12px; }
    .shell .heading, .shell .ops-head { padding: 9px 11px; }
    .shell .ops-head h1, .shell h1 { font-size: 20px; }
    .shell .crm-filter { padding-inline: 10px; }
    .shell .ops-kpi-value strong { font-size: 24px; }
    .shell .ops-kpi[data-metric=ar] .ops-kpi-value strong,
    .shell .ops-kpi[data-metric=ap] .ops-kpi-value strong { font-size: 21px; }
  }
}
