/* v57 admin UI refresh - Tailwind-inspired local CSS, no CDN needed */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: #e2e8f0;
  --border-2: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --text-3: #64748b;
  --text-inv: #ffffff;
  --primary: #0f172a;
  --primary-h: #1e293b;
  --accent: #2563eb;
  --accent-h: #1d4ed8;
  --accent-light: #eff6ff;
  --accent-border: #bfdbfe;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --ok-border: #a7f3d0;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 8px 24px rgba(15,23,42,.08);
  --shadow-lg: 0 20px 50px rgba(15,23,42,.14);
  --topbar-h: 64px;
  --sidebar-w: 286px;
  --transition: .16s ease;
}

html { background: var(--bg); }
body {
  background:
    radial-gradient(circle at top right, rgba(37,99,235,.08), transparent 34rem),
    radial-gradient(circle at bottom left, rgba(14,165,233,.07), transparent 28rem),
    var(--bg);
  color: var(--text);
  letter-spacing: -.01em;
}

.topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,.88);
  color: var(--text);
  border-bottom: 1px solid rgba(226,232,240,.9);
  box-shadow: 0 1px 0 rgba(15,23,42,.04), 0 10px 30px rgba(15,23,42,.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 0 22px;
}
.topbar a { color: var(--accent); }
.topbar-brand, .topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #0f172a);
  font-weight: 900;
  box-shadow: 0 10px 25px rgba(37,99,235,.28);
  flex: 0 0 auto;
}
.brand-title { display: flex; flex-direction: column; line-height: 1.55; min-width: 0; }
.brand-title b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.version-pill, .user-chip, .agency-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: #fff;
  color: var(--text-3);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.user-chip { color: var(--text-2); }
.logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2) !important;
  font-weight: 800;
  text-decoration: none !important;
}
.logout-link:hover { background: #e2e8f0; }

.layout { min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  background: rgba(255,255,255,.82);
  border-left: 1px solid rgba(226,232,240,.9);
  box-shadow: -10px 0 30px rgba(15,23,42,.035);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.menu-brand {
  background: linear-gradient(135deg, #0f172a, #1d4ed8);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 14px 32px rgba(15,23,42,.18);
}
.menu-logo { background: rgba(255,255,255,.16); }
.menu-group {
  border-color: rgba(226,232,240,.85);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(15,23,42,.03);
}
.menu-group[open] { box-shadow: 0 10px 24px rgba(15,23,42,.055); }
.menu-group > summary { padding: 11px 12px; }
.menu-group > summary::after { background: #eff6ff; color: #2563eb; }
.sidebar .menu-link {
  border-radius: 12px;
  padding: 10px 11px;
  color: #334155;
}
.sidebar .menu-link:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
  transform: translateX(-1px);
}
.sidebar .menu-link.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 10px 22px rgba(37,99,235,.26);
}
.menu-icon, .menu-group-icon { background: #f1f5f9; }

.content {
  padding: 24px;
  max-width: none !important;
}
.content > .card:first-child,
.content > .page-head:first-child {
  margin-top: 0;
}
.wrap, .container {
  max-width: 1160px;
  margin: 28px auto;
  padding: 0 16px;
}

.card, .soft-card, .stat, .stat-card, .sale-step-card, .summary-card, .report-link, .modal-box {
  border-color: rgba(226,232,240,.92);
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 10px 26px rgba(15,23,42,.055);
}
.card {
  border-radius: 20px;
  padding: 22px;
}
.card:hover { box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 14px 32px rgba(15,23,42,.075); }
.soft-card, .summary-card, .quick-box, .hint-box { background: #f8fafc; }

h1, h2, h3, h4 { letter-spacing: -.025em; color: #0f172a; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
.muted, .small-note { color: #64748b; }

.btn, button.btn, a.btn {
  border-radius: 12px;
  min-height: 40px;
  box-shadow: 0 1px 2px rgba(15,23,42,.08);
  background: #0f172a;
  border-color: #0f172a;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(15,23,42,.16); }
.btn.accent, .btn.primary-accent { background: #2563eb; border-color: #2563eb; }
.btn.accent:hover, .btn.primary-accent:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn.secondary {
  background: #fff;
  color: #334155;
  border-color: #cbd5e1;
}
.btn.secondary:hover { background: #f8fafc; border-color: #94a3b8; box-shadow: 0 8px 18px rgba(15,23,42,.09); }
.btn.danger { background: #dc2626; border-color: #dc2626; }
.icon-btn, .mini-tab, .link-button { border-radius: 12px; }

label { color: #334155; font-weight: 800; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea, .search-select-input {
  min-height: 42px;
  border-radius: 12px;
  border-color: #cbd5e1;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(15,23,42,.02);
}
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus, .search-select-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
input::placeholder, textarea::placeholder { color: #94a3b8; }
.inline-check, .check-row, .switch-line {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.table-wrap, .card:has(table) {
  border-radius: 18px;
}
.table-wrap {
  border: 1px solid #e2e8f0;
  background: #fff;
}
.table-wrap table { border: 0; }
table { border-collapse: separate; border-spacing: 0; }
th {
  background: #f8fafc;
  color: #475569;
  font-weight: 900;
  border-bottom: 1px solid #e2e8f0;
}
td { border-bottom-color: #eef2f7; }
tr:hover td { background: #f8fafc; }
.table-wrap tr:last-child td { border-bottom: 0; }

.badge, .pill {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
  font-weight: 800;
}
.alert { border-radius: 16px; }

.page-head, .dashboard-hero {
  background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(239,246,255,.92));
  border: 1px solid #e2e8f0;
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 14px 32px rgba(15,23,42,.06);
}
.page-head h1, .dashboard-hero h1 { margin-bottom: 4px; }
.hero-actions, .actions { align-items: center; }

.stat, .stat-card {
  position: relative;
  overflow: hidden;
  background: #fff;
  border-radius: 18px;
}
.stat::before, .stat-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, #2563eb, #38bdf8);
}
.stat span, .stat-card span { color: #64748b; font-weight: 800; }
.stat b, .stat-card b { color: #0f172a; font-weight: 950; }
.stat-link:hover { transform: translateY(-3px); }
.dashboard-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.dashboard-panels { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.notice { border-radius: 14px; }
.mini-row { border-bottom-color: #eef2f7; }

.search-select-list, .jcal-box {
  border-color: #cbd5e1;
  box-shadow: 0 20px 50px rgba(15,23,42,.16);
}
.jcal-days button:hover { background: #eff6ff; }

/* utility helpers inspired by Tailwind for future pages */
.tw-flex { display: flex; }
.tw-grid { display: grid; }
.tw-items-center { align-items: center; }
.tw-justify-between { justify-content: space-between; }
.tw-gap-2 { gap: .5rem; }
.tw-gap-3 { gap: .75rem; }
.tw-gap-4 { gap: 1rem; }
.tw-rounded-xl { border-radius: 1rem; }
.tw-rounded-2xl { border-radius: 1.25rem; }
.tw-bg-white { background: #fff; }
.tw-bg-slate-50 { background: #f8fafc; }
.tw-text-slate-500 { color: #64748b; }
.tw-text-slate-900 { color: #0f172a; }
.tw-shadow-sm { box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.tw-shadow { box-shadow: 0 10px 24px rgba(15,23,42,.08); }
.tw-border { border: 1px solid #e2e8f0; }
.tw-p-4 { padding: 1rem; }
.tw-p-5 { padding: 1.25rem; }
.tw-mb-4 { margin-bottom: 1rem; }

@media (max-width: 800px) {
  :root { --topbar-h: auto; }
  .topbar {
    position: sticky;
    min-height: 64px;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
  }
  .topbar-brand, .topbar-user { width: 100%; justify-content: space-between; }
  .version-pill, .agency-chip { display: none; }
  .sidebar { background: #fff; }
  .content { padding: 14px; }
  .card, .page-head, .dashboard-hero { border-radius: 18px; padding: 16px; }
  .menu-items { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  h1 { font-size: 20px; }
  .content { padding: 10px; }
  .topbar-user { align-items: flex-start; flex-direction: column; }
  .logout-link { width: 100%; }
}

/* v58 mobile shell hardening: fixes horizontal overflow and broken header on small screens */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
body.app-body {
  min-width: 0;
}
.topbar,
.layout,
.sidebar,
.content,
.app-menu,
.menu-group,
.menu-brand,
.card,
.page-head,
.dashboard-hero {
  max-width: 100%;
}
.topbar,
.sidebar,
.content {
  box-sizing: border-box;
}
.brand-title,
.brand-title b,
.user-chip,
.agency-chip,
.logout-link,
.menu-brand > div,
.menu-group > summary > span:last-child,
.sidebar .menu-link span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 800px) {
  :root {
    --topbar-h: auto;
    --sidebar-w: 100%;
  }

  body {
    background: #f8fafc;
  }

  body.app-body > .topbar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    width: 100%;
    max-width: 100vw;
    height: auto !important;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    align-items: stretch;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
    margin: 0;
    border-radius: 0;
    background: rgba(255,255,255,.98);
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 0 rgba(15,23,42,.04), 0 8px 20px rgba(15,23,42,.06);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overflow: hidden;
  }

  .topbar-brand {
    width: 100%;
    max-width: 100%;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    justify-content: initial;
    direction: rtl;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    grid-column: 1;
    justify-self: start;
  }

  .brand-title {
    grid-column: 2;
    display: block;
    max-width: 100%;
    line-height: 1.55;
  }

  .brand-title b {
    display: block;
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
    font-size: 14px;
    line-height: 1.7;
  }

  .version-pill {
    display: none !important;
  }

  .topbar-user {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: row !important;
    flex-wrap: nowrap;
    align-items: center !important;
    justify-content: space-between;
    gap: 8px;
    overflow: hidden;
  }

  .topbar-user .user-chip {
    flex: 1 1 auto;
    max-width: none;
    justify-content: flex-start;
    padding: 5px 9px;
    font-size: 12px;
    background: #f8fafc;
  }

  .agency-chip {
    display: none !important;
  }

  .topbar-user .logout-link {
    flex: 0 0 auto;
    width: auto !important;
    min-height: 32px;
    padding: 5px 10px;
    font-size: 12px;
  }

  body.app-body > .layout {
    display: block !important;
    width: 100%;
    max-width: 100vw;
    min-height: 0;
    overflow: visible;
  }

  body.app-body > .layout > .sidebar {
    position: relative !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100vw;
    height: auto !important;
    min-height: 0;
    padding: 12px;
    margin: 0;
    border: 0;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    box-shadow: none;
    overflow: visible;
  }

  .menu-brand {
    width: 100%;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    margin: 0 0 12px;
    padding: 14px;
    border-radius: 20px;
  }

  .menu-logo {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  .menu-brand b,
  .menu-brand span {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .app-menu {
    width: 100%;
    display: grid;
    gap: 10px;
  }

  .menu-group {
    width: 100%;
    margin: 0;
    border-radius: 18px;
    overflow: hidden;
  }

  .menu-group > summary {
    min-height: 62px;
    padding: 12px 14px;
    gap: 10px;
    font-size: 15px;
  }

  .menu-group > summary::after {
    margin-right: auto;
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    border-radius: 10px;
  }

  .menu-group-icon,
  .menu-icon {
    flex: 0 0 auto;
  }

  .menu-items {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 6px;
    padding: 0 12px 12px;
  }

  .sidebar .menu-link {
    width: 100%;
    min-height: 48px;
    padding: 11px 12px;
    gap: 10px;
    font-size: 14px;
    border-radius: 14px;
  }

  .sidebar .menu-link span:last-child {
    display: block;
    white-space: nowrap;
    max-width: 100%;
  }

  body.app-body > .layout > .content {
    width: 100%;
    max-width: 100vw !important;
    padding: 12px;
    margin: 0;
    overflow-x: hidden;
  }

  .wrap,
  .container {
    width: 100%;
    max-width: 100vw;
    margin: 14px auto;
    padding: 0 12px;
    overflow-x: hidden;
  }

  .card,
  .page-head,
  .dashboard-hero,
  .soft-card {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .table-wrap,
  .card:has(table) {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 640px;
  }
}

@media (max-width: 420px) {
  body.app-body > .topbar {
    padding-right: 10px;
    padding-left: 10px;
  }

  body.app-body > .layout > .sidebar,
  body.app-body > .layout > .content {
    padding-right: 10px;
    padding-left: 10px;
  }

  .menu-brand {
    padding: 12px;
    border-radius: 18px;
  }

  .menu-group > summary {
    min-height: 58px;
    font-size: 14px;
  }
}
/* v59 super admin control panel additions */
.super-admin-hero{background:linear-gradient(135deg,#0f172a,#1d4ed8);color:#fff;border:none;box-shadow:0 24px 60px rgba(29,78,216,.22)}
.super-admin-hero .muted{color:rgba(255,255,255,.78)}
.quick-actions{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin-top:14px}
.stats-grid{grid-template-columns:repeat(auto-fit,minmax(160px,1fr))}
.two-col{grid-template-columns:repeat(auto-fit,minmax(300px,1fr))}
.alert-card{border-color:#fecaca;background:#fff7f7}
.log-row{padding:12px 0;border-bottom:1px solid #eef2f7;display:flex;flex-direction:column;gap:4px}.log-row span{font-size:12px;color:#64748b}
.badge{display:inline-flex;align-items:center;border-radius:999px;background:#eef2ff;color:#1d4ed8;padding:4px 10px;font-size:12px;font-weight:700}
.impersonation-banner{border:1px solid #facc15;background:#fffbeb;color:#713f12;display:flex;align-items:center;gap:10px;justify-content:space-between;flex-wrap:wrap}
.table-wrap{width:100%;overflow:auto;-webkit-overflow-scrolling:touch}
.checkbox{display:flex!important;align-items:center;gap:8px;background:#f8fafc;border:1px solid #e2e8f0;border-radius:14px;padding:12px;min-height:46px}.checkbox input{width:auto!important}.full{grid-column:1/-1}
@media(max-width:720px){.quick-actions .btn{width:100%;text-align:center}.two-col{grid-template-columns:1fr}.super-admin-hero h1{font-size:24px}.impersonation-banner{display:block}.impersonation-banner .btn{margin-top:10px;width:100%}}

/* v61.38 - mobile bottom navigation: Tailwind-like internal CSS, minimal agency panel */
.mobile-bottom-nav { display: none; }

@media (max-width: 800px) {
  body.agency-panel {
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
  }

  body.agency-panel > .layout > .sidebar {
    display: none !important;
  }

  body.agency-panel > .layout > .content {
    padding-bottom: calc(96px + env(safe-area-inset-bottom)) !important;
  }

  body.agency-panel .mobile-bottom-nav {
    display: block;
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 999;
    pointer-events: none;
    font-family: inherit;
  }

  body.agency-panel .mobile-more-toggle {
    position: fixed;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
  }

  body.agency-panel .mobile-bottom-bar {
    pointer-events: auto;
    width: min(100% - 18px, 560px);
    margin: 0 auto calc(8px + env(safe-area-inset-bottom));
    min-height: 66px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: center;
    gap: 4px;
    padding: 7px;
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: 28px;
    background: rgba(255, 255, 255, .88);
    box-shadow: 0 18px 48px rgba(15, 23, 42, .18), 0 2px 10px rgba(15, 23, 42, .08);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
    backdrop-filter: blur(18px) saturate(1.2);
  }

  body.agency-panel .mobile-nav-item {
    min-width: 0;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 21px;
    color: #64748b;
    text-decoration: none;
    cursor: pointer;
    transition: transform .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease;
    -webkit-tap-highlight-color: transparent;
  }

  body.agency-panel .mobile-nav-item:hover,
  body.agency-panel .mobile-nav-item:focus-visible {
    background: #f8fafc;
    color: #0f172a;
    text-decoration: none;
  }

  body.agency-panel .mobile-nav-item.active {
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 10px 24px rgba(37, 99, 235, .26);
  }

  body.agency-panel .mobile-nav-ico {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    line-height: 1;
  }

  body.agency-panel .mobile-nav-txt {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10.5px;
    font-weight: 800;
    line-height: 1.2;
  }

  body.agency-panel .mobile-more-backdrop {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 998;
    opacity: 0;
    background: rgba(15, 23, 42, .34);
    transition: opacity .22s ease;
  }

  body.agency-panel .mobile-more-sheet {
    pointer-events: auto;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    z-index: 999;
    max-height: min(72vh, 620px);
    overflow: auto;
    overscroll-behavior: contain;
    padding: 10px 10px 14px;
    border: 1px solid rgba(226, 232, 240, .96);
    border-radius: 30px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 30px 80px rgba(15, 23, 42, .26);
    -webkit-backdrop-filter: blur(20px) saturate(1.25);
    backdrop-filter: blur(20px) saturate(1.25);
    transform: translateY(24px) scale(.98);
    opacity: 0;
    visibility: hidden;
    transition: transform .24s cubic-bezier(.2,.8,.2,1), opacity .2s ease, visibility .2s ease;
  }

  body.agency-panel .mobile-more-toggle:checked ~ .mobile-more-backdrop {
    pointer-events: auto;
    opacity: 1;
  }

  body.agency-panel .mobile-more-toggle:checked ~ .mobile-more-sheet {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
  }

  body.agency-panel .mobile-sheet-handle {
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: #cbd5e1;
    margin: 2px auto 10px;
  }

  body.agency-panel .mobile-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 4px 12px;
  }

  body.agency-panel .mobile-sheet-head b {
    display: block;
    color: #0f172a;
    font-size: 15px;
    line-height: 1.7;
  }

  body.agency-panel .mobile-sheet-head span {
    display: block;
    color: #64748b;
    font-size: 11px;
    line-height: 1.7;
  }

  body.agency-panel .mobile-sheet-close {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: #f1f5f9;
    color: #0f172a;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
  }

  body.agency-panel .mobile-sheet-grid {
    display: grid;
    gap: 9px;
  }

  body.agency-panel .mobile-sheet-group {
    border: 1px solid #e2e8f0;
    border-radius: 22px;
    background: #fff;
    overflow: hidden;
  }

  body.agency-panel .mobile-sheet-group.active {
    border-color: #bfdbfe;
    background: #eff6ff;
  }

  body.agency-panel .mobile-sheet-group > summary {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 13px;
    list-style: none;
    color: #0f172a;
    cursor: pointer;
    user-select: none;
  }

  body.agency-panel .mobile-sheet-group > summary::-webkit-details-marker { display: none; }

  body.agency-panel .mobile-sheet-group > summary::after {
    content: '+';
    margin-right: auto;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: #2563eb;
    background: #dbeafe;
    font-weight: 900;
  }

  body.agency-panel .mobile-sheet-group[open] > summary::after { content: '−'; }

  body.agency-panel .mobile-sheet-group > summary span {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #f8fafc;
  }

  body.agency-panel .mobile-sheet-group > summary b {
    font-size: 13px;
  }

  body.agency-panel .mobile-sheet-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 0 10px 10px;
  }

  body.agency-panel .mobile-sheet-link {
    min-width: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #f8fafc;
    color: #334155;
    text-decoration: none;
  }

  body.agency-panel .mobile-sheet-link:hover,
  body.agency-panel .mobile-sheet-link:focus-visible {
    background: #fff;
    color: #0f172a;
    text-decoration: none;
  }

  body.agency-panel .mobile-sheet-link.active {
    border-color: #2563eb;
    background: #2563eb;
    color: #fff;
    box-shadow: 0 10px 22px rgba(37, 99, 235, .22);
  }

  body.agency-panel .mobile-sheet-link span {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: rgba(255,255,255,.56);
    font-size: 13px;
  }

  body.agency-panel .mobile-sheet-link b {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11.5px;
    line-height: 1.5;
  }
}

@media (max-width: 390px) {
  body.agency-panel .mobile-bottom-bar {
    width: calc(100% - 12px);
    gap: 2px;
    padding: 6px;
    border-radius: 24px;
  }

  body.agency-panel .mobile-nav-item {
    min-height: 49px;
    border-radius: 18px;
  }

  body.agency-panel .mobile-nav-txt { font-size: 9.5px; }

  body.agency-panel .mobile-sheet-links {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* v61.39 - app-like compact mobile UI: minimal headers, chip tabs, less empty space */
@media (max-width: 800px) {
  body.agency-panel {
    background:
      radial-gradient(circle at top right, rgba(37,99,235,.055), transparent 20rem),
      #f8fafc;
  }

  body.agency-panel .topbar {
    min-height: 54px;
    height: auto;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 12px;
    border-bottom-color: rgba(226,232,240,.75);
    box-shadow: 0 1px 0 rgba(15,23,42,.04);
  }

  body.agency-panel .topbar-brand,
  body.agency-panel .topbar-user {
    width: auto;
    min-width: 0;
    flex: 0 1 auto;
    display: flex;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start;
    gap: 7px;
  }

  body.agency-panel .topbar-brand { flex: 1 1 auto; }
  body.agency-panel .topbar-user { flex: 0 0 auto; }

  body.agency-panel .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 13px;
    box-shadow: 0 8px 18px rgba(37,99,235,.20);
  }

  body.agency-panel .brand-title b {
    max-width: 170px;
    font-size: 12.5px;
  }

  body.agency-panel .user-chip {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 5px 9px;
    font-size: 11px;
  }

  body.agency-panel .logout-link {
    min-height: 31px;
    padding: 5px 9px;
    font-size: 11px;
    border-radius: 14px;
  }

  body.agency-panel > .layout > .content {
    padding: 10px 10px calc(100px + env(safe-area-inset-bottom)) !important;
  }

  body.agency-panel .content > .page-head:first-child,
  body.agency-panel .content > .card:first-child {
    margin-top: 0;
  }

  body.agency-panel .page-head,
  body.agency-panel .dashboard-hero {
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    flex-direction: column;
    gap: 9px;
    margin: 0 0 10px;
    padding: 13px 14px;
    border-radius: 20px;
    background: rgba(255,255,255,.92);
    border-color: rgba(226,232,240,.85);
    box-shadow: 0 1px 2px rgba(15,23,42,.035), 0 10px 24px rgba(15,23,42,.05);
  }

  body.agency-panel .page-head h1,
  body.agency-panel .dashboard-hero h1 {
    margin: 0;
    font-size: 19px;
    line-height: 1.55;
    letter-spacing: -.035em;
  }

  /* Hide explanatory header copy on mobile; keep only title and actions. */
  body.agency-panel .page-head p,
  body.agency-panel .page-head .muted,
  body.agency-panel .page-head .small-note,
  body.agency-panel .dashboard-hero p,
  body.agency-panel .dashboard-hero .muted,
  body.agency-panel .dashboard-hero .small-note {
    display: none !important;
  }

  body.agency-panel .page-head > div,
  body.agency-panel .page-head .row,
  body.agency-panel .page-head .actions,
  body.agency-panel .page-head .hero-actions,
  body.agency-panel .page-head .report-actions,
  body.agency-panel .dashboard-hero .actions,
  body.agency-panel .dashboard-hero .hero-actions {
    width: 100%;
    display: flex;
    flex-wrap: nowrap !important;
    gap: 7px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 1px;
  }

  body.agency-panel .page-head > div::-webkit-scrollbar,
  body.agency-panel .page-head .row::-webkit-scrollbar,
  body.agency-panel .page-head .actions::-webkit-scrollbar,
  body.agency-panel .page-head .hero-actions::-webkit-scrollbar,
  body.agency-panel .page-head .report-actions::-webkit-scrollbar,
  body.agency-panel .tabs::-webkit-scrollbar {
    display: none;
  }

  body.agency-panel .page-head .btn,
  body.agency-panel .dashboard-hero .btn,
  body.agency-panel .tabs .btn,
  body.agency-panel .mini-tab,
  body.agency-panel .link-button {
    min-height: 36px;
    height: 36px;
    padding: 7px 12px;
    border-radius: 15px;
    font-size: 12px;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(15,23,42,.06);
  }

  body.agency-panel .card:has(> .tabs) {
    padding: 0;
    margin: 0 0 10px;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  body.agency-panel .tabs {
    display: flex;
    flex-wrap: nowrap !important;
    gap: 7px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0 4px;
    scrollbar-width: none;
  }

  body.agency-panel .tabs .btn:not(.secondary),
  body.agency-panel .mini-tab.active,
  body.agency-panel .link-button.active {
    background: #0f172a;
    border-color: #0f172a;
    color: #fff;
    box-shadow: 0 8px 18px rgba(15,23,42,.16);
  }

  body.agency-panel .card,
  body.agency-panel .soft-card,
  body.agency-panel .summary-card,
  body.agency-panel .stat,
  body.agency-panel .stat-card {
    padding: 14px;
    border-radius: 18px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(15,23,42,.035), 0 8px 20px rgba(15,23,42,.045);
  }

  body.agency-panel .card h2,
  body.agency-panel .stat h2,
  body.agency-panel .stat-card h2 {
    font-size: 20px;
    margin: 2px 0 0;
    line-height: 1.5;
  }

  body.agency-panel .card h3 {
    font-size: 15px;
    margin-bottom: 8px;
  }

  body.agency-panel .tw-gap-4 { gap: .65rem; }
  body.agency-panel .tw-gap-3 { gap: .55rem; }

  body.agency-panel .tw-grid .card {
    min-height: auto;
  }

  body.agency-panel .form,
  body.agency-panel form.form {
    gap: 9px !important;
  }

  body.agency-panel input:not([type="checkbox"]):not([type="radio"]),
  body.agency-panel select,
  body.agency-panel textarea,
  body.agency-panel .search-select-input {
    min-height: 39px;
    border-radius: 13px;
  }

  body.agency-panel .table-wrap {
    border-radius: 16px;
    border: 1px solid #e2e8f0;
  }

  body.agency-panel table th,
  body.agency-panel table td {
    padding: 9px 10px;
    font-size: 12px;
  }

  body.agency-panel .alert,
  body.agency-panel .notice {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 15px;
  }
}

@media (max-width: 390px) {
  body.agency-panel .brand-title b { max-width: 132px; }
  body.agency-panel .user-chip { max-width: 88px; }
  body.agency-panel .page-head h1,
  body.agency-panel .dashboard-hero h1 { font-size: 18px; }
  body.agency-panel .page-head,
  body.agency-panel .dashboard-hero,
  body.agency-panel .card { padding: 12px; }
}


/* v61.43 - app-like forms and global money input polish */
body.agency-panel .app-form .card,
body.agency-panel form.form > .card {
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 14px 30px rgba(15,23,42,.055);
}
body.agency-panel .form label,
body.agency-panel form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -.01em;
}
body.agency-panel input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
body.agency-panel select,
body.agency-panel textarea,
body.agency-panel .search-select-input {
  width: 100%;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 16px;
  min-height: 44px;
  padding: 10px 13px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.78);
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}
body.agency-panel input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
body.agency-panel select:focus,
body.agency-panel textarea:focus,
body.agency-panel .search-select-input:focus {
  border-color: rgba(37, 99, 235, .55);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37,99,235,.10), 0 10px 22px rgba(15,23,42,.055);
}
body.agency-panel input[readonly],
body.agency-panel textarea[readonly] {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #1e3a8a;
  font-weight: 900;
}
body.agency-panel .money-input-ready,
body.agency-panel input[data-money="1"],
body.agency-panel .money-input {
  direction: ltr;
  text-align: left;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  font-weight: 850;
}
body.agency-panel .form .grid,
body.agency-panel form .grid {
  gap: 13px;
}
body.agency-panel .form .btn,
body.agency-panel form.form .btn {
  border-radius: 16px;
  min-height: 42px;
}
body.agency-panel .form h3,
body.agency-panel form.form h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: #0f172a;
}
@media (max-width: 800px) {
  body.agency-panel .app-form .card,
  body.agency-panel form.form > .card {
    border-radius: 20px;
    padding: 13px;
    margin-bottom: 10px;
  }
  body.agency-panel .form label,
  body.agency-panel form label {
    font-size: 11.5px;
    gap: 5px;
  }
  body.agency-panel input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  body.agency-panel select,
  body.agency-panel textarea,
  body.agency-panel .search-select-input {
    min-height: 40px;
    border-radius: 14px;
    padding: 9px 12px;
    font-size: 13px;
  }
  body.agency-panel .form .grid,
  body.agency-panel form .grid {
    gap: 9px;
  }
}
