/* Rank Tracker: "Quiet glass" design system, from docs/ui-mockups/DESIGN.md.
   Hand-written, no build step. Tokens first, then base, shell, components, screens. */

:root {
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --surface-2: #FAFAFC;
  --ink: #1D1D1F;
  --ink-2: #636366;
  --line: rgba(0, 0, 0, 0.08);
  --line-2: rgba(0, 0, 0, 0.12);
  --fill: #EEEEF0;
  --fill-2: #E5E5EA;
  --blue: #0071E3;
  --blue-text: #0066CC;
  --blue-tint: #E8F2FD;
  --green: #1E7B34;
  --green-tint: #EAF6ED;
  --red: #D70015;
  --red-tint: #FDECEE;
  --orange: #B24D00;
  --orange-tint: #FFF3E6;
  --bar-off: #C7C7CC;
  --yt: #E5251B;
  --ig: #C13584;
  --tt: #1D1D1F;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --shadow-card: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);
  --shadow-pop: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 24px 64px rgba(0, 0, 0, 0.18);
  --seg-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

/* --- base ---------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--blue-text); text-decoration: none; }
a:hover { color: #004C99; }
:focus-visible { outline: 3px solid rgba(0, 113, 227, 0.45); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
p { margin: 0; }
h1, h2, h3 { margin: 0; }
.icon { flex: none; display: block; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.hov:hover { box-shadow: inset 0 0 0 100px rgba(0, 0, 0, 0.04); }

/* --- shell --------------------------------------------------------------------------- */

.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side {
  flex: 0 0 248px;
  background: rgba(255, 255, 255, 0.72);
  border-right: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.main { flex: 999 1 560px; min-width: 0; padding: 28px clamp(16px, 4vw, 48px) 64px; }
.content { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }

/* sidebar */
.nav { display: flex; flex-direction: column; gap: 18px; padding: 20px 12px 16px; min-height: 100%; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand b { display: block; font-size: 15px; line-height: 20px; font-weight: 600; }
.brand small { display: block; font-size: 12px; line-height: 16px; color: var(--ink-2); }
.nav-search {
  display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px;
  border-radius: 9px; background: rgba(118, 118, 128, 0.12); color: var(--ink-2);
}
.nav-search input {
  flex: 1; min-width: 0; border: 0; background: transparent; font-size: 14px; outline: none;
  color: var(--ink);
}
.nav-search input::placeholder { color: var(--ink-2); }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 0 10px 4px; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-2); }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 9px;
  font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap;
}
.nav-item:hover { color: var(--ink); background: rgba(0, 0, 0, 0.04); }
.nav-item .icon { color: var(--ink-2); }
.nav-item[aria-current="page"] { background: rgba(0, 113, 227, 0.10); color: var(--blue-text); font-weight: 600; }
.nav-item[aria-current="page"] .icon { color: var(--blue); }
.nav-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item .count { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.nav-item.add { color: var(--blue-text); }
.nav-item.add .icon { color: var(--blue); }
.nav-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 4px 10px; }
.user-row b { display: block; font-size: 13px; line-height: 18px; font-weight: 600; }
.user-row small { display: block; font-size: 12px; line-height: 16px; color: var(--ink-2); }

.mono {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 20px; height: 20px; border-radius: 999px; color: #FFFFFF;
  font-size: 11px; line-height: 1; font-weight: 600; letter-spacing: 0;
}
.mono.lg { width: 30px; height: 30px; font-size: 12px; }
.mono.xl { width: 44px; height: 44px; font-size: 16px; }
.mono.empty { background: transparent; border: 1.5px dashed var(--bar-off); color: var(--ink-2); }

/* phone tab bar */
.tabbar { display: none; }

/* --- page header ---------------------------------------------------------------------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head > div:first-child { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.crumbs a { color: var(--ink-2); }
.crumbs a:hover { color: var(--ink); }
.title {
  font-family: var(--font-display); font-size: 34px; line-height: 40px; font-weight: 700;
  letter-spacing: -0.022em; overflow-wrap: anywhere;
}
.sub { font-size: 15px; line-height: 20px; color: var(--ink-2); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* --- buttons -------------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 16px; border: 0; border-radius: 999px;
  font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap; text-decoration: none;
}
.btn:hover { filter: brightness(0.95); }
.btn-primary { background: var(--blue); color: #FFFFFF; }
.btn-primary:hover { color: #FFFFFF; }
.btn-primary[disabled] { background: var(--fill-2); color: var(--ink-2); cursor: default; filter: none; }
.btn-secondary { background: var(--fill); color: var(--ink); }
.btn-secondary:hover { color: var(--ink); }
.btn-plain { background: transparent; color: var(--blue-text); padding: 0 8px; }
.btn-danger { background: var(--red-tint); color: var(--red); }
.btn-danger:hover { color: var(--red); }
.btn-icon { width: 34px; padding: 0; background: var(--fill); color: var(--ink); }
.btn-sm { height: 28px; padding: 0 12px; font-size: 13px; }
.btn-icon.btn-sm { width: 28px; padding: 0; }
.btn-block { width: 100%; height: 44px; font-size: 15px; }
form.inline { display: inline; margin: 0; }

/* --- segmented control ---------------------------------------------------------------- */

.seg { display: inline-flex; width: fit-content; flex-wrap: wrap; padding: 2px; gap: 2px; border-radius: 10px; background: var(--fill); max-width: 100%; }
.seg > a, .seg > button, .seg > label > span {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 14px; border: 0;
  border-radius: 8px; background: transparent; color: var(--ink); font-size: 13px; font-weight: 500;
  white-space: nowrap; cursor: pointer;
}
.seg > a:hover { color: var(--ink); }
.seg > a[aria-current="page"], .seg > a[aria-pressed="true"], .seg > button[aria-pressed="true"],
.seg > label > input:checked + span {
  background: #FFFFFF; box-shadow: var(--seg-shadow); font-weight: 600;
}
.seg > label > input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg > label > input:focus-visible + span { outline: 3px solid rgba(0, 113, 227, 0.45); outline-offset: 1px; }
.seg .count { color: var(--ink-2); font-weight: 500; font-variant-numeric: tabular-nums; }

/* --- cards ---------------------------------------------------------------------------- */

.card { position: relative; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-card); overflow: hidden; min-width: 0; }
.card-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 18px 20px 6px;
}
.card-head h2, .card h2 { font-size: 17px; line-height: 22px; font-weight: 600; }
.card-head .meta { font-size: 13px; color: var(--ink-2); }
.card-body { padding: 12px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.card-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 12px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2);
}
.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.cols > * { flex: 1 1 440px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.cols > .wide { flex: 1.5 1 440px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }

/* grouped list rows */
.list { list-style: none; margin: 0; padding: 0 0 4px; }
.li {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin-left: 20px; padding: 8px 20px 8px 0; min-height: 52px; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.li:last-child { border-bottom: 0; }
.li > label, .li > .label { font-weight: 500; }
.li .value { color: var(--ink-2); }
.li .control { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 1 280px; min-width: 0; }
.li .control > * { max-width: 100%; }

/* --- fields --------------------------------------------------------------------------- */

.input, .select, .textarea {
  height: 36px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px;
  background: #FFFFFF; font-size: 14px; width: 100%;
}
.select { padding-right: 28px; }
.textarea { height: auto; min-height: 220px; padding: 10px 12px; line-height: 20px; resize: vertical; }
.input.lg { height: 44px; font-size: 15px; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--red); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 13px; line-height: 18px; font-weight: 600; }
.field-error, .error-text { font-size: 13px; line-height: 18px; color: var(--red); }
.filter { position: relative; flex: 1 1 240px; max-width: 340px; }
.filter .icon { position: absolute; left: 12px; top: 10px; color: var(--ink-2); }
.filter .input { padding-left: 34px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }

/* switch */
.switch { position: relative; display: inline-flex; flex: none; }
.switch input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; cursor: pointer; }
.switch span {
  width: 44px; height: 26px; border-radius: 999px; background: var(--fill-2); transition: background 0.15s;
  position: relative;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 999px;
  background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 0.15s;
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid rgba(0, 113, 227, 0.45); outline-offset: 2px; }

/* --- notices -------------------------------------------------------------------------- */

.notice {
  display: flex; align-items: flex-start; gap: 8px; padding: 12px 14px; border-radius: 14px;
  background: var(--orange-tint); color: var(--orange); font-size: 13px; line-height: 18px; font-weight: 500;
}
.notice .icon { margin-top: 1px; }
.notice.info { background: var(--blue-tint); color: var(--blue-text); }
.notice.ok { background: var(--green-tint); color: var(--green); }
.notice.bad { background: var(--red-tint); color: var(--red); }

/* --- table ---------------------------------------------------------------------------- */

.table-box { position: relative; overflow-x: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; line-height: 20px; }
.tbl.keywords { min-width: 1080px; }
.tbl th {
  text-align: left; padding: 8px 12px; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-2);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl tr:last-child td { border-bottom: 0; }
.row:hover { background: #FAFAFC; }
.tbl .kw { font-weight: 500; color: var(--ink); }
.tbl .kw:hover { color: var(--blue-text); }
.tbl .note { display: block; font-size: 12px; line-height: 16px; color: var(--ink-2); }
.empty { padding: 32px 20px; text-align: center; color: var(--ink-2); font-size: 14px; }

/* platform glyph pills, status dots, badges */
.plats { display: flex; gap: 4px; }
.plat { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 24px; border-radius: 999px; background: var(--fill); }
.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 999px; background: var(--bar-off); flex: none; }
.dot.green { background: var(--green); }
.dot.blue { background: var(--blue); }
.dot.orange { background: var(--orange); }
.beta {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px;
  background: var(--orange-tint); color: var(--orange); font-size: 12px; line-height: 16px; font-weight: 600;
}
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px;
  background: var(--fill); color: var(--ink); font-size: 12px; line-height: 16px; font-weight: 600; white-space: nowrap;
}
.tag.ok { background: var(--green-tint); color: var(--green); }
.tag.warn { background: var(--orange-tint); color: var(--orange); }
.tag.bad { background: var(--red-tint); color: var(--red); }
.tag.info { background: var(--blue-tint); color: var(--blue-text); }

/* row action menu */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: 32px; z-index: 5; min-width: 180px; padding: 6px;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
}
.menu-pop a, .menu-pop button {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 34px; padding: 0 10px; border: 0;
  border-radius: 9px; background: transparent; color: var(--ink); font-size: 14px; text-align: left;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--fill); color: var(--ink); }
.menu-pop .danger { color: var(--red); }
.menu-pop form { margin: 0; }

/* --- home and lists ------------------------------------------------------------------- */

.client-card { display: flex; flex-direction: column; }
.client-card .card-head { padding-bottom: 12px; }
.client-name { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--ink); }
.client-name:hover { color: var(--ink); }
.client-name h2 { overflow-wrap: anywhere; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 0 20px 18px; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.facts b { display: block; font-size: 15px; line-height: 20px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.handles { display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 0 20px 16px; font-size: 13px; color: var(--ink-2); }
.handles span { display: inline-flex; align-items: center; gap: 6px; }

.activity { list-style: none; margin: 0; padding: 0 0 4px; }
.activity li {
  display: flex; align-items: flex-start; gap: 12px; margin-left: 20px; padding: 12px 20px 12px 0;
  border-bottom: 1px solid var(--line); font-size: 14px; line-height: 20px;
}
.activity li:last-child { border-bottom: 0; }
.activity .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.activity .who { display: block; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.activity .when { flex: none; font-size: 13px; line-height: 18px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px;
  border-radius: 999px; background: var(--fill); color: var(--ink); font-size: 12px; font-weight: 600;
}
.avatar.job { background: var(--blue-tint); color: var(--blue); }

/* add keywords preview */
.preview-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.preview-list li { display: flex; align-items: flex-start; gap: 8px; overflow-wrap: anywhere; }
.preview-list .ok-mark {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 18px; height: 18px;
  border-radius: 999px; background: var(--green-tint); color: var(--green); margin-top: 1px;
}
.meter { display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 18px; }
.meter-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.meter-top span:first-child { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.bar { position: relative; height: 6px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.bar i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 999px; }
.bar .now { background: var(--blue); }
.bar .add { background: rgba(0, 113, 227, 0.35); }
.bar.over .add { background: var(--orange); }

/* invite link box */
.link-box { display: flex; flex-wrap: wrap; gap: 8px; }
.link-box .input { flex: 1 1 260px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* --- sign in -------------------------------------------------------------------------- */

.auth { display: flex; min-height: 100vh; }
.auth-main { flex: 1 1 520px; display: flex; align-items: center; justify-content: center; padding: 48px 16px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-card);
  padding: 32px 28px; display: flex; flex-direction: column; gap: 20px;
}
.auth-card .logo { width: 64px; height: 64px; border-radius: 16px; }
.auth-card .head { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-hero {
  flex: 1 1 520px; min-height: 100vh; overflow: hidden; display: flex;
  align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.35), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(90, 200, 250, 0.45), transparent 50%),
    linear-gradient(140deg, #4f8cff, #2b5bd7 60%, #1d3f9e);
}
.auth-bars { display: flex; align-items: flex-end; gap: 22px; height: 46%; }
.auth-bars i {
  display: block; width: 64px; border-radius: 18px;
  background: rgba(255, 255, 255, 0.82); box-shadow: 0 18px 40px rgba(16, 32, 90, 0.25);
}
.auth-bars i:nth-child(1) { height: 34%; opacity: 0.55; }
.auth-bars i:nth-child(2) { height: 52%; opacity: 0.7; }
.auth-bars i:nth-child(3) { height: 74%; opacity: 0.85; }
.auth-bars i:nth-child(4) { height: 100%; }

/* --- phone ---------------------------------------------------------------------------- */

@media (max-width: 880px) {
  .auth-hero { display: none; }
}

@media (max-width: 760px) {
  .side { display: none; }
  .main { padding: 20px 16px 112px; }
  .title { font-size: 28px; line-height: 34px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: 83px;
    padding: 6px 8px 28px; justify-content: space-around;
    background: rgba(255, 255, 255, 0.94); border-top: 1px solid var(--line-2);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 4px;
    font-size: 11px; line-height: 13px; font-weight: 500; color: var(--ink-2);
  }
  .tabbar a[aria-current="page"] { color: var(--blue); }
  .li .control { flex: 1 1 100%; align-items: stretch; }
  .card-head, .card-foot { padding-left: 16px; padding-right: 16px; }
  .card-body { padding-left: 16px; padding-right: 16px; }
}
