/* Claw design system on Web Awesome - onegate-cloud (purple accent #7c3aed). */

/* ---------- Web Awesome token overrides ---------- */
:root {
  --claw-accent: #7c3aed;

  /* brand scale derived from the accent (95 = lightest) */
  --wa-color-brand-95: color-mix(in oklab, var(--claw-accent) 11%, white);
  --wa-color-brand-90: color-mix(in oklab, var(--claw-accent) 20%, white);
  --wa-color-brand-80: color-mix(in oklab, var(--claw-accent) 38%, white);
  --wa-color-brand-70: color-mix(in oklab, var(--claw-accent) 56%, white);
  --wa-color-brand-60: color-mix(in oklab, var(--claw-accent) 76%, white);
  --wa-color-brand-50: var(--claw-accent);
  --wa-color-brand-40: color-mix(in oklab, var(--claw-accent) 88%, black);
  --wa-color-brand-30: color-mix(in oklab, var(--claw-accent) 72%, black);
  --wa-color-brand-20: color-mix(in oklab, var(--claw-accent) 55%, black);
  --wa-color-brand-10: color-mix(in oklab, var(--claw-accent) 36%, black);
  --wa-color-brand-05: color-mix(in oklab, var(--claw-accent) 25%, black);
  --wa-color-brand: var(--wa-color-brand-50);

  /* system font stack, medium radius */
  --wa-font-family-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --wa-font-family-heading: var(--wa-font-family-body);
  --wa-font-family-code: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --wa-border-radius-scale: 1;

  --claw-shadow: 0 1px 2px rgb(16 20 40 / .05), 0 10px 30px rgb(16 20 40 / .07);
}
html.wa-dark { --claw-shadow: 0 1px 2px rgb(0 0 0 / .45), 0 10px 30px rgb(0 0 0 / .4); }

/* keep undefined overlays hidden until WA defines them */
wa-dialog:not(:defined) { display: none; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
body {
  margin: 0; font-family: var(--wa-font-family-body); font-size: 14.5px; line-height: 1.55;
  background: var(--wa-color-surface-lowered); color: var(--wa-color-text-normal);
}
a { color: var(--wa-color-text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: var(--wa-font-family-code); font-size: 12.5px;
  background: var(--wa-color-neutral-fill-quiet); border: 1px solid var(--wa-color-surface-border);
  border-radius: var(--wa-border-radius-s); padding: 2px 6px; word-break: break-all;
}
.muted { color: var(--wa-color-text-quiet); font-size: 13px; }
.hidden { display: none !important; }

/* ---------- app shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 22px; background: var(--wa-color-surface-default);
  border-bottom: 1px solid var(--wa-color-surface-border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand .logo {
  width: 30px; height: 30px; border-radius: var(--wa-border-radius-s); display: grid; place-items: center;
  background: linear-gradient(135deg, var(--wa-color-brand-50), var(--wa-color-brand-40)); color: #fff; flex: none;
}
.brand .tag { font-weight: 400; color: var(--wa-color-text-quiet); font-size: 12.5px; margin-left: 2px; }
.spacer { flex: 1; }
.who {
  display: none; align-items: center; gap: 7px;
  font-size: 13px; color: var(--wa-color-text-quiet);
  background: var(--wa-color-neutral-fill-quiet); border: 1px solid var(--wa-color-surface-border);
  border-radius: var(--wa-border-radius-pill); padding: 4px 12px; max-width: 320px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who.show { display: inline-flex; }
.who .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--wa-color-success-fill-loud); flex: none; }

main { max-width: 1020px; margin: 0 auto; padding: 28px 22px 64px; }

/* ---------- cards ---------- */
wa-card { display: block; width: 100%; box-shadow: var(--claw-shadow); }
wa-card + wa-card { margin-top: 18px; }
wa-card h2 { margin: 0 0 14px; font-size: 15px; letter-spacing: -.01em; }

/* ---------- forms ---------- */
form.stack { display: flex; flex-direction: column; gap: 12px; }
.create-row { display: flex; gap: 10px; }
.create-row wa-input { flex: 1; }
.create-row wa-button { flex: none; }

/* ---------- auth ---------- */
.hero { text-align: center; margin: 30px 0; }
.hero h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--wa-color-text-quiet); }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: 720px; margin: 0 auto; }
.auth-grid wa-card + wa-card { margin-top: 0; }
.operator { max-width: 720px; margin: 16px auto 0; }
.operator summary { cursor: pointer; color: var(--wa-color-text-quiet); font-size: 13px; padding: 6px 2px; }
.operator wa-card { margin-top: 10px; }

/* ---------- billing banner ---------- */
#billing-banner { margin-bottom: 18px; }
#billing-banner .banner-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
#billing-banner .banner-row span { flex: 1; min-width: 200px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; margin: -6px -8px; padding: 6px 8px; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--wa-color-surface-border); font-size: 13.5px; vertical-align: middle; }
th { color: var(--wa-color-text-quiet); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--wa-color-neutral-fill-quiet); }
.actions { white-space: nowrap; }
.actions wa-button { margin-right: 5px; }
td .skel-cell { display: block; width: 100%; }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 38px 16px; color: var(--wa-color-text-quiet); }
.empty .glyph { font-size: 0; margin-bottom: 10px; color: var(--wa-color-surface-border); }
.empty strong { display: block; color: var(--wa-color-text-normal); font-size: 15px; margin-bottom: 4px; }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; bottom: 18px; right: 18px; z-index: 100;
  display: flex; flex-direction: column; gap: 9px; max-width: min(380px, calc(100vw - 36px));
}
#toasts wa-callout { box-shadow: var(--claw-shadow); animation: toast-in .2s ease-out; word-break: break-word; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- dialog ---------- */
wa-dialog h3 { margin: 0 0 8px; font-size: 16px; }
wa-dialog .body { color: var(--wa-color-text-quiet); font-size: 13.5px; margin-bottom: 18px; }
wa-dialog .body code { display: block; padding: 9px 11px; margin-top: 9px; user-select: all; }
wa-dialog .row { display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- mobile (hard requirement: works at 360px) ---------- */
@media (max-width: 700px) {
  .auth-grid { grid-template-columns: 1fr; }
  .brand .tag { display: none; }
  .create-row { flex-direction: column; }
  main { padding: 20px 14px 56px; }

  /* tenant table stacks into cards */
  table.responsive { min-width: 0; }
  table.responsive thead { display: none; }
  table.responsive tbody tr {
    display: block; border: 1px solid var(--wa-color-surface-border);
    border-radius: var(--wa-border-radius-m); margin-bottom: 12px; padding: 4px 0;
  }
  table.responsive tbody tr:hover { background: transparent; }
  table.responsive td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border-bottom: 0; padding: 8px 14px;
  }
  table.responsive td::before {
    content: attr(data-label); color: var(--wa-color-text-quiet);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; flex: none;
  }
  table.responsive td[data-label=""]::before { display: none; }
  table.responsive .actions { flex-wrap: wrap; justify-content: flex-end; white-space: normal; }

  /* 44px+ tap targets */
  wa-button::part(base) { min-height: 44px; }
  wa-button[size="small"]::part(base) { min-height: 40px; }
}
