/* Betlive People & Teams - responsive workspace refresh. Layered on top of legacy CSS.
   Design tokens are intentionally centralized to keep the PHP/domain code unchanged. */
:root, html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f3f6fb;
  --muted: #aab6c7;
  --accent: #ed0039;
  --accent-strong: #ff315f;
  --accent-soft: #381725;
  --line: #ffffff18;
  --paper: #0b1018;
  --surface: #111a27;
  --surface2: #192433;
  --surface-3: #233144;
  --field: #0e1723;
  --soft: #311b2a;
  --green: #83dab4;
  --amber: #f0c27b;
  --shadow: 0 22px 60px #03081185;
}
html[data-theme="light"] {
  color-scheme: light;
  --ink: #192638;
  --muted: #56657a;
  --accent: #d90035;
  --accent-strong: #e6003b;
  --accent-soft: #fce7ed;
  --line: #dfe5ed;
  --paper: #f4f7fa;
  --surface: #ffffff;
  --surface2: #f0f3f8;
  --surface-3: #e7edf4;
  --field: #f9fbfd;
  --soft: #fdeaf0;
  --green: #247958;
  --amber: #7a5214;
  --shadow: 0 18px 48px #1c34531c;
}
html { scroll-behavior: smooth; }
body {
  min-width: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Georgian", "Noto Sans", Arial, sans-serif;
  line-height: 1.55;
  background: radial-gradient(ellipse 75% 45% at 75% -10%, #293c572d 0, transparent 85%), var(--paper);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
html[data-theme="light"] body {
  background: radial-gradient(ellipse 70% 40% at 80% -5%, #dce7f68c 0, transparent 90%), var(--paper);
}
body.menu-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, .button-link {
  min-height: 42px;
  border-color: var(--line);
  border-radius: 11px;
  background: var(--surface2);
  color: var(--ink);
  transition: color .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
  -webkit-tap-highlight-color: transparent;
}
button:active:not(:disabled), .button-link:active { transform: scale(.985); }
button:hover:not(:disabled), .button-link:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--surface-3); }
button.primary, .button-link.primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }
button.primary:hover:not(:disabled), .button-link.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button.quiet { background: transparent; }
button.small, .button-link.small { min-height: 40px; padding: 8px 12px; }
input, select, textarea {
  border-radius: 10px;
  border-color: var(--line);
  background: var(--field);
  min-height: 45px;
  padding: 11px 13px;
  color: var(--ink);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .88; }
input[type="checkbox"] { min-height: auto; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 65%, white); outline-offset: 3px; }
h1 { font-size: clamp(25px, 2.35vw, 34px); line-height: 1.25; letter-spacing: -.035em; font-weight: 700; text-wrap: balance; }
h2 { font-size: 19px; line-height: 1.35; letter-spacing: -.025em; }
h3 { line-height: 1.4; }
p { line-height: 1.65; }
small, .muted { color: var(--muted); }
.eyebrow { font-size: 10px; font-weight: 600; letter-spacing: .13em; }
.pill { border-radius: 9px; padding: 5px 9px; }
.pill.red, .role-admin { color: #ff9cb5; }
html[data-theme="light"] .pill.red, html[data-theme="light"] .role-admin { color: #9d1436; }
.pill.green { background: color-mix(in srgb, var(--green) 12%, transparent); }
.pill.amber { background: color-mix(in srgb, var(--amber) 12%, transparent); }

/* Top-level shell: compact, consistent and calm on desktop. */
header.app-header {
  position: relative;
  z-index: 20;
  min-height: 78px;
  padding: 13px clamp(20px, 2.2vw, 34px);
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 20px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border-bottom-color: var(--line);
}
.brand { white-space: nowrap; min-width: 0; }
.brand-logo { width: 114px; height: auto; }
.brand .scrum-badge { font-size: 10px; letter-spacing: .035em; padding: 6px 8px; border-radius: 6px; }
.brand-sub { padding-left: 20px; border-left-color: var(--line); font-weight: 550; line-height: 1.4; white-space: nowrap; }
.brand-sub small { font-size: 11px; font-weight: 400; }
.header-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }
.header-actions { display: flex; flex-wrap: nowrap; align-items: center; margin-left: 0; gap: 9px; }
.header-actions .pill { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions #status { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions form { margin: 0; }
.header-actions button { min-height: 40px; padding: 9px 12px; white-space: nowrap; }
.header-actions .action-icon { width: 16px; height: 16px; flex: none; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.header-actions #export, .header-actions #import { display: inline-flex; gap: 8px; align-items: center; }
.header-actions .logout-button { display: inline-flex; align-items: center; gap: 8px; }
.theme-toggle {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  place-items: center;
  width: 84px;
  min-width: 84px;
  height: 44px;
  padding: 4px;
  border-radius: 13px;
  background: var(--surface2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.theme-toggle::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 4px;
  top: 4px;
  height: 34px;
  width: 36px;
  border-radius: 9px;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent), 0 2px 8px #00000018;
  transition: transform .23s cubic-bezier(.2,.8,.25,1);
}
html[data-theme="light"] .theme-toggle::before { transform: translateX(37px); }
.theme-toggle:hover:not(:disabled) { background: var(--surface-3); }
.theme-choice { display: grid; place-items: center; width: 34px; height: 34px; color: var(--muted); }
.theme-choice svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
html[data-theme="dark"] .theme-choice.moon, html[data-theme="light"] .theme-choice.sun { color: var(--ink); }
.menu-toggle, .drawer-close { display: none; padding: 0; place-items: center; height: 44px; width: 44px; border-radius: 12px; }
.menu-toggle svg, .drawer-close svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
.drawer-head, .drawer-actions-slot { display: none; }
.drawer-backdrop[hidden] { display: none !important; }
.shell { grid-template-columns: 246px minmax(0, 1fr); min-height: calc(100dvh - 78px); }
.workspace-sidebar {
  background: color-mix(in srgb, var(--surface) 65%, var(--paper));
  border-right: 1px solid var(--line);
  padding: 31px 17px 24px;
  gap: 22px;
}
.workspace-sidebar h3 { font-size: 16px; letter-spacing: -.02em; margin: 0 0 20px; }
.workspace-sidebar .eyebrow { padding: 0 11px; }
.workspace-sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.workspace-sidebar nav .workspace-nav-item {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  gap: 12px;
  margin: 0;
  padding: 12px 13px;
  min-height: 48px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
}
.workspace-sidebar nav .workspace-nav-item:hover { color: var(--ink); background: var(--surface2); border-color: transparent; }
.workspace-sidebar nav .workspace-nav-item.active,
.workspace-sidebar nav .workspace-nav-item[aria-current="page"] {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: inset 3px 0 var(--accent);
}
.nav-icon { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.workspace-nav-item.active .nav-icon { stroke: var(--accent-strong); }
.side-note { margin-top: auto; border-color: var(--line); padding: 23px 11px 0; }
.side-note b { letter-spacing: -.01em; }
.side-note p { line-height: 1.7; }
.side-note .mark { font-size: 28px; }
main { max-width: 1560px; margin: 0 auto; padding: clamp(25px, 2.7vw, 42px); }
.heading { gap: 22px; margin-bottom: 26px; }
.heading p { max-width: 620px; font-size: 13px; }
.heading .row { gap: 9px; }
.stats { gap: 14px; margin: 23px 0 30px; }
.stat { border-color: var(--line); background: var(--surface); border-radius: 15px; padding: 20px 23px; }
.stat strong { color: var(--ink); font-weight: 670; letter-spacing: -.03em; font-size: clamp(26px, 2.2vw, 32px); line-height: 1.25; }
.stat small { display: block; margin-top: 9px; line-height: 1.45; font-size: 11px; }
.tabs { display: flex; gap: 9px; padding-bottom: 13px; }
.tabs button { flex: none; min-height: 42px; padding: 9px 16px; color: var(--muted); font-size: 13px; font-weight: 550; }
.tabs button.active { background: var(--accent-soft); color: var(--ink); }
.tabs button.active:hover:not(:disabled) { background: var(--accent-soft); }
.toolbar { align-items: center; gap: 11px; }
.toolbar input, .toolbar select { background: var(--surface); }
.toolbar input { max-width: 490px; }
.toolbar select { max-width: 240px; }
.table-wrap, .panel { border-color: var(--line); border-radius: 15px; background: var(--surface); }
.table-wrap { scrollbar-color: var(--muted) var(--surface); }
.panel { padding: 23px; }
.table-wrap table { font-variant-numeric: tabular-nums; }
.table-wrap th { background: var(--surface2); font-size: 11px; font-weight: 600; letter-spacing: .015em; }
.table-wrap td, .table-wrap th { border-color: var(--line); }
.table-wrap tbody tr:hover td { background: color-mix(in srgb, var(--surface2) 55%, transparent); }
.avatar { border-radius: 13px; background: var(--accent-soft); color: #ff9fb7; font-weight: 650; }
html[data-theme="light"] .avatar { color: #ab2343; }
.grid { gap: 16px; }
.team-card { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 15px; background: var(--surface); }
.team-card .team-icon { color: var(--accent-strong); }
.team-card footer { margin-top: auto; border-color: var(--line); }
.empty { background: color-mix(in srgb, var(--surface) 72%, transparent); border-color: var(--line); border-radius: 16px; }
.note { background: var(--surface2); border: 1px solid var(--line); }
.comment { background: var(--surface2); border-left-color: var(--accent); }
dialog { width: min(660px, calc(100vw - 32px)); border: 1px solid var(--line); background: var(--surface); border-radius: 19px; box-shadow: var(--shadow); padding: 27px; }
dialog::backdrop { background: #02070fbd; backdrop-filter: blur(4px); }
dialog h2 { font-size: 20px; }
dialog .actions { gap: 10px; }
#toast { max-width: min(480px, calc(100vw - 28px)); bottom: max(20px, env(safe-area-inset-bottom)); background: var(--surface-3); border-color: var(--line); box-shadow: var(--shadow); }

/* Admin settings: one consistent component language. */
.admin-main { max-width: 1480px; }
.accounts-panel { padding: 0; }
.accounts-heading { padding: 23px 24px 18px; }
.accounts-toolbar { align-items: center; }
.accounts-toolbar label { min-width: 0; }
.accounts-toolbar .search-field { max-width: 520px; }
.accounts-footer { background: var(--surface); }
.users-table tr td:last-child a { min-width: 77px; }
.role-label { background: var(--surface2); border-color: var(--line); }
.role-admin { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 20%, transparent); }
.permission-guide { padding: 21px 23px; }
.account-dialog { width: min(680px, calc(100vw - 32px)); }
.account-access { background: var(--surface2); }
.dialog-close { min-height: 42px; min-width: 42px; }

/* Responsive layout: sidebar becomes an accessible off-canvas navigation. */
@media (max-width: 1100px) {
  header.app-header { gap: 13px; }
  .brand-sub { display: none; }
  .header-actions .pill { max-width: 95px; }
  .header-actions #status { display: none; }
  .shell { grid-template-columns: 218px minmax(0, 1fr); }
  main { padding: 26px 23px; }
  .workspace-sidebar { padding: 25px 11px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  header.app-header { position: sticky; top: 0; min-height: 68px; padding: 10px max(16px, env(safe-area-inset-left)); gap: 12px; }
  .brand-logo { width: 105px; }
  .brand .scrum-badge { padding: 6px 7px; font-size: 9px; }
  .header-tools { margin-left: auto; gap: 8px; }
  .menu-toggle, .drawer-close { display: grid; }
  .theme-toggle { height: 44px; }
  header.app-header > .header-actions { display: none; }
  .shell { display: block; min-height: calc(100dvh - 68px); }
  .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 39; width: 100%; height: 100dvh; padding: 0; border: 0; border-radius: 0; background: #030a14a8; backdrop-filter: blur(3px); }
  .workspace-sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(340px, 88vw);
    min-height: 100dvh;
    max-height: 100dvh;
    padding: calc(20px + env(safe-area-inset-top)) 18px calc(16px + env(safe-area-inset-bottom));
    border-right: 1px solid var(--line);
    border-bottom: 0;
    background: var(--surface);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-x: hidden;
    overflow-y: auto;
    transform: translateX(-104%);
    visibility: hidden;
    pointer-events: none;
    transition: transform .27s cubic-bezier(.2,.85,.24,1), visibility .27s;
  }
  .workspace-sidebar.is-open { transform: translateX(0); visibility: visible; pointer-events: auto; }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 3px 25px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
  .drawer-head strong { font-size: 15px; letter-spacing: -.02em; }
  .workspace-sidebar .eyebrow, .workspace-sidebar h3 { display: block; }
  .workspace-sidebar .eyebrow { font-size: 10px; }
  .workspace-sidebar h3 { margin-bottom: 18px; }
  .workspace-sidebar nav { flex-direction: column; flex-wrap: nowrap; gap: 7px; }
  .workspace-sidebar nav .workspace-nav-item { flex: none; width: 100%; margin: 0; padding: 13px 14px; min-height: 50px; font-size: 13px; }
  .side-note { display: none; }
  .drawer-actions-slot { display: block; margin-top: auto; padding-top: 20px; border-top: 1px solid var(--line); }
  .drawer-actions-slot .header-actions { display: flex; flex-direction: column; align-items: stretch; gap: 9px; margin: 0; }
  .drawer-actions-slot .header-actions #status { display: block; max-width: none; white-space: normal; font-size: 11px; }
  .drawer-actions-slot .header-actions .pill { align-self: flex-start; max-width: 100%; margin-bottom: 3px; }
  .drawer-actions-slot .header-actions button, .drawer-actions-slot .header-actions form, .drawer-actions-slot .header-actions form button { width: 100%; min-height: 46px; justify-content: center; }
  main { width: 100%; max-width: 100%; padding: 25px clamp(16px, 4vw, 28px) calc(28px + env(safe-area-inset-bottom)); }
  .heading { align-items: stretch; flex-direction: column; gap: 19px; }
  .heading .row { width: 100%; }
  .heading .row button { flex: 1 1 auto; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input { max-width: none; flex: 1 1 100%; }
  .toolbar select { max-width: none; flex: 1 1 200px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  main { padding: 24px 16px calc(28px + env(safe-area-inset-bottom)); }
  .heading { margin-bottom: 23px; }
  .heading p { margin-top: 9px; font-size: 13px; }
  .heading .row { gap: 8px; }
  .heading .row button, .heading .row .button-link { min-height: 46px; padding: 10px 13px; font-size: 12px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 20px 0 24px; }
  .stat { min-width: 0; padding: 16px; border-radius: 13px; }
  .stat strong { font-size: clamp(24px, 7vw, 30px); }
  .stat small { margin-top: 7px; font-size: 11px; }
  .tabs { margin: 0 -16px 18px; padding: 0 16px 13px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; flex-wrap: nowrap; white-space: nowrap; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { min-height: 44px; padding: 10px 14px; font-size: 12px; }
  .toolbar { gap: 9px; }
  .toolbar input, .toolbar select { flex: 1 1 100%; width: 100%; }
  button.small, .button-link.small { min-height: 44px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .team-card, .panel { border-radius: 14px; padding: 19px; }
  .team-card { min-height: 0; }
  .team-card p { min-height: 0; }
  .team-card footer { margin-top: 22px; }
  .accounts-panel { padding: 0; }
  .accounts-heading { padding: 20px 16px 16px; gap: 16px; }
  .accounts-heading .button-link { width: 100%; min-height: 46px; }
  .accounts-toolbar { margin-bottom: 18px; padding: 0 16px; }
  .accounts-toolbar .search-field, .accounts-toolbar>label:not(.search-field) { flex-basis: 100%; width: 100%; max-width: none; }
  .accounts-footer { padding: 15px 16px; }
  .permission-guide { padding: 18px 16px; }
  .permission-guide .table-wrap { overflow-x: auto; }
  .permission-guide .table-wrap table { min-width: 570px; }
  .account-dialog, dialog {
    position: fixed;
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 18px - env(safe-area-inset-top));
    margin: auto 0 0;
    padding: 23px 18px calc(18px + env(safe-area-inset-bottom));
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  dialog .form-grid { grid-template-columns: minmax(0, 1fr); }
  dialog .full { grid-column: 1; }
  dialog .actions { gap: 9px; flex-wrap: wrap; }
  dialog .actions button, dialog .actions .button-link { flex: 1 1 auto; min-height: 45px; }
  .account-access { flex-direction: column; gap: 12px; }
  .account-dialog .dialog-heading { gap: 12px; }
  #toast { left: 14px; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); max-width: none; }
  /* Tables turn into scannable field cards, with labels populated from headers by workspace-ui.js. */
  .table-wrap.mobile-card-wrap { border: 0; background: transparent; overflow: visible; }
  .mobile-card-table, .mobile-card-table tbody { display: block; width: 100%; min-width: 0; }
  .mobile-card-table thead { display: none; }
  .mobile-card-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 13px;
    margin-bottom: 11px;
    overflow: hidden;
  }
  .mobile-card-table tbody tr:hover td { background: transparent; }
  .mobile-card-table td, .users-table .mobile-card-table td { display: block; min-width: 0; padding: 9px 7px; border: 0; text-align: left; font-size: 12px; overflow-wrap: anywhere; }
  .mobile-card-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .02em; margin-bottom: 6px; }
  .mobile-card-table td:first-child, .users-table .mobile-card-table td:first-child { grid-column: 1 / -1; padding: 3px 7px 13px; margin-bottom: 5px; border-bottom: 1px solid var(--line); }
  .mobile-card-table td:first-child::before { display: none; }
  .mobile-card-table td:last-child { grid-column: 1 / -1; padding: 11px 7px 1px; }
  .mobile-card-table td:last-child::before { display: none; }
  .mobile-card-table td:last-child button, .mobile-card-table td:last-child a { width: 100%; min-height: 43px; display: inline-flex; justify-content: center; align-items: center; }
  .mobile-card-table td .person { align-items: center; }
  .mobile-card-table td .pill { margin: 2px 3px 2px 0; }
  .users-table { border: 0; background: transparent; }
  .users-table .mobile-card-table tr { margin: 0 14px 11px; }
  .users-table .mobile-card-table td:last-child { text-align: left; }
}
@media (max-width: 380px) {
  header.app-header { padding-left: 12px; padding-right: 12px; gap: 7px; }
  .brand { gap: 7px; }
  .brand-logo { width: 88px; }
  .brand .scrum-badge { font-size: 8px; }
  .theme-toggle { width: 75px; min-width: 75px; }
  .theme-toggle::before { width: 32px; }
  html[data-theme="light"] .theme-toggle::before { transform: translateX(33px); }
  .theme-choice { width: 30px; }
  .header-tools { gap: 6px; }
  .menu-toggle { width: 44px; }
  .mobile-card-table tr { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Login uses the same tokens and theme control, without exposing application navigation. */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: clamp(20px, 5vw, 48px) 16px; }
.login-main { display: block; width: 100%; max-width: 480px; margin: 0 auto; padding: 0; }
.login-panel { padding: clamp(22px, 5vw, 34px); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.login-panel-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 29px; }
.login-page .login-panel .eyebrow { margin-bottom: 10px; }
.login-form { display: grid; gap: 17px; margin-top: 28px; }
.login-form button { min-height: 48px; }
.login-error { color: #ff9cb5; font-size: 12px; }
html[data-theme="light"] .login-error { color: #b5143b; }
/* The legacy users table enforces a 580px minimum. Cancel it only in mobile card mode. */
@media (max-width: 600px) {
  .users-table table.mobile-card-table { min-width: 0; }
}
