/* Admin shell layout: app shell, sidebar, header, cards, tables, pills, forms, messages, theme toggle, spinner, sign-in and access screens,
  conversation bubbles and the sidebar parity rules. One of the shell stylesheets; they load in the shell's order, which keeps the cascade. */
  /* ── App layout — IT4Y_SIDEBAR_V1 ── */
  #app { display: contents; }
  .app-shell { display: flex; flex-direction: row; height: 100vh; overflow: hidden; }

  /* ── Sidebar palette (theme-aware) ── */
  html:not([data-theme="dark"]) {
    --sn-bg:#ffffff; --sn-hover:#eef2f8; --sn-active-bg:#dbeafe;
    --sn-active:#2563eb; --sn-text:#1e293b; --sn-muted:#2d3748;
    --sn-grp:#64748b; --sn-border:#e6e9ef;
  }
  html[data-theme="dark"] {
    --sn-bg:#0d1520; --sn-hover:rgba(255,255,255,.06); --sn-active-bg:rgba(74,158,255,.15);
    --sn-active:#4a9eff; --sn-text:rgba(232,241,252,.92); --sn-muted:rgba(172,198,230,.80);
    --sn-grp:rgba(148,180,218,.60); --sn-border:rgba(255,255,255,.08);
  }

  /* ── Sidebar shell ── */
  .app-sidebar {
    position: relative; flex-shrink: 0;
    width: var(--admin-nav-w); height: 100vh;
    background: var(--sn-bg); border-inline-end: 1px solid var(--sn-border);
    display: flex; flex-direction: column; overflow: hidden;
    transition: width .22s cubic-bezier(.4,0,.2,1); z-index: 100;
  }
  .app-sidebar.sb-collapsed { width: 52px; }

  /* Sidebar header */
  .sb-header {
    display: flex; align-items: center; gap: 10px;
    padding: 0 15px; height: var(--header-h); flex-shrink: 0;
    border-bottom: 1px solid var(--sn-border); overflow: hidden; white-space: nowrap;
  }
  /* The official IT-4You SWE logo badge (/brand/it4you-swe-logo-on-light.svg, a navy badge that reads on the light and
     the dark theme alike; owner request 2026-11-12).  The small mark is only the favicon.  The collapsed rail scales the
     badge to its width; the sidebar's name stays for assistive technology (.sr-only). */
  .sb-logo { flex-shrink: 0; display: flex; }
  .sb-logo img { height: 36px; width: auto; aspect-ratio: 253 / 146; display: block; }
  .app-sidebar.sb-collapsed .sb-header { padding: 0 6px; justify-content: center; }
  .app-sidebar.sb-collapsed .sb-logo img { height: auto; width: 40px; }
  .sb-title { font-size: 14px; font-weight: 700; color: var(--sn-text);
              transition: opacity .18s; white-space: nowrap; overflow: hidden; }
  .app-sidebar.sb-collapsed .sb-title { opacity: 0; pointer-events: none; }

  /* Scrollable nav — direction:rtl pushes scrollbar to left edge */
  .sb-scroll {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 8px 6px 4px;
    direction: rtl;
    scrollbar-width: thin; scrollbar-color: transparent transparent;
    transition: scrollbar-color .2s;
  }
  .sb-scroll:hover { scrollbar-color: rgba(0,0,0,.22) transparent; }
  html[data-theme="dark"] .sb-scroll { scrollbar-color: transparent transparent; }
  html[data-theme="dark"] .sb-scroll:hover { scrollbar-color: rgba(255,255,255,.24) transparent; }
  .sb-scroll::-webkit-scrollbar { width: 4px; }
  .sb-scroll::-webkit-scrollbar-track { background: transparent; }
  .sb-scroll::-webkit-scrollbar-thumb { background: transparent; border-radius: 2px; transition: background .2s; }
  .sb-scroll:hover::-webkit-scrollbar-thumb { background: rgba(0,0,0,.22); }
  html[data-theme="dark"] .sb-scroll:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,.24); }
  .sb-inner { direction: ltr; } /* reset content to LTR */
  /* IT4Y_ADMIN_SHELL_MIRROR_2026_11_11 — a right-to-left chrome keeps the scrollbar at the outer (left) edge and its
     content right-to-left: the two directions swap. */
  .app-sidebar[dir="rtl"] .sb-scroll { direction: ltr; }
  .app-sidebar[dir="rtl"] .sb-inner { direction: rtl; }

  /* Group headers */
  .sb-group { margin-bottom: 2px; }
  .sb-grp-hdr {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 8px 4px; margin-top: 10px; cursor: pointer; user-select: none;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em;
    color: var(--sn-grp); border-radius: 5px; transition: color .15s;
    white-space: nowrap; overflow: hidden;
  }
  .sb-grp-hdr:hover { color: var(--sn-muted); }
  .app-sidebar.sb-collapsed .sb-grp-hdr { display: none; }
  .sb-grp-lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .sb-grp-caret { font-size: 11px; opacity: .8; transition: transform .18s; flex-shrink: 0; margin-inline-start: 8px; }
  .sb-grp-hdr.sb-coll > .sb-grp-caret { transform: rotate(-90deg); }
  .sb-grp-items { overflow: hidden; transition: max-height .22s cubic-bezier(.4,0,.2,1); }

  /* Nav items */
  .sb-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px; cursor: pointer;
    color: var(--sn-muted); font-size: 13px; font-weight: 500;
    text-decoration: none; white-space: nowrap; overflow: hidden;
    transition: background .13s, color .13s; position: relative;
  }
  .sb-item:hover { background: var(--sn-hover); color: var(--sn-text); }
  .sb-item.active { background: var(--sn-active-bg); color: var(--sn-active); font-weight: 600; }
  .sb-item.active::before {
    content: ''; position: absolute; inset-inline-start: 0; top: 20%; bottom: 20%;
    width: 3px; background: var(--sn-active); border-start-end-radius: 3px; border-end-end-radius: 3px;
  }
  .sb-item-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 14px; }
  .sb-item-lbl { transition: opacity .18s; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .app-sidebar.sb-collapsed .sb-item-lbl { opacity: 0; width: 0; }
  .sb-ext { font-size: 9px; opacity: .4; margin-inline-start: auto; flex-shrink: 0; }
  .app-sidebar.sb-collapsed .sb-ext { display: none; }

  /* Single items (Overview, Security) */
  .sb-single { margin-top: 4px; }
  .sb-single:first-child { margin-top: 0; }

  /* An entry names itself through its title attribute (the scrolling list clips any drawn hint).  A closed
     group's entries are hidden from pointer and keyboard; an icon-only sidebar (collapsed, or the 769-900px
     rail) has no group headers, so it shows every entry. */
  .sb-grp-hdr.sb-coll + .sb-grp-items { visibility: hidden; transition: max-height .22s cubic-bezier(.4,0,.2,1), visibility 0s .22s; }
  @media (min-width: 769px) {
    .app-sidebar.sb-collapsed .sb-grp-items, .app-sidebar.sb-collapsed .sb-grp-hdr.sb-coll + .sb-grp-items {
      max-height: none !important; visibility: visible; }
  }

  /* Sidebar footer */
  .sb-footer { flex-shrink: 0; padding: 6px; border-top: 1px solid var(--sn-border); }
  .sb-toggle-btn {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 9px 8px 12px; border-radius: 6px; cursor: pointer;
    color: var(--sn-muted); font-size: 13px; font-weight: 500;
    background: none; border: none; width: 100%; white-space: nowrap; overflow: hidden;
    transition: background .13s, color .13s;
  }
  .sb-toggle-btn:hover { background: var(--sn-hover); color: var(--sn-text); }
  .sb-toggle-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 14px; }
  .app-sidebar[dir="rtl"] .sb-toggle-icon { transform: scaleX(-1); }
  .sb-toggle-lbl { transition: opacity .18s; }
  .app-sidebar.sb-collapsed .sb-toggle-lbl { opacity: 0; width: 0; }

  /* ── Right column (header + main) ── */
  .app-right { display: flex; flex-direction: column; flex: 1; min-width: 0; overflow: hidden; }
  .app-header {
    display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
    background: var(--panel); border-bottom: 1px solid var(--border);
    padding: 0 22px; height: var(--header-h); z-index: 10;
  }
  .app-header .brand { font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 10px; white-space: nowrap; min-width: 0; }
  .app-header .brand-icon, .access-brand .brand-icon { display: flex; flex-shrink: 0; }
  /* The full logo badge (never hidden, never squeezed) and the product name beside it. */
  .app-header .brand-badge img, .access-brand .brand-badge img { height: 38px; width: auto; aspect-ratio: 253 / 146; display: block; }
  .app-header .brand-text { color: var(--text); font-size: 15px; font-weight: 650; letter-spacing: -.01em;
                            overflow: hidden; text-overflow: ellipsis; }
  .access-brand .brand-badge img { height: 44px; }
  .app-header .right { display: flex; gap: 14px; align-items: center; font-size: 13px; }
  .app-header .session-info { color: var(--text-dim); }
  .app-header .session-info .email { color: var(--text); font-weight: 600; }
  .app-header .session-info .role { color: var(--accent); margin-inline-start: 6px; }
  .app-header .right .btn { white-space: nowrap; }
  /* IT4Y_ADMIN_STABLE_VIEWPORT_2026_11_14 - the content pane keeps its width and contains its own content on every
     page switch: the scrollbar's space is always reserved (a short loading frame no longer drops the scrollbar and
     widens every page by its width), and the pane is the containing block of every absolutely placed descendant,
     so a visually hidden caption can never land below the viewport and give the whole document a second scrollbar. */
  .app-main { padding: 22px 26px; flex: 1; overflow-y: auto; scrollbar-gutter: stable; position: relative; }
  /* IT4Y_ADMIN_NAV_DOMAINS_2026_11_11 — one breakpoint pair: at 768px and below the mobile drawer owns the
     sidebar (admin-shell-mobile-drawer.js); between 769 and 900px the sidebar is an icon rail of every entry,
     each naming itself through its title, and the header keeps its words on one line. */
  @media (min-width: 769px) and (max-width: 900px) {
    .app-sidebar { width: 52px; }
    .app-sidebar .sb-header { padding: 0 6px; justify-content: center; }
    .app-sidebar .sb-logo img { height: auto; width: 40px; }
    .app-sidebar .sb-title, .app-sidebar .sb-item-lbl,
    .app-sidebar .sb-grp-hdr, .app-sidebar .sb-toggle-lbl,
    .app-sidebar .sb-ext { display: none; }
    /* The closed-group rule (.sb-grp-hdr.sb-coll + .sb-grp-items) is more specific than a plain items rule, so the
       rail names it: with no group header to open a group, every entry of every group stays reachable. */
    .app-sidebar .sb-grp-items, .app-sidebar .sb-grp-hdr.sb-coll + .sb-grp-items { max-height: none !important; visibility: visible; }
    .app-header .session-info { display: none; }
    .app-main { padding: 14px 12px; }
  }
  .breadcrumbs { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
  .breadcrumbs a { color: var(--muted); }
  .breadcrumbs .sep { margin: 0 8px; opacity: 0.5; }
  .page-title { font-size: 22px; font-weight: 700; margin: 0 0 16px; }
  .page-subtitle { color: var(--muted); margin-top: -10px; margin-bottom: 16px; font-size: 13px; }

  /* ── Cards / KPIs ── */
  .card { background: var(--panel); border: 1px solid var(--border-soft); border-radius: 10px;
          padding: 18px; margin-bottom: 16px; }
  .card h3 { margin: 0 0 12px 0; font-size: 15px; }
  .card-toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
  .kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
  .kpi { background: var(--panel-2); padding: 14px 16px; border-radius: 8px; border: 1px solid var(--border-soft); position: relative; }
  .kpi .v { font-size: 26px; font-weight: 700; color: var(--accent); }
  .kpi .l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; margin-top: 4px; }
  /* IT4Y_PHASE184_KPI_INTERACTIVE_V1 — interactive drill-down cards */
  .kpi.clickable { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; user-select: none; }
  .kpi.clickable:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.12); border-color: var(--accent); }
  .kpi.clickable:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
  .kpi.clickable:active { transform: translateY(0); }
  .kpi.clickable .arrow { position: absolute; top: 12px; right: 12px; color: var(--muted); opacity: 0; transition: opacity .12s, transform .12s;
    font-size: 14px; }
  .kpi.clickable:hover .arrow { opacity: 1; transform: translateX(2px); }
  .kpi.clickable .sub { font-size: 10px; color: var(--muted); margin-top: 2px; opacity: .7; }
  /* Breakdown row clickability */
  tr.row-link { cursor: pointer; transition: background .12s; }
  tr.row-link:hover { background: var(--panel-2); }
  tr.row-link td:last-child::after { content: ' ›'; color: var(--muted); opacity: 0; transition: opacity .12s; }
  tr.row-link:hover td:last-child::after { opacity: 1; }
  .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
  @media (max-width: 1100px) { .row-3 { grid-template-columns: 1fr; } .row-2 { grid-template-columns: 1fr; } }

  /* ── Tables ── */
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th { text-align: start; color: var(--muted); font-weight: 600; padding: 9px 12px;
       border-bottom: 1px solid var(--border-soft); font-size: 11px;
       text-transform: uppercase; letter-spacing: 0.6px; }
  td { padding: 9px 12px; border-bottom: 1px solid var(--table-row-border); }
  tr.clickable { cursor: pointer; }
  /* A table wider than its card scrolls inside the card, never the page; .table-empty is the empty row. */
  .table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-empty { padding: 16px; text-align: center; }
  tr.clickable:hover td { background: var(--row-hover); }

  /* ── Pills / badges (dark-theme palette by default) ── */
  .pill { display: inline-block; padding: 2px 8px; border-radius: 11px; font-size: 10px;
          font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
          background: #1f3a5e; color: #b9d3f0; }
  .pill.green { background: #14331a; color: #b3f5c4; }
  .pill.red   { background: #3a1818; color: #fda4a4; }
  .pill.amber { background: #3a2f18; color: #fde2a4; }
  .pill.yotta { background: #14253d; color: #6fb8ff; }
  /* IT4Y_PHASE177_LIGHT_PILLS_V1 — softer pastel palette for light mode */
  html:not([data-theme="dark"]) .pill          { background:#dbeafe; color:#1e3a8a; }
  html:not([data-theme="dark"]) .pill.green    { background:#dcfce7; color:#14532d; }
  html:not([data-theme="dark"]) .pill.red      { background:#fee2e2; color:#7f1d1d; }
  html:not([data-theme="dark"]) .pill.amber    { background:#fef3c7; color:#78350f; }
  html:not([data-theme="dark"]) .pill.yotta    { background:#e0f2fe; color:#0c4a6e; }

  /* ── Forms / buttons ── */
  .field { margin: 12px 0; }
  .field label { display: block; font-size: 11px; color: var(--muted);
                 text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
  .field input, .field select, .field textarea {
    width: 100%; padding: 9px 12px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--bg-2);
    color: var(--text); font: 13px ui-monospace, monospace; }
  .field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--accent); border-color: var(--accent); }
  .btn { padding: 8px 14px; border-radius: 6px; border: 0; cursor: pointer;
         background: var(--accent-fill); color: #fff; font: 600 13px system-ui; transition: filter 0.15s, background-color .2s ease; }
  .btn:hover { filter: brightness(1.1); }
  .btn:disabled { opacity: 0.5; cursor: not-allowed; }
  .btn.small { padding: 4px 10px; font-size: 11px; }
  .btn.ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
  .btn.warn { background: var(--warn-fill); color: #fff; }
  .btn.danger { background: var(--danger-fill); color: #fff; }
  html:not([data-theme="dark"]) .btn.ghost:hover { background: var(--panel-2); }

  /* ── Status / messages (dark palette by default) ── */
  .msg { padding: 11px 14px; border-radius: 6px; font-size: 13px; margin: 10px 0; }
  .msg.error { background: #3a1818; color: #fda4a4; border: 1px solid #7f3333; }
  .msg.ok    { background: #14331a; color: #b3f5c4; border: 1px solid #2f6e44; }
  .msg.info  { background: #14253d; color: #b6d4f8; border: 1px solid #2a4a76; }
  /* IT4Y_PHASE177_LIGHT_MSGS_V1 */
  html:not([data-theme="dark"]) .msg.error { background:#fef2f2; color:#7f1d1d; border-color:#fecaca; }
  html:not([data-theme="dark"]) .msg.ok    { background:#f0fdf4; color:#14532d; border-color:#bbf7d0; }
  html:not([data-theme="dark"]) .msg.info  { background:#eff6ff; color:#1e3a8a; border-color:#bfdbfe; }

  /* IT4Y_PHASE177_THEME_TOGGLE_BTN_V1 */
  .theme-toggle { background:transparent; color:var(--text-dim); border:1px solid var(--border);
                  padding:6px 10px; border-radius:6px; cursor:pointer; font-size:14px; line-height:1; }
  .theme-toggle:hover { background:var(--panel-2); color:var(--text); }

  .muted { color: var(--muted); }
  .small { font-size: 11px; }
  .right { text-align: right; }
  .center { text-align: center; }

  /* ── Loading spinner ── */
  .spinner { display: inline-block; width: 14px; height: 14px;
             border: 2px solid var(--border); border-top-color: var(--accent);
             border-radius: 50%; animation: spin 0.6s linear infinite;
             vertical-align: middle; margin-right: 6px; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .loading-overlay { position: fixed; top: var(--header-h); left: 0; right: 0;
                     height: 2px; background: var(--accent); transform-origin: left;
                     animation: progress 1.5s linear infinite; z-index: 100; display: none; }
  .loading-overlay.active { display: block; }
  @keyframes progress { 0% { transform: scaleX(0); } 50% { transform: scaleX(0.7); } 100% { transform: scaleX(1); } }

  /* ── Login views ── */
  .auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
  .auth-card { width: 100%; max-width: 440px; background: var(--panel);
               border: 1px solid var(--border); border-radius: 12px; padding: 28px; }
  .auth-card h1 { margin: 0 0 6px; font-size: 22px; }
  .auth-card .muted { font-size: 13px; line-height: 1.5; margin-bottom: 18px; }

  /* ── IT4Y_AUTH_ACCESS_PAGE_2026_06_01 — enterprise Operator Access Required ── */
  .access-card { max-width: 460px; padding: 34px 32px; text-align: center;
                 box-shadow: var(--shadow-md); }
  .access-card #acc-title { margin: 4px 0 10px; font-size: 23px; letter-spacing: -.2px; }
  .access-brand { display: flex; align-items: center; justify-content: center; gap: 8px;
                  font-weight: 700; color: var(--accent); font-size: 15px; margin-bottom: 20px; }
  .access-brand-sub { color: var(--muted); font-weight: 600; }
  .access-lock { width: 60px; height: 60px; margin: 4px auto 14px; border-radius: 50%;
                 display: flex; align-items: center; justify-content: center;
                 background: var(--accent-soft); color: var(--accent); }
  .access-lede { font-size: 14px; line-height: 1.6; color: var(--text-dim);
                 max-width: 380px; margin: 0 auto 20px; }
  .access-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
  .access-primary { width: 100%; padding: 12px 16px; font-size: 14px; font-weight: 600; }
  .access-secondary { width: 100%; padding: 11px 16px; font-size: 13.5px; font-weight: 500;
                      text-align: center; text-decoration: none; }
  .access-secondary:hover { text-decoration: none; }
  .access-form { text-align: left; margin-top: 6px;
                 animation: accReveal .2s ease; }
  @keyframes accReveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
  .access-form-actions { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
  .access-form-actions #li-btn { flex: 0 0 auto; }
  .access-form-link { font-size: 13px; }
  .access-back-link { display: inline-block; margin-top: 14px; font-size: 12.5px; color: var(--muted); }
  .access-foot { font-size: 12.5px; margin: 22px 0 0; padding-top: 16px;
                 border-top: 1px solid var(--border-soft); color: var(--muted); }
  .access-foot a { font-weight: 600; }

  details { background: var(--panel-2); border: 1px solid var(--border-soft);
            border-radius: 6px; padding: 8px 12px; margin-top: 14px; }
  details summary { cursor: pointer; color: var(--text-dim); font-size: 12px; }
  details[open] summary { margin-bottom: 8px; }

  /* ── Conversation bubbles (tickets) ── */
  .msg-bubble { background: var(--panel-2); border: 1px solid var(--border-soft);
                border-left: 3px solid var(--accent); padding: 12px 14px;
                margin-bottom: 8px; border-radius: 0 8px 8px 0; }
  .msg-bubble.internal { border-left-color: var(--warn); background: #2b2410; }
  .msg-bubble .meta { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
  .msg-bubble pre { margin: 0; white-space: pre-wrap; font: inherit; }


/* IT4Y_SBPAR_2026_07_02 — customer-panel sidebar parity: light active text + keyboard focus ring */
html:not([data-theme="dark"]) .sb-item.active { color:#1e3a8a; }
.sb-item:focus-visible, .sb-grp-hdr:focus-visible { outline:2px solid var(--sn-active); outline-offset:-2px; }
