/* SalesWRK shared base styles. Each app overrides --brand in its own css. */
:root {
  --brand: #2563eb;
  --brand-dark: #1e40af;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --radius: 8px;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

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

h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
p  { margin: 0 0 1rem; }

/* ---- Forms ---- */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }

input, select, textarea {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

.field { margin-bottom: 1rem; }

.btn {
  display: inline-block;
  padding: .6rem 1.1rem;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.secondary { background: transparent; color: var(--brand); }
.btn.secondary:hover { background: var(--bg); }
.btn.block { width: 100%; }

.error { color: var(--danger); font-size: .85rem; min-height: 1.2em; }

/* ---- Auth layout (login pages) ---- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}
.auth-card .logo { font-weight: 700; font-size: 1.25rem; color: var(--brand); margin-bottom: 1.5rem; }

/* ---- App shell (dashboard pages) ---- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
}
.sidebar .logo { font-weight: 700; color: var(--brand); padding: 0 .5rem 1.25rem; }
.sidebar nav a {
  display: block;
  padding: .55rem .75rem;
  border-radius: var(--radius);
  color: var(--text);
}
.sidebar nav a:hover { background: var(--bg); text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar .spacer { flex: 1; }

.main { flex: 1; padding: 1.5rem 2rem; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.topbar .user { color: var(--muted); font-size: .9rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.75rem; font-weight: 600; margin-top: .25rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: .85rem; }

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); }
  .main { padding: 1rem; }
}

/* ---- Added for admin console / CRM dashboards ---- */
.auth-links { margin-top: 1rem; text-align: center; font-size: .85rem; color: var(--muted); }
.two-col { display: grid; gap: 1rem; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }
.table-wrap { overflow-x: auto; }
tr[data-id] { cursor: pointer; }
tr[data-id]:hover td { background: var(--bg); }
tr.selected td { background: color-mix(in srgb, var(--brand) 8%, white); }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn:disabled { opacity: .6; cursor: default; }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-actions { grid-column: 1 / -1; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.form-actions .error { flex-basis: 100%; }
.kv { display: grid; gap: .4rem 1rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); font-size: .9rem; }
.kv span { display: block; color: var(--muted); font-size: .78rem; }
.grid.mini { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .5rem; }
.grid.mini .stat { padding: .5rem .75rem; background: var(--bg); border-radius: var(--radius); }
.grid.mini .value { font-size: 1.15rem; }
.grid.mini .value small { color: var(--muted); font-size: .8rem; font-weight: 400; }
h3 { font-size: 1rem; margin-top: .5rem; }
