/* Yuvau CRM — minimal, professional */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #1f6feb;
  --primary-hover: #175bcc;
  --success: #059669;
  --danger: #dc2626;
  --code-bg: #f3f4f6;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top nav */
.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.topnav .brand a {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.topnav .navlinks {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; gap: 0.25rem;
  flex: 1;
}
.topnav .navlinks a {
  display: block;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
}
.topnav .navlinks a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.topnav .navlinks a.active { background: var(--bg); color: var(--text); }
.userbox { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.username { color: var(--muted); }
.linkbtn {
  background: none; border: none; color: var(--primary);
  cursor: pointer; font: inherit; padding: 0;
}
.linkbtn:hover { text-decoration: underline; }

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.success { color: var(--success); }
.wrap { word-break: break-all; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.two-col > .card { margin-bottom: 0; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.row-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.row-between h1 { margin: 0; }

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}
.stat-label { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-size: 1.75rem; font-weight: 700; margin-top: 0.25rem; }

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th, .table td {
  padding: 0.55rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg); }

code {
  background: var(--code-bg);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.85em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

pre.webhook {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.85rem;
  overflow-x: auto;
}

/* Badges */
.rolebadge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--code-bg);
  color: var(--muted);
}
.rolebadge.master_admin { background: #fef3c7; color: #92400e; }
.rolebadge.client_admin { background: #dbeafe; color: #1e40af; }
.rolebadge.client_user  { background: #e5e7eb; color: #374151; }

.stage-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--code-bg);
  color: var(--text);
}
.stage-badge.won  { background: #d1fae5; color: #065f46; }
.stage-badge.lost { background: #fee2e2; color: #991b1b; }

/* Forms and buttons */
.filter-bar {
  display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.filter-bar input, .filter-bar select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font: inherit;
}
.inline-form { display: flex; flex-direction: column; gap: 0.6rem; }
.inline-form input, .inline-form select, .inline-form textarea {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  width: 100%;
}
.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  align-items: end;
}
.grid-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }
.grid-form input, .grid-form select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

.btn {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

/* DL */
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 0.4rem 0.75rem; margin: 0; }
.dl dt { color: var(--muted); font-size: 0.85rem; }
.dl dd { margin: 0; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  border-left: 2px solid var(--border);
  padding: 0.15rem 0 0.9rem 0.9rem;
  margin-left: 0.35rem;
  position: relative;
}
.timeline li::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 0.4rem;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
}
.tl-time { font-size: 0.75rem; color: var(--muted); }
.tl-note {
  background: var(--bg);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  margin-top: 0.35rem;
  font-size: 0.9rem;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  padding: 2rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
}
.login-card h1 { margin: 0 0 0.25rem; }
.login-card label { display: block; margin-bottom: 0.85rem; font-size: 0.85rem; color: var(--muted); }
.login-card label input {
  display: block;
  margin-top: 0.25rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
}
.login-card .btn { width: 100%; padding: 0.65rem; }

.alert { padding: 0.6rem 0.8rem; border-radius: 6px; margin-bottom: 0.75rem; font-size: 0.9rem; }
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
