    :root { --bg:#f6f7f9; --panel:#fff; --ink:#1c2430; --muted:#667085; --line:#e4e7ec; --accent:#2f6feb; --accent-ink:#fff; --danger:#b42318; --ok:#067647; --radius:10px;
      /* theme tokens (overridden in themes.css) */
      --accent-soft:#eef4ff; --accent-line:#d6e4ff; --accent-hover-line:#c7dbfb; --hover:#f2f4f7; --subtle:#f7f9fc; --thead:#fbfcfe;
      --font:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
      --ch1:#2563eb; --ch2:#16a34a; --ch3:#d97706; --ch4:#9333ea; --ch5:#dc2626; --ch6:#0891b2; --ch7:#4f46e5; --ch8:#ca8a04; }
    * { box-sizing:border-box; }
    body { margin:0; font-family:var(--font); color:var(--ink); background:var(--bg); line-height:1.5; display:flex; flex-direction:column; min-height:100vh; }
    .app-footer { text-align:center; color:var(--muted); font-size:12px; padding:12px 20px; border-top:1px solid var(--line); background:var(--panel); }
    .app-footer a { color:var(--accent); text-decoration:none; }
    .icon-only { width:36px; height:34px; padding:0; display:inline-flex; align-items:center; justify-content:center; }
    .icon-only svg { width:18px; height:18px; }
    .launchpad { padding:0; }
    .lp-nav { display:flex; gap:22px; flex-wrap:wrap; align-items:center; padding:2px 4px 14px; margin-bottom:10px; border-bottom:1px solid var(--line); position:sticky; top:61px; background:var(--bg); z-index:5; }
    .lp-nav a { font-size:13px; color:var(--muted); cursor:pointer; padding:6px 0; border-bottom:2px solid transparent; white-space:nowrap; }
    .lp-nav a:hover { color:var(--ink); }
    .lp-nav a.active { color:var(--accent); border-bottom-color:var(--accent); font-weight:600; }
    .lp-search { margin-left:auto; position:relative; flex:0 1 260px; }
    .lp-search svg { position:absolute; left:10px; top:50%; transform:translateY(-50%); width:15px; height:15px; color:var(--muted); pointer-events:none; }
    /* [type=search] so it outranks the general input rule further down, which would reset the left padding the icon needs */
    .lp-search input[type=search] { width:100%; box-sizing:border-box; margin:0; padding:7px 10px 7px 34px; border:1px solid var(--line); border-radius:6px; background:var(--panel); color:var(--ink); font:inherit; font-size:13px; }
    .lp-search input[type=search]:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
    @media (max-width:640px) { .lp-search { flex:1 1 100%; margin-left:0; } }
    .lp-results { min-height:calc(100vh - 160px); } /* page height stays put while the result list grows and shrinks */
    .lp-section { margin-bottom:26px; scroll-margin-top:120px; }
    .lp-section > h3 { font-size:15px; text-transform:none; letter-spacing:0; color:var(--ink); font-weight:600; margin:0 0 14px; display:flex; align-items:center; gap:8px; }
    .lp-section .mi-icon { color:var(--muted); }
    .lp-tiles { display:flex; flex-wrap:wrap; gap:14px; }
    .lp-tile { position:relative; display:flex; flex-direction:column; width:184px; height:138px; background:var(--panel); border:1px solid var(--line); border-radius:4px; padding:14px 14px 12px; cursor:pointer; text-align:left; font:inherit; color:var(--ink); transition:box-shadow .15s, border-color .15s; }
    .lp-tile:hover { box-shadow:0 4px 14px rgba(16,24,40,.12); border-color:var(--accent-hover-line); }
    .lp-tile .lp-label { font-size:14px; font-weight:600; color:var(--accent); line-height:1.25; }
    .lp-tile .lp-sub { font-size:12px; color:var(--ink); margin-top:3px; }
    .lp-tile .lp-ico { position:absolute; left:14px; bottom:12px; width:24px; height:24px; color:#5b6b82; display:flex; align-items:center; justify-content:center; }
    .lp-tile .lp-ico svg { width:22px; height:22px; }
    .lp-empty { color:var(--muted); font-size:13px; padding:24px; text-align:center; }
    body.tiles-mode .sidebar { display:none; }
    body.tiles-mode #menuToggle { display:none; }
    header { background:var(--panel); border-bottom:1px solid var(--line); padding:12px 20px; display:flex; flex-wrap:nowrap; gap:16px; align-items:center; position:sticky; top:0; z-index:40; }
    .hdr-left { display:flex; align-items:center; gap:10px; flex:1 1 0; min-width:0; }
    .header-ticker { flex:0 1 340px; max-width:34%; min-width:0; overflow:hidden; }
    .hdr-right { display:flex; align-items:center; gap:10px; flex:1 1 0; min-width:0; justify-content:flex-end; flex-wrap:nowrap; }
    @media (max-width:1100px){ .header-ticker { display:none; } }
    #formTools { flex-wrap:nowrap; }
    #applySchema.icon-only { font-size:16px; }
    @media (max-width:860px){ header { flex-wrap:wrap; } .hdr-left, .hdr-right { flex:1 1 auto; } }
    .brand { display:flex; align-items:baseline; gap:8px; cursor:pointer; }
    .home-hero { background:linear-gradient(135deg,var(--accent-soft),#f7fafc); border:1px solid var(--line); border-radius:14px; padding:28px 26px; margin-bottom:22px; }
    .ticker { display:flex; align-items:center; gap:10px; border-radius:10px; padding:9px 14px; margin-bottom:18px; overflow:hidden; border:1px solid var(--line); background:var(--subtle); color:var(--ink); }
    .ticker .ticker-icon { flex:0 0 auto; font-size:16px; }
    .ticker-track { flex:1 1 auto; overflow:hidden; white-space:nowrap; min-width:0; }
    .ticker-move { display:inline-block; white-space:nowrap; will-change:transform; padding-left:100%; animation:tickerscroll linear infinite; font-size:13px; font-weight:500; }
    .ticker:hover .ticker-move { animation-play-state:paused; }
    @keyframes tickerscroll { from { transform:translateX(0); } to { transform:translateX(-100%); } }
    .tk-item { margin-right:46px; }
    .tk-item .tk-dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:7px; vertical-align:middle; }
    .tk-item.sev-info { color:#1c4fa0; } .tk-item.sev-info .tk-dot { background:#2f6feb; }
    .tk-item.sev-success { color:#0a6b3b; } .tk-item.sev-success .tk-dot { background:#067647; }
    .tk-item.sev-warning { color:#8a5a00; } .tk-item.sev-warning .tk-dot { background:#d9930a; }
    .tk-item.sev-danger { color:#a11c14; } .tk-item.sev-danger .tk-dot { background:#b42318; }
    .header-ticker { flex:1 1 auto; min-width:0; overflow:hidden; }
    .header-ticker .ticker { margin:0; border:none; background:transparent; padding:0; }
    @media (max-width:860px){ .header-ticker { display:none; } }
    .home-hero h2 { margin:0 0 6px; font-size:22px; }
    .home-hero p { margin:0; color:var(--muted); }
    .home-hero .home-welcome { margin-top:10px; color:var(--ink); }
    .home-section { margin-bottom:22px; }
    .home-section h3 { font-size:12px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); margin:0 0 12px; }
    .tiles { display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr)); gap:14px; }
    .tile { display:flex; gap:12px; align-items:flex-start; background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:16px; cursor:pointer; text-align:left; font:inherit; color:var(--ink); transition:box-shadow .15s, transform .15s, border-color .15s; }
    .tile:hover { box-shadow:0 6px 20px rgba(16,24,40,.09); transform:translateY(-1px); border-color:var(--accent-hover-line); }
    .tile .tile-icon { width:40px; height:40px; border-radius:10px; background:var(--accent-soft); color:var(--accent); display:flex; align-items:center; justify-content:center; flex:0 0 auto; }
    .tile .tile-icon svg { width:20px; height:20px; }
    .tile h4 { margin:0 0 3px; font-size:14px; }
    .tile p { margin:0; font-size:12px; color:var(--muted); }
    .brand h1 { font-size:18px; margin:0; font-weight:700; letter-spacing:-.01em; }
    .brand .ver { font-size:11px; font-weight:600; color:var(--accent); background:var(--accent-soft); border:1px solid var(--accent-line); padding:1px 7px; border-radius:999px; }
    .brand .sub { color:var(--muted); font-size:12px; }
    #pageContext { display:none; }
    header h1 { font-size:16px; margin:0; font-weight:650; } header .sub { color:var(--muted); font-size:13px; }
    .toolbar { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
    .toolbar[hidden] { display:none; }
    main { max-width:1180px; margin:20px auto; padding:0 20px; }
    .app { display:flex; align-items:flex-start; width:100%; max-width:1340px; margin:0 auto; flex:1 1 auto; }
    .app > main { max-width:none; margin:20px; flex:1; min-width:0; }
    .sidebar { width:230px; flex:0 0 230px; background:var(--panel); border-right:1px solid var(--line); min-height:calc(100vh - 61px); padding:14px 8px; position:sticky; top:61px; overflow:auto; max-height:calc(100vh - 61px); }
    .sidebar .menu-group { margin-bottom:2px; }
    .sidebar .menu-grp-head { display:flex; align-items:center; gap:8px; width:100%; background:none; border:none; padding:9px 10px; margin-top:6px; cursor:pointer; color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.05em; font-weight:700; border-radius:8px; }
    .sidebar .menu-grp-head:hover { background:var(--hover); color:var(--ink); }
    .sidebar .grp-label { text-align:left; }
    .sidebar .grp-chev { margin-left:auto; display:inline-flex; transition:transform .2s ease; color:var(--muted); }
    .sidebar .menu-group.collapsed > .menu-grp-head .grp-chev { transform:rotate(-90deg); }
    .sidebar .menu-children { display:flex; flex-direction:column; overflow:hidden; transition:max-height .22s ease; max-height:1500px; }
    .sidebar .menu-group.collapsed > .menu-children { max-height:0; }
    .sidebar .menu-children .menu-children { margin-left:16px; border-left:1px solid var(--line); padding-left:4px; }
    .sidebar > .menu-group > .menu-grp-head { color:var(--ink); font-size:11px; }
    .sidebar > .menu-group > .menu-children { margin-left:12px; border-left:1px solid var(--line); padding-left:2px; }
    .sidebar .menu-children .menu-grp-head { text-transform:none; font-size:11px; font-weight:600; letter-spacing:0; color:var(--muted); }
    .sidebar .menu-children .menu-grp-head .mi-icon { width:15px; height:15px; }
    .sidebar .menu-link { display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:8px; color:var(--ink); font-size:13px; cursor:pointer; margin:1px 4px; text-decoration:none; }
    .sidebar .menu-link:hover { background:var(--hover); }
    .sidebar .menu-link.active { background:var(--accent-soft); color:var(--accent); font-weight:600; box-shadow:inset 3px 0 0 var(--accent); }
    .sidebar .mi-icon { display:inline-flex; align-items:center; justify-content:center; width:18px; height:18px; flex:0 0 auto; color:var(--muted); }
    .sidebar .mi-icon.mi-emoji { font-size:15px; }
    .sidebar .menu-link.active .mi-icon { color:var(--accent); }
    .sidebar .menu-empty { color:var(--muted); font-size:12px; padding:12px; line-height:1.6; }
    #menuToggle { width:36px; height:34px; padding:0; font-size:17px; line-height:1; display:inline-flex; align-items:center; justify-content:center; }
    .backdrop { display:none; }
    @media (min-width:861px){
      body.nav-collapsed .sidebar { width:60px; flex:0 0 60px; padding:14px 6px; overflow:visible; }
      body.nav-collapsed .sidebar .ml-label, body.nav-collapsed .sidebar .grp-chev { display:none; }
      /* top-level groups become icon buttons; their children slide out on hover */
      body.nav-collapsed .sidebar > .menu-group > .menu-grp-head { justify-content:center; gap:0; padding:10px 0; margin-top:4px; }
      body.nav-collapsed .sidebar > .menu-group > .menu-grp-head .grp-label { display:none; }
      body.nav-collapsed .sidebar > .menu-link { justify-content:center; gap:0; padding:10px 0; }
      body.nav-collapsed .sidebar > .menu-link .ml-label { display:none; }
      /* the flyout */
      body.nav-collapsed .sidebar > .menu-group { position:relative; }
      body.nav-collapsed .sidebar > .menu-group > .menu-children {
        position:absolute; left:100%; top:0; margin:0; min-width:220px; max-height:none !important;
        background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:8px;
        box-shadow:0 12px 32px rgba(16,24,40,.18); opacity:0; visibility:hidden; transform:translateX(-6px);
        transition:opacity .15s ease, transform .15s ease; z-index:70; pointer-events:none;
      }
      body.nav-collapsed .sidebar > .menu-group:hover > .menu-children { opacity:1; visibility:visible; transform:translateX(0); pointer-events:auto; }
      /* inside the flyout, show everything normally (labels, nested groups expanded) */
      body.nav-collapsed .sidebar > .menu-group > .menu-children .ml-label,
      body.nav-collapsed .sidebar > .menu-group > .menu-children .grp-label { display:inline; }
      body.nav-collapsed .sidebar > .menu-group > .menu-children .grp-chev { display:none; }
      body.nav-collapsed .sidebar > .menu-group > .menu-children .menu-children { position:static; opacity:1; visibility:visible; transform:none; box-shadow:none; border:none; background:none; padding:2px 0 6px; margin-left:0; min-width:0; max-height:none !important; }
      /* sub-group = a labelled section: small heading, its links indented under it */
      body.nav-collapsed .sidebar > .menu-group > .menu-children .menu-grp-head { justify-content:flex-start; padding:6px 10px 2px; border:none; margin-top:4px; cursor:default; font-size:10px; color:var(--muted); }
      body.nav-collapsed .sidebar > .menu-group > .menu-children .menu-grp-head:hover { background:none; color:var(--muted); }
      body.nav-collapsed .sidebar > .menu-group > .menu-children .menu-grp-head .mi-icon { display:none; }
      body.nav-collapsed .sidebar > .menu-group > .menu-children .menu-children .menu-link { padding-left:14px; }
      body.nav-collapsed .sidebar > .menu-group > .menu-children .menu-group + .menu-group > .menu-grp-head { border-top:1px solid var(--line); margin-top:6px; padding-top:8px; }
      /* a subtle flyout title from the group's own label */
      body.nav-collapsed .sidebar > .menu-group > .menu-children::before { content:attr(data-grp); display:block; font-size:12px; font-weight:700; color:var(--ink); padding:6px 10px 8px; border-bottom:1px solid var(--line); margin-bottom:4px; }
    }
    @media (max-width:860px){
      .app { flex-direction:column; }
      .app > main { margin:16px; }
      body:not(.nav-open) .sidebar { display:none; }
      .sidebar { position:fixed; top:0; left:0; bottom:0; width:250px; min-height:100vh; z-index:60; border-right:1px solid var(--line); border-bottom:none; box-shadow:0 0 40px rgba(16,24,40,.25); }
      body.nav-open .backdrop { display:block; position:fixed; inset:0; background:rgba(16,24,40,.4); z-index:55; }
    }
    .card { background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:20px; }
    .card > h2 { font-size:14px; margin:0 0 16px; font-weight:650; }
    .tabs { display:flex; gap:4px; border-bottom:1px solid var(--line); margin-bottom:20px; }
    .tabs[hidden] { display:none; }
    .tab { background:none; border:none; border-bottom:2px solid transparent; border-radius:0; padding:10px 18px; color:var(--muted); font-weight:600; cursor:pointer; }
    .tab:hover { color:var(--ink); } .tab.active { color:var(--accent); border-bottom-color:var(--accent); }
    label { display:block; font-size:13px; font-weight:550; margin-bottom:6px; }
    label .req { color:var(--danger); margin-left:2px; } label .type { color:var(--muted); font-weight:400; font-size:11px; margin-left:6px; }
    .field { margin-bottom:4px; }
    input:not([type]),input[type=text],input[type=search],input[type=email],input[type=password],input[type=number],input[type=date],input[type=datetime-local],textarea,select { width:100%; padding:9px 11px; border:1px solid var(--line); border-radius:8px; font:inherit; color:var(--ink); background:var(--panel); }
    input:disabled, select:disabled, textarea:disabled { background:var(--hover); color:var(--muted); }
    textarea { min-height:84px; resize:vertical; }
    input:focus,textarea:focus,select:focus { outline:2px solid var(--accent); outline-offset:1px; border-color:var(--accent); }
    .help { font-size:12px; color:var(--muted); margin-top:4px; }
    .mic-wrap { position:relative; } .mic-wrap textarea { padding-right:46px; }
    .mic-btn { position:absolute; right:8px; bottom:10px; width:30px; height:30px; padding:0; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:14px; line-height:1; }
    .mic-btn.rec { background:var(--danger); color:#fff; border-color:var(--danger); animation:micpulse 1.1s infinite; }
    @keyframes micpulse { 0%,100%{opacity:1} 50%{opacity:.55} }
    .check { display:flex; align-items:center; gap:8px; padding:8px 0; } .check input { width:16px; height:16px; }
    button { font:inherit; font-weight:550; border-radius:8px; border:1px solid var(--line); background:var(--panel); color:var(--ink); padding:9px 14px; cursor:pointer; }
    button:hover { background:var(--hover); }
    button.primary { background:var(--accent); color:var(--accent-ink); border-color:var(--accent); } button.primary:hover { filter:brightness(.95); }
    button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
    .row { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
    .spacer { flex:1; }
    .section-card { border:1px solid var(--line); border-radius:8px; padding:16px; margin-bottom:16px; background:var(--subtle); }
    .section-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; }
    .section-head h3 { margin:0; font-size:13px; font-weight:650; } .collapse { padding:2px 10px; line-height:1; }
    .section-grid { display:grid; grid-template-columns:repeat(12,minmax(0,1fr)); gap:14px 18px; }
    .section-card { background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:18px 20px; margin-bottom:16px; box-shadow:0 1px 3px rgba(16,24,40,.04); }
    .section-head h3 { display:flex; align-items:center; gap:8px; }
    .sec-ico { display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:7px; background:var(--accent-soft); color:var(--accent); font-size:14px; }
    .form-actions-sticky { position:sticky; bottom:0; background:linear-gradient(to top, var(--bg) 70%, transparent); padding:14px 0 6px; margin-top:8px; display:flex; gap:10px; z-index:20; }
    .portal-summary[hidden] { display:none; }
    .portal-hero-card { background:linear-gradient(120deg,#1e3a8a,#2563eb 65%,#3b82f6); color:#fff; border-radius:14px; padding:18px 22px; margin-bottom:16px; box-shadow:0 10px 26px rgba(37,99,235,.22); }
    .ph-top { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
    .ph-title { font-size:20px; font-weight:800; letter-spacing:-.01em; }
    .ps-chips { display:flex; flex-wrap:wrap; gap:20px; margin-top:12px; }
    .ps-chip { display:flex; flex-direction:column; }
    .ps-lbl { font-size:11px; opacity:.8; text-transform:uppercase; letter-spacing:.04em; }
    .ps-val { font-size:14px; font-weight:600; }
    .ps-totals { display:flex; flex-wrap:wrap; gap:24px; margin-top:14px; padding-top:12px; border-top:1px solid rgba(255,255,255,.25); }
    .ps-total { display:flex; flex-direction:column; }
    .ps-tval { font-size:20px; font-weight:800; }
    .portal-layout .section-card { box-shadow:0 2px 8px rgba(16,24,40,.06); }
    .panel-grid { display:grid; grid-template-columns:repeat(12,minmax(0,1fr)); grid-auto-flow:dense; gap:16px; align-items:start; }
    .panel-grid .section-card { margin-bottom:0; }
    @media (max-width:720px){ .panel-grid { grid-template-columns:1fr; } .panel-grid .section-card { grid-column:1 / -1 !important; grid-row:auto !important; } }
    .lg-host { margin-top:8px; }
    .lg-title { font-size:12px; font-weight:700; color:var(--muted); margin-bottom:4px; }
    .lg-wrap { border:1px solid var(--line); border-radius:8px; overflow:auto; max-height:240px; }
    .lg-table { width:100%; border-collapse:collapse; font-size:12.5px; }
    .lg-table th { text-align:left; background:var(--subtle); padding:6px 10px; position:sticky; top:0; border-bottom:1px solid var(--line); }
    .lg-table td { padding:5px 10px; border-bottom:1px solid var(--line); }

    .grid-toolbar { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:12px; position:relative; }
    .grid-toolbar button { padding:8px 12px; font-size:13px; }
    .col-chooser { position:absolute; top:44px; right:0; z-index:20; background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:12px; box-shadow:0 8px 24px rgba(16,24,40,.12); max-height:300px; overflow:auto; min-width:280px; }
    .col-chooser.chooser-left { left:0; right:auto; }
    .col-chooser .cc-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
    .col-chooser .cc-head strong { font-size:13px; } .col-chooser .cc-close { padding:3px 12px; font-size:12px; }
    .col-chooser .cc-grid { display:grid; grid-template-columns:1fr 1fr; gap:6px 18px; }
    .col-chooser label.cc { display:flex; align-items:center; gap:6px; font-weight:500; margin:0; font-size:13px; white-space:nowrap; }
    .filter-bar { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:10px 14px; margin-bottom:12px; }
    .filter-bar .fb label { font-size:12px; margin-bottom:4px; }
    .frow { display:flex; gap:6px; align-items:center; }
    .frow .fop { width:auto; flex:0 0 auto; }
    .frow .fsep { color:var(--muted); font-size:12px; }
    .frow input { min-width:0; }
    table { width:100%; border-collapse:collapse; font-size:13px; }
    th,td { text-align:left; padding:8px 10px; border-bottom:1px solid var(--line); white-space:nowrap; }
    thead th { color:var(--muted); font-weight:600; background:#fafbfc; position:sticky; top:0; }
    th.sortable { cursor:pointer; user-select:none; } th.sortable:hover { color:var(--ink); } th .arrow { margin-left:6px; color:var(--accent); }
    td.mono, th.mono { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }
    .empty { color:var(--muted); font-size:13px; padding:24px 0; text-align:center; }
    .scroll { overflow:auto; max-height:56vh; border:1px solid var(--line); border-radius:8px; }
    .actions { white-space:nowrap; }
    .icon-btn { width:32px; height:30px; padding:0; display:inline-flex; align-items:center; justify-content:center; border-radius:7px; margin-right:6px; }
    .icon-btn.edit { color:var(--accent); border-color:var(--accent-hover-line); background:var(--accent-soft); } .icon-btn.edit:hover { background:#dde9ff; }
    .icon-btn.del { color:var(--danger); border-color:#f2c7c3; background:#fdeeed; } .icon-btn.del:hover { background:#fbdedb; }
    .pager { display:flex; align-items:center; gap:10px; margin-top:12px; flex-wrap:wrap; }
    .pager button:disabled { opacity:.5; cursor:default; } .pager select { width:auto; padding:6px 8px; } .pager .info { color:var(--muted); font-size:13px; }
    .grid-info { color:var(--muted); font-size:12px; }
    .inline-edit { padding:5px 8px; font-size:12px; border:1px solid var(--line); border-radius:6px; width:auto; min-width:120px; transition:outline .2s; }
    .inline-edit.saved { outline:2px solid var(--ok); outline-offset:1px; }
    .row-open-btn { padding:4px 11px; font-size:12px; margin-right:6px; color:var(--accent); border-color:var(--accent-hover-line); background:var(--accent-soft); }
    .row-open-btn:hover { background:#dde9ff; }
    .form-context { background:#f0f6ff; border:1px solid var(--accent-line); border-radius:10px; padding:14px 16px; margin-bottom:18px; }
    .form-context .fc-title { font-size:12px; font-weight:700; color:var(--accent); text-transform:uppercase; letter-spacing:.03em; margin-bottom:10px; }
    .ctx-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:8px 18px; }
    .ctx-item { display:flex; gap:8px; font-size:13px; }
    .ctx-item .k { color:var(--muted); min-width:120px; font-weight:600; }
    .ctx-item .v { color:var(--ink); }
    .calc-wrap { display:flex; gap:6px; align-items:stretch; }
    .calc-wrap .calc-field { flex:1 1 auto; background:#f6f8fc; font-weight:600; }
    .calc-wrap .calc-btn { flex:0 0 auto; width:38px; padding:0; font-weight:700; color:var(--accent); border-color:var(--accent-hover-line); background:var(--accent-soft); }
    .calc-wrap .calc-btn:hover { background:#dde9ff; }
    #formWarnings { display:flex; flex-direction:column; gap:8px; margin-bottom:16px; }
    #formWarnings:empty { display:none; }
    .warn { padding:10px 14px; border-radius:10px; font-size:13px; border:1px solid; }
    .warn-info { background:var(--accent-soft); border-color:#cfe0ff; color:#1c4e91; }
    .warn-warning { background:#fff7e6; border-color:#ffe1a6; color:#8a5a00; }
    .warn-danger { background:#fdeceb; border-color:#f6c9c5; color:#a11c14; }
    .detail-block { margin-top:22px; border-top:1px solid var(--line); padding-top:18px; }
    .detail-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
    .detail-head h3 { margin:0; font-size:15px; font-weight:600; }
    .detail-scroll { overflow-x:auto; }
    .detail-table { width:100%; border-collapse:collapse; }
    .detail-table th { text-align:left; font-size:12px; color:var(--muted); font-weight:600; padding:6px 8px; white-space:nowrap; }
    .detail-table td { padding:4px 8px; vertical-align:middle; }
    .detail-table td.actions { width:44px; text-align:center; }
    .detail-table input, .detail-table select { width:100%; min-width:120px; padding:6px 8px; }
    .detail-table input[type=checkbox] { width:auto; min-width:0; }
    .detail-table .empty { color:var(--muted); text-align:center; padding:14px; }
    .autofilled { background:#eef6ee !important; color:#2a6a34; }
    .field-invalid { border-color:#e11d48 !important; box-shadow:0 0 0 2px #fde2e7 !important; }
    .field-err { color:#c01a3a; font-size:12px; margin-top:4px; }
    /* ---- auth ---- */
    body.login-mode > header, body.login-mode > .app, body.login-mode > footer { display:none !important; }
    #loginScreen { position:fixed; inset:0; z-index:2000; display:flex; align-items:center; justify-content:center; background:linear-gradient(120deg,#eef2fb,#dfe8fb); }
    #loginScreen[hidden] { display:none; }
    .login-card { width:360px; max-width:92vw; background:var(--panel); border:1px solid var(--line); border-radius:16px; padding:30px 28px; box-shadow:0 20px 50px rgba(16,24,40,.18); }
    .login-brand { display:flex; align-items:center; gap:8px; }
    .login-brand h1 { margin:0; font-size:24px; font-weight:800; letter-spacing:-.02em; }
    .login-sub { color:var(--muted); font-size:13px; margin:4px 0 18px; }
    .login-card label { display:block; font-size:12px; color:var(--muted); font-weight:600; margin:12px 0 4px; }
    .login-card input { width:100%; }
    .login-btn { width:100%; margin-top:18px; padding:11px; font-size:14px; }
    .login-err { color:#c01a3a; font-size:12.5px; margin-top:10px; min-height:16px; }
    .login-foot { text-align:center; color:var(--muted); font-size:11px; margin-top:16px; }
    .user-menu { display:inline-flex; align-items:center; gap:8px; }
    .user-avatar { width:30px; height:30px; border-radius:50%; background:var(--accent); color:#fff; display:inline-flex; align-items:center; justify-content:center; font-size:13px; font-weight:700; flex:0 0 auto; }
    .user-name { font-size:13px; font-weight:600; max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    #logoutBtn { font-size:16px; }
    @media (max-width:860px){ .user-name { display:none; } }
    .form-audit { font-size:12px; color:var(--muted); margin:0 0 14px; padding:8px 12px; background:var(--subtle); border:1px solid var(--line); border-radius:8px; }
    .form-audit[hidden] { display:none; }
    .form-audit { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
    .hist-btn { font-size:12px; padding:4px 12px; color:var(--accent); border-color:var(--accent-hover-line); background:var(--accent-soft); flex:0 0 auto; }
    .hist-overlay { position:fixed; inset:0; z-index:1500; background:rgba(16,24,40,.4); display:flex; align-items:center; justify-content:center; padding:20px; }
    .hist-overlay[hidden] { display:none; }
    .hist-modal { width:640px; max-width:96vw; max-height:82vh; background:var(--panel); border-radius:14px; box-shadow:0 24px 60px rgba(16,24,40,.28); display:flex; flex-direction:column; overflow:hidden; }
    .hist-head { display:flex; align-items:center; justify-content:space-between; padding:14px 18px; border-bottom:1px solid var(--line); }
    .hist-head h3 { margin:0; font-size:15px; }
    .hist-body { overflow-y:auto; padding:12px 18px; }
    .hist-item { padding:12px 0; border-bottom:1px solid var(--line); }
    .hist-item:last-child { border-bottom:none; }
    .hist-line { font-size:13px; color:var(--ink); }
    .hist-badge { display:inline-block; font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.03em; padding:2px 8px; border-radius:6px; margin-right:6px; }
    .hist-badge.ok { background:#e7f6ea; color:#1f7a34; } .hist-badge.info { background:var(--accent-soft); color:#1c4e91; } .hist-badge.danger { background:#fdeceb; color:#a11c14; }
    .hist-ip { color:var(--muted); font-variant-numeric:tabular-nums; }
    .hist-changes { margin-top:8px; padding-left:10px; border-left:2px solid var(--line); display:flex; flex-direction:column; gap:4px; }
    .hist-chg { font-size:12.5px; }
    .hist-f { font-weight:600; color:var(--muted); margin-right:6px; }
    .hist-old { color:#a11c14; text-decoration:line-through; } .hist-new { color:#1f7a34; font-weight:600; } .hist-arrow { color:var(--muted); }
    .al-filters { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:14px; }
    .al-filters select, .al-filters input { width:auto; }
    .al-filters #alQ { flex:1 1 180px; }
    .al-chg { font-size:12px; color:var(--muted); max-width:340px; }
    .al-pager { display:flex; align-items:center; gap:12px; justify-content:center; margin-top:14px; color:var(--muted); font-size:13px; }
    .rl-grid { width:100%; border-collapse:collapse; font-size:13px; }
    .rl-grid th, .rl-grid td { padding:7px 10px; border-bottom:1px solid var(--line); text-align:center; }
    .rl-grid th:first-child, .rl-grid td.rl-res { text-align:left; font-weight:600; }
    .rl-grid thead th { font-size:11px; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); }
    .um-roles { display:flex; flex-wrap:wrap; gap:10px 18px; padding:8px 0; }
    .perm-ro { margin-top:14px; padding:10px 14px; background:#fff7ed; border:1px solid #fed7aa; border-radius:8px; color:#9a3412; font-size:13px; }
    .home-empty { margin:24px 4px; padding:28px; text-align:center; color:var(--muted); background:var(--panel); border:1px dashed var(--line); border-radius:12px; font-size:14px; }
    .view-prompt { display:flex; gap:8px; margin-bottom:12px; }
    .view-prompt .ent-search { flex:1; }
    .pres-dot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:6px; vertical-align:middle; }
    .pres-dot.on { background:#22c55e; box-shadow:0 0 0 3px #22c55e33; } .pres-dot.off { background:#cbd5e1; }
    .pres-chip { position:absolute; top:18px; right:20px; background:rgba(255,255,255,.18); color:#fff; border:1px solid rgba(255,255,255,.3); border-radius:20px; padding:6px 14px; font-size:13px; font-weight:600; backdrop-filter:blur(4px); }
    .pres-chip[hidden] { display:none; }
    .pres-cards { display:flex; gap:14px; margin:14px 0; }
    .pres-card { flex:0 0 auto; min-width:130px; background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:16px 20px; }
    .pres-num { font-size:28px; font-weight:800; color:var(--accent); } .pres-lbl { color:var(--muted); font-size:12px; }
    .pres-kick { font-size:12px; padding:4px 12px; color:#c01a3a; border-color:#f3c9cf; background:#fdf2f4; }
    .pres-kick:hover { background:#fbe3e7; }
    .form-actions-custom { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; padding-top:12px; border-top:1px dashed var(--line); }
    .fa-btn { background:#f4f6fb; border:1px solid var(--line); }
    .fa-btn.primary { background:var(--accent); color:#fff; border-color:var(--accent); }
    .fa-btn.danger { background:#fdf2f4; color:#c01a3a; border-color:#f3c9cf; }
    .sb-act { border:1px solid var(--line); border-radius:10px; padding:12px; margin-bottom:10px; background:#fafbfe; }
    .wf-step { border:1px solid var(--line); border-radius:10px; padding:10px 12px; margin-bottom:8px; background:#fafbfe; }
    .wf-step-h { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
    .wf-step-n { width:24px; height:24px; border-radius:50%; background:var(--accent); color:#fff; display:inline-flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; flex:0 0 auto; }
    .wf-step-cfg { display:flex; gap:12px; flex-wrap:wrap; margin-top:8px; padding-left:32px; }
    .wf-mini { padding:2px 8px; font-size:12px; }
    .form-workflow[hidden] { display:none; }
    .wf-panel { border:1px solid var(--line); border-radius:10px; padding:12px 14px; margin-bottom:14px; background:var(--subtle); }
    .wf-panel-h { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:8px; }
    .wf-steps-list { display:flex; flex-direction:column; gap:6px; }
    .wf-srow { display:flex; align-items:center; gap:8px; padding:6px 0; border-top:1px solid var(--line); }
    .wf-sn { width:20px; height:20px; border-radius:50%; background:#e8f0ff; color:var(--accent); display:inline-flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; flex:0 0 auto; }
    .wf-sbody { flex:1; font-size:13px; }
    .wf-act { display:flex; gap:8px; margin-top:10px; }
    .wf-lock { margin:8px 0; padding:8px 12px; background:#fff7ed; border:1px solid #fed7aa; border-radius:8px; color:#9a3412; font-size:12.5px; }
    .wf-recall { font-size:12.5px; padding:6px 12px; color:#92400e; border-color:#fcd9a8; background:#fff7ed; }
    .inbox-btn { position:relative; font-size:16px; }
    .inbox-badge { position:absolute; top:-4px; right:-4px; background:#e11d48; color:#fff; border-radius:10px; font-size:10px; font-weight:700; min-width:16px; height:16px; line-height:16px; text-align:center; padding:0 4px; }
    .inbox-badge[hidden] { display:none; }
    .ibx-item { display:flex; align-items:center; gap:10px; padding:12px 0; border-bottom:1px solid var(--line); }
    .ibx-item:last-child { border-bottom:none; }
    .ibx-main { flex:1; }
    .ibx-title { font-size:13.5px; font-weight:600; }
    .ibx-actions { display:flex; gap:6px; flex:0 0 auto; }
    .ibx-actions button { font-size:12px; padding:5px 10px; }
    .ibx-rej { color:#c01a3a; border-color:#f3c9cf; background:#fdf2f4; }
    .apv-cards { display:flex; gap:12px; flex-wrap:wrap; margin:14px 0; }
    .apv-card { flex:1 1 120px; min-width:110px; background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:14px 16px; }
    .apv-n { font-size:26px; font-weight:800; color:var(--accent); } .apv-l { color:var(--muted); font-size:11.5px; }
    .apv-tabs { display:flex; gap:6px; border-bottom:1px solid var(--line); margin:8px 0 14px; }
    .apv-tab { background:none; border:none; border-bottom:2px solid transparent; border-radius:0; padding:8px 14px; font-size:13px; color:var(--muted); cursor:pointer; }
    .apv-tab.active { color:var(--accent); border-bottom-color:var(--accent); font-weight:600; }
    .apv-age { display:inline-block; font-size:11px; font-weight:700; padding:2px 8px; border-radius:6px; }
    .age-new { background:var(--accent-soft); color:#1c4e91; } .age-mid { background:#fff7ed; color:#9a3412; } .age-old { background:#fdeceb; color:#a11c14; }
    .apv-view { font-size:12px; padding:4px 10px; }
    .notif-btn { position:relative; font-size:16px; }
    .notif-panel { position:absolute; top:56px; right:20px; width:340px; max-height:70vh; overflow-y:auto; background:var(--panel); border:1px solid var(--line); border-radius:12px; box-shadow:0 16px 40px rgba(16,24,40,.2); z-index:1400; }
    .notif-panel[hidden] { display:none; }
    .notif-head { padding:12px 14px; font-weight:700; font-size:13px; border-bottom:1px solid var(--line); }
    .notif-item { padding:11px 14px; border-bottom:1px solid var(--line); cursor:pointer; }
    .notif-item:hover { background:var(--subtle); }
    .notif-item.unread { background:#f0f6ff; }
    .notif-title { font-size:13px; font-weight:600; }
    .notif-body { font-size:12px; color:var(--muted); margin-top:2px; }
    .notif-time { font-size:11px; color:var(--muted); margin-top:4px; }
    .img-field { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
    .img-preview { width:90px; height:90px; border:1px solid var(--line); border-radius:8px; display:flex; align-items:center; justify-content:center; overflow:hidden; background:var(--subtle); cursor:pointer; }
    .img-preview img { width:100%; height:100%; object-fit:cover; }
    .img-empty { font-size:11px; color:var(--muted); }
    .img-btn { font-size:12px; padding:6px 12px; border:1px solid var(--line); border-radius:8px; background:var(--panel); cursor:pointer; }
    .img-clear { font-size:12px; padding:6px 10px; color:#c01a3a; border-color:#f3c9cf; background:#fdf2f4; }
    .img-cam { font-size:12px; padding:6px 12px; border:1px solid var(--line); border-radius:8px; background:var(--panel); cursor:pointer; }
    .cam-modal { position:fixed; inset:0; z-index:3200; background:rgba(0,0,0,.85); display:flex; align-items:center; justify-content:center; padding:20px; }
    .cam-modal[hidden] { display:none; }
    .cam-box { background:#111; border-radius:12px; padding:12px; max-width:96vw; }
    .cam-box video { width:min(640px,90vw); max-height:70vh; border-radius:8px; display:block; background:#000; }
    .cam-actions { display:flex; gap:10px; justify-content:center; margin-top:10px; }
    .form-attach[hidden] { display:none; }
    .att-panel { border:1px solid var(--line); border-radius:10px; padding:12px 14px; margin-bottom:14px; background:var(--subtle); }
    .att-head { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
    .att-badge { background:var(--accent); color:#fff; border-radius:10px; font-size:11px; font-weight:700; padding:1px 8px; }
    .att-add { margin-left:auto; font-size:12px; padding:6px 12px; border:1px solid var(--line); border-radius:8px; background:var(--panel); cursor:pointer; }
    .att-grid { display:flex; flex-wrap:wrap; gap:10px; }
    .att-item { width:120px; border:1px solid var(--line); border-radius:8px; background:var(--panel); padding:8px; position:relative; }
    .att-face { height:64px; display:flex; align-items:center; justify-content:center; cursor:pointer; border-radius:6px; overflow:hidden; background:#eef2f7; }
    .att-thumb { width:100%; height:100%; object-fit:cover; }
    .att-ico { font-size:32px; }
    .att-meta { margin-top:6px; display:flex; flex-direction:column; }
    .att-name { font-size:11.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:var(--accent); text-decoration:none; }
    .att-size { font-size:10.5px; color:var(--muted); }
    .att-del { position:absolute; top:4px; right:4px; width:20px; height:20px; padding:0; border-radius:50%; background:rgba(255,255,255,.9); border:1px solid var(--line); color:#c01a3a; font-size:12px; line-height:1; cursor:pointer; }
    .qr-field { display:flex; align-items:center; gap:10px; }
    .qr-canvas { width:96px; height:96px; display:flex; align-items:center; justify-content:center; border:1px solid var(--line); border-radius:8px; background:var(--panel); }
    .qr-canvas img { width:100%; height:100%; }
    .qr-empty { font-size:11px; color:var(--muted); }
    .qr-print { font-size:12px; padding:6px 12px; border:1px solid var(--line); border-radius:8px; background:var(--panel); cursor:pointer; }
    .scan-wrap { display:flex; gap:6px; align-items:center; }
    .scan-wrap input { flex:1; }
    .scan-btn { flex:0 0 auto; width:34px; padding:0; font-size:15px; border:1px solid var(--line); border-radius:8px; background:var(--panel); cursor:pointer; }
    .cam-hint { color:#ccc; text-align:center; font-size:12px; margin-top:8px; }
    .imp-actions { display:flex; gap:10px; margin:12px 0; }
    .imp-map { width:100%; border-collapse:collapse; font-size:13px; }
    .imp-map th, .imp-map td { padding:6px 8px; border-bottom:1px solid var(--line); text-align:left; }
    .imp-map select { width:100%; }
    .imp-summary { display:flex; gap:8px; margin:12px 0; }
    .imp-fails { font-size:12px; color:#a11c14; background:#fdf2f4; border:1px solid #f3c9cf; border-radius:8px; padding:10px; margin-bottom:12px; max-height:200px; overflow-y:auto; }
    .tp-cols { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
    @media (max-width:820px){ .tp-cols { grid-template-columns:1fr; } }
    .tp-card { border:1px solid var(--line); border-radius:12px; padding:16px; background:var(--panel); }
    .tp-card h3 { margin:0 0 10px; font-size:14px; }
    .tp-toggles { display:flex; flex-direction:column; gap:6px; font-size:13px; }
    .tp-ents { max-height:260px; overflow-y:auto; border:1px solid var(--line); border-radius:8px; padding:8px; }
    .tp-ent { display:block; font-size:13px; padding:4px 2px; }
    .tp-table { width:100%; border-collapse:collapse; font-size:13px; }
    .tp-table td { padding:5px 8px; border-bottom:1px solid var(--line); }
    .tp-add { color:#1f7a34; font-weight:600; }
    .sb-err-banner { display:flex; align-items:flex-start; gap:10px; justify-content:space-between; background:#fdeceb; border:1px solid #f5b5b0; color:#a11c14; border-radius:10px; padding:12px 14px; margin-bottom:14px; font-size:13px; line-height:1.5; }
    .sb-err-banner button { flex:0 0 auto; background:none; border:none; color:#a11c14; font-size:14px; cursor:pointer; padding:0 4px; }
    .sb-ai { border:1px dashed var(--line); border-radius:10px; padding:12px 14px; margin:10px 0 14px; }
    .sb-ai label { display:block; font-size:13px; margin-bottom:6px; }
    .sb-ai textarea { width:100%; box-sizing:border-box; font:inherit; }
    .sb-ai-bar { display:flex; gap:10px; align-items:center; margin-top:8px; }
    .sb-ai-notes { margin-top:8px; font-size:13px; line-height:1.5; }
    .g-file { display:flex; gap:8px; align-items:center; white-space:nowrap; }
    .g-file a { text-decoration:none; }
    .grid-thumb { width:36px; height:36px; object-fit:cover; border-radius:6px; border:1px solid var(--line); cursor:pointer; vertical-align:middle; }
    .lightbox { position:fixed; inset:0; z-index:3000; background:rgba(0,0,0,.8); display:flex; align-items:center; justify-content:center; padding:30px; cursor:zoom-out; }
    .lightbox[hidden] { display:none; }
    .lightbox img { max-width:92vw; max-height:88vh; border-radius:8px; box-shadow:0 20px 60px rgba(0,0,0,.5); }
    .grid-host + .grid-host { margin-top:10px; }
    .ftabwrap { }
    .ftabs { display:flex; gap:4px; flex-wrap:wrap; border-bottom:1px solid var(--line); margin-bottom:16px; }
    .ftab { background:none; border:none; border-bottom:2px solid transparent; border-radius:0; padding:9px 16px; font-size:13px; color:var(--muted); cursor:pointer; display:inline-flex; align-items:center; gap:8px; }
    .ftab:hover { color:var(--ink); }
    .ftab.active { color:var(--accent); border-bottom-color:var(--accent); font-weight:600; }
    .fsteps { gap:0; }
    .fsteps .ftab { flex:1; justify-content:center; border-bottom:2px solid var(--line); }
    .fstep-n { display:inline-flex; align-items:center; justify-content:center; width:22px; height:22px; border-radius:50%; background:#eef1f6; color:var(--muted); font-size:12px; font-weight:700; }
    .fsteps .ftab.active .fstep-n { background:var(--accent); color:#fff; }
    .fstep-nav { display:flex; justify-content:space-between; margin-top:16px; padding-top:14px; border-top:1px solid var(--line); }
    .md-toolbar { display:flex; gap:10px; align-items:center; margin-bottom:12px; }
    .md-toolbar .ent-search { flex:1; margin:0; }
    .md-table { width:100%; border-collapse:collapse; }
    .md-table thead th { text-align:left; font-size:12px; color:var(--muted); font-weight:600; padding:8px 10px; border-bottom:1px solid var(--line); }
    .md-row > td { padding:9px 10px; border-bottom:1px solid var(--line); }
    .md-caret { background:none; border:none; cursor:pointer; color:var(--muted); font-size:11px; transition:transform .15s; padding:2px; }
    .md-caret.open { transform:rotate(90deg); color:var(--accent); }
    .md-child-row > td { background:var(--subtle); padding:0; }
    .md-child { padding:12px 16px 16px 44px; }
    .md-child-title { font-size:12px; font-weight:700; color:var(--accent); text-transform:uppercase; letter-spacing:.03em; margin-bottom:8px; }
    .md-child-table { width:100%; border-collapse:collapse; background:var(--panel); border:1px solid var(--line); border-radius:8px; overflow:hidden; }
    .md-child-table th { text-align:left; font-size:11px; color:var(--muted); font-weight:600; padding:6px 10px; background:var(--thead); border-bottom:1px solid var(--line); }
    .md-child-table td { padding:6px 10px; font-size:13px; border-bottom:1px solid var(--line); }
    .md-child-table tr:last-child td { border-bottom:none; }
    .md-child .muted, .md-toolbar .muted { color:var(--muted); font-size:12px; }
    /* ---- portal dashboard ---- */
    .portal-hero { position:relative; background:linear-gradient(120deg,#1e3a8a,#2563eb 60%,#3b82f6); color:#fff; border-radius:16px; padding:30px 32px; margin-bottom:22px; box-shadow:0 12px 30px rgba(37,99,235,.20); }
    .portal-hero h2 { margin:0; font-size:24px; font-weight:700; }
    .portal-hero p { margin:6px 0 0; color:#dbe6ff; font-size:14px; }
    .portal-hero .home-welcome { color:#eaf1ff; }
    .kpi-row { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:14px; margin-bottom:26px; }
    .kpi-card { display:flex; align-items:center; gap:14px; background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:16px 18px; cursor:pointer; text-align:left; font:inherit; transition:box-shadow .15s, transform .15s, border-color .15s; }
    .kpi-card:hover { box-shadow:0 8px 22px rgba(16,24,40,.10); transform:translateY(-2px); border-color:var(--accent-hover-line); }
    .kpi-ico { width:46px; height:46px; border-radius:12px; background:var(--accent-soft); color:var(--accent); display:flex; align-items:center; justify-content:center; flex:0 0 auto; }
    .kpi-ico svg { width:22px; height:22px; }
    .kpi-body { display:flex; flex-direction:column; min-width:0; }
    .kpi-num { font-size:26px; font-weight:750; line-height:1.1; color:var(--ink); }
    .kpi-label { font-size:12.5px; color:var(--muted); margin-top:2px; }
    .recent-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr)); gap:14px; }
    .recent-card { border:1px solid var(--line); border-radius:12px; padding:12px 14px; background:var(--panel); }
    .recent-head { display:flex; align-items:center; gap:8px; font-size:12px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; margin-bottom:8px; }
    .recent-head svg { width:15px; height:15px; }
    .recent-item { display:block; width:100%; text-align:left; background:none; border:none; padding:6px 8px; border-radius:7px; cursor:pointer; font:inherit; font-size:13px; color:var(--ink); }
    .recent-item:hover { background:var(--hover); color:var(--accent); }
    /* ---- dashboard widgets ---- */
    .widget-grid { display:grid; grid-template-columns:repeat(12,1fr); gap:16px; margin-bottom:26px; }
    .widget { grid-column:span 4; background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:16px 18px; min-height:120px; display:flex; flex-direction:column; }
    .widget-s { grid-column:span 3; } .widget-m { grid-column:span 4; } .widget-l { grid-column:span 6; } .widget-w { grid-column:span 8; } .widget-xl { grid-column:span 12; }
    @media (max-width:900px){ .widget, .widget-s, .widget-m, .widget-l, .widget-w, .widget-xl { grid-column:span 12; } }
    .widget-head { font-size:13px; font-weight:700; color:var(--ink); margin-bottom:10px; cursor:pointer; }
    .widget-head:hover { color:var(--accent); }
    .widget-body { flex:1; display:flex; flex-direction:column; justify-content:center; }
    .wdg-bignum { font-size:34px; font-weight:750; color:var(--accent); background:none; border:none; cursor:pointer; text-align:left; padding:0; font-family:inherit; }
    .wdg-table { width:100%; border-collapse:collapse; }
    .wdg-table th { text-align:left; font-size:11px; color:var(--muted); font-weight:600; padding:4px 6px; border-bottom:1px solid var(--line); }
    .wdg-table td { padding:5px 6px; font-size:12.5px; border-bottom:1px solid var(--line); }
    .wdg-table tr:last-child td { border-bottom:none; }
    .wdg-bars { display:flex; flex-direction:column; gap:7px; }
    .wdg-bar-row { display:flex; align-items:center; gap:8px; font-size:12px; }
    .wdg-bar-label { flex:0 0 90px; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    .wdg-bar-track { flex:1; height:14px; background:#eef1f6; border-radius:7px; overflow:hidden; }
    .wdg-bar-fill { display:block; height:100%; border-radius:7px; }
    .wdg-bar-val { flex:0 0 auto; color:var(--muted); font-weight:600; }
    .wdg-chart-row { display:flex; gap:14px; align-items:center; }
    .wdg-pie { width:130px; height:130px; flex:0 0 auto; }
    .wdg-legend { display:flex; flex-direction:column; gap:4px; font-size:12px; }
    .wdg-leg span { display:inline-block; width:10px; height:10px; border-radius:2px; margin-right:6px; }
    .wdg-line { width:100%; height:auto; }
    .widget .muted { color:var(--muted); font-size:12px; }
    /* ---- reports ---- */
    .rp-report { background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:0; overflow:hidden; }
    .rp-bar { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:16px 20px; border-bottom:1px solid var(--line); flex-wrap:wrap; }
    .rp-table-wrap { overflow-x:auto; }
    .rp-table { width:100%; border-collapse:collapse; font-size:13px; }
    .rp-table th { text-align:left; font-size:11px; color:var(--muted); font-weight:700; padding:8px 12px; border-bottom:2px solid var(--line); background:var(--thead); white-space:nowrap; }
    .rp-table td { padding:7px 12px; border-bottom:1px solid var(--line); }
    .rp-table td.num, .rp-table th.num { text-align:right; }
    .rp-grp td { background:var(--accent-soft); font-weight:700; color:var(--accent); font-size:12px; }
    .rp-sub td { background:var(--subtle); font-weight:600; }
    .rp-grand td { background:#eaf1ff; font-weight:750; border-top:2px solid var(--accent); }
    .rp-modebar { display:inline-flex; border:1px solid var(--line); border-radius:9px; overflow:hidden; margin-bottom:14px; }
    .rp-mode { background:var(--panel); border:none; border-radius:0; padding:8px 16px; font-size:13px; color:var(--muted); cursor:pointer; }
    .rp-mode + .rp-mode { border-left:1px solid var(--line); }
    .rp-mode.active { background:var(--accent-soft); color:var(--accent); font-weight:600; }
    .rp-table tfoot .rp-foot td { background:#eaf1ff; border-top:2px solid var(--accent); font-weight:750; position:sticky; bottom:0; }
    @media print {
      header, .sidebar, .backdrop, footer, #footer, .app > .sidebar { display:none !important; }
      .app > main { margin:0 !important; }
      .rp-bar div:last-child { display:none !important; }
      .rp-report { border:none; }
    }
    input.autofilled { cursor:not-allowed; }
    .studio-shell { display:flex; gap:0; background:var(--panel); border:1px solid var(--line); border-radius:14px; overflow:hidden; min-height:70vh; }
    .studio-nav { flex:0 0 210px; background:var(--subtle); border-right:1px solid var(--line); padding:14px 10px; overflow-y:auto; }
    .snav-group { margin-bottom:14px; }
    .snav-head { display:block; font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); padding:4px 10px; }
    .studio-nav .stab { display:block; width:100%; text-align:left; background:none; border:none; border-radius:8px; padding:8px 10px; font-size:13px; color:var(--ink); cursor:pointer; margin-top:2px; }
    .studio-nav .stab:hover { background:#eef2f7; }
    .studio-nav .stab.active { background:#e8f0ff; color:var(--accent); font-weight:600; }
    .studio-main { flex:1; padding:22px 24px; overflow-x:auto; min-width:0; }
    @media (max-width:760px){ .studio-shell { flex-direction:column; } .studio-nav { flex:none; border-right:none; border-bottom:1px solid var(--line); display:flex; flex-wrap:wrap; gap:4px; } .snav-group { margin:0; } .snav-head { width:100%; } }
    .sb-note { color:var(--muted); font-size:12.5px; margin:0 0 16px; }
    .sb-editbar { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:14px; padding-bottom:14px; border-bottom:1px dashed var(--line); }
    .sb-editbar select { width:auto; min-width:220px; }
    .ent-list-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:4px; }
    .ent-search { width:100%; margin-bottom:8px; }
    .ent-count { font-size:12px; color:var(--muted); margin-bottom:10px; }
    .ent-list { display:flex; flex-direction:column; gap:8px; }
    .ent-row { display:flex; align-items:center; gap:12px; border:1px solid var(--line); border-radius:10px; padding:12px 14px; background:var(--thead); }
    .ent-row:hover { border-color:var(--accent-hover-line); }
    .ent-main { flex:1; min-width:0; }
    .ent-name { font-size:14px; font-weight:600; }
    .ent-code { font-size:12px; color:var(--muted); font-weight:400; margin-left:6px; }
    .ent-meta { font-size:12px; color:var(--muted); margin-top:2px; }
    .ent-dates { font-size:11px; color:var(--muted); margin-top:2px; }
    .ent-edit { flex:0 0 auto; }
    .ent-toolbar { display:flex; gap:10px; align-items:center; margin-bottom:8px; }
    .ent-toolbar .ent-search { flex:1; margin:0; }
    .ent-views { display:inline-flex; border:1px solid var(--line); border-radius:8px; overflow:hidden; flex:0 0 auto; }
    .ent-vbtn { border:none; background:var(--panel); padding:7px 10px; cursor:pointer; color:var(--muted); display:inline-flex; align-items:center; border-radius:0; }
    .ent-vbtn + .ent-vbtn { border-left:1px solid var(--line); }
    .ent-vbtn svg { width:16px; height:16px; }
    .ent-vbtn:hover { background:var(--hover); color:var(--ink); }
    .ent-vbtn.active { background:var(--accent-soft); color:var(--accent); }
    .ent-listmode { display:flex; flex-direction:column; gap:2px; }
    .ent-litem { display:flex; align-items:center; gap:10px; width:100%; text-align:left; background:none; border:none; border-radius:8px; padding:8px 10px; cursor:pointer; font:inherit; }
    .ent-litem:hover { background:var(--hover); }
    .ent-li-ico { width:18px; height:18px; color:var(--muted); flex:0 0 auto; display:inline-flex; }
    .ent-li-ico svg { width:18px; height:18px; }
    .ent-li-name { font-weight:600; font-size:13px; flex:0 0 auto; }
    .ent-li-sub { font-size:12px; color:var(--muted); }
    .ent-tiles { display:grid; grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:12px; }
    .ent-tile { display:flex; flex-direction:column; align-items:flex-start; gap:6px; border:1px solid var(--line); border-radius:12px; padding:16px; background:var(--thead); cursor:pointer; font:inherit; text-align:left; }
    .ent-tile:hover { border-color:var(--accent-hover-line); box-shadow:0 4px 14px rgba(16,24,40,.10); }
    .ent-tile-ico { width:32px; height:32px; border-radius:9px; background:var(--accent-soft); color:var(--accent); display:inline-flex; align-items:center; justify-content:center; }
    .ent-tile-ico svg { width:18px; height:18px; }
    .ent-tile-name { font-weight:600; font-size:13px; line-height:1.25; }
    .ent-tile-sub { font-size:11px; color:var(--muted); }
    .mb-tree { display:flex; flex-direction:column; gap:6px; }
    .mb-node { }
    .mb-row { display:flex; gap:8px; align-items:center; padding:8px; border:1px solid var(--line); border-radius:9px; background:var(--thead); flex-wrap:wrap; }
    .mb-group > .mb-row { background:var(--accent-soft); border-color:var(--accent-line); }
    .mb-badge { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--accent); background:var(--panel); border:1px solid var(--accent-line); border-radius:6px; padding:2px 6px; flex:0 0 auto; }
    .mb-badge.item { color:var(--muted); border-color:var(--line); }
    .mb-label { flex:1 1 140px; min-width:120px; }
    .mb-row select { width:auto; min-width:96px; }
    .mb-ctrls { display:flex; gap:3px; margin-left:auto; flex:0 0 auto; }
    .mb-ctrls button { width:30px; height:30px; padding:0; }
    .mb-children { margin-left:20px; border-left:2px solid var(--line); padding-left:10px; margin-top:6px; display:flex; flex-direction:column; gap:6px; }
    .mb-add { display:flex; gap:6px; }
    .mb-add button { background:none; border:1px dashed var(--line); color:var(--accent); font-size:12px; padding:5px 10px; border-radius:8px; cursor:pointer; }
    .mb-add-root { margin-top:6px; }
    .lv-cols { display:flex; flex-direction:column; gap:6px; }
    .lv-col { display:flex; align-items:center; gap:12px; border:1px solid var(--line); border-radius:9px; padding:8px 12px; background:var(--thead); }
    .lv-col-name { flex:1; font-size:13px; font-weight:600; }
    .lv-ctx { display:flex; flex-wrap:wrap; gap:6px 16px; }
    .ss-wrap { position:relative; }
    .ss-btn { width:100%; text-align:left; background:var(--panel); border:1px solid var(--line); border-radius:9px; padding:9px 28px 9px 12px; font:inherit; color:var(--ink); cursor:pointer; position:relative; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    .ss-btn:after { content:'▾'; position:absolute; right:10px; top:50%; transform:translateY(-50%); color:var(--muted); font-size:11px; }
    .ss-btn.ss-ph { color:var(--muted); }
    .ss-btn:disabled { background:var(--hover); color:var(--muted); cursor:not-allowed; }
    .ss-panel { position:fixed; z-index:1000; background:var(--panel); border:1px solid var(--line); border-radius:10px; box-shadow:0 12px 32px rgba(16,24,40,.18); padding:6px; max-height:300px; display:flex; flex-direction:column; }
    .ss-panel[hidden] { display:none; }
    .ss-search { width:100%; margin-bottom:6px; padding:7px 10px; flex:0 0 auto; }
    .ss-list { overflow-y:auto; flex:1 1 auto; min-height:0; }
    .ss-opt { padding:8px 10px; border-radius:7px; cursor:pointer; font-size:13px; }
    .ss-opt:hover { background:var(--hover); }
    .ss-opt.sel { background:var(--accent-soft); color:var(--accent); font-weight:600; }
    .ss-none { padding:10px; color:var(--muted); font-size:13px; text-align:center; }
    .detail-table .ss-btn { min-width:120px; padding:6px 26px 6px 8px; }
    .sb-head { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:12px; margin-bottom:16px; }
    .sb-head label, .sb-ref label, .sb-extra-t { display:block; font-size:11px; color:var(--muted); font-weight:600; margin-bottom:4px; }
    .sb-fields-head { display:flex; align-items:center; justify-content:space-between; margin:18px 0 10px; }
    .sb-fields-head h3 { margin:0; font-size:14px; }
    .sb-field { border:1px solid var(--line); border-radius:10px; padding:10px; margin-bottom:10px; background:var(--thead); }
    .sb-field-main { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
    .sb-field-main > input, .sb-field-main > select { flex:1 1 150px; min-width:120px; }
    .sb-field-main > input[type=color] { flex:0 0 44px; min-width:44px; width:44px; height:38px; }
    .sb-chk { display:inline-flex; align-items:center; gap:4px; font-size:12px; color:var(--muted); flex:0 0 auto; }
    .sb-chk input { width:auto; }
    .sb-field-btns { display:flex; gap:4px; flex:0 0 auto; }
    .sb-field-btns button { width:32px; height:32px; padding:0; }
    .sb-extra { margin-top:10px; padding-top:10px; border-top:1px dashed var(--line); }
    .sb-ref { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:8px; }
    .sb-opt { display:flex; gap:6px; margin-bottom:6px; }
    .sb-opt input { flex:1; }
    .sb-opt-del { width:32px; flex:0 0 auto; }
    .sb-opt-add, .sb-adv summary { cursor:pointer; }
    .sb-adv { margin:8px 0 4px; }
    .sb-adv summary { font-size:13px; color:var(--accent); padding:6px 0; }
    .sb-more { margin-top:10px; padding-top:8px; border-top:1px dashed var(--line); }
    .sb-more-sum { cursor:pointer; font-size:12px; color:var(--accent); font-weight:600; }
    .sb-colname { font-size:12px; color:var(--muted); margin:8px 0 2px; }
    .sb-colname code { background:#eef1f6; padding:2px 7px; border-radius:6px; color:var(--ink); font-size:12px; }
    .sb-colnote { font-size:11px; color:var(--muted); }
    .sb-actions { display:flex; align-items:center; gap:10px; margin-top:18px; padding-top:16px; border-top:1px solid var(--line); flex-wrap:wrap; }
    .sb-ok { color:var(--ok); font-size:13px; font-weight:600; }
    .sb-sec-row { display:flex; gap:8px; align-items:center; margin-bottom:8px; flex-wrap:wrap; }
    .sb-sec-row > input { flex:1 1 140px; }
    .sb-sec-del, .sb-rule-del { width:32px; flex:0 0 auto; }
    .sb-rule { border:1px solid var(--line); border-radius:10px; padding:10px; margin-bottom:10px; background:var(--thead); }
    .sb-rule-head { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:8px; }
    .sb-rule-head > input, .sb-rule-head > select { flex:1 1 150px; width:auto; min-width:120px; }
    .sb-conds { padding-left:6px; border-left:2px solid var(--line); }
    .sb-cond { display:flex; gap:6px; align-items:center; margin-bottom:6px; flex-wrap:wrap; }
    .sb-cond > select, .sb-cond > input { flex:1 1 120px; min-width:100px; }
    .sb-cond-del { width:30px; flex:0 0 auto; }
    .sb-cond-add, .sb-opt-add { background:none; border:1px dashed var(--line); color:var(--accent); font-size:12px; padding:5px 10px; border-radius:8px; }
    .toast { position:fixed; right:20px; bottom:20px; padding:12px 16px; border-radius:8px; font-size:13px; color:#fff; opacity:0; transform:translateY(8px); transition:opacity .2s,transform .2s; pointer-events:none; max-width:420px; z-index:50; }
    .toast.show { opacity:1; transform:translateY(0); } .toast.ok { background:var(--ok); } .toast.err { background:var(--danger); }
    @media (max-width:720px){ .section-grid { grid-template-columns:1fr; } .field[style]{ grid-column:1 / -1 !important; } .col-chooser { left:0; right:auto; } .col-chooser .cc-grid { grid-template-columns:1fr; } main { padding:0 12px; } .card { padding:14px; } }

/* ---------- Workflow Phase 4: SLA, escalation, delegation ---------- */
.wf-sla { display:flex; flex-direction:column; gap:10px; margin:8px 0 16px; }
.wf-sla-row { display:flex; flex-wrap:wrap; gap:12px; align-items:flex-end; border:1px solid var(--line); border-radius:10px; padding:10px 12px; background:var(--subtle); }
.wf-sla-t { font-weight:700; font-size:12.5px; min-width:90px; align-self:center; }
.apv-card-warn { border-color:#f3b7b2; background:#fff6f5; } .apv-card-warn .apv-n { color:#a11c14; }
.apv-banner { background:var(--accent-soft); color:#1c4e91; border:1px solid #cddcf6; border-radius:10px; padding:9px 12px; margin:10px 0 0; font-size:13px; }
.apv-banner-out { background:#fff7ed; color:#9a3412; border-color:#f5d7b5; }
.apv-sub { font-size:11px; color:var(--muted); margin-top:2px; }
.apv-flag { display:inline-block; font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.03em; padding:1px 6px; border-radius:5px; background:#fdf2e7; color:#9a3412; margin-left:4px; }
tr.apv-overdue td { background:#fff8f7; }
.apv-nudge, .ap-nudge, .ap-reassign, .dg-cancel { font-size:12px; padding:4px 10px; }
.apv-nudge[disabled] { opacity:.5; cursor:not-allowed; }
.dg-form { border:1px solid var(--line); border-radius:12px; padding:12px 14px; background:var(--panel); margin-bottom:12px; }
.dg-title { font-weight:700; margin-bottom:8px; }
.dg-grid { display:flex; flex-wrap:wrap; gap:12px; align-items:flex-end; }
.dg-grid label { display:block; font-size:11.5px; color:var(--muted); margin-bottom:3px; }
.ap-bar { display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:10px; }

/* ---------- Save bar at the very bottom (after lines) + sections after detail grids ---------- */
#form #formDetail:empty { display:none; }
#form #formDetail { margin:6px 0 4px; }
.after-lines { margin-top:10px; }
.after-lines .section-grid input[readonly], .after-lines .calc-field { font-weight:700; text-align:right; }
.detail-table tfoot .detail-foot td { background:var(--accent-soft); border-top:2px solid var(--accent); font-weight:750; padding:7px 10px; }
.detail-table tfoot td.num { text-align:right; white-space:nowrap; }
.form-actions-sticky { z-index:5; box-shadow:0 -6px 12px -10px rgba(0,0,0,.25); }
