/* ═══════════════════════════════════════════════════
   EGLIT CRM — Complete Stylesheet
   ═══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:     #0F172A;
  --ink2:    #1E293B;
  --muted:   #64748B;
  --light:   #94A3B8;
  --line:    #E2E8F0;
  --bg:      #F1F5F9;
  --card:    #ffffff;
  --blue:    #3B82F6;
  --blue-d:  #2563EB;
  --green:   #22C55E;
  --red:     #EF4444;
  --yellow:  #F59E0B;
  --purple:  #8B5CF6;
  --radius:  10px;
  --shadow:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

body { font-family: Inter, system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--ink2); background: var(--bg); min-height: 100vh; }

a { text-decoration: none; color: var(--blue); }
a:hover { color: var(--blue-d); }
code { font-family: monospace; background: #F8FAFC; padding: 1px 5px; border-radius: 4px; font-size: .85em; border: 1px solid var(--line); }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 230px; min-width: 230px;
  background: var(--ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sb-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid #1e293b;
  display: flex; align-items: center; gap: 10px;
}
.sb-brand-icon { width: 32px; height: 32px; background: var(--blue); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.sb-brand-text  { color: #fff; font-weight: 700; font-size: .95rem; line-height: 1.2; }
.sb-brand-sub   { color: #64748B; font-size: .68rem; }

.sb-nav { flex: 1; padding: 8px 0; }
.sb-section { padding: 14px 14px 4px; font-size: .65rem; color: #475569; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.sb-link {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px; color: #94A3B8;
  font-size: .855rem; font-weight: 500;
  transition: all .15s; border-radius: 0;
  position: relative;
}
.sb-link:hover { background: #1e293b; color: #e2e8f0; }
.sb-link.active { background: #1e293b; color: #fff; }
.sb-link.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--blue); border-radius: 0 2px 2px 0; }
.sb-link-icon { width: 18px; text-align: center; font-size: .9rem; }
.sb-badge { margin-left: auto; background: var(--blue); color: #fff; font-size: .65rem; padding: 1px 6px; border-radius: 99px; font-weight: 700; }

.sb-footer { padding: 12px 14px; border-top: 1px solid #1e293b; }
.sb-user { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sb-avatar { width: 28px; height: 28px; background: var(--blue); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: .75rem; font-weight: 700; }
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name { color: #e2e8f0; font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { color: #64748B; font-size: .68rem; }
.sb-logout { display: block; text-align: center; color: #64748B; font-size: .78rem; padding: 5px; border-radius: 6px; transition: background .15s; }
.sb-logout:hover { background: #1e293b; color: #94A3B8; }

/* ── Main area ── */
.main { flex: 1; overflow: auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 0 24px; height: 54px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-weight: 700; font-size: 1rem; color: var(--ink); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.content { padding: 20px 24px; flex: 1; }

/* ── Cards ── */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.card-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.card-head-title { font-weight: 600; font-size: .9rem; color: var(--ink); }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--blue)); padding: 16px; box-shadow: var(--shadow); }
.stat-val { font-size: 1.9rem; font-weight: 800; color: var(--c, var(--blue)); line-height: 1; }
.stat-lbl { font-size: .75rem; color: var(--muted); margin-top: 5px; font-weight: 500; }

/* ── Table ── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { background: #F8FAFC; padding: 9px 13px; text-align: left; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody td { padding: 11px 13px; border-bottom: 1px solid #F8FAFC; color: var(--ink2); font-size: .855rem; vertical-align: middle; }
tbody tr:hover td { background: #FAFBFC; }
tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 8px 16px; border-radius: 8px; font-size: .855rem; font-weight: 600; cursor: pointer; border: none; transition: all .15s; white-space: nowrap; text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); color: #fff; }
.btn-outline { background: #fff; color: var(--ink2); border: 1.5px solid var(--line); }
.btn-outline:hover { border-color: #94A3B8; }
.btn-danger { background: #FEF2F2; color: var(--red); border: 1px solid #FECACA; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: .78rem; border-radius: 6px; background: #F1F5F9; color: var(--ink2); border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; font-weight: 500; text-decoration: none; }
.btn-sm:hover { background: #E2E8F0; color: var(--ink); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #16A34A; color: #fff; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: .73rem; font-weight: 600; white-space: nowrap; }
.badge-src { background: #F1F5F9; color: var(--muted); padding: 2px 8px; border-radius: 5px; font-size: .73rem; font-weight: 600; text-transform: capitalize; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: .78rem; font-weight: 600; color: var(--ink2); }
.form-ctrl { border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 11px; font-size: .875rem; font-family: inherit; color: var(--ink); background: #fff; outline: none; transition: border .2s; width: 100%; }
.form-ctrl:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
select.form-ctrl { cursor: pointer; }
textarea.form-ctrl { resize: vertical; min-height: 72px; }

/* ── Filter bar ── */
.filter-bar { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 24px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-bar input, .filter-bar select { padding: 6px 10px; border: 1.5px solid var(--line); border-radius: 7px; font-size: .83rem; color: var(--ink); background: #fff; outline: none; }
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--blue); }

/* ── Alerts ── */
.alert { padding: 11px 15px; border-radius: 8px; font-size: .875rem; line-height: 1.6; margin-bottom: 14px; }
.alert-success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.alert-danger  { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-info    { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.alert-warn    { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }

/* ── Info rows ── */
.info-lbl { font-size: .72rem; font-weight: 700; color: var(--light); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.info-val  { font-size: .875rem; color: var(--ink2); font-weight: 500; }

/* ── Activity timeline ── */
.timeline { padding: 12px; }
.tl-item { display: flex; gap: 10px; margin-bottom: 14px; }
.tl-icon { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .85rem; flex-shrink: 0; }
.tl-body { flex: 1; }
.tl-type { font-weight: 600; font-size: .8rem; color: var(--ink2); }
.tl-note { font-size: .8rem; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.tl-meta { font-size: .72rem; color: var(--light); margin-top: 3px; }

/* ── Status buttons ── */
.status-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.status-pill { padding: 4px 12px; border-radius: 99px; font-size: .75rem; font-weight: 600; cursor: pointer; border: 1.5px solid transparent; transition: all .15s; background: transparent; }

/* ── Pagination ── */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.pg-link { padding: 5px 11px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink2); font-size: .83rem; text-decoration: none; transition: all .15s; }
.pg-link:hover { border-color: var(--blue); color: var(--blue); }
.pg-link.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Toast ── */
#toast { position: fixed; bottom: 20px; right: 20px; padding: 10px 18px; border-radius: 8px; font-size: .875rem; font-weight: 600; color: #fff; z-index: 9999; display: none; box-shadow: 0 4px 12px rgba(0,0,0,.2); }

/* ── Login page ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0F172A 0%, #1e3a5f 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo-icon { width: 52px; height: 52px; background: var(--blue); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; margin: 0 auto 10px; }
.login-logo h1 { font-size: 1.4rem; color: var(--ink); font-weight: 800; }
.login-logo p  { color: var(--muted); font-size: .83rem; margin-top: 3px; }

/* ── Grid helpers ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.flex    { display: flex; }
.flex-col { flex-direction: column; }
.gap-3   { gap: 12px; }
.gap-4   { gap: 16px; }
.gap-5   { gap: 20px; }
.mt-1 { margin-top: 4px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.p-4  { padding: 16px; }
.text-muted { color: var(--muted); }
.text-sm    { font-size: .8rem; }
.text-xs    { font-size: .72rem; }
.fw-600     { font-weight: 600; }
.fw-700     { font-weight: 700; }
.text-right { text-align: right; }
.text-center{ text-align: center; }
.nowrap     { white-space: nowrap; }
.red        { color: var(--red); }
.green      { color: var(--green); }

/* ── Progress bars ── */
.bar-wrap { height: 6px; background: #F1F5F9; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar-fill { height: 100%; border-radius: 99px; transition: width .5s; }

/* ── Modal ── */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 900; align-items: center; justify-content: center; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; }
.modal-title { font-weight: 700; font-size: 1rem; color: var(--ink); margin-bottom: 18px; }

/* ── Empty state ── */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty h3 { font-size: 1rem; color: var(--ink2); margin-bottom: 6px; }
.empty p  { font-size: .85rem; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .topbar  { padding: 0 14px; }
  .content { padding: 14px; }
  .filter-bar { padding: 8px 14px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
