/* ============================================================================
   Zetimagine client portal
   ----------------------------------------------------------------------------
   Deliberately a different visual language from the public site. The marketing
   pages are a marketplace (Fiverr/Upwork patterns, light, promotional); this
   is an application someone works inside all day, so it follows dashboard
   conventions instead: a persistent dark nav rail, dense data surfaces, and
   status that is legible at a glance.
   ============================================================================ */

:root {
  --rail: #16161d;
  --rail-2: #1f1f28;
  --rail-text: #a1a1aa;
  --rail-text-hi: #fff;

  --bg: #f6f7f9;
  --surface: #fff;
  --line: #e5e7eb;
  --line-2: #f3f4f6;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;

  --brand: #0c87ea;
  --brand-dark: #0155a2;
  --brand-50: #eff6ff;

  --green: #16a34a;
  --green-50: #f0fdf4;
  --amber: #b45309;
  --amber-50: #fffbeb;
  --red: #dc2626;
  --red-50: #fef2f2;
  --violet: #7c3aed;
  --violet-50: #f5f3ff;
  --slate-50: #f8fafc;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --sh-1: 0 1px 2px rgba(17, 24, 39, .05);
  --sh-2: 0 1px 3px rgba(17, 24, 39, .08), 0 1px 2px rgba(17, 24, 39, .04);
  --sh-3: 0 10px 30px rgba(17, 24, 39, .12);

  --rail-w: 248px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
p { margin: 0; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.cp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease;
}
.cp-btn--primary { background: var(--brand); color: #fff; }
.cp-btn--primary:hover { background: var(--brand-dark); }
.cp-btn--ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.cp-btn--ghost:hover { background: var(--slate-50); }
.cp-btn:disabled { opacity: .55; cursor: not-allowed; }
.cp-btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }

/* ---- Rail ---------------------------------------------------------------- */

.cp-rail {
  position: fixed; inset: 0 auto 0 0;
  width: var(--rail-w);
  display: flex; flex-direction: column;
  background: var(--rail);
  color: var(--rail-text);
  z-index: 50;
}

.cp-rail__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px; height: 60px;
  border-bottom: 1px solid var(--rail-2);
}
.cp-rail__brand img { height: 26px; width: auto; filter: brightness(0) invert(1); }

.cp-rail__nav { flex: 1; padding: 14px 10px; overflow-y: auto; }

.cp-rail__label {
  padding: 14px 8px 7px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: #52525b;
}

.cp-navitem {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px; margin-bottom: 2px;
  border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--rail-text);
  font-size: 14px; font-weight: 500; text-align: left; cursor: pointer;
  transition: background-color .14s ease, color .14s ease;
}
.cp-navitem:hover { background: var(--rail-2); color: var(--rail-text-hi); }
.cp-navitem.is-active { background: var(--brand); color: #fff; font-weight: 600; }
.cp-navitem__count {
  margin-left: auto; padding: 1px 7px;
  border-radius: 999px; background: rgba(255, 255, 255, .12);
  font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.cp-navitem.is-active .cp-navitem__count { background: rgba(255, 255, 255, .25); }

.cp-rail__foot { padding: 12px; border-top: 1px solid var(--rail-2); }

.cp-user { display: flex; align-items: center; gap: 10px; padding: 6px 6px 10px; }
.cp-user__avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cp-user b { display: block; color: var(--rail-text-hi); font-size: 13.5px; font-weight: 600; }
.cp-user span { font-size: 12px; color: #71717a; }

.cp-linkbtn {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--rail-2); border-radius: var(--r-sm);
  background: transparent; color: var(--rail-text);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: background-color .14s ease;
}
.cp-linkbtn:hover { background: var(--rail-2); color: var(--rail-text-hi); }

/* ---- Main ---------------------------------------------------------------- */

.cp-main { margin-left: var(--rail-w); min-height: 100vh; display: flex; flex-direction: column; }

.cp-topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 28px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.cp-topbar h1 { font-size: 19px; }
.cp-topbar__spacer { margin-left: auto; }

.cp-burger { display: none; }

.cp-content { padding: 28px; flex: 1; }
.cp-content > * + * { margin-top: 24px; }

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

.cp-stats {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.cp-stat {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
}
.cp-stat__label {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px;
}
.cp-stat__value { font-size: 27px; font-weight: 700; letter-spacing: -.02em; }
.cp-stat__hint { margin-top: 4px; font-size: 13px; color: var(--muted); }
.cp-stat--owed { background: var(--amber-50); border-color: #fde68a; }
.cp-stat--owed .cp-stat__value { color: var(--amber); }

/* ---- Panels -------------------------------------------------------------- */

.cp-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.cp-panel__head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line-2);
}
.cp-panel__head h2 { font-size: 15.5px; }
.cp-panel__head .cp-btn { margin-left: auto; }
.cp-panel__body { padding: 20px; }
.cp-panel__body--flush { padding: 0; }

/* ---- Badges -------------------------------------------------------------- */

.cp-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.cp-badge--green  { background: var(--green-50);  color: var(--green); }
.cp-badge--amber  { background: var(--amber-50);  color: var(--amber); }
.cp-badge--red    { background: var(--red-50);    color: var(--red); }
.cp-badge--violet { background: var(--violet-50); color: var(--violet); }
.cp-badge--slate  { background: #f1f5f9;           color: var(--muted); }
.cp-badge--blue   { background: var(--brand-50);  color: var(--brand-dark); }

.cp-badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

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

.cp-projects { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.cp-project {
  display: block; padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  cursor: pointer; text-align: left; width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.cp-project:hover { border-color: #bfdbfe; box-shadow: var(--sh-2); transform: translateY(-1px); }

.cp-project__top { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.cp-project__top h3 { font-size: 15.5px; margin-bottom: 4px; }
.cp-project__top .cp-badge { margin-left: auto; flex-shrink: 0; }

.cp-bar {
  height: 6px; border-radius: 999px; background: #eef0f3; overflow: hidden;
}
.cp-bar__fill { height: 100%; border-radius: 999px; background: var(--brand); transition: width .3s ease; }
.cp-bar__fill--done { background: var(--green); }
.cp-bar__fill--hold { background: var(--amber); }

.cp-project__foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 10px; font-size: 12.5px; color: var(--muted);
}

/* ---- Tables -------------------------------------------------------------- */

.cp-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cp-table th {
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--slate-50);
  font-size: 12px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); text-align: left;
}
.cp-table td { padding: 14px 20px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.cp-table tr:last-child td { border-bottom: 0; }
.cp-table tbody tr:hover { background: var(--slate-50); }
.cp-table__num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cp-table__muted { color: var(--muted); font-size: 13px; }

/* ---- Ticket thread ------------------------------------------------------- */

.cp-thread { display: flex; flex-direction: column; gap: 14px; }

.cp-msg { max-width: 78%; padding: 13px 16px; border-radius: var(--r-md); }
.cp-msg--them { align-self: flex-start; background: var(--slate-50); border: 1px solid var(--line); }
.cp-msg--me {
  align-self: flex-end;
  background: var(--brand); color: #fff;
}
.cp-msg__meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
  font-size: 12px; font-weight: 600; opacity: .75;
}
.cp-msg__body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }

.cp-composer {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px; margin-top: 16px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--slate-50);
}
.cp-composer textarea {
  width: 100%; min-height: 88px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); font: inherit; font-size: 14px; resize: vertical;
}
.cp-composer textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.cp-composer__foot { display: flex; align-items: center; gap: 12px; }
.cp-composer__foot small { color: var(--muted); font-size: 12.5px; }

/* ---- Forms --------------------------------------------------------------- */

.cp-field { margin-bottom: 16px; }
.cp-field label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 600; }
.cp-field input, .cp-field textarea, .cp-field select {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); font: inherit; font-size: 14.5px;
}
.cp-field textarea { resize: vertical; min-height: 110px; }
.cp-field input:focus, .cp-field textarea:focus, .cp-field select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50);
}
.cp-field small { display: block; margin-top: 6px; font-size: 12.5px; color: var(--muted); }

.cp-alert {
  padding: 11px 14px; margin-bottom: 16px;
  border-radius: var(--r-sm); font-size: 13.5px;
}
.cp-alert--ok { background: var(--green-50); color: var(--green); border: 1px solid #bbf7d0; }
.cp-alert--err { background: var(--red-50); color: var(--red); border: 1px solid #fecaca; }

/* ---- Empty / loading ----------------------------------------------------- */

.cp-empty { padding: 44px 24px; text-align: center; }
.cp-empty h3 { font-size: 16px; margin-bottom: 6px; }
.cp-empty p { color: var(--muted); font-size: 13.5px; }

.cp-loading { padding: 44px 24px; text-align: center; color: var(--muted); font-size: 14px; }

.cp-skeleton {
  height: 13px; border-radius: 4px; margin-bottom: 10px;
  background: linear-gradient(90deg, #eef0f3 25%, #e2e5ea 37%, #eef0f3 63%);
  background-size: 400% 100%;
  animation: cp-shimmer 1.3s ease-in-out infinite;
}
@keyframes cp-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---- Login --------------------------------------------------------------- */

.cp-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(800px 400px at 20% 0%, #eaf3fd, transparent 60%),
    var(--bg);
}
.cp-login__card {
  width: 100%; max-width: 400px;
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
}
.cp-login__card img { height: 32px; margin-bottom: 22px; }
.cp-login__card h1 { font-size: 21px; margin-bottom: 6px; }
.cp-login__card > p { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.cp-login__foot { margin-top: 20px; text-align: center; font-size: 13px; color: var(--muted); }
.cp-login__foot a { color: var(--brand); font-weight: 600; }

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 900px) {
  .cp-rail {
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .cp-rail.is-open { transform: none; box-shadow: var(--sh-3); }
  .cp-main { margin-left: 0; }
  .cp-burger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; margin-right: 4px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--surface); cursor: pointer;
  }
  .cp-content { padding: 18px; }
  .cp-topbar { padding: 0 18px; }
  .cp-scrim {
    position: fixed; inset: 0; z-index: 45;
    background: rgba(17, 24, 39, .4);
  }
}

@media (max-width: 620px) {
  .cp-table thead { display: none; }
  .cp-table tr { display: grid; gap: 4px; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
  .cp-table td { display: flex; justify-content: space-between; gap: 16px; padding: 2px 16px; border: 0; }
  .cp-table td::before {
    content: attr(data-label);
    font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--muted); flex-shrink: 0;
  }
  .cp-msg { max-width: 92%; }
}

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