/* ───────────────────────────────────────────────────────────────────────────
   klareGroup CRM — UI theme
   Modern, professional, slightly compact admin-app aesthetic.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  --c-bg:        #f5f7fb;
  --c-surface:   #ffffff;
  --c-border:    #e5e7eb;
  --c-border-2:  #eef0f4;
  --c-text:      #111827;
  --c-text-2:    #4b5563;
  --c-text-3:    #6b7280;
  --c-text-4:    #9ca3af;

  --c-brand:     #4f46e5;          /* indigo-600 */
  --c-brand-2:   #4338ca;
  --c-brand-soft:#eef2ff;
  --c-accent:    #06b6d4;

  --sidebar-bg:    #0f172a;        /* slate-900 */
  --sidebar-bg-2:  #111c34;
  --sidebar-fg:    #cbd5e1;
  --sidebar-fg-2:  #94a3b8;
  --sidebar-section:#64748b;
  --sidebar-active-bg: rgba(99, 102, 241, .14);
  --sidebar-active-bd: #6366f1;

  --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 1px rgba(15,23,42,.03);
  --shadow-md: 0 4px 14px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 20px 48px rgba(15,23,42,.18), 0 4px 10px rgba(15,23,42,.08);

  --radius:    8px;
  --radius-lg: 12px;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

html, body { height: 100%; }
body {
  background: var(--c-bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13.5px;
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
* { -webkit-tap-highlight-color: transparent; }

/* ───────── App shell ───────── */
.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-fg);
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar .brand {
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar .brand .name {
  font-weight: 600; color: #fff; font-size: 16px; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
.sidebar .brand .name:before {
  content: ''; display: inline-block; width: 22px; height: 22px;
  background: linear-gradient(135deg, var(--c-brand), var(--c-accent));
  border-radius: 6px; box-shadow: 0 4px 8px rgba(79,70,229,.35);
}
.sidebar .brand .tagline { color: var(--sidebar-fg-2); font-size: 11.5px; margin-top: 4px; letter-spacing: .02em; }

.sidebar nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }

.sidebar .nav-section {
  padding: 14px 12px 4px;
  color: var(--sidebar-section);
  text-transform: uppercase;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .08em;
}
.sidebar .nav-link {
  color: var(--sidebar-fg);
  padding: 7px 12px;
  margin: 1px 4px;
  border-radius: 6px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  font-weight: 500;
  transition: background .12s ease, color .12s ease;
  border-left: none;
}
.sidebar .nav-link:hover {
  background: rgba(255,255,255,.05);
  color: #fff;
}
.sidebar .nav-link.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  position: relative;
}
.sidebar .nav-link.active::before {
  content: ''; position: absolute; left: -4px; top: 6px; bottom: 6px;
  width: 3px; background: var(--sidebar-active-bd); border-radius: 0 3px 3px 0;
}
.sidebar .nav-link i {
  width: 18px; text-align: center; font-size: 15px; opacity: .85;
}
.sidebar .nav-link.active i { opacity: 1; color: #a5b4fc; }

.sidebar .user-block {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: 12px;
  color: var(--sidebar-fg-2);
  background: rgba(0,0,0,.18);
}
.sidebar .user-block strong { color: #fff; font-weight: 600; }
.sidebar .user-block a { color: #a5b4fc; text-decoration: none; }
.sidebar .user-block a:hover { color: #c7d2fe; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-brand), var(--c-accent));
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; letter-spacing: -.02em;
}

/* ───────── Topbar ───────── */
.main-area { display: flex; flex-direction: column; min-width: 0; background: var(--c-bg); }

.topbar {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 12px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .crumb {
  font-weight: 600;
  color: var(--c-text);
  font-size: 15px;
  letter-spacing: -.01em;
}
.topbar-actions .btn { font-weight: 500; }

.content { padding: 22px; }

/* ───────── Cards ───────── */
.card {
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
  background: var(--c-surface);
}
.card .card-body { padding: 16px 18px; }
.card h5, .card h6 { font-weight: 600; letter-spacing: -.01em; }
.card h6 { color: var(--c-text-2); text-transform: none; font-size: 13px; }

/* ───────── Tables ───────── */
.table {
  color: var(--c-text);
  margin: 0;
}
.table thead th {
  background: #fafbfc;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text-3);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: .06em;
  padding: 10px 12px;
}
.table tbody td {
  padding: 10px 12px;
  border-color: var(--c-border-2);
  vertical-align: middle;
}
.table tbody tr:hover { background: #fafcff; }
.table a { color: var(--c-brand); text-decoration: none; font-weight: 500; }
.table a:hover { color: var(--c-brand-2); text-decoration: underline; }

/* Tighten compact tables */
.table-sm thead th, .table-sm tbody td { padding: 8px 12px; font-size: 13px; }

/* ───────── Forms ───────── */
.form-label, .form-label.small { font-weight: 500; color: var(--c-text-2); font-size: 12px; margin-bottom: 4px; letter-spacing: .01em; }
.form-control, .form-select {
  border: 1px solid var(--c-border);
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--c-text);
  background: var(--c-surface);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control:focus, .form-select:focus {
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
  outline: 0;
}
.form-control-sm, .form-select-sm {
  font-size: 13px;
  padding: 5px 9px;
  border-radius: 6px;
}
.form-control[disabled], .form-select[disabled] { background: #f9fafb; color: var(--c-text-3); }
textarea.form-control { line-height: 1.45; }

/* Checkboxes / radios */
.form-check-input { border-color: #cbd5e1; }
.form-check-input:checked { background-color: var(--c-brand); border-color: var(--c-brand); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(79,70,229,.15); }

/* ───────── Buttons ───────── */
.btn {
  font-weight: 500;
  font-size: 13.5px;
  letter-spacing: -.005em;
  border-radius: 6px;
  padding: 6px 14px;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease, transform .03s ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-primary {
  background: var(--c-brand);
  border-color: var(--c-brand);
  box-shadow: 0 1px 2px rgba(79,70,229,.25);
}
.btn-primary:hover, .btn-primary:focus { background: var(--c-brand-2); border-color: var(--c-brand-2); }
.btn-outline-primary { color: var(--c-brand); border-color: #c7d2fe; }
.btn-outline-primary:hover { background: var(--c-brand); border-color: var(--c-brand); color: #fff; }
.btn-outline-secondary { color: var(--c-text-2); border-color: var(--c-border); background: var(--c-surface); }
.btn-outline-secondary:hover { background: #f3f4f6; color: var(--c-text); border-color: #d1d5db; }
.btn-outline-danger { color: #dc2626; border-color: #fecaca; }
.btn-outline-danger:hover { background: #dc2626; border-color: #dc2626; }

/* ───────── Badges & pills ───────── */
.badge { font-weight: 500; padding: 4px 8px; border-radius: 999px; font-size: 11.5px; letter-spacing: .01em; }

.badge-stage {
  display: inline-block;
  background: #f1f5f9; color: #475569;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 500;
}
.badge-stage.won { background: #d1fae5; color: #047857; }
.badge-stage.lost { background: #fee2e2; color: #b91c1c; }

/* ───────── kv list ───────── */
dl.kv { display: grid; grid-template-columns: 150px 1fr; row-gap: 6px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--c-text-3); font-weight: 500; }
dl.kv dd { margin: 0; color: var(--c-text); }

/* ───────── Misc ───────── */
.tiny { font-size: 12px; color: var(--c-text-3); }
.text-muted { color: var(--c-text-3) !important; }

.kanban-col {
  background: #f3f4f6;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  min-height: 240px;
  padding: 10px;
}
.kanban-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 6px;
  font-size: 13px;
}

.timeline-item { border-left: 2px solid var(--c-border); padding: 6px 0 12px 14px; margin-left: 6px; position: relative; }
.timeline-item:before { content:''; position:absolute; left:-5px; top:8px; width:8px; height:8px; background: var(--c-brand); border-radius:50%; }

.totals-table td { padding: 5px 10px; font-size: 13px; }
.totals-table tr.total td { font-weight: 600; border-top: 2px solid #d1d5db; padding-top: 8px; }

td.right, th.right { text-align: right; }
td.center, th.center { text-align: center; }

.line-row td { vertical-align: middle; }

.btn-icon { padding: 2px 6px; line-height: 1; }
.dot-online { display: inline-block; width: 8px; height: 8px; background: #22c55e; border-radius: 50%; margin-right: 4px; }

/* Alerts */
.alert {
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 13.5px;
  padding: 10px 14px;
}
.alert-success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.alert-warning { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.alert-danger  { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ───────── Mobile ───────── */
@media (max-width: 767.98px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar.offcanvas { background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%); color: var(--sidebar-fg); }
  .content { padding: 14px; }
  .topbar { padding: 10px 14px; }
}

/* ───────────────────────────────────────────────────────────────────────────
   Login page
   ─────────────────────────────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--c-bg);
}
.login-brand {
  background:
    radial-gradient(1200px 600px at 0% 100%, rgba(99,102,241,.55) 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(6,182,212,.45) 0%, transparent 55%),
    linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  color: #fff;
  padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-brand .logo {
  display: inline-flex; align-items: center; gap: 12px;
  font-weight: 700; font-size: 18px; letter-spacing: -.01em;
}
.login-brand .logo-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, #818cf8, #22d3ee);
  box-shadow: 0 8px 24px rgba(99,102,241,.4);
}
.login-brand h2 {
  font-size: 36px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em;
  margin-bottom: 16px;
}
.login-brand p { color: #c7d2fe; font-size: 15px; line-height: 1.55; max-width: 420px; }
.login-brand .feature-list {
  display: grid; gap: 12px; margin-top: 32px;
  color: #e0e7ff; font-size: 13.5px;
}
.login-brand .feature-list .row { display: flex; align-items: center; gap: 10px; }
.login-brand .feature-list .row i { color: #67e8f9; font-size: 16px; }
.login-brand .footer-note { font-size: 12px; color: #94a3b8; }

.login-form-pane {
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
  background: var(--c-surface);
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.02em;
  margin-bottom: 4px;
  color: var(--c-text);
}
.login-card .sub { color: var(--c-text-3); margin-bottom: 24px; font-size: 13.5px; }

.login-card .field { margin-bottom: 14px; }
.login-card .field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text-2);
  margin-bottom: 6px;
}
.login-card .input-group-text {
  background: transparent;
  border-right: 0;
  color: var(--c-text-4);
  padding-left: 12px;
}
.login-card .input-group .form-control {
  border-left: 0;
  padding-left: 4px;
}
.login-card .input-group .form-control:focus {
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
.login-card .input-group:focus-within .input-group-text {
  border-color: var(--c-brand);
  color: var(--c-brand);
}
.login-card .form-control {
  height: 42px;
  font-size: 14px;
}
.login-card .btn-primary {
  height: 42px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .01em;
  background: linear-gradient(135deg, var(--c-brand), #6366f1);
  border: none;
  box-shadow: 0 4px 12px rgba(79,70,229,.3);
  margin-top: 6px;
}
.login-card .btn-primary:hover {
  background: linear-gradient(135deg, var(--c-brand-2), var(--c-brand));
  box-shadow: 0 6px 16px rgba(79,70,229,.4);
}
.login-card .helper {
  margin-top: 18px;
  font-size: 12px;
  color: var(--c-text-3);
  text-align: center;
}

@media (max-width: 880px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { padding: 32px; min-height: 240px; }
  .login-brand h2 { font-size: 26px; }
  .login-brand .feature-list { display: none; }
  .login-form-pane { padding: 32px 20px; }
}

/* ───────── Print ───────── */
.print-only { display: none; }
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-area, .content, .app-shell { display: block; padding: 0; margin: 0; background: #fff; }
  .print-only { display: block; }
  body { font-size: 11pt; }
}
