/* ===== ATLAS CodX Client Portal ===== */
:root {
  --pink: #FF2D78;
  --purple: #7029FF;
  --ink: #0f172a;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e9e4f5;
  --bg: #f6f4fb;
  --card: #ffffff;
  --grad: linear-gradient(90deg, #FF2D78, #7029FF);
  --radius: 18px;
  --shadow: 0 10px 30px -18px rgba(76, 29, 149, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Satoshi', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
img { max-width: 100%; }
a { color: var(--purple); }
h1, h2, h3 { font-family: 'Clash Grotesk', 'Satoshi', sans-serif; color: var(--ink); line-height: 1.2; font-weight: 600; }
h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); margin: 0 0 6px; }
h2 { font-size: 1.25rem; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.small.ok { color: #047857; }
.small.err { color: #b91c1c; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.16em; font-size: 11px; font-weight: 700; color: var(--pink); margin: 0 0 6px; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: #fff; padding: 8px 14px; border-radius: 10px; box-shadow: var(--shadow); }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

/* Top bar */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar::before { content: ''; display: block; height: 4px; background: var(--grad); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 66px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 36px; width: auto; }
.brand-tag { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--purple); background: #f3f0ff; padding: 4px 10px; border-radius: 999px; }
.topnav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; font-size: 14px; font-weight: 600; }
.topnav a { color: var(--text); text-decoration: none; }
.topnav a:hover { color: var(--pink); }
.topnav form { margin: 0; }
.who { color: var(--muted); font-weight: 500; }
.linklike { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; }
.linklike:hover { color: var(--pink); }

.main { flex: 1; padding-top: 28px; padding-bottom: 48px; }
.foot { border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 13px; padding: 18px 0; }
.foot a { color: var(--muted); }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.grid-cards { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.empty { text-align: center; padding: 40px 24px; }
.crumb { margin: 0 0 14px; font-size: 14px; }
.crumb a { text-decoration: none; font-weight: 600; }
.engagement h2 { margin-top: 12px; }
.engagement-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 18px; margin: 14px 0 16px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; color: var(--ink); }
.facts-stack { grid-template-columns: 1fr; }

/* Auth */
.auth { display: flex; justify-content: center; padding: 20px 0; }
.auth-card { width: 100%; max-width: 440px; padding: 32px; }
.auth-links { text-align: center; margin: 16px 0 6px; font-size: 14px; }

/* Forms */
.form label { display: block; font-size: 13px; font-weight: 700; color: var(--ink); margin: 16px 0 6px; }
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=number], .form input[type=date], .form textarea, .form select {
  width: 100%; font: inherit; color: var(--ink); background: #fbfaff; border: 1px solid #ddd6f3; border-radius: 12px; padding: 11px 14px;
}
.form textarea { min-height: 96px; resize: vertical; }
.form input:focus, .form textarea:focus, .form select:focus { outline: none; border-color: var(--purple); background: #fff; box-shadow: 0 0 0 3px rgba(112, 41, 255, 0.12); }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.check { display: flex !important; gap: 10px; align-items: flex-start; font-weight: 500 !important; font-size: 14px !important; line-height: 1.5; margin-top: 20px !important; cursor: pointer; }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--purple); flex-shrink: 0; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 6px 18px 18px; margin: 0 0 18px; }
legend { font-family: 'Clash Grotesk', 'Satoshi', sans-serif; font-weight: 600; color: var(--ink); padding: 0 6px; font-size: 16px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px; padding: 11px 22px; font: inherit; font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: transform .15s ease, box-shadow .15s ease, opacity .15s; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 10px 22px -12px rgba(255, 45, 120, 0.8); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-ghost { background: #fff; color: var(--purple); border-color: #d8cff7; }
.btn-ghost:hover { border-color: var(--purple); }
.btn-danger { background: #fff; color: #b91c1c; border-color: #fecaca; }
.btn-block { width: 100%; margin-top: 18px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Badges */
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge-slate { background: #f1f5f9; color: #475569; }
.badge-blue { background: #e0f2fe; color: #0369a1; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }

/* Flash messages */
.flash { border-radius: 12px; padding: 12px 16px; margin: 0 0 18px; font-size: 14px; font-weight: 500; }
.flash-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Agreement page */
.doc-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 22px; align-items: start; }
.doc-side { position: sticky; top: 92px; display: grid; gap: 16px; }
.side-title { font-size: 1.1rem; margin: 12px 0 4px; }
.side-card .btn-block { margin-top: 10px; }
.steps { margin: 0; padding: 18px 18px 18px 38px; font-size: 14px; display: grid; gap: 6px; }
.doc { padding: clamp(20px, 4vw, 44px); }
.sig-heading { font-size: 14px; color: #4c1d95; margin: 26px 0 10px; }
.sig-table { width: 100%; border-collapse: separate; border-spacing: 14px 0; margin-left: -14px; width: calc(100% + 28px); }
.sig-cell { width: 50%; vertical-align: top; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.sig-party { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--purple); font-weight: 700; }
.sig-box { height: 84px; margin: 8px 0; border-bottom: 1px solid #94a3b8; display: flex; align-items: flex-end; }
.sig-img { max-height: 78px; max-width: 100%; }
.sig-empty { color: #94a3b8; font-size: 13px; padding-bottom: 6px; }
.sig-line { font-size: 14px; }
.sig-meta { color: var(--muted); font-size: 12px; }

.sign-card { margin-top: 22px; }
.pad-wrap { position: relative; }
.pad { display: block; width: 100%; height: 190px; border: 2px dashed #c9bdf2; border-radius: 14px; background: #fff; touch-action: none; cursor: crosshair; }
.pad-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #b5a8e3; font-size: 18px; pointer-events: none; font-family: 'Clash Grotesk', sans-serif; }
.pad-clear { position: absolute; right: 10px; top: 10px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--muted); }
.otp-box { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; background: #faf8ff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-top: 20px; }
.otp-box p { margin: 2px 0 0; }
.otp-input { max-width: 220px; letter-spacing: 0.4em; font-size: 20px !important; font-weight: 700; text-align: center; }
.otp-input::placeholder { letter-spacing: normal; font-size: 15px; font-weight: 500; }
.doc, .mou { overflow-wrap: anywhere; }
.grid-cards > *, .stack > *, .doc-layout > *, .admin-grid > * { min-width: 0; }

/* Admin tables */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 12px; border-bottom: 1px solid #f1edfa; vertical-align: middle; }
table.list tr:hover td { background: #fcfbff; }
table.list a.row-link { font-weight: 700; color: var(--ink); text-decoration: none; }
table.list a.row-link:hover { color: var(--pink); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { padding: 16px 18px; }
.stat b { display: block; font-size: 26px; font-family: 'Clash Grotesk', sans-serif; color: var(--ink); }
.stat span { font-size: 13px; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid #e9e4f5; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--grad); }
.timeline time { color: var(--muted); display: block; font-size: 12px; }
.pay-row { display: grid; grid-template-columns: 1.4fr 1.2fr 0.9fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.pay-row input { margin: 0; }
.pay-remove { background: none; border: 0; color: #b91c1c; font-size: 20px; cursor: pointer; padding: 4px 8px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.stack { display: grid; gap: 16px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; color: var(--muted); }

@media (max-width: 900px) {
  .doc-layout, .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .doc-side { position: static; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .card { padding: 18px; }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .brand img { height: 30px; }
  .topbar-inner { min-height: 58px; padding: 6px 0; }
  .who { display: none; }
  .topbar-inner { flex-wrap: nowrap; }
  .sig-table, .sig-table tbody, .sig-table tr, .sig-table td { display: block; width: 100%; margin: 0; }
  .sig-table { margin-left: 0; }
  .sig-cell { margin-bottom: 12px; }
  .pay-row { grid-template-columns: 1fr 1fr; }
  .pay-row .pay-amount { grid-column: 1 / 2; }
  .mou-title { font-size: 19px; }
}
@media (max-width: 420px) {
  .brand-tag { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}

/* Signature upload + preview */
.pad-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.upload-btn { margin: 0 !important; font-size: 13px !important; font-weight: 700 !important; cursor: pointer; }
.preview-dialog { width: min(960px, 96vw); max-height: 92vh; padding: 0; border: 0; border-radius: 20px; box-shadow: 0 30px 80px -20px rgba(15, 23, 42, 0.5); }
.preview-dialog::backdrop { background: rgba(15, 23, 42, 0.55); }
.preview-dialog[open] { display: flex; flex-direction: column; }
.preview-head, .preview-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 16px 22px; background: #faf8ff; }
.preview-head { border-bottom: 1px solid var(--line); }
.preview-foot { border-top: 1px solid var(--line); }
.preview-body { overflow-y: auto; padding: 18px; background: var(--bg); flex: 1; }
.preview-body .doc { box-shadow: none; }
.sig-cell-preview { border: 2px solid #a78bfa !important; background: #faf5ff; }
@media (max-width: 640px) {
  .preview-head, .preview-foot { padding: 12px 14px; }
  .preview-body { padding: 10px; }
}

/* Project tracker */
.bar { height: 8px; background: #efeaf9; border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.bar span { display: block; height: 100%; background: var(--grad); border-radius: 999px; }
.bar-lg { height: 14px; }
.proj-mini { background: #faf8ff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 8px 0 14px; }
.plan { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.plan-item { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fff; }
.plan-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
.plan-title { font-weight: 700; color: var(--ink); }
.plan-milestone { background: #faf5ff; border-color: #ddd6fe; }
.plan-done .plan-title { color: #166534; }
.plan-edit input[type=text], .plan-edit input[type=date], .plan-edit input[type=number], .plan-edit select { width: 100%; font: inherit; font-size: 13px; border: 1px solid #ddd6f3; border-radius: 9px; padding: 7px 9px; background: #fbfaff; }
.plan-edit td { padding: 8px 6px; vertical-align: top; }
.plan-edit td:first-child { min-width: 240px; }
.plan-edit .small-input { margin-top: 6px; font-size: 12px !important; color: var(--muted); }
.thread { display: grid; gap: 10px; max-height: 520px; overflow-y: auto; padding-right: 4px; }
.msg { border-radius: 14px; padding: 10px 14px; border: 1px solid var(--line); max-width: 92%; }
.msg-mine { background: #f3f0ff; margin-left: auto; }
.msg-theirs { background: #fff; }
.msg-update { border-left: 4px solid #7029FF; }
.msg-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.msg-head time { margin-left: auto; }
.msg-body { margin-top: 4px; font-size: 14px; white-space: normal; overflow-wrap: anywhere; }

.plan-edit select { min-width: 130px; }
.plan-edit input[type=date] { min-width: 140px; }
