/* Adapted from IMS AppSidebar.ascx and Main.css; domain behavior stays in app.js. */
@media screen {
  :root {
    --ims-page: #f4f7fb;
    --ims-surface: #fff;
    --ims-input: #f8fafc;
    --ims-secondary: #e2e8f0;
    --ims-header: #eef3fa;
    --ims-row-line: #e2e8f0;
    --ims-heading: #475569;
    --ims-error-bg: #fff1f2;
    --ims-shadow: 0 14px 36px #21314f14;
    --ims-text: #172033;
    --ims-muted: #64748b;
    --ims-line: #d9e1ee;
    --ims-hover: #eef4fb;
    --ims-selected: #e5f1fb;
    --ims-nav: #334155;
    --brand: #0b8bd3;
    --line: var(--ims-line);
    --muted: var(--ims-muted);
    background: var(--ims-page);
    color: var(--ims-text);
    font-family: "Segoe UI", Arial, sans-serif;
  }
  :root[data-theme=dark] {
    --ims-page: #090b12;
    --ims-surface: #151927;
    --ims-input: #303449;
    --ims-secondary: #1e2334;
    --ims-header: #1a1f30;
    --ims-row-line: #252a3d;
    --ims-heading: #8990a8;
    --ims-error-bg: #351c2a;
    --ims-shadow: 0 14px 36px #0000002e;
    --ims-text: #eef0f7;
    --ims-muted: #9298ad;
    --ims-line: #30364c;
    --ims-hover: #191e2e;
    --ims-selected: #152b42;
    --ims-nav: #aeb4c8;
    --brand: #0b8bd3;
    --green: #86efac;
    --amber: #fbbf24;
    --red: #fda4af;
    --line: var(--ims-line);
    --muted: var(--ims-muted);
    background: var(--ims-page);
    color: var(--ims-text);
  }
  body { background: var(--ims-page); color: var(--ims-text); }
  :root:not([data-theme=dark]) { background: var(--ims-page); }
  .shell.ims-shell { display: block; min-height: 100dvh; }
  .ims-shell .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 236px; height: 100dvh;
    background: #fff; border-right: 1px solid var(--ims-line);
    padding: 24px 18px; display: flex; flex-direction: column; gap: 0; z-index: 20;
  }
  :root:not([data-theme=dark]) .ims-shell .sidebar { background: #fff; box-shadow: 8px 0 28px #21314f14; }
  :root[data-theme=dark] .ims-shell .sidebar { background: #121522; }
  .sidebar-brand { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0 28px; }
  .ims-shell .brand:has(.product-logo) { width: auto; min-width: 0; }
  .ims-shell .brand .product-logo { gap: 8px; }
  .ims-shell .brand .product-symbol { width: 46px; height: 46px; }
  .ims-shell .brand .product-wordmark { display: flex; }
  .ims-shell .brand .product-wordmark strong { font-family: "Segoe UI", Arial, sans-serif; font-size: 20px; font-weight: 700; line-height: 1.2; background: none; -webkit-text-fill-color: currentColor; -webkit-text-stroke: 0; color: var(--ims-text); filter: none; }
  .ims-shell .sidebar-toggle { display: none; }
  .ims-shell .sidebar nav { display: flex; flex: 1 1 auto; flex-direction: column; gap: 7px; overflow-y: auto; overflow-x: hidden; min-height: 0; padding-right: 4px; margin-right: -4px; scrollbar-width: thin; scrollbar-color: #596179 transparent; }
  .ims-shell .nav-link { display: flex; align-items: center; flex: 0 0 auto; gap: 10px; width: 100%; min-height: 44px; padding: 0 14px; border: 0; border-radius: 8px; box-shadow: none; font-size: 14px; color: var(--ims-nav); }
  .ims-shell .nav-link:hover, .ims-shell .nav-sublink:hover { color: var(--ims-text); background: var(--ims-hover); }
  .ims-shell .nav-link.active { color: #fff; background: #0b72b9; box-shadow: none; }
  .ims-shell .nav-link.active svg { color: inherit; }
  .nav-group { flex: 0 0 auto; }
  .nav-group summary { display: flex; align-items: center; position: relative; list-style: none; cursor: pointer; border-radius: 8px; }
  .nav-group summary::-webkit-details-marker { display: none; }
  .nav-group summary>.nav-link { padding-right: 36px; }
  .nav-group summary>svg { position: absolute; right: 12px; width: 16px; height: 16px; pointer-events: none; color: var(--ims-muted); transition: transform .16s ease; }
  .nav-group[open] summary>svg { transform: rotate(90deg); }
  .ims-shell .nav-group summary>.nav-link.active { background: var(--ims-hover); color: var(--ims-text); }
  .nav-submenu { display: flex; flex-direction: column; gap: 4px; padding: 5px 0 0 12px; }
  .ims-shell .nav-sublink { position: relative; display: flex; align-items: center; min-height: 36px; padding: 7px 10px 7px 20px; border-radius: 8px; font-size: 13px; color: var(--ims-muted); overflow-wrap: anywhere; }
  .nav-sublink::before { content: ""; position: absolute; left: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--ims-muted); }
  .ims-shell .nav-sublink.active { background: #0b72b9; color: #fff; }
  .nav-sublink.active::before { background: #fff; }
  .ims-shell .sidebar-foot { display: flex; flex: 0 0 auto; flex-direction: column; gap: 12px; padding: 16px 0 0; margin-top: 12px; border-top: 1px solid var(--ims-line); }
  .sidebar-foot .user { min-width: 0; gap: 9px; }
  .sidebar-foot .user-detail { display: block; min-width: 0; overflow-wrap: anywhere; color: var(--ims-text); line-height: 1.5; }
  .sidebar-foot .preview { margin-left: auto; font-size: 10px; padding: 2px 4px; }
  .ims-shell .sidebar-foot .sidebar-logout { width: 100%; justify-content: flex-start; background: transparent; color: #b42342; border-color: transparent; border-radius: 8px; }
  :root[data-theme=dark] .ims-shell .sidebar-logout { color: #fda4af; }
  .ims-shell .sidebar-foot .sidebar-logout:hover { background: var(--ims-hover); }
  .sidebar-preferences { display: grid; grid-template-columns: minmax(0,1fr) 64px; gap: 8px; align-items: center; padding: 4px; border: 1px solid var(--ims-line); border-radius: 8px; background: var(--ims-hover); }
  .sidebar-preferences [data-action=theme] { width: 100%; border: 0; background: transparent; }
  .sidebar-preferences select { width: 100%; min-width: 0; padding-inline: 6px; }
  .ims-shell .main { width: auto; min-width: 0; margin-left: 236px; padding: 30px 34px 38px; min-height: 100dvh; }
  .ims-shell .page-head { margin: 0; }
  .ims-shell .page-head h1 { color: var(--ims-text); font-size: 24px; font-weight: 700; }
  :root[data-theme] .table-wrap, :root[data-theme] dialog, :root[data-theme] .dialog-head, :root[data-theme] .login-form { background: var(--ims-surface); color: var(--ims-text); border-color: var(--ims-line); }
  :root[data-theme] input, :root[data-theme] select, :root[data-theme] textarea { background: var(--ims-input); color: var(--ims-text); border-color: var(--ims-line); border-radius: 6px; }
  :root input:focus, :root select:focus, :root textarea:focus { outline: 2px solid #0b8bd366; outline-offset: 1px; border-color: #0b8bd3; }
  :root button { border-radius: 6px; }
  :root[data-theme] button:not(.primary):not(.product-logo) { background: var(--ims-secondary); color: var(--ims-text); border-color: var(--ims-line); }
  :root[data-theme] button:not(.primary):not(.product-logo):hover { background: var(--ims-hover); }
  :root[data-theme] button.danger:not(.primary):not(.product-logo) { color: var(--red); }
  :root[data-theme] :is(.subnav,.station-type-tabs,.erp-guide-tabs) button:not(.primary):not(.product-logo) { background: transparent; color: var(--ims-muted); border-radius: 0; }
  :root[data-theme] :is(.subnav,.station-type-tabs,.erp-guide-tabs) button:is(.active,[aria-selected=true]):not(.primary):not(.product-logo) { color: var(--brand); border-bottom-color: var(--brand); }
  :root[data-theme=dark] :is(.subnav,.station-type-tabs,.erp-guide-tabs) button:is(.active,[aria-selected=true]):not(.primary):not(.product-logo) { color: #8ecfff; border-bottom-color: #8ecfff; }
  :root[data-theme] .report-view-switch button[aria-pressed=true] { background: #0b8bd324; color: var(--ims-text); border-color: var(--brand); }
  :root[data-theme] .sidebar-foot button.sidebar-logout { background: transparent; color: #be123c; border-color: transparent; }
  :root[data-theme=dark] .sidebar-foot button.sidebar-logout { color: #fda4af; }
  :root[data-theme] .sidebar-foot button.sidebar-logout:hover { background: var(--ims-error-bg); }
  :root[data-theme] .sidebar-preferences button[data-action=theme] { background: transparent; border: 0; }
  :root[data-theme] .report-row-action button.icon { background: transparent; border-color: transparent; }
  :root button.primary { background: #0b8bd3; border-color: #0b8bd3; color: #fff; }
  :root button.primary:hover { background: #0a78b7; border-color: #0a78b7; }
  :root button.danger { color: var(--red); }
  :root .table-wrap th { background: var(--ims-header); color: var(--ims-heading); border-color: var(--ims-line); font-size: 11px; }
  :root .table-wrap td { border-color: var(--ims-row-line); }
  :root .table-wrap td:first-child { color: var(--ims-text); }
  :root .table-wrap tbody tr:hover { background: var(--ims-hover); }
  :root .table-wrap tbody tr.selected { background: var(--ims-selected); }
  :root .subnav button:not(.primary):not(.product-logo) { border-radius: 0; background: transparent; color: var(--ims-muted); }
  :root .subnav button.active { color: #0b72b9; border-color: #0b72b9; }
  :root[data-theme=dark] .subnav button.active { color: #8ecfff; border-color: #8ecfff; }
  :root .breadcrumb, :root .table-foot { color: var(--ims-muted); }
  :root[data-theme] .program-settings-actions, :root .login-page { background: var(--ims-page); }
  :root .station-type-tabs [role=tab] { background: transparent; border-radius: 0; }
  :root .station-type-tabs [aria-selected=true] { color: #0b72b9; }
  :root[data-theme=dark] .station-type-tabs [aria-selected=true] { color: #8ecfff; }
  :root .detail-meta { background: var(--ims-hover); }
  :root .summary-strip strong, :root .detail-meta strong, :root .detail-title h3, :root .login-form h1 { color: var(--ims-text); }
  .login-form { border-radius: 8px; box-shadow: 0 14px 44px #00000014; }
  :root .login-form .product-wordmark strong { font-size: 28px; background: none; -webkit-text-fill-color: currentColor; -webkit-text-stroke: 0; color: var(--ims-text); filter: none; }
  .ims-shell .main > .table-wrap { border-radius: 8px; box-shadow: var(--ims-shadow); }
  :root .table-wrap table { font-size: 13px; }
  :root .table-wrap th, :root .table-wrap td { padding-block: 12px; }
  :root .table-wrap tbody tr.selected { background: var(--ims-selected); }
  :root .avatar, :root .version { background: var(--ims-secondary); color: var(--ims-text); border-color: var(--ims-line); }
  :root .role-label, :root .summary-strip span { color: var(--ims-muted); }
  :root .empty { color: var(--ims-muted) !important; }
  :root .error { background: var(--ims-error-bg); color: var(--red); border-color: var(--red); }
  :root dialog { border-radius: 8px; border-color: var(--ims-line); box-shadow: 0 26px 70px #00000045; }
  :root[data-theme] .dialog-head { background: var(--ims-header); border-color: var(--ims-row-line); }
  :root dialog::backdrop { background: #0f172a47; backdrop-filter: blur(4px); }
  :root[data-theme=dark] dialog::backdrop { background: #03060cb8; }
  :root .form-actions { border-color: var(--ims-row-line); }
  :root .field { color: var(--ims-heading); }
  :root input::placeholder, :root textarea::placeholder { color: var(--ims-muted); opacity: 1; }
  :root .badge.pending { background: #f59e0b1a; color: #a16207; }
  :root .badge.inProgress { background: #0b8bd31a; color: #0b72b9; }
  :root .badge.completed, :root .badge.active { background: #22c55e1a; color: #166534; }
  :root .badge.cancelled, :root .badge.inactive { background: #ef44441a; color: #be123c; }
  :root[data-theme=dark] .badge.pending { color: #fbbf24; }
  :root[data-theme=dark] .badge.inProgress { color: #8ecfff; }
  :root[data-theme=dark] .badge.completed, :root[data-theme=dark] .badge.active { color: #86efac; }
  :root[data-theme=dark] .badge.cancelled, :root[data-theme=dark] .badge.inactive { color: #fda4af; }
  @media(max-width:1000px) and (min-width:721px) {
    .ims-shell .sidebar { width: 218px; padding-inline: 14px; }
    .ims-shell .main { margin-left: 218px; padding: 24px 20px; }
    .ims-shell .brand .product-wordmark strong { font-size: 19px; }
  }
  @media(max-width:720px) {
    .ims-shell .sidebar { inset: 0 0 auto 0; width: 100%; height: 64px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--ims-line); overflow: hidden; }
    .sidebar-brand { height: 47px; padding: 0; }
    .ims-shell .brand .product-symbol { width: 40px; height: 40px; }
    .ims-shell .brand .product-wordmark strong { font-size: 20px; }
    .ims-shell .sidebar-toggle { display: inline-flex; flex: 0 0 auto; }
    .ims-shell .sidebar nav, .ims-shell .sidebar-foot { display: none; }
    .ims-shell .sidebar.is-mobile-open { height: 100dvh; padding-bottom: 14px; }
    .ims-shell .sidebar.is-mobile-open nav { display: flex; padding-top: 16px; }
    .ims-shell .sidebar.is-mobile-open .sidebar-foot { display: flex; }
    .ims-shell .nav-link { min-height: 44px; }
    .ims-shell .nav-sublink { min-height: 40px; }
    .ims-shell .main { width: 100%; margin: 0; padding: 84px 12px 24px; }
    .ims-shell .sidebar-foot .user-detail { display: block; }
    :root .login-form .product-wordmark strong { font-size: 24px; }
  }
  @media(prefers-reduced-motion:reduce) { .nav-group summary>svg { transition: none; } }
}
