/* ============================================================
   Upload Quotas demo — styled to mimic the real Welley product
   Tokens lifted from web-apps/packages/ui/styles/themes (light)
   ============================================================ */
:root {
  /* surfaces */
  --bg-main: #f7f7f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f1f1f1;
  /* borders */
  --border: #e5e5e5;
  --border-strong: #c7c7c7;
  /* brand */
  --brand: #3b82f6;
  --brand-hover: #2563eb;
  --brand-soft: #eff6ff;
  /* status */
  --error: #f04438;
  --error-soft: #fef3f2;
  --warn: #d99100;
  --warn-soft: #fff3d0;
  --ok: #3f9b1b;
  --ok-soft: #e4fbcc;
  /* text */
  --t1: #171717;
  --t2: #404040;
  --t3: #737373;
  --t4: #a1a1a1;
  --on-brand: #ffffff;
  /* shape */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow: 0 0 12px 0 rgba(0, 0, 0, 0.08);
  --shadow-pop: 0 8px 28px rgba(0, 0, 0, 0.16);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }
body {
  background: var(--bg-main);
  color: var(--t1);
  font-size: 15px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }

/* ---------- persona bar (demo scaffolding) ---------- */
.persona-bar {
  flex: 0 0 auto;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 5;
}
.persona-brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: var(--brand); color: #fff; font-weight: 800; font-size: 15px;
  display: grid; place-items: center;
}
.brand-title { font-weight: 600; font-size: 16px; }
.brand-tag {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--t3); background: var(--surface-3); padding: 2px 8px; border-radius: 999px;
}
.persona-switch {
  display: inline-flex; background: var(--surface-3); border-radius: var(--r-md); padding: 3px;
}
.persona-btn {
  border: none; background: transparent; color: var(--t3); cursor: pointer;
  font-size: 13px; font-weight: 600; padding: 7px 16px; border-radius: 9px;
  transition: background .15s, color .15s;
}
.persona-btn:hover { color: var(--t2); }
.persona-btn.active { background: var(--surface); color: var(--t1); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- app area / shell ---------- */
.app-area { flex: 1 1 auto; min-height: 0; overflow: hidden; }
.shell { display: flex; gap: 12px; height: 100%; padding: 12px; }
.shell.user { justify-content: center; }

.sidebar {
  background: var(--surface); border-radius: var(--r-lg); flex: 0 0 auto;
  display: flex; flex-direction: column; overflow: hidden;
}
.shell.user .sidebar { width: 300px; }
.shell.wide .sidebar { width: 256px; }

.sidebar-head {
  display: flex; align-items: center; gap: 10px; padding: 18px 16px 12px;
}
.sidebar-head .avatar { width: 32px; height: 32px; font-size: 13px; border-radius: var(--r-sm); }
.sidebar-head h2 { font-size: 17px; font-weight: 600; }
.sidebar-head .sub { font-size: 12px; color: var(--t3); }
.nav { padding: 4px 10px 14px; overflow-y: auto; flex: 1; }
.nav-section-label {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  color: var(--t3); padding: 14px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: var(--r-md);
  color: var(--t3); font-size: 14px; font-weight: 500; min-height: 38px; cursor: default;
}
.nav-item .ico { width: 18px; height: 18px; flex: 0 0 18px; color: currentColor; }
.nav-item.active { background: var(--surface-3); color: var(--t1); font-weight: 600; cursor: default; }
.nav-item.blurred { filter: blur(2.5px); opacity: .45; pointer-events: none; user-select: none; }

/* ---------- main content ---------- */
.main {
  background: var(--surface); border-radius: var(--r-lg); overflow-y: auto;
  flex: 1 1 auto; min-width: 0;
}
.shell.user .main { flex: 0 0 600px; max-width: 600px; }
.main-inner { padding: 28px 32px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.page-title { font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.page-sub { color: var(--t3); font-size: 14px; margin-top: 2px; margin-bottom: 22px; }

/* group context header inside group-admin main */
.group-context { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.group-context .avatar { width: 44px; height: 44px; border-radius: var(--r-md); font-size: 16px; }
.group-context .gc-name { font-size: 18px; font-weight: 600; }
.group-context .gc-meta { font-size: 13px; color: var(--t3); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab {
  border: none; background: none; color: var(--t3); cursor: pointer;
  font-size: 14px; font-weight: 600; padding: 10px 4px; margin-right: 18px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--t2); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- cards / panels ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 20px; margin-bottom: 16px;
}
.card.tint { background: var(--surface-2); }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.muted { color: var(--t3); font-size: 13px; }
.hint { color: var(--t4); font-size: 12px; margin-top: 6px; }

/* ---------- usage bars ---------- */
.usage { margin: 14px 0; }
.usage-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.usage-label { font-size: 13px; font-weight: 500; color: var(--t2); }
.usage-nums { font-size: 13px; color: var(--t2); font-variant-numeric: tabular-nums; }
.usage-nums b { color: var(--t1); font-weight: 600; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--brand); transition: width .4s ease; }
.bar.near .bar-fill { background: var(--warn); }
.bar.over .bar-fill { background: var(--error); }
.bar.unlimited { background: repeating-linear-gradient(90deg, var(--surface-3) 0 6px, transparent 6px 12px); }
.usage-sub { font-size: 12px; color: var(--t3); margin-top: 6px; }

/* ---------- badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.tier-badge { text-transform: uppercase; letter-spacing: .3px; font-size: 11px; }
.tier-NEW { background: var(--surface-3); color: var(--t2); }
.tier-ESTABLISHED { background: #e0edff; color: #1d4ed8; }
.tier-ACTIVE { background: var(--brand-soft); color: var(--brand-hover); }
.tier-ACTIVE.high { background: #dbeafe; color: #1e40af; }
.tier-TRUSTED, .tier-LARGE { background: #ede9fe; color: #6d28d9; }
.badge.ov-auto { background: var(--surface-3); color: var(--t3); }
.badge.ov-pin { background: #e0e7ff; color: #4338ca; }
.badge.ov-custom { background: var(--warn-soft); color: #92600a; }
.badge.ov-blocked { background: var(--error-soft); color: var(--error); }
.badge.st-active { background: var(--ok-soft); color: #2f7d12; }
.badge.st-limited { background: var(--warn-soft); color: #92600a; }
.badge.st-suspended { background: var(--error-soft); color: var(--error); }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot.green { background: var(--ok); } .dot.amber { background: var(--warn); } .dot.red { background: var(--error); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid transparent; border-radius: var(--r-md); font-size: 14px; font-weight: 600;
  padding: 9px 16px; cursor: pointer; transition: background .15s, border-color .15s, color .15s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--surface-3); color: var(--t2); }
.btn-secondary:hover { background: #e8e8e8; color: var(--t1); }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-danger { background: var(--error-soft); color: var(--error); }
.btn-danger:hover { background: #fde0dd; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--t3);
  width: 32px; height: 32px; border-radius: var(--r-sm); cursor: pointer; display: grid; place-items: center;
}
.icon-btn:hover { color: var(--error); border-color: var(--border-strong); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--t3); }
input[type=text], input[type=number], select {
  width: 100%; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); padding: 9px 11px; font-size: 14px; color: var(--t1); outline: none;
  transition: border-color .15s, background .15s;
}
input:focus, select:focus { border-color: var(--brand); background: var(--surface-2); }
input[disabled], select[disabled] { background: var(--surface-2); color: var(--t4); cursor: not-allowed; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.with-unit { display: flex; align-items: stretch; }
.with-unit input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.with-unit .unit {
  display: grid; place-items: center; padding: 0 11px; font-size: 13px; color: var(--t3);
  border: 1px solid var(--border-strong); border-left: none;
  border-top-right-radius: var(--r-md); border-bottom-right-radius: var(--r-md); background: var(--surface-2);
}

/* ---------- toggle switch ---------- */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 40px; height: 22px; border-radius: 999px; background: var(--border-strong);
  transition: background .2s; flex: 0 0 auto;
}
.switch .track::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s;
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch .switch-label { font-size: 14px; font-weight: 500; color: var(--t2); }

/* ---------- override editor ---------- */
.override-editor { margin-top: 6px; }
.opt {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--r-md); margin-bottom: 10px; cursor: pointer; transition: border-color .15s, background .15s;
}
.opt:hover { border-color: var(--border-strong); }
.opt input[type=radio] { margin-top: 2px; accent-color: var(--brand); width: 16px; height: 16px; }
.override-editor:has(.opt input[value=auto]:checked) .opt:has(input[value=auto]),
.override-editor:has(.opt input[value=pin]:checked) .opt:has(input[value=pin]),
.override-editor:has(.opt input[value=custom]:checked) .opt:has(input[value=custom]),
.override-editor:has(.opt input[value=blocked]:checked) .opt:has(input[value=blocked]) {
  border-color: var(--brand); background: var(--brand-soft);
}
.opt-body { flex: 1; }
.opt-title { font-size: 14px; font-weight: 600; }
.opt-desc { font-size: 12px; color: var(--t3); margin-top: 2px; }
.opt-fields { margin-top: 12px; display: none; }
.override-editor:has(input[value=pin]:checked) .opt:has(input[value=pin]) .opt-fields { display: block; }
.override-editor:has(input[value=custom]:checked) .opt:has(input[value=custom]) .opt-fields { display: block; }

/* ---------- tables / lists ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--t3); padding: 8px 12px;
  border-bottom: 1px solid var(--border); text-transform: none;
}
.table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.selected { background: var(--brand-soft); }
.table .mini-bar { width: 120px; }
.cell-entity { display: flex; align-items: center; gap: 10px; }
.cell-entity .who { display: flex; flex-direction: column; }
.cell-entity .who .nm { font-weight: 600; font-size: 13px; }
.cell-entity .who .hd { font-size: 12px; color: var(--t3); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  color: #fff; font-weight: 600; font-size: 12px;
}

.search {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px; max-width: 320px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 0 11px; background: var(--surface);
}
.search input { border: none; padding: 9px 0; }
.search input:focus { background: transparent; }
.search .ico { color: var(--t4); width: 16px; height: 16px; }

/* admin two-column: list + detail */
.split { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
.detail { position: sticky; top: 0; }
.detail-empty { color: var(--t4); font-size: 14px; text-align: center; padding: 40px 16px; }

/* ---------- signals / next tier ---------- */
.signal { margin: 12px 0; }
.signal-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.signal-top .lbl { color: var(--t2); font-weight: 500; }
.signal-top .val { color: var(--t3); font-variant-numeric: tabular-nums; }
.signal-top .val.met { color: var(--ok); font-weight: 600; }
.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter-fill { height: 100%; background: var(--brand); border-radius: 999px; }
.meter-fill.met { background: var(--ok); }
.next-tier-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.unlock-line { font-size: 13px; color: var(--t2); margin: 8px 0 14px; }
.summary-line {
  font-size: 13px; color: var(--brand-hover); background: var(--brand-soft);
  padding: 10px 12px; border-radius: var(--r-sm); margin-top: 12px; font-weight: 500;
}

/* ---------- banners ---------- */
.banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md);
  font-size: 13px; margin-bottom: 16px; line-height: 1.5;
}
.banner .ico { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; }
.banner.warn { background: var(--warn-soft); color: #7a4f06; }
.banner.error { background: var(--error-soft); color: var(--error); }
.banner.info { background: var(--brand-soft); color: var(--brand-hover); }
.banner b { font-weight: 600; }

/* ---------- ladder editor ---------- */
.ladder-tier {
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px; margin-bottom: 14px;
  background: var(--surface);
}
.ladder-tier.is-default { background: var(--surface-2); }
.ladder-tier-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.ladder-tier-head .lt-left { display: flex; align-items: center; gap: 10px; }
.ladder-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px; }
.ladder-grid.wide { grid-template-columns: repeat(4, 1fr); }
.sub-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--t4); margin: 4px 0 2px; grid-column: 1 / -1; }

/* role defaults */
.role-row { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.role-row:first-of-type { border-top: none; }

/* ---------- modal ---------- */
.modal {
  border: none; border-radius: var(--r-lg); padding: 0; width: min(480px, 92vw);
  box-shadow: var(--shadow-pop); color: var(--t1);
}
.modal::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(2px); }
.modal-inner { padding: 24px; }
.modal h3 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.modal p { font-size: 14px; color: var(--t3); margin-bottom: 18px; }

/* ---------- toast ---------- */
.toast-stack {
  position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px;
  z-index: 50; align-items: flex-end;
}
.toast {
  background: #1d1f25; color: #fff; padding: 12px 16px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-pop); display: flex; align-items: center; gap: 10px;
  opacity: 0; transform: translateY(12px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast .tick { width: 18px; height: 18px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 11px; }
.toast.info .tick { background: var(--brand); }

/* misc */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 6px; }
.kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 16px; }
.kpi .k-val { font-size: 22px; font-weight: 700; }
.kpi .k-lbl { font-size: 12px; color: var(--t3); margin-top: 2px; }
.inline-note { font-size: 12px; color: var(--t3); margin-top: 4px; }

@media (max-width: 1080px) {
  .split { grid-template-columns: 1fr; }
  .detail { position: static; }
}
