/* ============================================================
   CAVMIR CLIENT PORTAL — shared layout & components
   Brand-neutral: every colour that carries identity comes from
   brand.css (var(--brand), var(--accent), --wordmark, --product).
   This file is identical across Cavmir / WBD / Attorney.
   ============================================================ */

:root {
  --bg:       #f4f5f8;
  --surface:  #ffffff;
  --surface-2:#fafbfc;
  --line:     #e6e8ee;
  --line-2:   #eef0f4;
  --ink:      #1b2130;
  --mut:      #667085;
  --mut-2:    #98a0ae;

  --ok:#1f9d57;   --ok-bg:#e7f6ed;
  --warn:#b9770d; --warn-bg:#fdf2df;
  --info:#2563eb; --info-bg:#e9f0fe;
  --violet:#7c3aed; --violet-bg:#f1ebfd;
  --red:#c5392b;  --red-bg:#fbe9e7;
  --grey:#5b6472; --grey-bg:#eef0f3;

  --radius:10px;
  --shadow:0 1px 2px rgba(16,24,40,.05), 0 8px 24px -16px rgba(16,24,40,.18);
}

* { box-sizing:border-box; }
html,body { margin:0; padding:0; }
body {
  font-family:var(--brand-font);
  background:var(--bg);
  color:var(--ink);
  font-size:14.5px;
  line-height:1.55;
  -webkit-font-smoothing:antialiased;
}
a { color:inherit; text-decoration:none; }
h1,h2,h3,h4 { margin:0; font-weight:700; letter-spacing:-.01em; }
input,textarea,select,button { font-family:inherit; font-size:14px; }

/* ---- brand wordmark (text comes from brand.css) ---- */
.wordmark::before { content:var(--wordmark); }
.product::before  { content:var(--product); }
.wordmark { font-family:var(--brand-serif); font-weight:600; letter-spacing:.01em; }

.diamond { width:10px; height:10px; background:var(--accent); transform:rotate(45deg); border-radius:2px; flex:0 0 auto; }

/* ============================================================ LOGIN */
.login-wrap {
  min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(var(--brand-rgb),.10), transparent 60%),
    radial-gradient(700px 500px at 100% 110%, rgba(212,175,55,.10), transparent 55%),
    var(--bg);
}
.login-card {
  width:400px; max-width:94vw; background:var(--surface); border:1px solid var(--line);
  border-radius:16px; padding:38px 34px; box-shadow:var(--shadow);
}
.login-brand { display:flex; align-items:center; gap:9px; margin-bottom:26px; }
.login-brand .wordmark { font-size:22px; color:var(--brand); }
.login-brand .product { font-size:11px; letter-spacing:.18em; text-transform:uppercase; color:var(--mut-2);
  border-left:1px solid var(--line); padding-left:9px; margin-left:1px; }
.login-card h1 { font-size:21px; margin-bottom:5px; }
.login-card .sub { color:var(--mut); margin:0 0 22px; font-size:13.5px; }
.field { margin-bottom:15px; }
.field label { display:block; font-size:11.5px; text-transform:uppercase; letter-spacing:.06em; color:var(--mut); margin-bottom:6px; }
.field input {
  width:100%; padding:11px 13px; border:1px solid var(--line); border-radius:9px;
  background:var(--surface-2); color:var(--ink); transition:border-color .15s, box-shadow .15s;
}
.field input:focus { outline:none; border-color:var(--brand); box-shadow:0 0 0 3px rgba(var(--brand-rgb),.12); background:#fff; }
.notice { font-size:13px; padding:10px 12px; border-radius:8px; margin-bottom:16px; display:none; }
.notice.err { display:block; background:var(--red-bg); color:var(--red); border:1px solid #f1c4bd; }
.notice.ok  { display:block; background:var(--ok-bg); color:var(--ok); border:1px solid #bce5cb; }
.login-foot { margin-top:18px; text-align:center; color:var(--mut-2); font-size:11.5px; }

/* ============================================================ BUTTONS */
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  padding:10px 16px; border-radius:9px; border:1px solid var(--line); cursor:pointer;
  background:var(--surface); color:var(--ink); font-weight:500; transition:.15s; white-space:nowrap;
}
.btn:hover { border-color:var(--mut-2); }
.btn-primary { background:var(--brand); border-color:var(--brand); color:#fff; }
.btn-primary:hover { background:var(--brand-ink); border-color:var(--brand-ink); }
.btn-sm { padding:7px 12px; font-size:13px; border-radius:8px; }
.btn-block { width:100%; }
.btn:disabled { opacity:.55; cursor:default; }

/* ============================================================ APP SHELL */
.app { display:grid; grid-template-columns:248px 1fr; min-height:100vh; }

.sidebar {
  background:var(--brand); color:#fff; display:flex; flex-direction:column;
  position:sticky; top:0; height:100vh;
}
.sidebar-brand { display:flex; align-items:center; gap:9px; padding:22px 22px 18px; }
.sidebar-brand .wordmark { font-size:21px; color:#fff; }
.sidebar-brand .product { font-size:10px; letter-spacing:.16em; text-transform:uppercase; color:rgba(255,255,255,.6);
  border-left:1px solid rgba(255,255,255,.25); padding-left:8px; }
.nav { padding:8px 12px; display:flex; flex-direction:column; gap:2px; flex:1; overflow-y:auto; }
.nav a {
  display:flex; align-items:center; gap:11px; padding:10px 12px; border-radius:8px;
  color:rgba(255,255,255,.78); font-weight:500; font-size:14px; cursor:pointer;
}
.nav a:hover { background:rgba(255,255,255,.08); color:#fff; }
.nav a.active { background:rgba(255,255,255,.14); color:#fff; }
.nav a.active .ic { color:var(--accent); }
.nav .ic { width:18px; height:18px; flex:0 0 auto; opacity:.95; }
.nav .badge {
  margin-left:auto; background:var(--accent); color:#3a2c05; font-size:11px; font-weight:700;
  min-width:18px; height:18px; padding:0 5px; border-radius:9px; display:inline-flex; align-items:center; justify-content:center;
}
.nav-sep { height:1px; background:rgba(255,255,255,.12); margin:8px 12px; }
.nav-label { padding:6px 12px 2px; font-size:10px; letter-spacing:.12em; text-transform:uppercase; color:rgba(255,255,255,.45); }
.side-foot { padding:14px; border-top:1px solid rgba(255,255,255,.12); }
.side-user { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.avatar { width:34px; height:34px; border-radius:50%; background:var(--accent); color:#3a2c05;
  display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px; flex:0 0 auto; }
.side-user .who { font-size:13px; font-weight:600; line-height:1.2; }
.side-user .who small { display:block; color:rgba(255,255,255,.6); font-weight:400; font-size:11.5px; }
.side-foot .btn { background:rgba(255,255,255,.10); border-color:rgba(255,255,255,.18); color:#fff; }
.side-foot .btn:hover { background:rgba(255,255,255,.18); }

/* ---- main ---- */
.main { min-width:0; display:flex; flex-direction:column; }
.topbar {
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding:20px 30px; background:var(--surface); border-bottom:1px solid var(--line); position:sticky; top:0; z-index:20;
}
.topbar h1 { font-size:20px; }
.topbar .crumb { color:var(--mut); font-size:13px; margin-top:2px; }
.menu-btn { display:none; }
.content { padding:26px 30px 60px; max-width:1180px; width:100%; }

/* ============================================================ CARDS / GRID */
.card { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); }
.card-pad { padding:20px 22px; }
.card-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:16px 20px; border-bottom:1px solid var(--line-2); }
.card-head h3 { font-size:15px; }
.grid { display:grid; gap:18px; }
.grid.cols-4 { grid-template-columns:repeat(4,1fr); }
.grid.cols-3 { grid-template-columns:repeat(3,1fr); }
.grid.cols-2 { grid-template-columns:repeat(2,1fr); }
.section { margin-bottom:22px; }
.section-title { font-size:12px; letter-spacing:.08em; text-transform:uppercase; color:var(--mut); margin:0 0 12px; }

.stat { padding:18px 20px; }
.stat .label { font-size:12.5px; color:var(--mut); display:flex; align-items:center; gap:7px; }
.stat .num { font-size:30px; font-weight:700; letter-spacing:-.02em; margin-top:8px; line-height:1; }
.stat .sub { font-size:12px; color:var(--mut-2); margin-top:6px; }
.stat .ic { width:16px; height:16px; color:var(--brand); }

/* ============================================================ BADGES */
.badge-s { display:inline-flex; align-items:center; gap:5px; font-size:12px; font-weight:600;
  padding:3px 9px; border-radius:20px; line-height:1.4; white-space:nowrap; }
.badge-s::before { content:""; width:6px; height:6px; border-radius:50%; background:currentColor; opacity:.9; }
.s-submitted,.s-new   { color:var(--info);   background:var(--info-bg); }
.s-in_progress,.s-contacted { color:var(--warn); background:var(--warn-bg); }
.s-completed,.s-won,.s-paid { color:var(--ok); background:var(--ok-bg); }
.s-qualified { color:var(--violet); background:var(--violet-bg); }
.s-declined,.s-lost,.s-spam { color:var(--grey); background:var(--grey-bg); }
.s-due { color:var(--warn); background:var(--warn-bg); }
.s-overdue { color:var(--red); background:var(--red-bg); }
.pri-high { color:var(--red); }
.pri-normal { color:var(--mut); }
.pri-low { color:var(--mut-2); }

/* ============================================================ TABLE */
.tbl { width:100%; border-collapse:collapse; }
.tbl th { text-align:left; font-size:11.5px; text-transform:uppercase; letter-spacing:.05em; color:var(--mut);
  font-weight:600; padding:11px 14px; border-bottom:1px solid var(--line); background:var(--surface-2); }
.tbl td { padding:13px 14px; border-bottom:1px solid var(--line-2); vertical-align:top; }
.tbl tr:last-child td { border-bottom:0; }
.tbl tr.click { cursor:pointer; }
.tbl tr.click:hover td { background:var(--surface-2); }
.tbl .muted { color:var(--mut); }
.tbl .nowrap { white-space:nowrap; }
.cellname { font-weight:600; }
.cellsub { color:var(--mut); font-size:12.5px; }

/* ============================================================ REQUESTS */
.req-item { padding:15px 20px; border-bottom:1px solid var(--line-2); display:flex; gap:14px; align-items:flex-start; cursor:pointer; }
.req-item:hover { background:var(--surface-2); }
.req-item:last-child { border-bottom:0; }
.req-item .grow { flex:1; min-width:0; }
.req-item .subj { font-weight:600; }
.req-item .meta { color:var(--mut); font-size:12.5px; margin-top:3px; display:flex; gap:10px; flex-wrap:wrap; }

/* comment thread */
.thread { display:flex; flex-direction:column; gap:12px; }
.cmt { display:flex; gap:10px; }
.cmt .av { width:30px; height:30px; border-radius:50%; flex:0 0 auto; display:flex; align-items:center; justify-content:center;
  font-size:12px; font-weight:700; color:#fff; background:var(--mut); }
.cmt.admin .av { background:var(--brand); }
.cmt .bubble { background:var(--surface-2); border:1px solid var(--line-2); border-radius:10px; padding:9px 13px; flex:1; }
.cmt.admin .bubble { background:var(--brand-soft); border-color:#ecd9e5; }
.cmt .who { font-size:12.5px; font-weight:600; }
.cmt .who small { color:var(--mut-2); font-weight:400; margin-left:7px; }
.cmt .txt { margin-top:3px; }

/* ============================================================ BARS (analytics) */
.bars { display:flex; align-items:flex-end; gap:10px; height:130px; padding-top:8px; }
.bars .col { flex:1; display:flex; flex-direction:column; align-items:center; gap:7px; height:100%; justify-content:flex-end; }
.bars .bar { width:100%; max-width:34px; background:linear-gradient(var(--brand), var(--brand-ink)); border-radius:5px 5px 0 0; min-height:3px; transition:height .4s; }
.bars .blab { font-size:10.5px; color:var(--mut-2); }
.bars .bval { font-size:11px; color:var(--mut); font-weight:600; }

/* ============================================================ WEBSITE / HEALTH */
.score-card { display:flex; flex-direction:column; }
.gauge { flex:0 0 auto; line-height:0; }
.breakdown { display:flex; flex-direction:column; gap:11px; }
.brk-top { display:flex; align-items:center; justify-content:space-between; font-size:13px; font-weight:600; }
.brk-bar { height:6px; background:var(--line); border-radius:6px; margin:5px 0 3px; overflow:hidden; }
.brk-bar span { display:block; height:100%; background:linear-gradient(90deg, var(--brand), var(--accent)); border-radius:6px; transition:width .5s; }
.brk-note { font-size:11.5px; color:var(--mut-2); }

.mini { background:var(--surface-2); border:1px solid var(--line-2); border-radius:9px; padding:12px 8px; text-align:center; }
.mini .mlab { font-size:11px; color:var(--mut); }
.mini .mval { font-size:21px; font-weight:700; margin-top:3px; letter-spacing:-.01em; }

.spark { display:flex; align-items:flex-end; gap:3px; height:62px; }
.spark.tall { height:124px; gap:4px; }
.spark .sp { flex:1; background:linear-gradient(var(--brand), var(--brand-ink)); border-radius:3px 3px 0 0; min-height:3px; opacity:.85; transition:opacity .15s; }
.spark .sp:hover { opacity:1; }

.kv { padding:8px 16px 14px; display:flex; flex-direction:column; gap:3px; }
.kv-row { position:relative; display:flex; align-items:center; justify-content:space-between; gap:10px; padding:8px 11px; border-radius:7px; font-size:13px; overflow:hidden; }
.kv-bar { position:absolute; left:0; top:0; bottom:0; background:var(--brand-soft); border-radius:7px; z-index:0; transition:width .5s; }
.kv-k, .kv-v { position:relative; z-index:1; }
.kv-k { font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.kv-v { font-weight:700; color:var(--brand); flex:0 0 auto; }

/* ============================================================ FORM / PANEL */
.form-row { margin-bottom:14px; }
.form-row label { display:block; font-size:12px; color:var(--mut); margin-bottom:5px; font-weight:500; }
.form-row input, .form-row textarea, .form-row select {
  width:100%; padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:var(--surface-2); color:var(--ink);
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  outline:none; border-color:var(--brand); box-shadow:0 0 0 3px rgba(var(--brand-rgb),.10); background:#fff;
}
.form-row textarea { min-height:96px; resize:vertical; }
.row2 { display:grid; grid-template-columns:1fr 1fr; gap:14px; }

/* slide-over panel */
.overlay { position:fixed; inset:0; background:rgba(16,24,40,.42); opacity:0; pointer-events:none; transition:.2s; z-index:50; }
.overlay.show { opacity:1; pointer-events:auto; }
.panel {
  position:fixed; top:0; right:0; height:100vh; width:min(540px,94vw); background:var(--surface);
  box-shadow:-20px 0 60px -30px rgba(16,24,40,.4); transform:translateX(100%); transition:transform .25s; z-index:51;
  display:flex; flex-direction:column;
}
.panel.show { transform:translateX(0); }
.panel-head { padding:20px 24px; border-bottom:1px solid var(--line); display:flex; align-items:flex-start; justify-content:space-between; gap:14px; }
.panel-body { padding:20px 24px; overflow-y:auto; flex:1; }
.panel-foot { padding:14px 24px; border-top:1px solid var(--line); display:flex; gap:10px; }
.x { cursor:pointer; color:var(--mut); font-size:22px; line-height:1; border:0; background:none; padding:0; }

/* ============================================================ MISC */
.empty { text-align:center; color:var(--mut); padding:48px 20px; }
.empty .big { font-size:15px; color:var(--ink); font-weight:600; margin-bottom:4px; }
.muted { color:var(--mut); }
.right { text-align:right; }
.flex { display:flex; align-items:center; gap:10px; }
.between { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.spread { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.mt8{margin-top:8px}.mt16{margin-top:16px}.mt24{margin-top:24px}
.toast {
  position:fixed; bottom:22px; left:50%; transform:translateX(-50%) translateY(20px); opacity:0;
  background:var(--ink); color:#fff; padding:11px 18px; border-radius:10px; font-size:13.5px; z-index:80;
  transition:.25s; box-shadow:0 10px 30px -10px rgba(0,0,0,.4); pointer-events:none;
}
.toast.show { opacity:1; transform:translateX(-50%) translateY(0); }
.plan-card { background:linear-gradient(135deg, var(--brand), var(--brand-ink)); color:#fff; border:0; }
.plan-card .price { font-size:30px; font-weight:700; }
.plan-card .price small { font-size:14px; font-weight:400; opacity:.8; }
.plan-card .tier { font-family:var(--brand-serif); font-size:22px; font-weight:600; }
.dot-accent { color:var(--accent); }

/* ============================================================ RESPONSIVE */
@media (max-width:880px) {
  .app { grid-template-columns:1fr; }
  .sidebar { position:fixed; left:0; top:0; width:264px; transform:translateX(-100%); transition:transform .25s; z-index:60; }
  .sidebar.open { transform:translateX(0); }
  .menu-btn { display:inline-flex; }
  .grid.cols-4 { grid-template-columns:1fr 1fr; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns:1fr; }
  .row2 { grid-template-columns:1fr; }
  .content { padding:18px 16px 50px; }
  .topbar { padding:14px 16px; }
  .hide-sm { display:none; }
}
@media (max-width:520px) {
  .grid.cols-4 { grid-template-columns:1fr; }
}
