/* ==========================================================================
   PrimeIndex Pro — final mobile / responsive polish (loaded last).
   Keeps the existing dark + emerald + blue identity and only fixes layout.
   ========================================================================== */

/* ---------------------------------------------------------------- brand */
.brand-mark{
  width:34px;height:34px;flex:0 0 34px;display:inline-grid;place-items:center;
  border-radius:11px;color:#04121c;
  background:linear-gradient(135deg,var(--acc),var(--acc2));
  box-shadow:0 0 0 4px color-mix(in srgb,var(--acc) 14%,transparent),
             0 8px 18px -10px color-mix(in srgb,var(--acc) 70%,transparent);
}
.brand-mark svg{width:18px;height:18px;stroke-width:2.4}
.brand-logo{max-width:min(190px,44vw);max-height:34px;width:auto;object-fit:contain}
.logout-link{display:inline-flex;align-items:center;gap:6px;white-space:nowrap}
.nav-close{display:none}

/* ------------------------------------------------------------ smoothing */
html{scroll-behavior:smooth;-webkit-text-size-adjust:100%}
img,svg,video,iframe{max-width:100%}
main{min-width:0}

/* The scrim must stay below the sticky header: the public nav drawer and the
   admin/user panel drawer live inside stacking contexts with z-index 20/40.
   With the old z-index 38 the scrim covered the open drawer, which made the
   mobile menu look broken (links and the close button were unclickable). */
.ui-scrim{z-index:15}
.table-scroll{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
::selection{background:color-mix(in srgb,var(--acc) 35%,transparent)}

/* ------------------------------------------- admin users filter toolbar */
.users-filters{
  display:grid;grid-template-columns:minmax(220px,1.5fr) repeat(4,minmax(130px,1fr)) auto;
  gap:12px;align-items:end;
}
.users-filters label{margin:0 0 6px}
.users-filters .filter-actions{display:flex;gap:8px;align-items:center}
.users-filters .filter-actions .btn{white-space:nowrap}

/* --------------------------------------------- admin users table (desktop) */
.users-table{display:table;width:100%;table-layout:auto}
.users-table th,.users-table td{vertical-align:top}
.users-table td{min-width:0}
.users-table .credit-form{
  display:grid;grid-template-columns:minmax(72px,1fr) auto auto;
  gap:6px;align-items:center;min-width:190px;
}
.users-table .credit-form input{min-width:72px;padding:8px 10px}
.users-table .provider-form{
  display:grid;grid-template-columns:minmax(120px,1fr) auto;
  gap:6px;align-items:center;
}
.users-table .provider-form select{padding:8px 9px}
.users-table details.key-box{margin-top:8px}
.users-table details.key-box input{font-size:12px;padding:8px 10px}

/* ----------------------------------------------------------- <= 1100px */
@media (max-width:1100px){
  .users-filters{grid-template-columns:repeat(3,minmax(0,1fr))}
  .users-filters .filter-search{grid-column:span 2}
  .users-filters .filter-actions{grid-column:1/-1}
}

/* ------------------------------------------------------------ <= 820px */
@media (max-width:820px){
  .topbar{
    padding:10px 14px;gap:10px;flex-wrap:nowrap;align-items:center;
    min-height:64px;
  }
  /* A backdrop-filter on the header would make the fixed-position mobile
     drawer size itself to the header instead of the viewport. Turn it off
     only on small screens; the translucent header colour is kept. */
  .topbar{
    -webkit-backdrop-filter:none!important;
    backdrop-filter:none!important;
  }
  .topbar .brand{
    flex:1 1 auto;min-width:0;max-width:calc(100% - 66px);
    position:static!important;transform:none!important;
    font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  }
  .topbar .brand-logo{max-width:min(150px,40vw);max-height:30px}
  .brand-chip{display:none}

  /* burger sits on the left in app/admin mode and on the right in public mode */
  .topbar .ui-burger{
    margin-left:0;flex:0 0 42px;width:42px;height:42px;
  }
  .mode-public .topbar .ui-burger{margin-left:auto}
  .mode-public .topbar .brand{max-width:calc(100% - 58px)}

  .app-nav{margin-left:auto;gap:6px;flex-wrap:nowrap;min-width:0}
  .app-nav .app-switch{display:none}
  .app-nav .tg-btn{padding:8px;width:38px;height:38px;justify-content:center}
  .app-nav .tg-btn span{display:none}
  .app-nav .avatar.sm{width:32px;height:32px}
  .logout-link{padding:8px 10px;min-height:38px}
  .logout-link span{display:none}

  /* public navigation drawer close button */
  .nav-close{
    display:grid;place-items:center;position:absolute;top:14px;right:14px;
    width:38px;height:38px;border-radius:12px;border:1px solid var(--line);
    background:var(--panel);color:var(--txt);font-size:24px;line-height:1;
    cursor:pointer;z-index:2;
  }
  .topbar nav#siteNav .nav-close{display:grid}
  .topbar nav#siteNav{padding-top:64px}

  .users-filters{grid-template-columns:1fr 1fr}
  .users-filters .filter-search{grid-column:1/-1}
  .users-filters .filter-actions{grid-column:1/-1}
  .users-filters .filter-actions .btn{flex:1}

  .page-head{align-items:flex-start}
  .layout{padding:16px 14px;gap:16px}
  .card{padding:16px}
  input,select,textarea{font-size:16px}
  .row{gap:8px}
  .btn,button{min-height:42px}
  .btn.sm{min-height:36px}
  .pager{flex-wrap:wrap;gap:8px}
  .pager .btn{flex:1 1 auto;justify-content:center}
  .flash{margin:12px 0}
  main h2{font-size:22px}
  details summary{min-height:34px;display:flex;align-items:center}
}

/* ------------------------------------------- admin users as mobile cards */
@media (max-width:760px){
  .users-table{display:block;width:100%}
  .users-table thead{display:none}
  .users-table tbody{display:grid;gap:12px}
  .users-table tr{
    display:block;border:1px solid var(--line);border-radius:16px;padding:14px;
    background:linear-gradient(180deg,rgba(255,255,255,.035),rgba(255,255,255,.012));
  }
  .users-table td{
    display:block;width:100%;border:0;padding:8px 0;min-width:0;
  }
  .users-table td + td{border-top:1px dashed rgba(255,255,255,.08)}
  .users-table td[data-label]:before{
    content:attr(data-label);display:block;margin-bottom:5px;
    font-size:10.5px;font-weight:700;letter-spacing:.1em;
    text-transform:uppercase;color:var(--mut);
  }
  .users-table td[data-label="User"]{padding-top:0}
  .users-table td[data-label="User"]:before{display:none}
  .users-table .credit-form{grid-template-columns:1fr auto auto;min-width:0}
  .users-table .provider-form{grid-template-columns:1fr auto;min-width:0}
  .users-table .row{gap:6px}
  .users-table .btn{min-height:38px}
}

/* ------------------------------------------------------------ <= 520px */
@media (max-width:520px){
  .topbar{padding:9px 12px}
  .topbar .brand{font-size:15px}
  .brand-mark{width:32px;height:32px;flex-basis:32px}
  .users-filters{grid-template-columns:1fr}
  .users-filters .filter-search,
  .users-filters .filter-actions{grid-column:auto}
  .users-table .credit-form{grid-template-columns:1fr 1fr}
  .users-table .credit-form input{grid-column:1/-1}
  .users-table .provider-form{grid-template-columns:1fr}
  .users-table .provider-form .btn{width:100%}
}

/* --------------------------------------------------------- touch devices */
@media (hover:none){
  .card:hover{transform:none}
  .btn:hover{transform:none;filter:none}
}
