/* ─── CronicTech CRM v2.0 — Main Stylesheet ─────────────────── */
/* Theme: Cronic Technologies (cronictech.in) */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,600;0,700;1,600;1,700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Outfit:wght@400;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Brand */
  --red:        #C8282A;
  --red-dark:   #9E1F21;
  --red-light:  #FDF3F3;
  --red-mid:    #F0D0D0;
  /* Neutrals */
  --dark:       #1A1D23;
  --dark2:      #242830;
  --sidebar-bg: #1A1D23;
  --heading:    #111827;
  --text:       #374151;
  --muted:      #6B7280;
  --border:     #E5E7EB;
  --bg:         #F9FAFB;
  --bg2:        #F3F4F6;
  --white:      #FFFFFF;
  /* Status */
  --green:      #059669;
  --green-bg:   #D1FAE5;
  --warn:       #D97706;
  --warn-bg:    #FEF3C7;
  --danger:     #DC2626;
  --danger-bg:  #FEE2E2;
  --info:       #2563EB;
  --info-bg:    #DBEAFE;
  --purple:     #7C3AED;
  --purple-bg:  #EDE9FE;
  /* Layout */
  --sidebar-w:  240px;
  --topnav-h:   56px;
  --radius:     8px;
  --radius-lg:  12px;
  --shadow:     0 1px 8px rgba(0,0,0,0.07);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.1);
  --shadow-red: 0 4px 14px rgba(200,40,42,0.25);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
hr { border: none; border-top: 1px solid var(--border); }

/* ─── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--sidebar-bg);
  display: flex; flex-direction: column; z-index: 200;
  overflow-y: auto; scrollbar-width: thin; scrollbar-color: #374151 transparent;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo-img { width: 38px; height: 38px; object-fit: contain; }
.sidebar-logo-icon {
  width: 38px; height: 38px; border-radius: 8px; background: var(--red);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-logo-name { font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 0.82rem; color: #fff; letter-spacing: 0.04em; line-height: 1.2; }
.sidebar-logo-sub  { font-size: 0.58rem; color: rgba(255,255,255,0.35); letter-spacing: 0.08em; font-family: 'JetBrains Mono', monospace; }

.sidebar-section { padding: 18px 16px 4px; font-size: 0.6rem; font-family: 'JetBrains Mono', monospace; color: rgba(255,255,255,0.25); letter-spacing: 0.14em; text-transform: uppercase; }

.sidebar-link {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px; color: rgba(255,255,255,0.55); font-size: 0.82rem; font-weight: 500;
  border-left: 2px solid transparent; transition: all 0.15s; cursor: pointer;
  width: 100%; text-align: left;
}
.sidebar-link:hover  { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-link.active { background: rgba(200,40,42,0.12); border-left-color: var(--red); color: #fff; font-weight: 600; }
.sidebar-link .s-icon { width: 18px; text-align: center; font-size: 0.85rem; flex-shrink: 0; }
.sidebar-link .badge  { margin-left: auto; background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.6); font-size: 0.65rem; padding: 1px 7px; border-radius: 10px; font-family: 'JetBrains Mono', monospace; }
.sidebar-link .badge.warn { background: rgba(217,119,6,0.25); color: #FCD34D; }
.sidebar-link .badge.danger { background: rgba(220,38,38,0.25); color: #FCA5A5; }

.sidebar-footer { margin-top: auto; padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.06); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-size: 0.8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.6rem; color: rgba(255,255,255,0.35); font-family: 'JetBrains Mono', monospace; letter-spacing: 0.08em; }

/* ─── TOPNAV ──────────────────────────────────────────────── */
.topnav {
  position: fixed; left: var(--sidebar-w); right: 0; top: 0;
  height: var(--topnav-h); background: var(--white);
  border-bottom: 1px solid var(--border); display: flex; align-items: center;
  padding: 0 24px; gap: 12px; z-index: 150;
}
.topnav-title { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 0.92rem; color: var(--heading); letter-spacing: -0.2px; }
.topnav-right  { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topnav-breadcrumb { font-size: 0.72rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.topnav-breadcrumb span { color: var(--muted); }
.topnav-breadcrumb .current { color: var(--heading); font-weight: 600; }

/* ─── MAIN CONTENT ────────────────────────────────────────── */
.main-wrap { margin-left: var(--sidebar-w); padding-top: var(--topnav-h); min-height: 100vh; }
.main-content { padding: 24px; max-width: 1440px; }

/* ─── PAGE HEADER ─────────────────────────────────────────── */
.page-header { margin-bottom: 20px; }
.page-header h2 { font-family: 'Cormorant Garamond', serif; font-size: 1.7rem; font-weight: 700; color: var(--heading); letter-spacing: -0.5px; }
.page-header h2 em { color: var(--red); font-style: italic; }
.page-header p { font-size: 0.82rem; color: var(--muted); margin-top: 3px; }

/* ─── STAT CARDS ──────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; position: relative; overflow: hidden; }
.stat-card::before { content:''; position:absolute; left:0; top:0; bottom:0; width:3px; background:var(--border); border-radius:3px 0 0 3px; }
.stat-card.accent::before  { background: var(--red); }
.stat-card.green::before   { background: var(--green); }
.stat-card.warn::before    { background: var(--warn); }
.stat-card.danger::before  { background: var(--danger); }
.stat-card.info::before    { background: var(--info); }
.stat-label { font-size: 0.7rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; letter-spacing: 0.07em; text-transform: uppercase; margin-bottom: 6px; }
.stat-value { font-family: 'Outfit', sans-serif; font-size: 1.8rem; font-weight: 900; color: var(--heading); line-height: 1; letter-spacing: -1px; }
.stat-sub   { font-size: 0.68rem; color: var(--muted); margin-top: 4px; }

/* ─── TABLE CARD ──────────────────────────────────────────── */
.table-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 20px; }
.table-toolbar { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--bg2); }
.search-input { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.8rem; color: var(--heading); background: var(--white); width: 240px; transition: border-color 0.15s; }
.search-input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(200,40,42,0.06); }
.filter-select { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.8rem; color: var(--heading); background: var(--white); cursor: pointer; }
.filter-select:focus { outline: none; border-color: var(--red); }

table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
thead th { padding: 10px 14px; text-align: left; font-family: 'JetBrains Mono', monospace; font-size: 0.62rem; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; border-bottom: 1px solid var(--border); background: var(--bg2); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; cursor: pointer; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--red-light); }
td { padding: 11px 14px; vertical-align: middle; }
.td-company { font-weight: 600; color: var(--heading); font-size: 0.83rem; }
.td-muted { color: var(--muted); }
.td-actions { display: flex; gap: 5px; justify-content: flex-end; }

/* ─── STATUS PILLS ────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; font-size: 0.65rem; font-weight: 700; padding: 3px 9px; border-radius: 20px; font-family: 'JetBrains Mono', monospace; letter-spacing: 0.04em; white-space: nowrap; }
.pill-new        { background: var(--info-bg);   color: var(--info); }
.pill-contacted  { background: var(--purple-bg); color: var(--purple); }
.pill-followup   { background: var(--warn-bg);   color: var(--warn); }
.pill-proposal   { background: #FEF9C3; color: #713F12; }
.pill-negotiation{ background: #FEF3C7; color: #92400E; }
.pill-won        { background: var(--green-bg);  color: var(--green); }
.pill-lost       { background: var(--danger-bg); color: var(--danger); }
.pill-onhold     { background: var(--bg2); color: var(--muted); }
.pill-active     { background: var(--green-bg);  color: var(--green); }
.pill-expiring   { background: var(--warn-bg);   color: var(--warn); }
.pill-expired    { background: var(--danger-bg); color: var(--danger); }
.pill-renewed    { background: var(--info-bg);   color: var(--info); }

/* ─── BUTTONS ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 0.8rem; font-weight: 600; transition: all 0.15s; white-space: nowrap; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background: var(--red); color: #fff; box-shadow: var(--shadow-red); }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary { background: var(--white); color: var(--heading); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--red); color: var(--red); background: var(--red-light); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #FECACA; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--heading); background: var(--bg2); }
.btn-sm { padding: 5px 10px; font-size: 0.72rem; }
.btn-icon { padding: 7px; border-radius: var(--radius); }

/* ─── MODAL ───────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--white); border-radius: var(--radius-lg); width: 100%; max-width: 760px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-md); animation: modalIn 0.2s ease; }
@keyframes modalIn { from { opacity:0; transform:scale(0.97) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: var(--dark); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.modal-title { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 1rem; color: #fff; }
.modal-close { color: rgba(255,255,255,0.5); font-size: 1.1rem; padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { color: #fff; background: rgba(255,255,255,0.1); }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--bg2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.section-label { font-family: 'JetBrains Mono', monospace; font-size: 0.62rem; color: var(--red); letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600; padding: 6px 0; border-bottom: 1px solid var(--border); margin-bottom: 14px; }

/* ─── FORM ELEMENTS ───────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
.field-label { font-size: 0.72rem; font-weight: 700; color: var(--heading); }
.field-label .req { color: var(--red); }
.field { padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.82rem; color: var(--heading); background: var(--white); transition: border-color 0.15s; width: 100%; }
.field:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(200,40,42,0.06); }
.field.error { border-color: var(--danger); }
textarea.field { resize: vertical; min-height: 80px; }

/* ─── DETAIL PANEL ────────────────────────────────────────── */
.detail-panel { display: none; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-top: 16px; box-shadow: var(--shadow-md); animation: slideIn 0.2s ease; }
.detail-panel.open { display: block; }
@keyframes slideIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.detail-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; background: var(--dark); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.detail-company { font-family: 'Cormorant Garamond', serif; font-size: 1.3rem; font-weight: 700; color: #fff; letter-spacing: -0.3px; }
.detail-body { padding: 20px 22px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.detail-field { display: flex; flex-direction: column; gap: 3px; }
.detail-field.full { grid-column: 1 / -1; }
.detail-field label { font-size: 0.65rem; font-family: 'JetBrains Mono', monospace; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.detail-field span { font-size: 0.82rem; color: var(--heading); font-weight: 500; }
.detail-divider { grid-column: 1 / -1; border: none; border-top: 1px solid var(--border); }

/* ─── ACTIVITY LOG ────────────────────────────────────────── */
.activity-log { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.activity-log h4 { font-family: 'Outfit', sans-serif; font-size: 0.82rem; font-weight: 700; color: var(--heading); margin-bottom: 12px; }
.activity-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.78rem; }
.activity-item:last-child { border-bottom: none; }
.activity-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--red); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.58rem; font-weight: 700; flex-shrink: 0; font-family: 'Outfit', sans-serif; }
.activity-body { flex: 1; }
.activity-meta { display: flex; gap: 6px; align-items: center; margin-bottom: 2px; }
.activity-user { font-weight: 600; color: var(--heading); }
.activity-time { color: var(--muted); font-size: 0.68rem; }
.activity-type-badge { font-size: 0.58rem; padding: 1px 7px; border-radius: 10px; font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.type-note { background:#EDE9FE; color:#5B21B6; }
.type-call { background:#D1FAE5; color:#065F46; }
.type-email { background:#DBEAFE; color:#1E40AF; }
.type-meeting { background:#FEF3C7; color:#92400E; }
.type-status_change { background:#FCE7F3; color:#9D174D; }
.type-created { background:var(--bg2); color:var(--muted); }
.activity-text { color: var(--text); line-height: 1.5; }

/* ─── ALERTS ──────────────────────────────────────────────── */
.alert { padding: 11px 16px; border-radius: var(--radius); font-size: 0.8rem; display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #FECACA; }
.alert-warn   { background: var(--warn-bg);   color: var(--warn);   border: 1px solid #FDE68A; }
.alert-success{ background: var(--green-bg);  color: var(--green);  border: 1px solid #6EE7B7; }
.alert-info   { background: var(--info-bg);   color: var(--info);   border: 1px solid #BFDBFE; }

/* ─── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state-text { font-size: 0.85rem; color: var(--muted); line-height: 1.6; }

/* ─── DASHBOARD CARDS ─────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.dash-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.dash-card h3 { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 0.88rem; color: var(--heading); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.pipeline-bar { height: 8px; border-radius: 4px; background: var(--bg2); overflow: hidden; margin-bottom: 12px; display: flex; gap: 2px; }
.pipeline-seg { height: 100%; border-radius: 2px; transition: width 0.5s ease; }
.expiry-list .expiry-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.78rem; }
.expiry-item:last-child { border-bottom: none; }
.expiry-days { min-width: 40px; text-align: right; font-family: 'JetBrains Mono', monospace; font-weight: 700; }

/* ─── USER MANAGEMENT ─────────────────────────────────────── */
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--red); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; flex-shrink: 0; font-family: 'Outfit', sans-serif; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.user-info .u-name { font-weight: 600; font-size: 0.83rem; color: var(--heading); }
.user-info .u-meta { font-size: 0.68rem; color: var(--muted); }
.role-badge { padding: 2px 10px; border-radius: 12px; font-size: 0.65rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.role-Admin   { background: #FEF3C7; color: #92400E; }
.role-Manager { background: var(--purple-bg); color: var(--purple); }
.role-Sales   { background: var(--info-bg); color: var(--info); }
.role-Viewer  { background: var(--bg2); color: var(--muted); }

/* ─── LOGIN PAGE ──────────────────────────────────────────── */
.login-bg { min-height: 100vh; background: linear-gradient(135deg, var(--dark) 0%, var(--dark2) 50%, #2A1E1E 100%); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--white); border-radius: 16px; width: 100%; max-width: 400px; padding: 36px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: fadeUp 0.35s ease; }
@keyframes fadeUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon { width: 56px; height: 56px; background: var(--red); border-radius: 14px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; box-shadow: var(--shadow-red); }
.login-logo-text { font-family: 'Outfit', sans-serif; font-weight: 900; font-size: 1.15rem; color: var(--heading); letter-spacing: -0.3px; }
.login-logo-sub  { font-size: 0.7rem; color: var(--muted); margin-top: 3px; font-family: 'JetBrains Mono', monospace; }
.login-form h3 { font-family: 'Cormorant Garamond', serif; font-size: 1.3rem; font-weight: 700; color: var(--heading); margin-bottom: 18px; }
.login-field { margin-bottom: 14px; }
.login-hint { text-align: center; font-size: 0.68rem; color: var(--muted); margin-top: 18px; }

/* ─── TOAST ───────────────────────────────────────────────── */
#toast { position: fixed; bottom: 24px; right: 24px; z-index: 9999; padding: 12px 18px; border-radius: 10px; font-size: 0.8rem; font-weight: 600; opacity: 0; transform: translateY(10px); transition: all 0.3s; max-width: 300px; box-shadow: var(--shadow-md); }
#toast.show { opacity: 1; transform: translateY(0); }

/* ─── RENEWAL TIMELINE ────────────────────────────────────── */
.renewal-timeline { margin-top: 16px; }
.rt-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: center; }
.rt-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; flex-shrink: 0; }
.rt-icon.renewed { background: var(--green-bg); color: var(--green); }
.rt-icon.created  { background: var(--info-bg);  color: var(--info); }
.rt-info { flex: 1; font-size: 0.78rem; }
.rt-info strong { color: var(--heading); display: block; }
.rt-info span   { color: var(--muted); font-size: 0.7rem; }

/* ─── RESPONSIVE ──────────────────────────────────────────── */
@media(max-width:768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .topnav { left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .main-content { padding: 16px; }
  .search-input { width: 100%; }
  .modal-box { max-height: 95vh; }
}
