/* ============================================================
   Freelancer Zo — layout & components
   ============================================================ */

/* ------------------------------------------------------------
   1. Login
   ------------------------------------------------------------ */
.auth {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: var(--plane);
  transition: opacity var(--t-slow), visibility var(--t-slow);
}
.auth.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.auth__stage {
  position: relative;
  overflow: hidden;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(900px 600px at 15% 10%, rgba(110, 98, 245, .34), transparent 60%),
    radial-gradient(700px 520px at 85% 85%, rgba(57, 135, 229, .26), transparent 62%),
    var(--plane-2);
  border-right: 1px solid var(--border);
}
.auth__stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(760px 620px at 30% 40%, #000 20%, transparent 78%);
  pointer-events: none;
}
.auth__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .55;
  animation: float 16s ease-in-out infinite;
}
.auth__orb--a { width: 320px; height: 320px; background: #6e62f5; top: 8%; right: 12%; }
.auth__orb--b { width: 260px; height: 260px; background: #3987e5; bottom: 12%; left: 14%; animation-delay: -6s; }
@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%      { transform: translate3d(28px, -34px, 0) scale(1.12); }
}

.auth__stage > * { position: relative; z-index: 1; }
.auth__pitch { max-width: 460px; }
.auth__pitch h1 {
  font-size: 40px;
  line-height: 1.12;
  letter-spacing: -.028em;
  font-weight: 700;
  margin-bottom: 14px;
}
.auth__pitch p { color: var(--ink-2); font-size: 15px; line-height: 1.65; }

.auth__metrics { display: flex; gap: 12px; flex-wrap: wrap; }
.auth__metric {
  flex: 1 1 140px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(10px);
}
.auth__metric b { display: block; font-size: 24px; letter-spacing: -.02em; }
.auth__metric span { font-size: 12px; color: var(--ink-3); }

.auth__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  overflow-y: auto;
}
.auth__form { width: 100%; max-width: 372px; }
.auth__form h2 { font-size: 24px; letter-spacing: -.02em; margin-bottom: 6px; }
.auth__form > p { color: var(--ink-3); margin-bottom: 26px; font-size: 13.5px; }

.auth__hint {
  margin-top: 22px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px dashed var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--ink-2);
}
.auth__hint b { color: var(--ink); }
.auth__chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.auth__chip {
  padding: 5px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: all var(--t-fast);
}
.auth__chip:hover { color: var(--brand); border-color: var(--brand); transform: translateY(-1px); }

.auth__error {
  display: none;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--critical-wash);
  border: 1px solid color-mix(in srgb, var(--critical) 40%, transparent);
  color: var(--critical);
  font-size: 13px;
  font-weight: 600;
}
.auth__error.is-on { display: flex; align-items: center; gap: 8px; }

/* ------------------------------------------------------------
   2. Brand mark
   ------------------------------------------------------------ */
.brand { display: flex; align-items: center; gap: 11px; }
.brand__mark {
  width: 36px; height: 36px;
  border-radius: 11px;
  background: var(--brand-grad);
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 6px 18px -6px var(--brand);
  flex: none;
}
.brand__name { font-size: 15.5px; font-weight: 700; letter-spacing: -.02em; }
.brand__sub { font-size: 11px; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }

/* ------------------------------------------------------------
   3. App shell
   ------------------------------------------------------------ */
.app { display: none; min-height: 100vh; }
.app.is-on { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  background: var(--plane-2);
  border-right: 1px solid var(--border);
  z-index: 40;
}
.sidebar__head { padding: 6px 8px 20px; }
.sidebar__label {
  padding: 16px 10px 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 550;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav__item svg { flex: none; opacity: .85; }
.nav__item:hover { background: var(--surface-hover); color: var(--ink); }
.nav__item.is-active { background: var(--brand-wash); color: var(--brand-2); font-weight: 650; }
:root[data-theme="light"] .nav__item.is-active { color: var(--brand); }
.nav__item.is-active::before {
  content: "";
  position: absolute;
  left: -14px; top: 50%;
  width: 3px; height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
  transform: translateY(-50%);
}
.nav__badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.nav__item.is-active .nav__badge { background: var(--brand); color: #fff; }

.sidebar__foot { margin-top: auto; }
.usercard {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  transition: border-color var(--t-fast);
}
.usercard:hover { border-color: var(--brand); }
.usercard__meta { min-width: 0; flex: 1; }
.usercard__name { display: block; font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usercard__role { display: block; font-size: 11px; color: var(--ink-3); }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  color: #fff;
  flex: none;
  letter-spacing: .01em;
}
.avatar--sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar--lg { width: 52px; height: 52px; font-size: 17px; }

/* ------------------------------------------------------------
   4. Topbar
   ------------------------------------------------------------ */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  background: color-mix(in srgb, var(--plane) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.topbar__crumb { font-size: 11.5px; color: var(--ink-3); }

.search {
  position: relative;
  margin-left: auto;
  width: 260px;
}
.search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), width var(--t-base);
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }

.iconbtn {
  position: relative;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  transition: all var(--t-fast);
}
.iconbtn:hover { color: var(--ink); border-color: var(--ink-3); transform: translateY(-1px); }
.iconbtn__dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--critical);
  border: 2px solid var(--surface);
}

.clock {
  display: flex; align-items: center; gap: 7px;
  padding: 0 12px; height: 38px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ------------------------------------------------------------
   5. View container
   ------------------------------------------------------------ */
.view {
  padding: 24px 26px 56px;
  max-width: 1620px;
  width: 100%;
  margin: 0 auto;
  animation: viewIn var(--t-slow) both;
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.025em; }
.page-head p { color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
/* grid and flex children default to min-width:auto, which lets a wide table
   push the whole page sideways on a phone — opt every track back to 0 */
.grid > *, .page-head > div, .u-row > * { min-width: 0; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.g-12 { grid-template-columns: repeat(12, 1fr); }
.c-3, .c-4, .c-5, .c-6, .c-7, .c-8, .c-9, .c-12 { min-width: 0; }
.c-3 { grid-column: span 3; } .c-4 { grid-column: span 4; }
.c-5 { grid-column: span 5; } .c-6 { grid-column: span 6; }
.c-7 { grid-column: span 7; } .c-8 { grid-column: span 8; }
.c-9 { grid-column: span 9; } .c-12 { grid-column: span 12; }

/* ------------------------------------------------------------
   6. Card
   ------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  min-width: 0;
}
.card--pad { padding: 18px 20px; }
.card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card__head--plain { border-bottom: none; padding-bottom: 4px; }
.card__title { font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.card__sub { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.card__tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card__body { padding: 18px 20px; }
.card__body--flush { padding: 0; }

/* ------------------------------------------------------------
   7. Stat tiles & hero
   ------------------------------------------------------------ */
.hero {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 24px;
  align-items: center;
  padding: 22px 24px;
  background:
    radial-gradient(520px 260px at 0% 0%, var(--brand-wash), transparent 70%),
    var(--surface);
}
.hero__label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.hero__value {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.1;
  margin: 6px 0 10px;
}
.hero__foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero__spark { min-width: 0; }

.tile { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.tile__top { display: flex; align-items: center; gap: 9px; }
.tile__ico {
  width: 30px; height: 30px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
}
.tile__label { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.tile__value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.028em;
  margin-top: 4px;
}
.tile__foot { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.tile__spark { margin-top: 8px; height: 34px; }

.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-pill);
}
.delta--up   { color: var(--good);     background: var(--good-wash); }
.delta--down { color: var(--critical); background: var(--critical-wash); }
.delta--flat { color: var(--ink-3);    background: var(--surface-3); }

/* ------------------------------------------------------------
   8. Buttons, chips, segmented
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--t-fast);
}
.btn:hover { background: var(--surface-hover); border-color: var(--ink-3); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn--primary {
  background: var(--brand-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px -8px var(--brand);
}
.btn--primary:hover { filter: brightness(1.08); border-color: transparent; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-hover); color: var(--ink); }
.btn--danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 34%, transparent); background: var(--critical-wash); }
.btn--danger:hover { background: var(--critical); color: #fff; border-color: transparent; }
.btn--sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.seg button {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  transition: all var(--t-fast);
}
.seg button:hover { color: var(--ink); }
.seg button.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }

/* ------------------------------------------------------------
   9. Badges
   ------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge__dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.badge--plain { background: var(--surface-3); color: var(--ink-2); padding-left: 9px; }
.badge--outline { background: transparent; border-color: var(--border); color: var(--ink-2); padding-left: 9px; }

.prio { font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.prio--high { color: var(--critical); }
.prio--normal { color: var(--ink-2); }
.prio--low { color: var(--ink-3); }

/* Country chip — deterministic on every OS (Windows has no flag-emoji glyphs) */
.cc {
  display: inline-grid;
  place-items: center;
  width: 25px; height: 17px;
  flex: none;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .03em;
  vertical-align: -3px;
}

/* ------------------------------------------------------------
   10. Forms
   ------------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field__hint { font-size: 11.5px; color: var(--ink-3); }
.input, .select, .textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13.5px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
:root[data-theme="light"] .input,
:root[data-theme="light"] .select,
:root[data-theme="light"] .textarea { background: #fff; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.55; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23848ba5' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }

/* ------------------------------------------------------------
   11. Filter bar
   ------------------------------------------------------------ */
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.filters .input, .filters .select { min-height: 36px; height: 36px; padding-top: 0; padding-bottom: 0; font-size: 12.5px; }
.filters__search { position: relative; flex: 1 1 220px; max-width: 320px; }
.filters__search .input { padding-left: 34px; }
.filters__search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.filters__count { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* ------------------------------------------------------------
   12. Table
   ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
.table { font-size: 13px; }
.table th {
  position: sticky; top: 0;
  text-align: left;
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 1;
}
.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--ink); }
.table th .caret { opacity: .5; margin-left: 3px; }
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .is-clickable { cursor: pointer; }

.cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-main__t { font-weight: 600; color: var(--ink); }
.cell-main__s { font-size: 11.5px; color: var(--ink-3); }
.cell-title {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mono { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.code {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.rowactions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity var(--t-fast); }
tr:hover .rowactions { opacity: 1; }
.rowbtn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 7px;
  color: var(--ink-3);
  transition: all var(--t-fast);
}
.rowbtn:hover { background: var(--surface-3); color: var(--ink); }
.rowbtn--danger:hover { background: var(--critical-wash); color: var(--critical); }

/* progress bar (meter: track is a lighter step of the fill's ramp) */
.meter {
  position: relative;
  height: 6px;
  width: 100%;
  min-width: 68px;
  border-radius: var(--r-pill);
  background: var(--s1-track);
  overflow: hidden;
}
.meter__fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--s1);
  width: 0;
  transition: width 1s cubic-bezier(.22, 1, .36, 1);
}
.meter--good { background: color-mix(in srgb, var(--good) 24%, transparent); }
.meter--warn { background: color-mix(in srgb, var(--warning) 24%, transparent); }
.meter--crit { background: color-mix(in srgb, var(--critical) 24%, transparent); }
.meter--good .meter__fill { background: var(--good); }
.meter--warn .meter__fill { background: var(--warning); }
.meter--crit .meter__fill { background: var(--critical); }
.meter-row { display: flex; align-items: center; gap: 9px; min-width: 110px; }
.meter-row span { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; width: 32px; text-align: right; }

.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--ink-3);
}
.empty svg { margin: 0 auto 12px; opacity: .45; }
.empty b { display: block; color: var(--ink-2); font-size: 14px; margin-bottom: 4px; }

/* ------------------------------------------------------------
   13. Charts
   ------------------------------------------------------------ */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; overflow: visible; }
.chart__tip {
  position: absolute;
  z-index: 8;
  min-width: 132px;
  padding: 9px 11px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-3);
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%) translateY(-10px);
  transition: opacity var(--t-fast);
}
.chart__tip.is-on { opacity: 1; }
.chart__tip b { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 600; margin-bottom: 6px; }
.tip-row { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.tip-row i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.tip-row span { color: var(--ink-2); }
.tip-row em { margin-left: auto; font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.legend__item { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); }
.legend__key { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend__key--line { height: 3px; width: 14px; border-radius: 2px; }
.legend__val { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

.donut-legend { display: flex; flex-direction: column; gap: 2px; }
.donut-legend__row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: default;
  transition: background var(--t-fast);
}
.donut-legend__row:hover { background: var(--surface-hover); }
.donut-legend__row span { color: var(--ink-2); }
.donut-legend__row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.donut-legend__row i { font-style: normal; color: var(--ink-3); font-size: 11.5px; width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------
   14. Lists / feeds
   ------------------------------------------------------------ */
.list { display: flex; flex-direction: column; }
.list__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.list__item:last-child { border-bottom: none; }
.list__item:hover { background: var(--surface-hover); }
.list__body { min-width: 0; flex: 1; }
.list__t { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__s { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.list__end { text-align: right; white-space: nowrap; }

.timeline { position: relative; padding: 4px 20px 4px 20px; }
.timeline__item { position: relative; padding: 0 0 20px 26px; }
.timeline__item::before {
  content: "";
  position: absolute;
  left: 5px; top: 16px; bottom: -2px;
  width: 1px;
  background: var(--border);
}
.timeline__item:last-child { padding-bottom: 4px; }
.timeline__item:last-child::before { display: none; }
.timeline__dot {
  position: absolute;
  left: 0; top: 5px;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--s1);
}
.timeline__t { font-size: 13px; font-weight: 600; }
.timeline__s { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* ------------------------------------------------------------
   15. Project detail
   ------------------------------------------------------------ */
.detail-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 22px 24px;
}
.detail-head__main { min-width: 260px; flex: 1; }
.detail-head h1 { font-size: 20px; letter-spacing: -.024em; margin: 6px 0 8px; }
.detail-meta { display: flex; gap: 8px 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); }
.detail-meta b { color: var(--ink-2); font-weight: 600; }

.money-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border-top: 1px solid var(--border);
}
.money-strip__cell { padding: 16px 24px; border-right: 1px solid var(--border); }
.money-strip__cell:last-child { border-right: none; }
.money-strip__l { font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.money-strip__v { font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 20px; overflow-x: auto; }
.tabs button {
  position: relative;
  padding: 13px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
  transition: color var(--t-fast);
}
.tabs button:hover { color: var(--ink-2); }
.tabs button.is-on { color: var(--ink); }
.tabs button.is-on::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
}
.tabs__count {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  font-size: 10.5px;
  color: var(--ink-2);
}

/* ------------------------------------------------------------
   16. Modal
   ------------------------------------------------------------ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 8, 16, .62);
  backdrop-filter: blur(3px);
  opacity: 0;
  animation: fadeIn var(--t-base) forwards;
}
@keyframes fadeIn { to { opacity: 1; } }
.modal {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  transform: translateY(14px) scale(.985);
  opacity: 0;
  animation: modalIn var(--t-slow) forwards;
}
.modal--wide { max-width: 760px; }
@keyframes modalIn { to { transform: none; opacity: 1; } }
.modal__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 22px 14px;
}
.modal__head h3 { font-size: 16px; font-weight: 650; letter-spacing: -.015em; }
.modal__head p { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.modal__close { margin-left: auto; }
.modal__body { padding: 4px 22px 8px; overflow-y: auto; }
.modal__foot {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

/* ------------------------------------------------------------
   17. Toast
   ------------------------------------------------------------ */
.toasts {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 264px;
  max-width: 380px;
  padding: 13px 15px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-3);
  font-size: 13px;
  transform: translateX(120%);
  animation: toastIn var(--t-slow) forwards;
}
.toast.is-out { animation: toastOut var(--t-base) forwards; }
@keyframes toastIn { to { transform: none; } }
@keyframes toastOut { to { transform: translateX(120%); opacity: 0; } }
.toast__ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; }

/* ------------------------------------------------------------
   18. Popover menu
   ------------------------------------------------------------ */
.menu {
  position: fixed;
  z-index: 140;
  min-width: 208px;
  padding: 6px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-3);
  animation: menuIn var(--t-fast) both;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px); } }
.menu__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-2);
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
.menu__item:hover { background: var(--surface-hover); color: var(--ink); }
.menu__item--danger { color: var(--critical); }
.menu__item--danger:hover { background: var(--critical-wash); color: var(--critical); }
.menu__sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu__label { padding: 8px 10px 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

/* ------------------------------------------------------------
   19. Utilities
   ------------------------------------------------------------ */
.u-row { display: flex; align-items: center; gap: 10px; }
.u-col { display: flex; flex-direction: column; }
.u-gap-4 { gap: 4px; } .u-gap-8 { gap: 8px; } .u-gap-16 { gap: 16px; }
.u-wrap { flex-wrap: wrap; }
.u-auto { margin-left: auto; }
.u-mt-8 { margin-top: 8px; } .u-mt-16 { margin-top: 16px; } .u-mt-24 { margin-top: 24px; }
.u-mb-8 { margin-bottom: 8px; } .u-mb-16 { margin-bottom: 16px; }
.u-muted { color: var(--ink-3); }
.u-ink2 { color: var(--ink-2); }
.u-sm { font-size: 12px; }
.u-xs { font-size: 11.5px; }
.u-b { font-weight: 650; }
.u-num { font-variant-numeric: tabular-nums; }
.u-right { text-align: right; }
.u-center { text-align: center; }
.u-hide { display: none !important; }
.u-scroll-260 { max-height: 260px; overflow-y: auto; }
.u-scroll-360 { max-height: 360px; overflow-y: auto; }

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ------------------------------------------------------------
   21. Escrow
   ------------------------------------------------------------ */
.escrow {
  background:
    radial-gradient(620px 240px at 0% 0%, color-mix(in srgb, var(--s3) 12%, transparent), transparent 70%),
    var(--surface);
}
.escrow__head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 18px 22px 14px;
}
.escrow__ico {
  width: 44px; height: 44px;
  flex: none;
  border-radius: 13px;
  display: grid; place-items: center;
}
.escrow__lead { min-width: 0; }
.escrow__amount {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
}
.escrow__title { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.escrow__badge { margin-left: auto; }

.escrow__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.escrow__fact {
  padding: 13px 22px;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.escrow__fact:last-child { border-right: none; }
.escrow__fact span {
  display: block;
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: 3px;
}
.escrow__fact b {
  font-size: 14px;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.escrow__foot { padding: 16px 22px 20px; }

.escrow-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  color: var(--ink);
  border-color: color-mix(in srgb, var(--s3) 34%, var(--border));
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--s3) 10%, transparent), transparent 55%),
    var(--surface);
  transition: transform var(--t-fast), border-color var(--t-fast);
}
.escrow-banner:hover { transform: translateY(-1px); border-color: var(--s3); }
.escrow-banner__ico {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 11px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--s3) 16%, transparent);
  color: var(--s3);
}
.escrow-banner__body { min-width: 0; flex: 1; }
.escrow-banner__body b { display: block; font-size: 14.5px; }
.escrow-banner__body span {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.escrow-banner__end { text-align: right; white-space: nowrap; }
.escrow-banner__end b { display: block; font-size: 14px; }
.escrow-banner__end span { font-size: 11.5px; color: var(--ink-3); }

/* ------------------------------------------------------------
   20. Responsive
   ------------------------------------------------------------ */
@media (max-width: 1280px) {
  .c-3, .c-4, .c-5 { grid-column: span 6; }
  .c-7, .c-8, .c-9 { grid-column: span 12; }
}

@media (max-width: 1080px) {
  .auth { grid-template-columns: 1fr; }
  .auth__stage { display: none; }
  .auth__panel { padding: 32px 20px; }
  .hero { grid-template-columns: 1fr; }
}

/* ---- tablet / small laptop ---- */
@media (max-width: 900px) {
  .app.is-on { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, var(--sidebar-w));
    transform: translateX(-100%);
    transition: transform var(--t-base);
    box-shadow: var(--sh-3);
    z-index: 110;
  }
  .sidebar.is-open { transform: none; }
  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(6, 8, 16, .58);
    backdrop-filter: blur(2px);
    animation: fadeIn var(--t-fast) forwards;
  }

  .c-3, .c-4, .c-5, .c-6 { grid-column: span 12; }
  .view { padding: 16px 14px 44px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .search { width: 150px; }
  .form-row, .form-row--3 { grid-template-columns: 1fr; }
  .detail-head__main { flex: 1 1 100%; }
  .detail-head > div[style] { flex: 1 1 100% !important; }
}

/* ---- phones ---- */
@media (max-width: 640px) {
  :root { --topbar-h: 58px; }

  /* topbar keeps only what a thumb needs */
  .search, .clock { display: none; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar__title { font-size: 14px; }
  .topbar__crumb { display: none; }
  .topbar > div:nth-of-type(1) { flex: 1; min-width: 0; }
  .iconbtn { width: 36px; height: 36px; }

  .view { padding: 14px 12px 40px; }

  /* page header: title on top, actions on a scrollable rail */
  .page-head { gap: 12px; margin-bottom: 16px; align-items: stretch; }
  .page-head h1 { font-size: 19px; }
  .page-head p { font-size: 12px; }
  .page-head__actions {
    margin-left: 0;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .page-head__actions::-webkit-scrollbar { display: none; }
  .page-head__actions > * { flex: none; }

  .grid { gap: 12px; }

  /* hero */
  .hero { padding: 18px 16px; gap: 18px; }
  .hero__value { font-size: 34px; }
  .hero__foot { gap: 6px; }

  .card--pad, .card__body { padding: 14px 16px; }
  .card__head { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
  .card__tools { margin-left: 0; width: 100%; }
  .tile { padding: 14px 16px; }
  .tile__value { font-size: 23px; }

  /* filters stack and fill the width */
  .filters { padding: 12px 14px; gap: 8px; }
  .filters__search { flex: 1 1 100%; max-width: none; }
  .filters .select { flex: 1 1 calc(50% - 4px); max-width: none !important; }
  .filters__count { margin-left: 0; width: 100%; }

  /* tables scroll sideways, with a visible edge cue */
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 22px), transparent 100%);
  }
  .table-wrap:only-child { mask-image: none; }
  .table th, .table td { padding: 10px 12px; }
  .cell-title { max-width: 190px; }

  /* project detail */
  .detail-head { padding: 16px; gap: 14px; }
  .detail-head h1 { font-size: 17px; }
  .detail-meta { gap: 6px 14px; font-size: 12px; }
  .money-strip { grid-template-columns: 1fr 1fr; }
  .money-strip__cell { padding: 12px 16px; }
  .money-strip__cell:nth-child(2n) { border-right: none; }
  .money-strip__cell:not(:nth-last-child(-n+2)) { border-bottom: 1px solid var(--border); }
  .money-strip__v { font-size: 17px; }
  .tabs { padding: 0 12px; }
  .tabs button { padding: 12px 10px; font-size: 12.5px; }

  /* escrow */
  .escrow__head { padding: 16px 16px 12px; gap: 12px; }
  .escrow__ico { width: 38px; height: 38px; border-radius: 11px; }
  .escrow__amount { font-size: 23px; }
  .escrow__badge { margin-left: 0; width: 100%; justify-content: center; }
  .escrow__grid { grid-template-columns: 1fr 1fr; }
  .escrow__fact { padding: 11px 16px; }
  .escrow__fact:nth-child(2n) { border-right: none; }
  .escrow__fact:not(:nth-last-child(-n+2)) { border-bottom: 1px solid var(--border); }
  .escrow__foot { padding: 14px 16px 16px; }
  .escrow-banner { gap: 10px; padding: 12px 14px; flex-wrap: wrap; }
  .escrow-banner__body { flex: 1 1 60%; }
  .escrow-banner__end { margin-left: auto; }
  .escrow-banner > svg:last-child { display: none; }

  /* lists */
  .list__item { padding: 11px 16px; gap: 10px; }
  .timeline { padding: 16px 14px; }

  /* modals become sheets */
  .overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none;
    max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: none;
  }
  .modal__head { padding: 18px 18px 12px; }
  .modal__body { padding: 4px 18px 8px; }
  .modal__foot { padding: 14px 18px 20px; }
  .modal__foot .btn { flex: 1; }

  /* popover menus get breathing room */
  .menu { min-width: 200px; max-width: calc(100vw - 24px); }

  /* toasts span the width */
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }

  /* row actions are always visible — there is no hover on touch */
  .rowactions { opacity: 1; }

  .u-scroll-360 { max-height: 300px; }

  /* comfortable tap targets (>=36px) on touch */
  .seg button { padding: 9px 13px; }
  .btn--sm { height: 36px; padding: 0 13px; }
  .rowbtn { width: 36px; height: 36px; }
  .tabs button { padding: 14px 11px; }
  .menu__item { padding: 11px 12px; }
  .auth__chip { padding: 8px 12px; }
  .donut-legend__row { padding: 9px 8px; }
}

@media (max-width: 380px) {
  .escrow__grid, .money-strip { grid-template-columns: 1fr; }
  .escrow__fact, .money-strip__cell {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .hero__value { font-size: 30px; }
}

/* touch devices: no hover-only affordances */
@media (hover: none) {
  .rowactions { opacity: 1; }
}

@media (min-width: 901px) { .menu-toggle { display: none; } }
