:root {
  --ink: #1f2937;
  --muted: #6b7280;
  --bg: #f3f4f6;
  --card: #ffffff;
  --line: #e5e7eb;
  --brand: #1e3a5f;
  --accent: #f59e0b;
  --accent-dark: #b45309;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.center { text-align: center; }

.topbar { background: var(--brand); color: #fff; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 0.7rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 0.6rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand small { display: block; font-weight: 400; font-size: 0.7rem; opacity: 0.8; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #1e3a5f; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.2rem; }
.brand-mark.lg { width: 52px; height: 52px; font-size: 1.8rem; border-radius: 12px; }
.nav { display: flex; align-items: center; gap: 0.9rem; }
.nav a { color: #fff; text-decoration: none; opacity: 0.9; }
.nav a:hover { opacity: 1; text-decoration: underline; }
.user-chip { background: rgba(255,255,255,0.15); padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.85rem; }
.inline { display: inline; margin: 0; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 1.5rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem; margin-bottom: 1.2rem; }
.card h3 { margin-top: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0.2rem 0; font-size: 1.5rem; }
.btn-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.small-row { margin-top: 0.3rem; }

.btn { display: inline-block; padding: 0.55rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; font-size: 0.95rem; }
.btn:hover { background: #f9fafb; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1e3a5f; font-weight: 700; }
.btn-primary:hover { background: #fbbf24; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,0.4); color: #fff; padding: 0.35rem 0.7rem; }
.btn-danger-ghost { color: var(--danger); border-color: #fecaca; }
.btn-block { width: 100%; }
.linklike { background: none; border: none; color: var(--brand); cursor: pointer; padding: 0; font-size: 0.85rem; text-decoration: underline; }

.form label { display: block; margin-bottom: 0.8rem; font-weight: 600; font-size: 0.9rem; }
.form input, .form select, .form textarea { display: block; width: 100%; margin-top: 0.3rem; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; font-weight: 400; background: #fff; }
.form textarea { resize: vertical; }
.form h3 { margin: 1.2rem 0 0.6rem; }
.form.compact label { margin-bottom: 0.5rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }

.alert { padding: 0.8rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th, .table td { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { background: #f9fafb; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.inactive-row { opacity: 0.55; }

.pill { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: #eef2ff; color: #3730a3; margin: 0.1rem 0.15rem 0.1rem 0; }
.pill-lead { background: #e0e7ff; color: #3730a3; }
.pill-estimate_sent { background: #fef3c7; color: #92400e; }
.pill-won { background: #d1fae5; color: #065f46; }
.pill-in_progress { background: #dbeafe; color: #1e40af; }
.pill-completed { background: #e5e7eb; color: #374151; }
.pill-inactive { background: #f3f4f6; color: #6b7280; border: 1px dashed #d1d5db; }
.pill-admin { background: #1e3a5f; color: #fff; }
.pill-rep { background: #fef3c7; color: #92400e; }
.pill-doc { background: #f3f4f6; color: #374151; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.7rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.8rem; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 0.15rem; }
.stat.active { border-color: var(--accent); box-shadow: 0 0 0 2px #fde68a; }
.stat-num { font-size: 1.4rem; font-weight: 800; }
.stat-label { font-size: 0.85rem; color: var(--muted); }
.stat-val { font-size: 0.85rem; font-weight: 600; color: var(--accent-dark); }

.filters { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input, .filters select { padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; font-size: 0.95rem; }
.filters input[type="search"] { flex: 1; min-width: 180px; }

.dl { display: grid; grid-template-columns: 130px 1fr; gap: 0.3rem 0.8rem; margin: 0 0 1rem; }
.dl dt { color: var(--muted); font-size: 0.85rem; }
.dl dd { margin: 0; }
.notes { white-space: pre-wrap; background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem; }
.list { list-style: none; padding: 0; margin: 0.8rem 0 0; }
.list li { padding: 0.6rem 0; border-top: 1px solid var(--line); }

.login-wrap { display: flex; justify-content: center; padding: 3rem 1rem; }
.login-card { max-width: 380px; width: 100%; text-align: center; }
.login-card h1 { margin: 0.6rem 0 0.2rem; }
.login-brand { display: flex; justify-content: center; }
.login-card .form { text-align: left; }
