:root {
    --primary: var(--brand-primary); --primary-600: var(--brand-primary-600); --primary-700: var(--brand-primary-700);
    --primary-300: var(--brand-primary-300); --primary-50: var(--brand-primary-50);
    --grad: var(--brand-gradient);
    --grad-soft: var(--brand-gradient-soft);
    --bg: #F6F5FB; --surface: #FFFFFF; --border: #ECEAF3; --border-strong: #E0DCEE;
    --text: var(--brand-ink); --text-muted: #625E6E; --text-subtle: #9691A1;
    --green: #16A34A; --green-bg: #E9F8EF; --red: #DC2626; --red-bg: #FDECEC;
    --amber: #D97706; --amber-bg: #FEF3E2; --slate: #64748B; --slate-bg: #EEF1F6;
    --blue: #2563EB; --blue-bg: #E7EEFD;
    --radius: 14px; --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,.06), 0 2px 6px rgba(0,0,0,.04);
    --shadow-lg: 0 12px 40px rgba(46,15,157,.14);
    --sidebar-w: 256px;
    font-family: var(--font-brand), "Poppins", system-ui, sans-serif;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; }
  body { background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
  .legacy-boot-splash {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(246,245,251,.96), rgba(246,245,251,.985));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, visibility .18s ease;
    z-index: 2000;
  }
  .legacy-boot-card {
    min-width: 220px;
    padding: 22px 24px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.92);
    box-shadow: 0 24px 60px rgba(46,15,157,.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  .legacy-boot-spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid #E9E2FB;
    border-top-color: var(--primary);
    animation: legacy-spin .8s linear infinite;
  }
  .legacy-boot-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -.01em;
  }
  @keyframes legacy-spin {
    to { transform: rotate(360deg); }
  }
  body.legacy-booting [data-legacy-page="admin"] .app {
    visibility: hidden;
  }
  body.legacy-booting [data-legacy-page="admin"] .legacy-boot-splash {
    opacity: 1;
    visibility: visible;
  }
  button { font-family: inherit; cursor: pointer; border: none; background: none; }
  a { color: inherit; text-decoration: none; }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: #DDD8EA; border-radius: 8px; border: 3px solid var(--bg); }

  .app { display: flex; height: 100vh; overflow: hidden; }

  /* sidebar */
  .sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--brand-ink); color: #D7D3DF; display: flex; flex-direction: column; height: 100%; }
  .logo { display: flex; align-items: center; gap: 11px; padding: 22px 20px 18px; }
  .sidebar-logo-img { display: block; width: auto; height: 44px; max-width: 126px; object-fit: contain; flex-shrink: 1; }
  .logo-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; flex-shrink: 0; }
  .logo-mark svg { width: 21px; height: 21px; color: #fff; }
  .logo-name { font-size: 18px; font-weight: 800; letter-spacing: -.02em; color: #fff; }
  .logo-name b { color: var(--primary-300); }
  .admin-tag { font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; background: rgba(175,160,250,.18); color: var(--primary-300); padding: 3px 7px; border-radius: 6px; margin-left: 2px; }
  .nav { flex: 1; overflow-y: auto; padding: 6px 14px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; scrollbar-color: rgba(175,160,250,.72) rgba(255,255,255,.04); }
  .nav::-webkit-scrollbar { width: 6px; }
  .nav::-webkit-scrollbar-track { background: rgba(255,255,255,.035); border-radius: 999px; }
  .nav::-webkit-scrollbar-thumb { background: linear-gradient(180deg, rgba(216,205,255,.92), rgba(168,85,247,.78)); border-radius: 999px; border: 1px solid rgba(0,0,0,.7); }
  .nav::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #ECE7FF, #B66BFF); }
  .nav-label { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #6E678C; padding: 14px 12px 6px; }
  .nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); color: #B7B0CE; font-size: 14px; font-weight: 600; text-align: left; transition: background .14s, color .14s; }
  .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
  .nav-item .badge-n { margin-left: auto; font-size: 11px; font-weight: 800; background: var(--red); color: #fff; border-radius: 20px; padding: 1px 7px; }
  .nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
  .nav-item.active { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(74,27,240,.36); }
  .nav-group { display: flex; flex-direction: column; gap: 2px; }
  .nav-parent .nav-chev { width: 15px; height: 15px; margin-left: auto; transition: transform .16s ease; }
  .nav-group.open .nav-chev { transform: rotate(180deg); }
  .nav-sub { display: none; margin: 2px 0 4px 18px; padding-left: 12px; border-left: 1px solid rgba(175,160,250,.2); }
  .nav-group.open .nav-sub { display: flex; flex-direction: column; gap: 2px; }
  .nav-subitem { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 8px 10px; border-radius: 9px; color: #AFA7CA; font-size: 13px; font-weight: 650; text-align: left; }
  .nav-subitem span { width: 6px; height: 6px; border-radius: 50%; background: #6E678C; flex-shrink: 0; }
  .nav-subitem:hover { background: rgba(255,255,255,.06); color: #fff; }
  .nav-subitem.active { background: rgba(74,27,240,.18); color: #fff; }
  .nav-subitem.active span { background: var(--primary-300); box-shadow: 0 0 0 4px rgba(175,160,250,.12); }
  .sidebar-bottom { padding: 12px 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
  .backapp { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm); color: #B7B0CE; font-weight: 600; font-size: 13.5px; }
  .backapp:hover { background: rgba(255,255,255,.06); color: #fff; }
  .backapp svg { width: 17px; height: 17px; }
  .admin-card { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(255,255,255,.05); }
  .admin-card .av { width: 34px; height: 34px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; overflow: hidden; }
  .admin-card .av.has-img { background-size: cover; background-position: center; color: transparent; }
  .admin-card .an { font-size: 13px; font-weight: 700; color: #fff; }
  .admin-card .ar { font-size: 11.5px; color: #8B83A8; }

  /* main */
  .main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; }
  .topbar { height: 66px; flex-shrink: 0; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 0 32px; }
  .menu-btn { display: none; }
  .page-title { font-size: 20px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
  .page-sub { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-top: 1px; white-space: nowrap; }
  .topbar > div:first-of-type { flex-shrink: 0; }
  .search { margin-left: 14px; flex: 1; max-width: 380px; display: flex; align-items: center; gap: 9px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 9px 13px; color: var(--text-subtle); }
  .search svg { width: 16px; height: 16px; }
  .search input { border: none; background: none; outline: none; flex: 1; font-family: inherit; font-size: 13.5px; color: var(--text); }
  .topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; position: relative; }
  .icon-btn { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: var(--text-muted); position: relative; }
  .icon-btn svg { width: 19px; height: 19px; }
  .icon-btn:hover { background: var(--primary-50); color: var(--primary); }
  .icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 2px solid var(--surface); }
  .icon-btn .dot[hidden] { display: none; }
  .admin-profile-wrap { position: relative; }
  .av-btn { width: 38px; height: 38px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }
  .av-btn.has-img, .avatar.has-img, .avatar-lg.has-img { background-size: cover; background-position: center; color: transparent; }
  .avatar { width: 34px; height: 34px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; }
  .dropdown { position: absolute; top: 48px; right: 0; width: 252px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 7px; opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity .16s, transform .16s, visibility .16s; z-index: 50; }
  .dropdown.show { opacity: 1; visibility: visible; transform: translateY(0); }
  .dd-head { padding: 11px 12px 12px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
  .dd-head .dd-avatar { width: 40px; height: 40px; border-radius: 11px; font-size: 15px; }
  .dd-head .pn { font-size: 14px; font-weight: 700; }
  .dd-head .pe { font-size: 12px; color: var(--text-muted); }
  .dd-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; border-radius: 9px; color: var(--text-muted); font-size: 13.5px; font-weight: 600; text-align: left; }
  .dd-item svg { width: 17px; height: 17px; }
  .dd-item:hover { background: var(--primary-50); color: var(--text); }
  .dd-item.danger:hover { background: var(--red-bg); color: var(--red); }
  .dd-sep { height: 1px; background: var(--border); margin: 6px 4px; }

  .content { flex: 1; overflow-y: auto; padding: 26px 32px 80px; }
  .content.unibox-content { overflow: hidden; padding-bottom: 0; }
  .view { display: none; animation: fade .25s ease; }
  .view.active { display: block; }
  @keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

  .row { display: flex; align-items: center; gap: 12px; }
  .btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px; font-weight: 700; font-size: 13.5px; transition: transform .12s, box-shadow .12s, background .14s; }
  .btn svg { width: 16px; height: 16px; }
  .btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(74,27,240,.26); }
  .btn-primary:hover { transform: translateY(-1px); }
  .btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
  .btn-ghost:hover { background: var(--bg); border-color: var(--primary-300); color: var(--primary); }
  .btn-danger { background: var(--red-bg); color: var(--red); }
  .btn-danger:hover { background: #FBDAD9; }

  /* KPI cards */
  .kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
  .kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
  .kpi .top { display: flex; align-items: center; justify-content: space-between; }
  .kpi .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; }
  .kpi .ic svg { width: 19px; height: 19px; }
  .kpi .delta { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
  .delta.up { background: var(--green-bg); color: var(--green); }
  .delta.down { background: var(--red-bg); color: var(--red); }
  .kpi .num { font-size: 27px; font-weight: 800; letter-spacing: -.02em; margin-top: 14px; }
  .kpi .lab { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

  .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
  .card-head { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
  .card-head h3 { font-size: 15.5px; font-weight: 700; }
  .card-head p { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
  .grid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }

  /* chart */
  .chart { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding: 20px; }
  .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
  .bar { width: 100%; max-width: 26px; border-radius: 7px 7px 0 0; background: var(--grad); transition: opacity .14s; min-height: 4px; }
  .bar-col:hover .bar { opacity: .82; }
  .bar-x { font-size: 11px; color: var(--text-subtle); font-weight: 600; }

  /* table */
  .tbl-wrap { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { width: 100%; border-collapse: collapse; }
  thead th { text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-subtle); padding: 12px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; }
  tbody td { padding: 13px 20px; border-bottom: 1px solid var(--border); font-size: 13.5px; white-space: nowrap; }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr:hover { background: var(--bg); }
  .u-cell { display: flex; align-items: center; gap: 11px; }
  .u-av { width: 34px; height: 34px; border-radius: 9px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
  .u-av.has-img { background-size: cover; background-position: center; color: transparent; }
  .u-name { font-weight: 700; }
  .u-email { font-size: 12px; color: var(--text-muted); }
  .muted { color: var(--text-muted); }
  .mono { font-family: ui-monospace, Menlo, monospace; font-weight: 600; }

  .pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 20px; font-size: 12px; font-weight: 700; }
  .pill svg { width: 13px; height: 13px; }
  .pill.green { background: var(--green-bg); color: var(--green); }
  .pill.red { background: var(--red-bg); color: var(--red); }
  .pill.amber { background: var(--amber-bg); color: var(--amber); }
  .pill.slate { background: var(--slate-bg); color: var(--slate); }
  .pill.blue { background: var(--blue-bg); color: var(--blue); }
  .pill.purple { background: var(--primary-50); color: var(--primary); }
  .cat-pill { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
  .cat-pill.ev { background: var(--primary-50); color: var(--primary); }
  .cat-pill.ca { background: var(--amber-bg); color: var(--amber); }

  .actions { display: flex; align-items: center; gap: 7px; }
  .a-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 12.5px; font-weight: 700; color: var(--text); cursor: pointer; }
  .a-btn svg { width: 14px; height: 14px; }
  .a-btn:hover { border-color: var(--primary-300); color: var(--primary); background: var(--primary-50); }
  .a-btn.danger:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }
  .a-icon { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; color: var(--text-muted); cursor: pointer; }
  .a-icon svg { width: 15px; height: 15px; }
  .a-icon:hover { border-color: var(--primary-300); color: var(--primary); background: var(--primary-50); }

  /* search box in card */
  .tsearch { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; color: var(--text-subtle); width: 250px; }
  .tsearch svg { width: 15px; height: 15px; }
  .tsearch input { border: none; background: none; outline: none; flex: 1; font-family: inherit; font-size: 13px; color: var(--text); }
  .users-kpis { margin-bottom: 14px; }
  .users-kpi { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr); grid-template-areas: "icon value" "label label" "copy copy"; align-items: center; column-gap: 12px; overflow: hidden; padding: 14px 18px 15px; }
  .users-kpi::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--primary); }
  .users-kpi-primary::after { background: var(--primary); }
  .users-kpi-green::after { background: var(--green); }
  .users-kpi-blue::after { background: var(--blue); }
  .users-kpi-amber::after { background: var(--amber); }
  .users-kpi .top { grid-area: icon; }
  .users-kpi .num { grid-area: value; margin-top: 0; font-size: 25px; line-height: 1; }
  .users-kpi .lab { grid-area: label; margin-top: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: 11px; }
  .users-kpi p { grid-area: copy; color: var(--text-subtle); font-size: 11.5px; margin-top: 5px; }
  .users-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-width: 0; }
  .users-toolbar-main { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
  .users-toolbar-main .tsearch { flex: 0 0 220px; width: 220px; background: var(--surface); }
  .users-toolbar-main .seg-ctrl { max-width: 100%; min-width: 0; overflow-x: auto; flex: 1 1 auto; }
  .users-toolbar-main .seg-btn { padding-left: 9px; padding-right: 9px; font-size: 12px; white-space: nowrap; }
  .users-toolbar-main .seg-n { display: none; }
  .users-toolbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; white-space: nowrap; }
  .users-toolbar-actions .btn, .users-toolbar-actions .a-btn { height: 38px; min-height: 38px; padding-top: 0; padding-bottom: 0; white-space: nowrap; }
  .users-table-head { padding-top: 14px; padding-bottom: 14px; }
  .users-table { min-width: 1320px; }
  .verification-pill-button { display: inline-flex; padding: 2px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; }
  .verification-pill-button:hover .pill { box-shadow: 0 0 0 3px var(--primary-50); }
  .verification-pill-button:focus-visible { outline: 3px solid var(--primary-300); outline-offset: 2px; }
  .users-actions-heading { text-align: center; }
  .users-actions-cell { text-align: center; }
  .users-actions { justify-content: center; }

  /* pager */
  .pager { display: flex; align-items: center; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); gap: 12px; flex-wrap: wrap; }
  .pager .info { font-size: 13px; color: var(--text-muted); font-weight: 600; }
  .pager .pages { display: flex; align-items: center; gap: 6px; }
  .pager .pg { min-width: 30px; height: 30px; padding: 0 7px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); box-shadow: 0 6px 16px rgba(20, 2, 42, .05); font-size: 12px; font-weight: 700; color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: .18s ease; }
  .pager .pg svg { width: 13px; height: 13px; }
  .pager .pg:hover:not(:disabled):not(.active) { border-color: var(--primary-300); color: var(--primary); background: var(--primary-50); }
  .pager .pg.active { background: var(--grad); color: #fff; border-color: transparent; }
  .pager .pg:disabled { opacity: .4; cursor: not-allowed; }
  .pager .pg-input { width: 48px; height: 30px; border-radius: 9px; border: 1px solid var(--primary-300); background: var(--surface); color: var(--text); box-shadow: 0 6px 16px rgba(20, 2, 42, .05); font: inherit; font-size: 14px; font-weight: 800; text-align: center; outline: none; transition: .18s ease; }
  .pager .pg-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-50), 0 8px 20px rgba(20, 2, 42, .08); }

  /* breakdown bars */
  .progressbar { height: 8px; background: var(--bg); border-radius: 20px; overflow: hidden; }
  .progressbar i { display: block; height: 100%; border-radius: 20px; }

  /* modal */
  .modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 100; opacity: 0; visibility: hidden; transition: opacity .18s, visibility .18s; padding: 24px; }
  .modal-overlay.show { opacity: 1; visibility: visible; }
  .modal { width: 560px; max-width: 100%; max-height: 88vh; background: var(--surface); border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.32); display: flex; flex-direction: column; overflow: hidden; transform: translateY(10px) scale(.985); transition: transform .18s; }
  .modal-overlay.show .modal { transform: none; }
  .modal-head { padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
  .modal-head h3 { font-size: 17px; font-weight: 800; }
  .modal-head p { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
  .modal-body { padding: 22px; overflow-y: auto; }
  .modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--bg); flex-wrap: wrap; }
  .job-download-foot { align-items: center; justify-content: space-between; background: linear-gradient(90deg, var(--primary-50), var(--surface)); gap: 14px; }
  .download-foot-copy { display: flex; flex: 1 1 260px; min-width: 0; flex-direction: column; gap: 3px; }
  .download-foot-copy span { color: var(--primary); font-size: 11px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
  .download-foot-copy strong { color: var(--text); font-size: 13px; font-weight: 700; line-height: 1.35; }
  .download-foot-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
  .download-foot-actions .btn, .download-foot-actions .a-btn { white-space: nowrap; }
  .uc-ic { width: 40px; height: 40px; border-radius: 11px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; flex-shrink: 0; }
  .uc-ic svg { width: 20px; height: 20px; }
  .kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-top: 4px; }
  .kv .cell { padding: 13px 16px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
  .kv .cell:nth-child(2n) { border-right: none; }
  .kv .k { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-subtle); }
  .kv .v { font-size: 14.5px; font-weight: 700; margin-top: 4px; }
  .fld { margin-bottom: 14px; }
  .fld label { display: block; font-size: 12px; font-weight: 700; color: var(--text-subtle); margin-bottom: 6px; }
  .fld input, .fld select { width: 100%; border: 1.5px solid var(--border-strong); border-radius: 10px; padding: 11px 13px; font-family: inherit; font-size: 14px; color: var(--text); outline: none; background: var(--surface); }
  .fld input:focus, .fld select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .avatar-lg { width: 64px; height: 64px; border-radius: 16px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px; flex-shrink: 0; }
  .verification-status-modal { width: 470px; }
  .verification-confirm-prompt { color: var(--text); font-size: 14px; font-weight: 650; line-height: 1.65; }
  .verification-status-message { display: none; margin-top: 12px; font-size: 12.5px; font-weight: 700; }

  /* ticket thread */
  .tk-msg { display: flex; gap: 11px; margin-bottom: 16px; }
  .tk-msg .av { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
  .tk-msg.user .av { background: var(--primary-50); color: var(--primary); }
  .tk-msg.admin .av { background: var(--grad); color: #fff; }
  .tk-who { font-size: 12.5px; font-weight: 700; }
  .tk-time { font-size: 11px; color: var(--text-subtle); font-weight: 600; }
  .tk-bubble { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; margin-top: 5px; }
  .tk-msg.admin .tk-bubble { background: var(--primary-50); border-color: #E4DCFB; }
  .tk-text { font-size: 13.5px; line-height: 1.55; }
  .tk-reply { width: 100%; border: 1.5px solid var(--border-strong); border-radius: 10px; padding: 11px 13px; font-family: inherit; font-size: 14px; color: var(--text); resize: vertical; min-height: 72px; outline: none; }
  .tk-reply:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }

  /* Match the customer support modal's compact chrome and roomy composer. */
  #ticketModal .modal-head { padding: 13px 18px; }
  #ticketModal .modal-head > .row { min-width: 0; gap: 10px; }
  #ticketModal .modal-head .uc-ic { width: 38px; height: 38px; min-width: 38px; border-radius: 11px; }
  #ticketModal .modal-head .uc-ic svg { width: 18px; height: 18px; }
  #ticketModal .modal-head h3 { font-size: 16px; line-height: 1.25; }
  #ticketModal .modal-head p { font-size: 11.5px; line-height: 1.3; margin-top: 1px; }
  #ticketModal .modal-head > .icon-btn { width: 34px; height: 34px; min-width: 34px; }
  #ticketModal .modal-foot { padding: 12px 18px 14px; gap: 8px !important; }
  #ticketModal #tkReply { min-height: 120px; padding: 13px 14px; line-height: 1.55; }
  #ticketModal #tkAttach,
  #ticketModal #tkResolve,
  #ticketModal #tkClose2,
  #ticketModal #tkSend {
    min-height: 36px;
    padding: 7px 12px;
    border-radius: 9px;
    font-size: 12.5px;
  }
  #ticketModal #tkAttach svg,
  #ticketModal #tkResolve svg,
  #ticketModal #tkSend svg { width: 15px; height: 15px; }

  /* package cards */
  .pkg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .pkg { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
  .pkg.popular { border-color: var(--primary); box-shadow: var(--shadow-lg); }
  .pkg .pk-name { font-weight: 700; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
  .pkg .pk-price { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 2px; }
  .pkg .pk-credits { font-size: 13px; font-weight: 700; color: var(--primary); }
  .pkg .pk-meta { font-size: 12.5px; color: var(--text-muted); margin-top: 12px; line-height: 1.7; border-top: 1px solid var(--border); padding-top: 12px; }

  .empty { padding: 50px; text-align: center; color: var(--text-muted); }
  .sb-backdrop { display: none; }
  @media (max-width: 980px) {
    .grid-2 { grid-template-columns: 1fr; }
    .kpis { grid-template-columns: 1fr 1fr; }
    .pkg-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
  }
  @media (max-width: 860px) {
    .menu-btn { display: grid !important; flex-shrink: 0; }
    .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform .25s; }
    .sidebar.open { transform: none; }
    .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; opacity: 0; visibility: hidden; transition: opacity .2s; }
    .sb-backdrop.show { opacity: 1; visibility: visible; }
    .search { display: none; }
    .page-sub { display: none; }
    .content { padding: 18px 16px 80px; overflow-x: hidden; }
    .topbar { padding: 0 16px; gap: 10px; }
    .topbar > div:first-of-type { min-width: 0; }
    .topbar-right, .topbar-right .icon-btn, .admin-profile-wrap { flex-shrink: 0; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    #paymentConnectionDetails { grid-template-columns: 1fr !important; }
    #view-settings-payment .row { flex-wrap: wrap; }
    #view-settings-payment .row > .fld { min-width: 100%; }
  }

  @media (max-width: 520px) {
    .topbar { padding: 0 10px; gap: 6px; }
    .page-title { max-width: 54vw; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
    .topbar-right { gap: 2px; }
    .content { padding: 14px 10px 72px; }
    .kpis { grid-template-columns: minmax(0, 1fr) !important; }
    .card, .view, .grid-2, .ml { min-width: 0; max-width: 100%; }
    .card-head { align-items: stretch; flex-direction: column; padding: 16px; }
    .card-head > * { width: 100%; min-width: 0; }
    .card-head > .row, .toolbar { flex-wrap: wrap; }
    .card-head .btn, .card-head .tsearch { width: 100%; justify-content: center; }
    .tsearch { width: 100%; min-width: 0; }
    .tsearch input { min-width: 0; }
    .tbl-wrap { overflow-x: scroll; scrollbar-gutter: stable; }
    .pager { justify-content: center; padding: 12px 14px; }
    .pager .pages { max-width: 100%; overflow-x: auto; padding: 2px; }
    .pager .pg { min-width: 28px; height: 28px; border-radius: 8px; }
    .pager .pg-input { width: 44px; height: 28px; border-radius: 8px; font-size: 13px; }
    .seg-ctrl { max-width: 100%; overflow-x: auto; }
    .seg-btn { min-height: 38px; flex-shrink: 0; }
    .users-toolbar { align-items: stretch; flex-direction: column; }
    .users-toolbar-main { align-items: stretch; flex-direction: column; }
    .users-toolbar-main .tsearch { flex-basis: auto; width: 100%; }
    .users-toolbar-main .seg-ctrl { width: 100%; }
    .users-toolbar-actions { width: 100%; overflow-x: auto; padding-bottom: 2px; }
    .users-toolbar-actions .btn, .users-toolbar-actions .a-btn { flex: 1 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; justify-content: center; gap: 5px; font-size: 11.5px; }
    .users-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
    .users-kpi { padding: 12px 14px 13px; }
    .users-kpi .num { font-size: 22px; }
    .users-kpi .lab { margin-top: 9px; }
    .users-kpi p { display: none; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .modal-overlay { align-items: flex-end; padding: 10px; }
    .modal { width: 100%; max-height: calc(100dvh - 20px); border-radius: 18px 18px 12px 12px; }
    .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
    .modal-foot .btn { flex: 1; justify-content: center; }
    .job-download-foot { align-items: stretch; }
    .download-foot-copy { flex-basis: 100%; text-align: center; }
    .download-foot-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
    .download-foot-actions .btn, .download-foot-actions .a-btn { width: 100%; min-width: 0; justify-content: center; padding-left: 8px; padding-right: 8px; font-size: 12px; }
    .download-foot-actions #jrDownload { grid-column: 1 / -1; }
    .verification-status-modal .modal-foot { justify-content: flex-end; }
    .verification-status-modal .modal-foot .btn { flex: 0 0 auto; white-space: nowrap; }
    #ticketModal .modal-head { padding: 11px 14px; }
    #ticketModal .modal-foot { padding: 10px 14px 12px; }
    #ticketModal #tkReply { min-height: 132px; }
    #ticketModal #tkAttach,
    #ticketModal #tkResolve,
    #ticketModal #tkClose2,
    #ticketModal #tkSend {
      min-height: 34px;
      padding: 6px 9px;
      font-size: 12px;
    }
    .et-toolbar { flex-wrap: wrap; }
    .payment-save-state { padding: 14px; }
    .payment-saved-at, .payment-save-actions { padding-left: 0; }
    .payment-save-actions .btn { width: 100%; justify-content: center; }
  }

  @media (max-width: 360px) {
    .topbar-right > .icon-btn { display: none; }
    .page-title { max-width: 58vw; font-size: 15px; }
    .content { padding-left: 8px; padding-right: 8px; }
    .card-head { padding: 14px; }
  }

  .payment-mode-panel { display:flex;align-items:center;justify-content:space-between;gap:18px;padding:16px;border:1px solid var(--border);border-radius:14px;background:linear-gradient(135deg,var(--surface-alt),var(--surface));margin-bottom:16px; }
  .payment-mode-title { color:var(--text);font-size:14px;font-weight:800; }
  .payment-mode-copy { color:var(--text-muted);font-size:12.5px;line-height:1.5;margin-top:3px;max-width:580px; }
  .payment-mode-toggle { display:inline-flex;gap:4px;padding:4px;border:1px solid var(--border);border-radius:12px;background:var(--surface);box-shadow:var(--shadow-xs);flex-shrink:0; }
  .payment-mode-btn { display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:38px;padding:8px 13px;border:0;border-radius:9px;background:transparent;color:var(--text-muted);font:inherit;font-size:12.5px;font-weight:800;cursor:pointer;transition:background .18s,color .18s,box-shadow .18s; }
  .payment-mode-btn svg { width:16px;height:16px; }
  .payment-mode-btn.active { background:var(--grad);color:#fff;box-shadow:0 6px 16px rgba(153,0,255,.2); }
  .payment-key-row .fld small { display:block;color:var(--text-muted);font-size:11.5px;line-height:1.45;margin-top:6px; }
  .payment-save-state { display:flex;align-items:center;gap:12px;padding:14px 16px;border:1px solid var(--border);border-radius:14px;margin-bottom:16px;transition:background .18s,border-color .18s; }
  .payment-save-state.neutral { background:var(--surface-alt); }
  .payment-save-state.saved { background:rgba(16,185,129,.08);border-color:rgba(16,185,129,.25); }
  .payment-save-state.dirty { background:rgba(245,158,11,.09);border-color:rgba(245,158,11,.28); }
  .payment-save-icon { width:38px;height:38px;border-radius:11px;display:grid;place-items:center;flex-shrink:0;background:var(--surface);color:var(--text-muted);box-shadow:var(--shadow-xs); }
  .payment-save-state.saved .payment-save-icon { color:var(--green); }
  .payment-save-state.dirty .payment-save-icon { color:#d97706; }
  .payment-save-icon svg { width:21px;height:21px;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round; }
  .payment-save-content { min-width:0;flex:1; }
  .payment-save-title { color:var(--text);font-size:13.5px;font-weight:800; }
  .payment-save-detail { color:var(--text-muted);font-size:12px;line-height:1.5;margin-top:2px; }
  .payment-saved-at { color:var(--text-muted);font-size:11.5px;font-weight:700;white-space:nowrap; }
  .payment-save-actions { display:flex;align-items:flex-end;flex-direction:column;gap:8px;flex-shrink:0; }
  .payment-edit-btn { background:var(--surface) !important; }
  .payment-key-label { display:flex !important;align-items:center;justify-content:space-between;gap:10px; }
  .credential-badge { display:inline-flex;align-items:center;border-radius:999px;padding:3px 8px;font-size:10.5px;font-weight:800;letter-spacing:.01em; }
  .credential-badge.saved { color:var(--green);background:rgba(16,185,129,.1); }
  .credential-badge.missing { color:#d97706;background:rgba(245,158,11,.12); }
  .credential-badge.checking { color:var(--text-muted);background:var(--surface-alt); }
  #paymentSaveBtn.save-confirmed { background:var(--green);box-shadow:0 8px 20px rgba(16,185,129,.22); }
  #view-settings-payment input.payment-masked:disabled { background:var(--surface-alt);color:var(--text);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-weight:800;letter-spacing:.08em;opacity:1;-webkit-text-fill-color:var(--text); }
  .payment-mode-btn:disabled { cursor:not-allowed;opacity:.72; }
  .limit-grid { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px; }
  .limit-card { border:1px solid var(--border);border-radius:18px;background:linear-gradient(180deg,var(--surface),var(--surface-alt));padding:18px;box-shadow:var(--shadow-xs); }
  .limit-title { display:flex;align-items:center;gap:12px;margin-bottom:16px; }
  .limit-title h4 { margin:0;color:var(--text);font-size:17px;font-weight:900; }
  .limit-title p { margin:3px 0 0;color:var(--text-muted);font-size:12.5px;line-height:1.45; }
  .limit-row { display:grid !important;grid-template-columns:1fr;gap:12px !important; }
  .limit-card .fld { margin:0; }
  .limit-card .fld small { display:block;color:var(--text-muted);font-size:11.5px;line-height:1.45;margin-top:6px; }
  .limit-note { display:flex;align-items:flex-start;gap:9px;margin-top:16px;padding:13px 14px;border:1px solid var(--border);border-radius:14px;background:rgba(153,0,255,.055);color:var(--text-muted);font-size:12.5px;line-height:1.55; }
  .limit-note svg { width:17px;height:17px;color:var(--primary);flex-shrink:0;margin-top:1px; }
  @media (max-width: 980px) {
    .limit-grid { grid-template-columns:1fr; }
  }
  @media (max-width: 760px) {
    .payment-mode-panel { align-items:stretch;flex-direction:column; }
    .payment-mode-toggle { width:100%; }
    .payment-mode-btn { flex:1; }
    .payment-save-state { align-items:flex-start;flex-wrap:wrap; }
    .payment-saved-at { width:100%;padding-left:50px;white-space:normal; }
    .payment-save-actions { width:100%;align-items:flex-start;padding-left:50px; }
  }
  @media (max-width: 520px) {
    .payment-saved-at, .payment-save-actions { padding-left:0; }
    .payment-save-actions .btn { width:100%;justify-content:center; }
  }
  .cost-step { display: flex; align-items: center; gap: 10px; }
  .cs-btn { width: 42px; height: 46px; border: 1.5px solid var(--border-strong); border-radius: 10px; display: grid; place-items: center; color: var(--text-muted); cursor: pointer; }
  .cs-btn:hover { border-color: var(--primary-300); color: var(--primary); background: var(--primary-50); }
  .cs-btn svg { width: 16px; height: 16px; }
  .cost-step input { width: 88px; text-align: center; font-size: 22px; font-weight: 800; border: 1.5px solid var(--border-strong); border-radius: 10px; padding: 9px; outline: none; font-family: inherit; color: var(--text); }
  .cost-step input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
  .cs-unit { font-size: 13px; font-weight: 600; color: var(--text-muted); }

  .ml { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
  .ml-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
  .ml-item { padding: 13px 16px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; gap: 11px; align-items: center; }
  .ml-item:last-child { border-bottom: none; }
  .ml-item:hover { background: var(--bg); }
  .ml-item.active { background: var(--primary-50); }
  .ml-item .mi-ic { width: 34px; height: 34px; border-radius: 9px; background: var(--bg); display: grid; place-items: center; color: var(--text-muted); flex-shrink: 0; }
  .ml-item .mi-ic svg { width: 16px; height: 16px; }
  .ml-item.active .mi-ic { background: var(--primary); color: #fff; }
  .ml-item .mi-t { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ml-item .mi-s { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ubx-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
  .switch { position: relative; width: 42px; height: 24px; border-radius: 20px; background: var(--border-strong); cursor: pointer; transition: background .15s; flex-shrink: 0; }
  .switch.on { background: var(--green); }
  .switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
  .switch.on::after { left: 21px; }
  .var-chip { display: inline-flex; align-items: center; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; font-weight: 700; background: var(--primary-50); color: var(--primary); border: 1px solid #E4DCFB; border-radius: 7px; padding: 4px 9px; cursor: pointer; }
  .var-chip:hover { background: #ECE6FB; }
  @media (max-width: 860px) { .ml { grid-template-columns: 1fr; } }
  /* blog editor */
  .blog-editor-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; border: 1px solid var(--border); background: linear-gradient(135deg, var(--primary-50), #fff); border-radius: 10px; padding: 9px 11px; margin-bottom: 10px; color: var(--text-muted); font-size: 12px; font-weight: 700; }
  .blog-editor-meta span:first-child { color: var(--primary); font-family: ui-monospace, Menlo, monospace; word-break: break-word; }
  .editor-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; border: 1.5px solid var(--border-strong); border-bottom: none; border-radius: 10px 10px 0 0; padding: 7px 9px; background: var(--bg); }
  .et-btn { width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; color: var(--text-muted); cursor: pointer; }
  .et-text { font-size: 11px; font-weight: 800; font-family: inherit; }
  .et-btn:hover { background: var(--primary-50); color: var(--primary); }
  .et-btn svg { width: 16px; height: 16px; }
  .et-sep { width: 1px; height: 20px; background: var(--border-strong); margin: 0 4px; }
  .editor { border: 1.5px solid var(--border-strong); border-radius: 0 0 10px 10px; padding: 14px 15px; min-height: 220px; font-size: 14px; line-height: 1.6; color: var(--text); outline: none; overflow-y: auto; max-height: 380px; }
  .editor:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
  .editor:empty::before { content: attr(data-placeholder); color: var(--text-subtle); }
  .editor h3 { font-size: 17px; font-weight: 700; margin: 10px 0 4px; }
  .editor h2 { font-size: 22px; font-weight: 800; margin: 14px 0 6px; }
  .editor p { margin: 6px 0; }
  .editor ul, .editor ol { margin: 6px 0 6px 22px; }
  .editor blockquote { border-left: 4px solid var(--primary); background: var(--primary-50); border-radius: 0 10px 10px 0; margin: 12px 0; padding: 12px 14px; font-weight: 600; color: var(--text); }
  .editor hr { border: 0; height: 1px; background: var(--border-strong); margin: 16px 0; }
  .editor a { color: var(--primary); }
  .blog-row { display: flex; align-items: center; gap: 13px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .blog-row:last-child { border-bottom: none; }
  .blog-row .bp-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; flex-shrink: 0; }
  .blog-row .bp-ic svg { width: 18px; height: 18px; }
  .blog-row .bp-t { font-weight: 700; font-size: 13.5px; line-height: 1.3; }
  .blog-row .bp-m { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
  .blog-row .bp-act { display: flex; gap: 6px; margin-left: auto; flex-shrink: 0; }
  .seg-ctrl { display: inline-flex; gap: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
  .seg-btn { padding: 8px 16px; border-radius: 7px; font-size: 13px; font-weight: 700; color: var(--text-muted); cursor: pointer; }
  .seg-btn.active { background: var(--grad); color: #fff; box-shadow: 0 4px 12px rgba(74,27,240,.24); }
  .exp-wrap { position: relative; }
  .exp-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 11px; box-shadow: var(--shadow-md); padding: 6px; min-width: 180px; z-index: 30; display: none; }
  .exp-menu.show { display: block; }
  .exp-menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; background: none; }
  .exp-menu button:hover { background: var(--primary-50); color: var(--primary); }
  .api-toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
  .api-toggle .at-t { font-weight: 700; font-size: 14px; }
  .api-toggle .at-s { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
  .ep-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
  .ep-row:last-child { border-bottom: none; }
  .ep-verb { font-family: ui-monospace, Menlo, monospace; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 6px; color: #fff; flex-shrink: 0; }
  .ep-verb.get { background: var(--green); }
  .ep-verb.post { background: var(--primary); }
  .ep-path { font-family: ui-monospace, Menlo, monospace; font-size: 13px; font-weight: 600; flex: 1; }
  .ep-up { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
  .ep-down { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
  .wh-row { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
  .wh-row:last-child { border-bottom: none; }
  .wh-url { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; font-weight: 600; flex: 1; word-break: break-all; }
  .wh-ev { font-size: 11px; font-weight: 700; color: var(--text-muted); }

  .invoice-billing-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(140,0,232,.07), rgba(74,27,240,.04));
  }
  .invoice-billing-preview h4 {
    margin: 4px 0 5px;
    font-size: 18px;
    letter-spacing: -.02em;
    color: var(--text);
  }
  .invoice-billing-preview p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.55;
    overflow-wrap: anywhere;
  }
  .invoice-billing-preview-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    border: 1px solid rgba(140,0,232,.18);
    background: var(--surface);
    color: var(--primary);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 10px 26px rgba(140,0,232,.08);
  }
  .invoice-billing-preview-badge svg { width: 15px; height: 15px; }

  .pv-stage { background: #f6f5fb; border: 1px solid var(--border); border-radius: 12px; padding: 20px; display: flex; justify-content: center; }
  .pv-frame { width: 100%; transition: max-width .2s; }
  .pv-frame.mobile { max-width: 360px; }
  .pv-email { background: #fff; border: 1px solid #ece7f5; border-radius: 14px; overflow: hidden; }
  .pv-top { background: #4a1bf0; color: #fff; padding: 20px 24px; display: flex; align-items: center; gap: 10px; font-weight: 800; }
  .pv-mk { width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.18); display: grid; place-items: center; }
  .pv-mk svg { width: 17px; height: 17px; }
  .pv-logo { display: block; width: 126px; height: auto; }
  .pv-bd { padding: 24px; }
  .pv-subj { color: #201334; font-size: 24px; line-height: 1.3; font-weight: 800; letter-spacing: -.01em; margin-bottom: 16px; }
  .pv-text { font-size: 14px; color: #5f557a; line-height: 1.7; }
  .pv-text p { margin: 0 0 16px; padding: 0; }
  .pv-text ul { margin: 0 0 16px; padding: 0 0 0 22px; }
  .pv-text li { margin: 0 0 6px; padding: 0; }
  .pv-text a { color: #4a1bf0; text-decoration: underline; overflow-wrap: anywhere; word-break: break-word; }
  .pv-cta { display: inline-block; margin: 6px 0 4px; background: #4a1bf0; color: #fff; font-weight: 700; font-size: 14px; line-height: 20px; padding: 12px 22px; border-radius: 9px; }
  .pv-attach { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--bg); font-size: 13px; font-weight: 700; color: var(--text); }
  .pv-attach svg { width: 17px; height: 17px; color: var(--red); }
  .pv-attach span:first-of-type { flex: 1; }
  .pv-attach .pv-attach-sz { font-size: 10.5px; font-weight: 800; color: var(--text-subtle); background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; }
  .pv-foot { padding: 16px 24px; border-top: 1px solid #ece7f5; font-size: 11px; color: #7a7295; line-height: 1.55; }
  .pv-frame.mobile .pv-top { padding: 18px 20px; }
  .pv-frame.mobile .pv-bd { padding: 22px 20px; }
  .pv-frame.mobile .pv-subj { font-size: 22px; line-height: 1.28; }
  .pv-frame.mobile .pv-foot { padding: 15px 20px; }
  .attach-chip { display: inline-flex; align-items: center; gap: 9px; background: var(--primary-50); border: 1px solid #E4DCFB; border-radius: 9px; padding: 8px 11px; font-size: 13px; font-weight: 700; color: var(--text); }
  .attach-chip > svg { width: 16px; height: 16px; color: var(--primary); }
  .attach-chip .ac-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .af-x { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; color: var(--text-muted); cursor: pointer; }
  .af-x svg { width: 13px; height: 13px; }
  .af-x:hover { background: var(--red-bg); color: var(--red); border-color: var(--red); }
  .tk-att { display: inline-flex; align-items: center; gap: 7px; margin-top: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 700; color: var(--primary); }
  .tk-att svg { width: 13px; height: 13px; }
  .kpis5 { grid-template-columns: repeat(5, 1fr); }
  @media (max-width: 1200px) { .kpis5 { grid-template-columns: repeat(3, 1fr); } }
  @media (max-width: 980px) { .kpis5 { grid-template-columns: 1fr 1fr; } }
  @media (max-width: 760px) { .kpis5 { grid-template-columns: 1fr; } }
  .seg-n { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px; padding: 0 6px; margin-left: 6px; border-radius: 20px; background: rgba(74,27,240,.12); color: inherit; font-size: 11px; font-weight: 800; }
  .seg-btn.active .seg-n { background: rgba(255,255,255,.28); }

  /* Admin Unibox */
  #view-unibox {
    height: calc(100dvh - 66px);
    min-height: 560px;
    max-width: none;
    margin: -26px -32px 0;
  }
  .unibox-shell {
    display: grid;
    grid-template-columns: 62px minmax(290px, 330px) minmax(0, 1fr);
    width: 100%;
    height: 100%;
    min-width: 0;
    overflow: hidden;
    background: var(--surface);
  }
  .ubx-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 12px 8px;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }
  .ubx-compose,
  .ubx-rail-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: color .16s, background .16s, border-color .16s, transform .16s;
  }
  .ubx-compose {
    background: var(--text);
    border-color: var(--text);
    color: var(--surface);
    box-shadow: var(--shadow-sm);
  }
  .ubx-compose:hover { transform: translateY(-1px); }
  .ubx-compose span,
  .ubx-rail-btn > span {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    z-index: 30;
    padding: 6px 9px;
    border-radius: 7px;
    background: var(--text);
    color: var(--surface);
    font-size: 10.5px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translate(-4px, -50%);
    transition: opacity .14s, transform .14s;
  }
  .ubx-compose:hover span,
  .ubx-rail-btn:hover > span { opacity: 1; transform: translate(0, -50%); }
  .ubx-compose svg,
  .ubx-rail-btn svg { width: 17px; height: 17px; }
  .ubx-rail-nav {
    min-height: 0;
    width: 100%;
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    overflow-y: auto;
    padding: 3px;
    scrollbar-width: none;
  }
  .ubx-rail-nav::-webkit-scrollbar { display: none; }
  .ubx-rail-btn:nth-child(2) { color: #c77700; background: rgba(245,158,11,.06); }
  .ubx-rail-btn:nth-child(3) { color: #059669; background: rgba(16,185,129,.06); }
  .ubx-rail-btn:nth-child(4) { color: #2563eb; background: rgba(37,99,235,.06); }
  .ubx-rail-btn:nth-child(5) { color: #64748b; background: rgba(100,116,139,.06); }
  .ubx-rail-btn:nth-child(6) { color: #b45309; background: rgba(245,158,11,.06); }
  .ubx-rail-btn:nth-child(7) { color: var(--red); background: rgba(220,38,38,.05); }
  .ubx-rail-btn:hover { border-color: var(--primary-300); color: var(--primary); transform: translateY(-1px); }
  .ubx-rail-nav .ubx-rail-btn.active {
    border-color: var(--primary) !important;
    background: var(--primary) !important;
    color: #fff !important;
    box-shadow: 0 0 0 3px rgba(74,27,240,.18), 0 5px 12px rgba(74,27,240,.22);
  }
  .ubx-rail-btn > b {
    position: absolute;
    top: -4px;
    right: -5px;
    display: none;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
    border-radius: 20px;
    background: var(--red);
    color: #fff;
    font-size: 8px;
    line-height: 1;
  }
  .ubx-maximize { margin-top: auto; }
  .ubx-list-pane {
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }
  .ubx-list-head {
    min-height: 72px;
    padding: 14px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--border);
  }
  .ubx-list-head h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
  .ubx-list-head p { margin: 2px 0 0; color: var(--text-muted); font-size: 10.5px; }
  .ubx-total-pill {
    flex: 0 0 auto;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--surface-alt);
    color: var(--text-muted);
    font-size: 9.5px;
    font-weight: 800;
  }
  .ubx-list-tools { padding: 11px 13px 9px; border-bottom: 1px solid var(--border); }
  .ubx-select-row { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(92px, .65fr); gap: 7px; margin-bottom: 8px; }
  .ubx-select-row label { min-width: 0; }
  .ubx-select-row select {
    width: 100%;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0 28px 0 9px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 10.5px;
    outline: 0;
  }
  .ubx-select-row select:focus { border-color: var(--primary); }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  .ubx-search {
    height: 37px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-subtle);
  }
  .ubx-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
  .ubx-search svg { width: 15px; height: 15px; flex: 0 0 auto; }
  .ubx-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 11.5px; }
  .ubx-filter-label {
    min-height: 25px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 9.5px;
    font-weight: 700;
  }
  .ubx-refresh { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; color: var(--text-muted); }
  .ubx-refresh:hover { background: var(--primary-50); color: var(--primary); }
  .ubx-refresh svg { width: 13px; height: 13px; }
  .ubx-conversation-list { min-height: 0; flex: 1; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--primary-300) transparent; }
  .ubx-conversation {
    width: 100%;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 9px;
    padding: 11px 12px;
    text-align: left;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    transition: background .15s;
  }
  .ubx-conversation:hover { background: var(--surface-alt); }
  .ubx-conversation.active { background: var(--primary-50); box-shadow: inset 3px 0 0 var(--primary); }
  .ubx-conversation.unread .ubx-conv-name,
  .ubx-conversation.unread .ubx-conv-subject { font-weight: 800; }
  .ubx-conv-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-alt); color: var(--text-muted); font-size: 10px; font-weight: 800; }
  .ubx-conversation.active .ubx-conv-avatar { background: var(--primary); color: #fff; }
  .ubx-conv-main { min-width: 0; max-width: 100%; overflow: hidden; }
  .ubx-conv-top { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
  .ubx-conv-name, .ubx-conv-subject, .ubx-conv-preview { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ubx-conv-name { font-size: 11.5px; font-weight: 700; }
  .ubx-conv-time { flex: 0 0 auto; color: var(--text-subtle); font-size: 8.5px; }
  .ubx-conv-subject { display: block; max-width: 100%; margin-top: 4px; font-size: 10.5px; font-weight: 700; }
  .ubx-conv-preview { display: block; max-width: 100%; margin-top: 2px; color: var(--text-muted); font-size: 9.5px; }
  .ubx-conv-foot { min-height: 18px; margin-top: 6px; display: flex; align-items: center; gap: 5px; }
  .ubx-source-pill, .ubx-unread-pill { display: inline-flex; align-items: center; min-height: 17px; padding: 2px 6px; border-radius: 999px; font-size: 8px; font-weight: 800; line-height: 1; }
  .ubx-source-pill { max-width: 128px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--surface-alt); color: var(--text-muted); }
  .ubx-unread-pill { margin-left: auto; background: var(--primary); color: #fff; }
  .ubx-detail-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); }
  .ubx-conversation-view { min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; }
  .ubx-conversation-view[hidden] { display: none; }
  .ubx-detail-head {
    position: relative;
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .ubx-back { width: 34px; height: 34px; display: none; place-items: center; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 9px; color: var(--text-muted); }
  .ubx-back svg { width: 16px; height: 16px; }
  .ubx-detail-title { min-width: 0; flex: 1; }
  .ubx-detail-title h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
  .ubx-detail-title p { margin: 3px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 9.5px; }
  .ubx-detail-actions { display: flex; align-items: center; gap: 5px; }
  .ubx-detail-actions[hidden] { display: none; }
  .ubx-detail-actions button { width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-muted); }
  .ubx-detail-actions button[hidden] { display: none; }
  .ubx-detail-actions button:hover { border-color: var(--primary-300); background: var(--primary-50); color: var(--primary); }
  .ubx-detail-actions button:last-child:hover { border-color: var(--red); background: var(--red-bg); color: var(--red); }
  .ubx-detail-actions button svg { width: 14px; height: 14px; }
  .ubx-detail-meta { min-height: 40px; padding: 8px 18px; display: flex; align-items: center; gap: 22px; flex-wrap: wrap; background: var(--surface); border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 9.5px; }
  .ubx-detail-meta[hidden] { display: none; }
  .ubx-detail-meta strong { color: var(--text); font-weight: 700; }
  .ubx-thread { min-height: 0; flex: 1; overflow-y: auto; padding: 18px; background: var(--surface); scrollbar-width: thin; scrollbar-color: var(--primary-300) transparent; }
  .ubx-empty { min-height: 100%; display: grid; place-content: center; justify-items: center; padding: 28px; color: var(--text-muted); text-align: center; }
  .ubx-empty-icon { width: 50px; height: 50px; display: grid; place-items: center; margin-bottom: 11px; border-radius: 15px; background: var(--primary-50); color: var(--primary); }
  .ubx-empty-icon svg { width: 23px; height: 23px; }
  .ubx-empty h3 { margin: 0; color: var(--text); font-size: 14px; }
  .ubx-empty p { max-width: 330px; margin: 6px 0 0; font-size: 10.5px; line-height: 1.55; }
  .ubx-message-card { max-width: min(860px, 96%); margin: 0 0 12px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
  .ubx-message-card.incoming { margin-right: auto; border-color: rgba(16,185,129,.25); background: rgba(236,253,245,.72); }
  .ubx-message-card.outgoing { margin-left: auto; border-color: rgba(74,27,240,.18); background: var(--primary-50); }
  .ubx-message-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .ubx-message-direction { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 9.5px; font-weight: 800; }
  .ubx-message-direction::before { width: 6px; height: 6px; border-radius: 50%; background: var(--green); content: ""; }
  .ubx-message-card.outgoing .ubx-message-direction::before { background: var(--primary); }
  .ubx-message-time { color: var(--text-subtle); font-size: 8.5px; }
  .ubx-message-route { margin-top: 7px; color: var(--text-muted); font-size: 9px; line-height: 1.55; }
  .ubx-message-route strong { color: var(--text); font-weight: 700; }
  .ubx-message-body { margin-top: 9px; color: var(--text); font-size: 11.5px; line-height: 1.65; overflow-wrap: anywhere; }
  .ubx-status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; font-size: 9px; font-weight: 800; white-space: nowrap; }
  .ubx-status-pill.open { background: var(--primary-50); color: var(--primary); }
  .ubx-status-pill.in_progress { background: var(--amber-bg); color: #b45309; }
  .ubx-status-pill.resolved { background: var(--green-bg); color: var(--green); }
  .ubx-status-pill.closed { background: var(--surface-alt); color: var(--text-muted); }
  .ubx-status-pill.failed { background: var(--red-bg); color: var(--red); }
  .ubx-status-pill::before { width: 5px; height: 5px; border-radius: 50%; background: currentColor; content: ""; }

  .ubx-composer { min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); }
  .ubx-composer[hidden] { display: none; }
  .ubx-compose-head { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 20px; border-bottom: 1px solid var(--border); }
  .ubx-compose-head h3 { margin: 0; font-size: 14px; }
  .ubx-compose-head p { margin: 3px 0 0; color: var(--text-muted); font-size: 10px; }
  .ubx-compose-close { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--text-muted); }
  .ubx-compose-close:hover { background: var(--primary-50); color: var(--primary); }
  .ubx-compose-close svg { width: 16px; height: 16px; }
  .ubx-compose-body { min-height: 0; flex: 1; overflow-y: auto; padding: 18px 22px 24px; scrollbar-width: thin; scrollbar-color: var(--primary-300) transparent; }
  .ubx-compose-field { margin-bottom: 13px; }
  .ubx-compose-field > label,
  .ubx-attachments > label { display: block; margin-bottom: 6px; color: var(--text); font-size: 10.5px; font-weight: 750; }
  .ubx-compose-field input,
  .ubx-compose-field select,
  .ubx-template-picker select,
  .ubx-plain-editor {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 11.5px;
    outline: 0;
  }
  .ubx-compose-field input,
  .ubx-compose-field select,
  .ubx-template-picker select { height: 40px; padding: 0 12px; }
  .ubx-compose-field input:focus,
  .ubx-compose-field select:focus,
  .ubx-template-picker select:focus,
  .ubx-plain-editor:focus,
  .ubx-editor-canvas:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
  .ubx-compose-field select:disabled { opacity: 1; background: var(--surface-alt); color: var(--text-muted); cursor: default; }
  .ubx-compose-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .ubx-frame-options {
    margin: 2px 0 14px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-alt);
  }
  .ubx-frame-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
  .ubx-frame-head > div { min-width: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
  .ubx-frame-head strong { color: var(--text); font-size: 11px; }
  .ubx-frame-head span { color: var(--text-muted); font-size: 9.5px; }
  .ubx-frame-head code,
  .ubx-frame-options > p code { padding: 2px 5px; border-radius: 5px; background: var(--primary-50); color: var(--primary); font-size: 9px; font-weight: 800; }
  .ubx-frame-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .ubx-frame-field { min-width: 0; }
  .ubx-frame-field > span { display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 9.5px; font-weight: 750; }
  .ubx-frame-field input,
  .ubx-frame-field textarea {
    width: 100%;
    min-height: 38px;
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 10.5px;
    line-height: 1.45;
    outline: 0;
  }
  .ubx-frame-field textarea { resize: vertical; }
  .ubx-frame-field input:focus,
  .ubx-frame-field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
  .ubx-reference-option { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--text-muted); font-size: 9.5px; cursor: pointer; }
  .ubx-reference-option input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }
  .ubx-reference-option b { color: var(--text); font-weight: 750; }
  .ubx-frame-options > p { margin: 8px 0 0; color: var(--text-muted); font-size: 9px; }
  .ubx-message-field { margin-bottom: 14px; }
  .ubx-editor-tabs { width: fit-content; max-width: 100%; display: flex; gap: 2px; margin-bottom: 9px; padding: 3px; overflow-x: auto; border-radius: 9px; background: var(--surface-alt); }
  .ubx-editor-tabs button { flex: 0 0 auto; min-height: 31px; padding: 6px 11px; border-radius: 7px; color: var(--text-muted); font-size: 10.5px; font-weight: 700; }
  .ubx-editor-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
  .ubx-template-picker { margin-bottom: 9px; padding: 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-alt); }
  .ubx-template-picker[hidden] { display: none; }
  .ubx-template-picker label { display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 9.5px; font-weight: 700; }
  .ubx-editor-toolbar { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; padding: 6px 8px; border: 1px solid var(--border-strong); border-bottom: 0; border-radius: 9px 9px 0 0; background: var(--surface-alt); }
  .ubx-editor-toolbar > span { width: 1px; height: 20px; margin: 0 3px; background: var(--border-strong); }
  .ubx-editor-toolbar select { width: 110px; height: 30px; border: 1px solid var(--border); border-radius: 7px; padding: 0 7px; background: var(--surface); color: var(--text); font: inherit; font-size: 9.5px; }
  .ubx-editor-toolbar button { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px; color: var(--text-muted); }
  .ubx-editor-toolbar button:hover { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
  .ubx-editor-toolbar button svg { width: 14px; height: 14px; }
  .ubx-editor-canvas,
  .ubx-plain-editor { min-height: 275px; padding: 14px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 12px; line-height: 1.65; outline: 0; overflow-y: auto; }
  .ubx-editor-canvas { border-radius: 0 0 9px 9px; }
  .ubx-editor-canvas:empty::before { content: attr(data-placeholder); color: var(--text-subtle); }
  .ubx-editor-canvas p { margin: 0 0 8px; }
  .ubx-editor-canvas h2, .ubx-editor-canvas h3 { margin: 10px 0 7px; }
  .ubx-editor-canvas ul, .ubx-editor-canvas ol { margin: 8px 0 8px 22px; }
  .ubx-editor-canvas blockquote { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--primary); color: var(--text-muted); }
  .ubx-editor-canvas a { color: var(--primary); text-decoration: underline; }
  .ubx-plain-editor { min-height: 330px; resize: vertical; border-radius: 9px; }
  .ubx-plain-editor[hidden] { display: none; }
  .ubx-attachments { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .ubx-attachments > label { width: 100%; margin: 0; }
  .ubx-attachments input[type="file"] { max-width: 100%; color: var(--text-muted); font: inherit; font-size: 10.5px; }
  .ubx-attachments input[type="file"]::file-selector-button { margin-right: 9px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 10.5px; font-weight: 700; cursor: pointer; }
  .ubx-compose-message { margin-top: 12px; color: var(--red); font-size: 10.5px; font-weight: 700; }
  .ubx-compose-message[hidden] { display: none; }
  .ubx-compose-message.success { color: var(--green); }
  .ubx-compose-foot { min-height: 60px; flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 10px 20px; border-top: 1px solid var(--border); background: var(--surface); }
  .ubx-compose-foot .btn { min-height: 36px; padding: 7px 13px; font-size: 11.5px; }
  .ubx-refresh .spin { animation: legacy-spin .75s linear infinite; }
  body.unibox-maximized { overflow: hidden; }
  .unibox-shell.is-maximized { position: fixed; inset: 0; z-index: 150; width: auto; height: auto; min-height: 0; }

  @media (max-width: 1200px) {
    .unibox-shell { grid-template-columns: 58px minmax(270px, 300px) minmax(0, 1fr); }
    .ubx-rail { padding-inline: 7px; }
    .ubx-compose, .ubx-rail-btn { width: 38px; height: 38px; }
  }
  @media (max-width: 860px) {
    #view-unibox { height: calc(100dvh - 66px); margin: -18px -16px 0; }
    .unibox-shell { grid-template-columns: 56px minmax(245px, 280px) minmax(0, 1fr); }
    .ubx-message-card { max-width: 98%; }
    .ubx-compose-body { padding-inline: 17px; }
  }
  @media (min-width: 721px) {
    .unibox-shell.composer-open > .ubx-rail,
    .unibox-shell.composer-open > .ubx-list-pane {
      display: flex;
      visibility: visible;
      opacity: 1;
    }
    .unibox-shell.composer-open > .ubx-rail > *,
    .unibox-shell.composer-open > .ubx-list-pane > * {
      visibility: visible;
      opacity: 1;
    }
  }
  @media (max-width: 720px) {
    .unibox-shell { display: flex; flex-direction: column; }
    .ubx-rail {
      min-height: 55px;
      flex-direction: row;
      align-items: center;
      gap: 7px;
      padding: 7px 9px;
      overflow-x: auto;
      border-right: 0;
      border-bottom: 1px solid var(--border);
      scrollbar-width: none;
    }
    .ubx-rail::-webkit-scrollbar { display: none; }
    .ubx-compose { width: auto; height: 38px; display: flex; gap: 7px; padding: 0 11px; border-radius: 10px; }
    .ubx-compose span { position: static; display: inline; padding: 0; background: none; color: inherit; font-size: 10px; opacity: 1; transform: none; }
    .ubx-rail-nav { width: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 2px 1px; }
    .ubx-rail-btn { width: 36px; height: 36px; flex: 0 0 auto; }
    .ubx-rail-btn > span { display: none; }
    .ubx-maximize { margin: 0 0 0 auto; }
    .ubx-list-pane, .ubx-detail-pane { flex: 1; min-height: 0; border-right: 0; }
    .unibox-shell:not(.has-selection):not(.composer-open) .ubx-detail-pane { display: none; }
    .unibox-shell.has-selection .ubx-rail,
    .unibox-shell.has-selection .ubx-list-pane,
    .unibox-shell.composer-open .ubx-rail,
    .unibox-shell.composer-open .ubx-list-pane { display: none; }
    .ubx-back { display: grid; }
    .ubx-detail-head { min-height: 66px; padding: 10px 12px; }
    .ubx-detail-meta { padding-inline: 12px; gap: 10px; }
    .ubx-thread { padding: 12px; }
    .ubx-compose-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .ubx-frame-grid { grid-template-columns: minmax(0, 1fr); }
  }
  @media (max-width: 520px) {
    #view-unibox { min-height: 470px; margin: -14px -10px 0; }
    .ubx-list-head { min-height: 64px; padding: 11px 12px; }
    .ubx-list-tools { padding: 9px 10px 7px; }
    .ubx-conversation { padding: 10px; }
    .ubx-detail-head { align-items: flex-start; flex-wrap: wrap; }
    .ubx-detail-title { flex-basis: calc(100% - 46px); }
    .ubx-detail-title h3, .ubx-detail-title p { white-space: normal; line-height: 1.3; }
    .ubx-detail-head #ubxStatus { order: 3; }
    .ubx-detail-actions { order: 4; margin-left: auto; }
    .ubx-detail-meta { padding-top: 9px; }
    .ubx-message-card { max-width: 100%; padding: 11px; }
    .ubx-compose-head { min-height: 64px; padding: 10px 12px; }
    .ubx-compose-head p { max-width: 260px; }
    .ubx-compose-body { padding: 13px 12px 18px; }
    .ubx-editor-toolbar { max-height: 78px; overflow-y: auto; }
    .ubx-editor-toolbar select { width: 100px; }
    .ubx-editor-canvas, .ubx-plain-editor { min-height: 250px; }
    .ubx-compose-foot { min-height: 56px; padding: 9px 12px; }
    .ubx-compose-foot .btn { flex: 0 0 auto; }
  }

  @media (max-width: 640px) {
    .invoice-billing-preview {
      align-items: flex-start;
      flex-direction: column;
    }
    .invoice-billing-preview-badge {
      white-space: normal;
    }
  }
