:root {
  --ink: #0d0f1a;
  --muted: #5d6377;
  --bg: #f6f7fb;
  --line: #e6e8ef;
  --violet: #7b5cff;
  --pink: #ff3d7f;
  --grad: linear-gradient(100deg, #ff6b45 0%, #ff3d7f 50%, #7b5cff 100%);
  --ok: #1c9c5c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(13, 15, 26, 0.04), 0 4px 16px rgba(13, 15, 26, 0.05);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Plus Jakarta Sans", -apple-system, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
.muted { color: var(--muted); }
h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; letter-spacing: -0.01em; }

label { display: block; font-size: 0.82rem; font-weight: 600; margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 0.95rem; padding: 11px 13px; border: 1.5px solid var(--line);
  border-radius: 10px; background: #fbfbfd; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); background: #fff; }
textarea { resize: vertical; min-height: 70px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 700; font-size: 0.9rem; padding: 10px 18px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #cfd2dc; }
.btn-primary { background: var(--grad); color: #fff; border: none; box-shadow: 0 8px 20px -8px rgba(255, 61, 127, 0.6); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; margin-top: 20px; padding: 13px; }
.alert { margin-top: 14px; padding: 10px 12px; border-radius: 10px; font-size: 0.88rem; }
.alert.error { background: #fdecef; color: #b4123f; }
.alert.success { background: #e8f7ef; color: #146b3f; }

/* Login */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border-radius: 18px; padding: 36px 30px; width: 100%; max-width: 400px; box-shadow: 0 24px 48px -12px rgba(13, 15, 26, 0.16); text-align: center; }
.login-card form { text-align: left; margin-top: 10px; }
.login-logo { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin-bottom: 12px; }

/* App */
.topbar { background: var(--ink); color: #fff; }
.topbar-in { max-width: 1100px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; gap: 14px; }
.topbar img { width: 36px; height: 36px; border-radius: 50%; background: #fff; padding: 2px; }
.topbar .brand { font-weight: 800; font-size: 1.05rem; }
.topbar .brand span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar .spacer { flex: 1; }
.topbar .btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 9px 16px; font: inherit; font-weight: 700; font-size: 0.9rem; color: var(--muted); cursor: pointer; }
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab .n { margin-left: 6px; background: var(--pink); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 0.75rem; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .k { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat .v { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: flex; background: #eceef4; border-radius: 10px; padding: 3px; }
.seg button { border: none; background: transparent; font: inherit; font-weight: 700; font-size: 0.82rem; padding: 7px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card.is-new { border-left: 4px solid var(--pink); }
.req-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.req-client { font-weight: 800; font-size: 1.02rem; }
.req-meta { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.req-msg { margin-top: 10px; white-space: pre-wrap; font-size: 0.95rem; }
.req-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.req-actions select { width: auto; padding: 7px 10px; font-size: 0.85rem; }
.req-reply { margin-top: 10px; font-size: 0.88rem; min-height: 42px; }
.badge { display: inline-block; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.b-new { background: #ffe9f1; color: #d6205f; }
.b-in_progress { background: #fff6e0; color: #a86b00; }
.b-done { background: #e8f7ef; color: #146b3f; }
.b-cat { background: #eef0f6; color: var(--muted); margin-left: 6px; }
.b-starter { background: #eef4ff; color: #2b5fd9; }
.b-pro { background: #efeaff; color: #5b3fe0; }
.b-demo { background: #eef0f6; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); }

.client-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.client-name { font-weight: 800; font-size: 1.05rem; }
.client-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.client-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.kv { font-size: 0.88rem; color: var(--muted); margin-top: 8px; }

.modal { position: fixed; inset: 0; background: rgba(13, 15, 26, 0.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 18px; padding: 26px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.keybox { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; word-break: break-all; background: #f3f4f8; border-radius: 10px; padding: 12px; margin-top: 8px; }

@media (min-width: 760px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .client-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- App shell: left sidebar like the client CRM ---------- */
.shell { min-height: 100vh; }
.side {
  position: fixed; inset: 0 auto 0 0; width: 230px; background: var(--ink); color: #fff;
  display: flex; flex-direction: column; padding: 22px 14px; z-index: 40;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; text-decoration: none; color: #fff; }
.side-brand img { width: 40px; height: 40px; border-radius: 50%; background: #fff; padding: 3px; }
.side-brand b { font-size: 1rem; line-height: 1.15; }
.side-brand small { display: block; font-size: 0.72rem; color: rgba(255, 255, 255, 0.5); font-weight: 500; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px; text-decoration: none;
  color: rgba(255, 255, 255, 0.72); font-weight: 600; font-size: 0.93rem;
}
.side nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side nav a.active { background: rgba(255, 255, 255, 0.1); color: #fff; }
.side nav .ico { width: 20px; text-align: center; }
.side nav .count { margin-left: auto; background: var(--pink); color: #fff; font-size: 0.72rem; font-weight: 800; border-radius: 999px; padding: 1px 8px; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.1); padding-top: 14px; display: grid; gap: 8px; }
.side-foot .who { font-weight: 700; font-size: 0.9rem; padding: 0 4px; }
.side-foot .btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.main { margin-left: 230px; padding: 30px 32px 60px; max-width: 1180px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.mobilebar { display: none; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.panel h2 { margin-bottom: 12px; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 16px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 0.92rem; text-decoration: none; color: inherit; }
.list-row:first-of-type { border-top: none; }
.list-row .sub { color: var(--muted); font-size: 0.8rem; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.tbl th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.b-draft { background: #eef0f6; color: var(--muted); }
.b-sent { background: #eef4ff; color: #2b5fd9; }
.b-paid { background: #e8f7ef; color: #146b3f; }
.b-overdue { background: #fdecef; color: #b4123f; }
.b-contacted { background: #eef4ff; color: #2b5fd9; }
.b-call_booked { background: #efeaff; color: #5b3fe0; }
.b-proposal_sent { background: #fff6e0; color: #a86b00; }
.b-won { background: #e8f7ef; color: #146b3f; }
.b-lost { background: #eef0f6; color: var(--muted); }
.b-onboarding { background: #fff6e0; color: #a86b00; }
.b-active { background: #e8f7ef; color: #146b3f; }
.b-paused, .b-cancelled { background: #eef0f6; color: var(--muted); }
.stat .s { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.stat.alert-stat .v { color: #b4123f; }

@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .side { transform: translateX(-100%); transition: transform 0.2s ease; }
  .side.open { transform: none; box-shadow: 20px 0 40px rgba(0, 0, 0, 0.3); }
  .main { margin-left: 0; padding: 20px 16px 50px; }
  .mobilebar { display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff; padding: 12px 16px; position: sticky; top: 0; z-index: 30; }
  .mobilebar button { background: none; border: 1px solid rgba(255, 255, 255, 0.3); color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 1.1rem; }
  .mobilebar b { font-size: 1rem; }
  .tbl-wrap { overflow-x: auto; }
}
