:root {
  --milk: #fafaf7;
  --surface: #ffffff;
  --surface-blue: #f0f3ff;
  --surface-lime: #f3ffd7;
  --ink: #17191f;
  --muted: #686b73;
  --faint: #92959d;
  --line: #e6e6df;
  --line-strong: #d6d7d1;
  --blue: #2751f5;
  --blue-dark: #173ad0;
  --blue-soft: #e9edff;
  --lime: #c4ff3d;
  --lime-dark: #435c00;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --warning: #795500;
  --warning-soft: #fff6d8;
  --shadow: 0 16px 50px rgba(30, 39, 77, 0.07);
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 28px;
  --sidebar: 274px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--milk); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--milk);
  font-family: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(39, 81, 245, 0.3); outline-offset: 3px; }
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 3vw, 48px);
  font-weight: 680;
  line-height: 1.04;
  letter-spacing: -0.045em;
}
h2 { margin-bottom: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.025em; }
.subtitle { max-width: 720px; margin: 9px 0 0; color: var(--muted); font-size: 15px; }
.skip-link {
  position: fixed; z-index: 1000; top: 10px; left: 10px; padding: 10px 16px;
  border-radius: 999px; background: var(--ink); color: #fff; transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

/* App shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; display: flex; flex: 0 0 var(--sidebar); flex-direction: column;
  height: 100vh; padding: 22px 16px 18px; border-right: 1px solid var(--line);
  background: rgba(250, 250, 247, 0.96);
}
.side-brand, .mobile-brand, .auth-brand {
  display: inline-flex; align-items: center; gap: 10px; color: var(--ink);
  font-size: 22px; font-weight: 800; letter-spacing: -0.06em;
}
.side-brand { align-self: flex-start; margin: 2px 10px 30px; }
.side-brand:hover, .mobile-brand:hover, .auth-brand:hover { text-decoration: none; }
.brand-dot { color: var(--blue); }
.brand-dot.lime { color: var(--lime); }
.brand-mark {
  display: inline-grid; width: 34px; height: 34px; place-items: center;
  border-radius: 11px; background: var(--blue); color: #fff;
  font-size: 16px; font-weight: 750; letter-spacing: -0.04em;
}
.brand-word { line-height: 1; }
.side-nav { flex: 1; overflow-y: auto; }
.side-label {
  padding: 0 12px 9px; color: var(--faint); font-size: 11px;
  font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase;
}
.side-label-spaced { margin-top: 26px; }
.side-item {
  display: flex; min-height: 46px; align-items: center; justify-content: space-between; gap: 10px;
  margin: 2px 0; padding: 11px 13px; border-radius: 14px; color: var(--muted); font-size: 14px;
}
.side-item:hover { background: var(--surface); color: var(--ink); text-decoration: none; }
.side-item.active { background: var(--blue); color: #fff; font-weight: 600; box-shadow: 0 8px 24px rgba(39,81,245,.18); }
.si-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-count {
  flex: none; min-width: 24px; padding: 2px 7px; border-radius: 999px;
  background: var(--lime); color: var(--ink); font-size: 11px; font-weight: 750; text-align: center;
}
.side-empty { padding: 9px 12px; color: var(--faint); font-size: 13px; }
.side-foot { padding-top: 12px; border-top: 1px solid var(--line); }
.side-user { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 10px 12px 14px; }
.su-info { min-width: 0; flex: 1; line-height: 1.3; }
.su-name { display: block; overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.su-role { display: block; overflow: hidden; color: var(--faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.side-item.logout:hover { background: var(--danger-soft); color: var(--danger); }
.main { width: calc(100% - var(--sidebar)); min-width: 0; padding: 46px clamp(24px, 4vw, 72px) 64px; }
.content-wrap { width: 100%; max-width: 1500px; margin: 0 auto; }
.mobile-header { display: none; }

/* Page heading and stats */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 30px; }
.head .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 12px;
  color: var(--blue); font-size: 12px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase;
}
.eyebrow::before { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 4px rgba(196,255,61,.24); content: ""; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 12px; margin: -8px 0 22px; }
.stat { padding: 18px 20px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.66); }
.stat:first-child { background: var(--blue); color: #fff; border-color: var(--blue); }
.stat-value { display: block; font-size: 27px; font-weight: 700; line-height: 1; letter-spacing: -.04em; }
.stat-label { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }
.stat:first-child .stat-label { color: rgba(255,255,255,.72); }
.metaline { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.metaline b { color: var(--ink); font-weight: 650; }
.dot-sep { color: var(--line-strong); }

/* Components */
.avatar {
  display: inline-grid; width: 38px; height: 38px; flex: none; place-items: center;
  border: 1px solid #dce2ff; border-radius: 13px; background: var(--blue-soft);
  color: var(--blue); font-size: 12px; font-weight: 700;
}
.avatar.sm { width: 34px; height: 34px; border-radius: 11px; font-size: 11px; }
.avatar.lg { width: 58px; height: 58px; border-radius: 18px; font-size: 17px; }
.sdot { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.sdot::before { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); content: ""; }
.sdot.new { color: var(--ink); font-weight: 600; }
.sdot.new::before { background: var(--lime); box-shadow: 0 0 0 4px rgba(196,255,61,.22); }
.btn {
  display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 19px; border: 1px solid var(--blue); border-radius: 999px;
  background: var(--blue); color: #fff; cursor: pointer; font-size: 14px; font-weight: 650;
  line-height: 1; white-space: nowrap; transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.btn:hover { border-color: var(--blue-dark); background: var(--blue-dark); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.secondary { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.btn.secondary:hover { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.btn.lime { border-color: var(--lime); background: var(--lime); color: var(--ink); }
.btn.lime:hover { border-color: #b3ed2b; background: #b3ed2b; }
.btn.sm { min-height: 38px; padding: 8px 15px; font-size: 12px; }
.btn[disabled] { cursor: wait; opacity: .58; transform: none; }
.back-link { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 24px; color: var(--muted); font-size: 13px; font-weight: 600; }
.back-link:hover { color: var(--blue); text-decoration: none; }
.back-link::before { content: "←"; font-size: 17px; }

.panel, .card { border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.panel { overflow: hidden; border-radius: var(--radius-lg); }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.card { margin-bottom: 18px; padding: clamp(22px, 3vw, 34px); border-radius: var(--radius); }
.card.narrow { max-width: 680px; }
.card-title { margin-bottom: 20px; }
.detail-hero { display: flex; align-items: center; gap: 15px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr); gap: 18px; align-items: start; }
.privacy-note { padding: 18px 20px; border-radius: 16px; background: var(--surface-lime); color: #34460a; font-size: 13px; }
.privacy-note strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 14px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 13px 18px; border-bottom: 1px solid var(--line); background: #fcfcfa;
  color: var(--faint); font-size: 10px; font-weight: 750; letter-spacing: .09em; text-align: left; text-transform: uppercase;
}
tbody td { padding: 15px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.row-link { cursor: pointer; }
tbody tr.row-link td { transition: background .12s ease; }
tbody tr.row-link:hover td { background: #f8f9ff; }
.row-link:focus-within td { background: #f8f9ff; }
.row-main-link { color: inherit; font-weight: inherit; }
.row-main-link:hover { color: var(--blue); text-decoration: none; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: -.015em; }
.cell-name { display: flex; min-width: 170px; align-items: center; gap: 11px; }
.cell-name .nm { color: var(--ink); font-weight: 650; }
.kv td { padding: 15px 0; border-bottom: 1px solid var(--line); }
.kv td:first-child { width: 150px; padding-right: 24px; color: var(--muted); font-size: 13px; }
.contact-cell { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.reveal-value.revealed { font-weight: 650; }
.badge { display: inline-flex; padding: 4px 10px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 650; }
.open-link { color: var(--blue); font-weight: 650; white-space: nowrap; }

/* Forms and messages */
.filters { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
label { color: var(--ink); font-size: 13px; font-weight: 600; }
input[type=text], input[type=password], input[type=email], input[type=file], select, textarea {
  min-height: 44px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 13px;
  background: var(--surface); color: var(--ink); font-size: 14px;
}
input[type=text], select { min-width: 170px; }
input::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 0; box-shadow: 0 0 0 4px rgba(39,81,245,.1); }
.search { min-width: 250px; }
.form-row { margin-bottom: 18px; }
.form-row label { display: block; margin-bottom: 7px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; }
.msg { margin-bottom: 16px; padding: 13px 16px; border: 1px solid transparent; border-radius: 15px; font-size: 13px; }
.msg.success { border-color: #d8ef9c; background: var(--surface-lime); color: #34460a; }
.msg.error { border-color: #ffd1ca; background: var(--danger-soft); color: var(--danger); }
.msg.warning { border-color: #f2dd94; background: var(--warning-soft); color: var(--warning); }
.note { color: var(--muted); font-size: 13px; }
.empty { padding: 70px 24px; color: var(--muted); text-align: center; }
.empty .empty-mark { display: grid; width: 54px; height: 54px; margin: 0 auto 16px; place-items: center; border-radius: 18px; background: var(--surface-lime); color: var(--lime-dark); font-size: 23px; }
.empty .t { margin-bottom: 5px; color: var(--ink); font-size: 17px; font-weight: 650; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.section-gap { margin-top: 22px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
code { color: var(--blue); }
pre.token { overflow-x: auto; padding: 14px 16px; border: 1px solid #dce2ff; border-radius: 14px; background: var(--surface-blue); color: var(--blue-dark); }

/* Authentication */
.auth-wrap { display: grid; min-height: 100vh; grid-template-columns: minmax(380px, .9fr) minmax(480px, 1.1fr); background: var(--milk); }
.auth-side { position: relative; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; padding: clamp(32px, 5vw, 72px); background: var(--blue); color: #fff; }
.auth-side::before { position: absolute; top: -18%; right: -16%; width: min(42vw, 560px); aspect-ratio: 1; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; content: ""; }
.auth-side::after { position: absolute; right: 12%; bottom: 13%; width: 104px; height: 104px; border-radius: 32px; background: var(--lime); content: ""; transform: rotate(14deg); }
.auth-side .auth-brand { position: relative; z-index: 1; color: #fff; }
.auth-pitch { position: relative; z-index: 1; max-width: 560px; margin-bottom: 9vh; }
.auth-pitch h1 { max-width: 570px; font-size: clamp(42px, 5vw, 74px); }
.auth-pitch p { max-width: 440px; margin: 22px 0 0; color: rgba(255,255,255,.76); font-size: 17px; }
.auth-foot { position: relative; z-index: 1; color: rgba(255,255,255,.55); font-size: 12px; }
.auth-form-area { display: grid; place-items: center; padding: 34px; }
.auth-card { width: 100%; max-width: 430px; }
.auth-card h2 { margin-bottom: 8px; font-size: 35px; font-weight: 680; letter-spacing: -.045em; }
.auth-card .subtitle { margin-bottom: 32px; }
.auth-card .btn { width: 100%; min-height: 50px; margin-top: 4px; }
.auth-security { display: flex; align-items: center; gap: 9px; margin-top: 22px; color: var(--faint); font-size: 12px; }
.auth-security::before { display: block; width: 9px; height: 9px; border-radius: 50%; background: var(--lime); content: ""; }

/* Project cards */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 28px; }
.project-card { display: flex; min-height: 220px; flex-direction: column; justify-content: space-between; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); transition: transform .16s ease, border-color .16s ease; }
.project-card:hover { border-color: #c9d2ff; text-decoration: none; transform: translateY(-2px); }
.project-card h2 { margin: 12px 0 6px; font-size: 24px; }
.project-client { color: var(--muted); font-size: 13px; }
.project-meta { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-top: 28px; }
.project-count { font-size: 13px; }
.project-count b { display: block; font-size: 28px; line-height: 1; }
.project-arrow { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: var(--lime); color: var(--ink); font-size: 20px; }

/* Internal client workspace */
.management-stats { max-width: 780px; }
.client-panel-head { align-items: flex-end; }
.client-panel-head .note { margin-top: 4px; }
.client-filters { justify-content: flex-end; }
.client-list-head, .client-row {
  display: grid;
  grid-template-columns: minmax(250px, 1.45fr) minmax(170px, .9fr) minmax(100px, .5fr) minmax(150px, .7fr) auto;
  align-items: center;
  column-gap: 24px;
}
.client-list-head {
  min-height: 42px; padding: 0 22px; border-bottom: 1px solid var(--line);
  background: #fcfcfa; color: var(--faint); font-size: 10px; font-weight: 750;
  letter-spacing: .09em; text-transform: uppercase;
}
.client-row { min-height: 104px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.client-row:last-child { border-bottom: 0; }
.client-row:hover { background: #fbfbff; }
.client-identity { display: flex; min-width: 0; align-items: center; gap: 12px; }
.client-copy { display: grid; min-width: 0; grid-template-columns: minmax(0, auto) 1fr; align-items: center; gap: 3px 8px; }
.client-name {
  grid-column: 1 / -1; overflow: hidden; color: var(--ink); font-size: 15px;
  font-weight: 680; text-overflow: ellipsis; white-space: nowrap;
}
.client-name:hover { color: var(--blue); text-decoration: none; }
.client-project { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.status-pill {
  display: inline-flex; width: max-content; align-items: center; gap: 6px; padding: 2px 8px;
  border-radius: 999px; background: #f0f1ed; color: var(--muted); font-size: 10px; font-weight: 650;
}
.status-pill::before { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); content: ""; }
.status-pill.active { background: var(--surface-lime); color: #3e5500; }
.status-pill.active::before { background: #78a700; }
.client-team { display: grid; gap: 3px; color: var(--ink); font-size: 13px; }
.client-leads { display: grid; gap: 2px; }
.client-leads strong { font-size: 19px; line-height: 1; }
.client-leads span { color: var(--muted); font-size: 11px; }
.client-last { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.client-action { justify-self: end; }
.client-action .btn { min-height: 44px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 34px 0 14px; }
.client-project-grid { margin-top: 0; }
.client-project-card { min-height: 190px; }
.client-project-card h2 { margin-top: 14px; }
.client-project-card .project-meta { align-items: center; }
.empty.compact { padding: 30px 20px; }

@media (max-width: 1080px) {
  :root { --sidebar: 238px; }
  .main { padding-right: 28px; padding-left: 28px; }
  .detail-grid { grid-template-columns: 1fr; }
  .privacy-note { max-width: 680px; }
  .auth-side { padding: 42px; }
  .client-list-head, .client-row { grid-template-columns: minmax(230px, 1.3fr) minmax(150px, .8fr) 90px minmax(130px, .65fr) auto; column-gap: 16px; }
}

@media (max-width: 780px) {
  .shell { display: block; }
  .sidebar { display: none; }
  .mobile-header { position: sticky; z-index: 50; top: 0; display: flex; min-height: 68px; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: rgba(250,250,247,.96); backdrop-filter: blur(14px); }
  .mobile-brand { font-size: 19px; }
  .mobile-brand .brand-mark { width: 31px; height: 31px; border-radius: 10px; font-size: 14px; }
  .mobile-menu { position: relative; }
  .mobile-menu summary { display: grid; width: 44px; height: 44px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer; list-style: none; font-size: 20px; }
  .mobile-menu summary::-webkit-details-marker { display: none; }
  .mobile-menu[open] summary { border-color: var(--blue); color: var(--blue); }
  .mobile-menu-panel { position: absolute; top: 52px; right: 0; width: min(310px, calc(100vw - 36px)); padding: 10px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
  .mobile-menu-panel .side-label { padding-top: 8px; }
  .main { width: 100%; padding: 30px 18px 50px; }
  .head { align-items: flex-start; flex-direction: column; margin-bottom: 24px; }
  .head .actions { width: 100%; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat { padding: 15px; }
  .stat-value { font-size: 23px; }
  .panel { border-radius: 20px; }
  .panel-head { align-items: stretch; flex-direction: column; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters .search { grid-column: 1 / -1; }
  .filters input, .filters select, .filters .btn { width: 100%; min-width: 0; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { min-height: 240px; padding: 28px; }
  .auth-pitch { margin: 58px 0 0; }
  .auth-pitch h1 { font-size: clamp(34px, 10vw, 52px); }
  .auth-pitch p, .auth-foot { display: none; }
  .auth-side::after { right: 8%; bottom: -34px; width: 82px; height: 82px; }
  .auth-form-area { padding: 38px 24px 52px; }
  .auth-card h2 { font-size: 30px; }
  .client-panel-head { align-items: stretch; }
  .client-filters { justify-content: stretch; }
  .client-list-head { display: none; }
  .client-row {
    grid-template-columns: minmax(0, 1fr) auto; gap: 16px 22px;
    min-height: 0; padding: 20px;
  }
  .client-identity { grid-column: 1 / -1; }
  .client-team, .client-leads, .client-last { position: relative; padding-top: 19px; }
  .client-team::before, .client-leads::before, .client-last::before {
    position: absolute; top: 0; left: 0; color: var(--faint); content: attr(data-label);
    font-size: 9px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase;
  }
  .client-action { align-self: end; }
}

@media (max-width: 560px) {
  body { font-size: 14px; }
  h1 { font-size: 32px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:last-child { grid-column: 1 / -1; }
  .head .actions .btn { flex: 1; }
  .filters { grid-template-columns: 1fr; }
  .filters .search { grid-column: auto; }
  .panel { margin-right: -2px; margin-left: -2px; }
  thead th, tbody td { padding: 13px 14px; }
  .project-grid { grid-template-columns: 1fr; }
  .detail-hero { align-items: flex-start; }
  .kv, .kv tbody, .kv tr, .kv td { display: block; width: 100%; }
  .kv tr { padding: 13px 0; border-bottom: 1px solid var(--line); }
  .kv td { padding: 2px 0; border: 0; }
  .kv td:first-child { width: auto; padding: 0 0 5px; }
  .auth-side { min-height: 210px; }
  .client-row { grid-template-columns: 1fr 1fr; }
  .client-team { grid-column: 1 / -1; }
  .client-last { grid-column: 1 / -1; }
  .client-action { grid-column: 1 / -1; justify-self: stretch; }
  .client-action .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
