/* Winners Club CRM — Nutshell-inspired design system */
:root {
  --accent: #0f6fde;
  --accent-dark: #0b57c0;
  --accent-soft: #e8f1fd;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e3e5e8;
  --border-strong: #d5d8dd;
  --text: #1c1e21;
  --muted: #6b7076;
  --green: #16a34a;
  --green-soft: #e6f6ec;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --orange: #d97706;
  --orange-soft: #fdf0dd;
  --purple: #7c3aed;
  --sidebar-w: 236px;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow: 0 4px 16px rgba(16,24,40,.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg,#f4f7fb 0%,#eaf1fb 100%); }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 40px 36px; width: 380px; max-width: 92vw; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg,var(--accent),#6aa5f0); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; }
.login-brand h1 { font-size: 20px; margin: 0; letter-spacing: -.02em; }
.login-sub { color: var(--muted); margin: 0 0 26px; font-size: 13.5px; }
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 12.5px; font-weight: 600; color: #3a3f45; margin-bottom: 6px; }
.login-field input { width: 100%; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: 9px; font-size: 14px; outline: none; }
.login-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-primary { width: 100%; padding: 12px; background: var(--accent); color: #fff; border: none; border-radius: 9px; font-size: 15px; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); }
.login-error { color: var(--red); font-size: 13px; margin: 10px 0 0; min-height: 18px; }

/* ---------- App shell ---------- */
#app { display: flex; height: 100vh; }
#sidebar { width: var(--sidebar-w); min-width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sb-brand { display: flex; align-items: center; gap: 9px; padding: 18px 18px 14px; }
.sb-logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg,var(--accent),#6aa5f0); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.sb-brand h1 { font-size: 16px; margin: 0; letter-spacing: -.02em; }
.sb-nav { padding: 6px 10px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: #3a3f45; font-weight: 500; cursor: pointer; margin-bottom: 2px; font-size: 13.5px; }
.nav-item:hover { background: #f2f4f7; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item .count { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 999px; font-weight: 700; }
.sb-foot { border-top: 1px solid var(--border); padding: 10px 14px; }
.sb-user { display: flex; align-items: center; gap: 9px; padding: 6px 4px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.sb-user .uname { font-size: 13px; font-weight: 600; }
.sb-user .urole { font-size: 11px; color: var(--muted); }
.btn-ghost { background: none; border: 1px solid var(--border); color: #3a3f45; padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; }
.btn-ghost:hover { background: #f2f4f7; }

/* ---------- Main ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#topbar { height: 58px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; gap: 14px; }
#topbar h2 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.search-wrap { flex: 1; max-width: 420px; position: relative; }
.search-wrap input { width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--border-strong); border-radius: 9px; outline: none; font-size: 13.5px; }
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
#search-results { position: absolute; top: 42px; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); z-index: 50; max-height: 360px; overflow-y: auto; }
.sr-item { padding: 9px 14px; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.sr-item:hover { background: #f2f4f7; }
.sr-item .stype { font-size: 10.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; width: 58px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.btn-add { background: var(--accent); color: #fff; border: none; padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.btn-add:hover { background: var(--accent-dark); }
#content { flex: 1; overflow-y: auto; padding: 24px; }

/* ---------- Cards / layout ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 7px; }
.kpi .k-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; font-weight: 650; }
.card-body { padding: 16px 18px; }
.section-title { font-size: 13px; font-weight: 700; color: #3a3f45; margin: 0 0 10px; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: #eef0f3; border-radius: 12px; min-width: 240px; width: 240px; display: flex; flex-direction: column; max-height: calc(100vh - 210px); }
.kcol-head { padding: 12px 14px 8px; display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 13px; }
.kcol-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.kcol-head .sum { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.kcol-body { padding: 4px 8px 12px; overflow-y: auto; flex: 1; min-height: 60px; }
.deal-card { background: #fff; border: 1px solid var(--border); border-radius: 9px; padding: 11px 12px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow-sm); }
.deal-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.deal-card.dragging { opacity: .5; }
.deal-card .dname { font-weight: 600; font-size: 13px; line-height: 1.3; margin-bottom: 5px; }
.deal-card .dvalue { font-size: 14px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.deal-card .dmeta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.deal-card .dmeta .avatar { width: 20px; height: 20px; font-size: 9px; }
.kcol.drop-over { outline: 2px dashed var(--accent); outline-offset: -2px; }

/* ---------- Lists / tables ---------- */
.list-table { width: 100%; border-collapse: collapse; }
.list-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.list-table td { padding: 11px 14px; border-bottom: 1px solid #f0f1f3; font-size: 13.5px; vertical-align: middle; }
.list-table tr { cursor: pointer; }
.list-table tr:hover td { background: #f8fafc; }
.list-table .cell-primary { font-weight: 600; color: var(--accent); }
.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-orange { background: var(--orange-soft); color: var(--orange); }
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-blue { background: var(--accent-soft); color: var(--accent); }
.tag-gray { background: #eef0f3; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; font-size: 14px; }
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ---------- Detail slide-over ---------- */
#drawer { position: fixed; top: 0; right: 0; width: 460px; max-width: 94vw; height: 100vh; background: #fff; border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(16,24,40,.12); z-index: 100; transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; }
#drawer.open { transform: translateX(0); }
#drawer-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.28); z-index: 90; }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.drawer-head .avatar { width: 38px; height: 38px; font-size: 15px; }
.drawer-head .dh-title { font-size: 17px; font-weight: 700; }
.drawer-head .dh-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.drawer-close { margin-left: auto; background: none; border: none; font-size: 20px; color: var(--muted); cursor: pointer; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.drawer-sec { margin-bottom: 22px; }
.drawer-sec h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 9px; font-weight: 700; }
.dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.dl .di { margin-bottom: 4px; }
.dl .di .k { font-size: 11px; color: var(--muted); font-weight: 600; }
.dl .di .v { font-size: 13.5px; margin-top: 2px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px solid #f0f1f3; }
.tl-icon { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.tl-body .tl-title { font-size: 13.5px; font-weight: 600; }
.tl-body .tl-date { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.tl-body .tl-note { font-size: 13px; color: #3a3f45; margin-top: 3px; }

/* ---------- Forms / modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.4); z-index: 120; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow); width: 520px; max-width: 94vw; max-height: 90vh; overflow-y: auto; padding: 24px; }
.modal h3 { margin: 0 0 18px; font-size: 17px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 12.5px; font-weight: 600; color: #3a3f45; margin-bottom: 6px; }
.form-field input, .form-field select, .form-field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px; outline: none; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.btn-secondary { background: #fff; border: 1px solid var(--border-strong); color: #3a3f45; padding: 9px 15px; border-radius: 8px; font-weight: 600; font-size: 13.5px; }
.btn-secondary:hover { background: #f2f4f7; }
.btn-primary-sm { background: var(--accent); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; font-weight: 600; font-size: 13.5px; }
.btn-primary-sm:hover { background: var(--accent-dark); }

/* ---------- Reports ---------- */
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bar-row .blabel { width: 100px; font-size: 13px; color: #3a3f45; font-weight: 500; text-align: right; }
.bar-row .btrack { flex: 1; background: #eef0f3; border-radius: 6px; height: 22px; overflow: hidden; }
.bar-row .bfill { height: 100%; background: linear-gradient(90deg,var(--accent),#6aa5f0); border-radius: 6px; }
.bar-row .bval { width: 90px; font-size: 12.5px; color: var(--muted); font-weight: 600; }

.toast { position: fixed; bottom: 22px; right: 22px; background: #111827; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow); z-index: 200; opacity: 0; transform: translateY(8px); transition: all .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
