/* EdVille — Dark Premium UI */
:root {
  --bg: #111416; --bg-2: #161a1d; --surface: #1c2125; --surface-2: #232a2f; --surface-3: #2b3339;
  --line: #2f383e; --line-2: #3a454c;
  --text: #e9eef0; --text-2: #b4bec4; --muted: #84919a;
  --green: #3ecf7f; --green-2: #2aa865; --green-ink: #0d2a1b; --green-soft: rgba(62, 207, 127, .12);
  --amber: #f2b84b; --amber-soft: rgba(242, 184, 75, .13);
  --red: #ff6b6b; --red-soft: rgba(255, 107, 107, .12);
  --blue: #6aa8ff; --blue-soft: rgba(106, 168, 255, .12);
  --violet: #b493ff;
  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand svg { flex: none; }
.brand b { display: block; font-size: 15px; letter-spacing: .02em; }
.brand span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text-2); font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--green-soft); color: var(--green); }
.nav a .ic { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .sep { margin: 14px 12px 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: rgba(17, 20, 22, .85); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20; }
.topbar .title { font-size: 17px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 24px 28px 60px; max-width: 1500px; width: 100%; animation: fade .25s ease; }
.burger { display: none; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.btn.primary:hover { background: #52dc8f; }
.btn.danger { color: var(--red); border-color: rgba(255, 107, 107, .4); background: var(--red-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { padding: 7px; }
input, select, textarea { width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
input[type=checkbox] { width: auto; accent-color: var(--green); }
textarea { min-height: 80px; resize: vertical; }
label.field { display: block; }
label.field > span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; font-weight: 550; }
label.field > span .req { color: var(--green); }
.field .err { color: var(--red); font-size: 12px; margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text-2); cursor: pointer; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; } .span-all { grid-column: 1 / -1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row > select, .row > input:not([type=checkbox]) { width: auto; flex: 1 1 160px; }
.drawer .row > select { flex: 0 1 240px; }
.spacer { flex: 1; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters > * { width: auto; min-width: 140px; flex: 0 1 180px; }
.filters input[type=search] { flex: 1 1 220px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.flat { padding: 0; overflow: hidden; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; flex: 1; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; transition: transform .2s, border-color .2s; }
.kpi:hover { transform: translateY(-2px); border-color: var(--line-2); }
.kpi .lbl { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.kpi .val { font-size: 23px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.kpi.accent { border-color: rgba(62, 207, 127, .35); }
.kpi.accent .val { color: var(--green); }
.kpi.warn .val { color: var(--amber); }
.kpi.bad .val { color: var(--red); }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: var(--green-soft); opacity: .5; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.chart-box { position: relative; height: 260px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; background: var(--surface); position: sticky; top: 0; white-space: nowrap; cursor: default; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--text); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.click { cursor: pointer; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.plain::before { display: none; }
.flag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--amber-soft); color: var(--amber); margin: 1px 3px 1px 0; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--text-2); padding: 10px 14px; font: inherit; font-weight: 550; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--green); border-bottom-color: var(--green); }

/* ---------- drawer / modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 7, 8, .6); backdrop-filter: blur(3px); z-index: 50; animation: fadein .15s; }
@keyframes fadein { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--bg-2); border-left: 1px solid var(--line); z-index: 51; display: flex; flex-direction: column; animation: slide .22s ease; box-shadow: var(--shadow); }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; flex: 1; }
.drawer-body { padding: 20px 22px 40px; overflow-y: auto; flex: 1; }
.modal { position: fixed; z-index: 61; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); animation: pop .18s ease; }
.modal.wide { width: min(900px, calc(100vw - 24px)); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(.98); } }
.overlay.top { z-index: 60; }
.dl { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 12.5px; }
.dl dd { margin: 0; word-break: break-word; }
.section { margin-top: 22px; }
.section > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 10px; }

/* ---------- misc ---------- */
.toast-box { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface-2); border: 1px solid var(--line-2); border-left: 3px solid var(--green); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; animation: pop2 .2s ease; }
.toast.err { border-left-color: var(--red); }
@keyframes pop2 { from { opacity: 0; transform: translateY(8px); } }
.progress { height: 7px; background: var(--surface-3); border-radius: 99px; overflow: hidden; min-width: 70px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green-2), var(--green)); border-radius: 99px; transition: width .6s ease; }
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: grid; grid-template-columns: 120px 1fr 150px; gap: 12px; align-items: center; }
.funnel-bar { height: 30px; border-radius: 8px; background: linear-gradient(90deg, var(--green-2), var(--green)); min-width: 3px; transition: width .7s cubic-bezier(.2, .8, .2, 1); display: flex; align-items: center; padding-left: 10px; color: var(--green-ink); font-weight: 700; font-size: 13px; }
.funnel-meta { font-size: 12px; color: var(--text-2); text-align: right; }
.stages { display: flex; gap: 3px; }
.stages i { width: 14px; height: 6px; border-radius: 3px; background: var(--surface-3); }
.stages i.on { background: var(--green); }
.codebox { display: flex; align-items: center; gap: 10px; background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: 12px; padding: 12px 14px; }
.codebox .mono { font-size: 15px; color: var(--green); flex: 1; word-break: break-all; }
.qr { background: #fff; border-radius: 12px; padding: 8px; width: 170px; height: 170px; }
.qr img, .qr svg { width: 100%; height: 100%; display: block; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--blue-soft); color: var(--blue); border: 1px solid rgba(106, 168, 255, .25); }
.notice.warn { background: var(--amber-soft); color: var(--amber); border-color: rgba(242, 184, 75, .3); }
.notice.ok { background: var(--green-soft); color: var(--green); border-color: rgba(62, 207, 127, .3); }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 360px; max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); z-index: 40; }
.dropdown .item { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dropdown .item.unread { background: var(--green-soft); }
.rel { position: relative; }
.dot { position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--green); color: var(--green-ink); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.lang-switch { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.lang-switch button { background: none; border: 0; color: var(--text-2); padding: 4px 8px; border-radius: 8px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.lang-switch button.active { background: var(--green); color: var(--green-ink); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--surface-3); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- auth & public form ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(1200px 600px at 10% 10%, rgba(62, 207, 127, .18), transparent 60%), linear-gradient(160deg, #13201a, #0f1214 60%); padding: 56px; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line); }
.auth-hero h1 { font-size: 38px; line-height: 1.15; max-width: 520px; }
.auth-hero p { color: var(--text-2); max-width: 460px; font-size: 15px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.public { max-width: 820px; margin: 0 auto; padding: 32px 20px 60px; }
.public-head { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.public-head .spacer + .lang-switch { margin-left: auto; }
.success { text-align: center; padding: 50px 20px; }
.success .big { font-size: 46px; color: var(--green); }

/* ---------- public site ---------- */
.site-head { display: flex; align-items: center; gap: 12px; padding: 18px 32px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.site-head .brand { padding: 0; }
.site-hero { padding: 72px 32px 56px; background: radial-gradient(900px 480px at 15% 0%, rgba(62, 207, 127, .16), transparent 60%); }
.site-hero-text { max-width: 760px; }
.site-hero h1 { font-size: clamp(30px, 5vw, 48px); line-height: 1.1; }
.site-hero p { color: var(--text-2); font-size: 17px; max-width: 620px; }
.site-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 0 32px; }
.site-step { width: 34px; height: 34px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: flex; align-items: center; justify-content: center; font-weight: 700; margin-bottom: 12px; }
.site-ref { margin: 24px 32px; }
.site-foot { display: flex; gap: 12px; padding: 24px 32px 40px; color: var(--muted); font-size: 13px; }

/* attachments */
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.file-list li a { font-weight: 550; word-break: break-all; }
.file-list li .btn { margin-left: auto; }
.invite-box { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; max-width: 520px; }
.invite-box input { flex: 1 1 220px; }

/* lead stage tracker */
.track { display: flex; gap: 3px; align-items: center; flex-wrap: nowrap; min-width: 112px; }
.track i { flex: 1 1 11px; min-width: 11px; max-width: 46px; height: 6px; border-radius: 3px; background: var(--surface-3); }
.track i.on { background: var(--green); }
.track i.now { background: var(--amber); }
.track-label { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.track.off i.on { background: var(--red); opacity: .5; }
.pw-gate { max-width: 440px; margin: 10vh auto; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 70; transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .burger { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 18px 16px 50px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .site-head, .site-hero { padding-left: 16px; padding-right: 16px; }
  .site-grid { grid-template-columns: 1fr; padding: 0 16px; }
  .site-ref { margin: 20px 16px; }
  .site-foot { padding: 20px 16px 32px; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .funnel-row { grid-template-columns: 90px 1fr; }
  .funnel-meta { grid-column: 2; text-align: left; }
  .filters > * { flex: 1 1 140px; }
  .dropdown { position: fixed; left: 12px; right: 12px; top: 60px; width: auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .val { font-size: 19px; }
  th, td { padding: 9px 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print {
  .sidebar, .topbar, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .kpi { border-color: #ccc; background: #fff; }
}
