/* =============================================
   AUTOFLO CLIENT DASHBOARD — V2
   Premium Dark + Gold Theme
   ============================================= */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #060608;
  --sf: #0D0F14;
  --sf2: #131620;
  --sf3: #1A1E2E;
  --gold: #C8A84C;
  --gold2: #E0C068;
  --gold-dim: rgba(200,168,76,0.1);
  --gold-glow: rgba(200,168,76,0.06);
  --gold-brd: rgba(200,168,76,0.12);
  --white: #F0F0F5;
  --t1: #D0D2DA;
  --t2: #8A8EA0;
  --t3: #4A4E62;
  --brd: #1A1E2A;
  --red: #E05555;
  --grn: #50B870;
  --r: 14px;
  --rs: 10px;
  --rx: 6px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--t1);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Subtle background gradient */
body::after {
  content: '';
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(200,168,76,0.03), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(200,168,76,0.02), transparent);
  pointer-events: none; z-index: 0;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brd); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--t3); }

.gold { color: var(--gold); }
.green { color: var(--grn); }

/* ===== GOLD TOP LINE ===== */
.topline {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 999;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 30%, var(--gold2) 50%, var(--gold) 70%, transparent 100%);
  animation: shimmer 4s ease-in-out infinite;
}
@keyframes shimmer { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

/* ===== PASSWORD GATE ===== */
.gate {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.gate.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.gate-glow {
  position: absolute; top: 30%; left: 50%; transform: translate(-50%,-50%);
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, rgba(200,168,76,0.08), transparent 70%);
  filter: blur(60px); pointer-events: none;
}

.gate-box { position: relative; text-align: center; width: 360px; max-width: 90vw; }
.gate-logo {
  font-size: 36px; font-weight: 900; letter-spacing: 4px;
  color: var(--white); margin-bottom: 8px;
}
.gate-logo span { color: var(--gold); }
.gate-sub { font-size: 13px; color: var(--t3); letter-spacing: 2px; text-transform: uppercase; margin-bottom: 40px; }

.gate-box form { display: flex; flex-direction: column; gap: 12px; }
.gate-box input {
  padding: 14px 18px; background: var(--sf); border: 1px solid var(--brd);
  border-radius: var(--rs); color: var(--t1); font-family: inherit; font-size: 14px;
  text-align: center; letter-spacing: 2px; transition: border-color 0.2s;
}
.gate-box input:focus { outline: none; border-color: var(--gold); }
.gate-box input::placeholder { color: var(--t3); letter-spacing: 1px; }

.gate-box button {
  padding: 14px; background: var(--gold); color: var(--bg);
  border: none; border-radius: var(--rs); font-family: inherit;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s;
  letter-spacing: 0.5px;
}
.gate-box button:hover { background: var(--gold2); transform: translateY(-1px); }

.gate-err { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 20px; }
.gate-foot { color: var(--t3); font-size: 11px; margin-top: 48px; letter-spacing: 1px; }

/* ===== HEADER ===== */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px;
  background: rgba(13,15,20,0.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(200,168,76,0.06);
  position: sticky; top: 2px; z-index: 100;
}
.h-left { display: flex; align-items: center; gap: 16px; }
.logo { font-size: 20px; font-weight: 900; letter-spacing: 3px; color: var(--white); }
.h-pipe { width: 1px; height: 20px; background: var(--brd); }
.h-sub { font-size: 12px; color: var(--t3); font-weight: 500; letter-spacing: 1.5px; text-transform: uppercase; }

.h-right { display: flex; align-items: center; gap: 10px; }
.h-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: var(--sf); border: 1px solid var(--brd); border-radius: var(--rs);
  color: var(--t2); cursor: pointer; transition: all 0.2s;
}
.h-btn:hover { background: var(--sf2); color: var(--gold); border-color: var(--gold-brd); }

.btn-gold {
  padding: 10px 20px; background: var(--gold); color: var(--bg);
  border: none; border-radius: var(--rs); font-family: inherit;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s;
  letter-spacing: 0.3px;
}
.btn-gold:hover { background: var(--gold2); transform: translateY(-1px); box-shadow: 0 4px 20px rgba(200,168,76,0.2); }

/* ===== STATS ===== */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--brd);
}
.stat {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px; background: var(--sf);
  border-right: 1px solid var(--brd);
  position: relative; z-index: 1;
}
.stat:last-child { border-right: none; }
.stat-val { font-size: 32px; font-weight: 800; color: var(--white); line-height: 1; }
.stat-lbl {
  font-size: 10px; color: var(--t3); text-transform: uppercase;
  letter-spacing: 1.5px; margin-top: 8px; font-weight: 600;
}

/* ===== TOOLBAR (SEARCH) ===== */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; border-bottom: 1px solid var(--brd);
  background: var(--sf);
}
.search-box {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; background: var(--bg);
  border: 1px solid var(--brd); border-radius: var(--rs);
  width: 300px; max-width: 100%; transition: border-color 0.2s;
}
.search-box:focus-within { border-color: var(--gold-brd); }
.search-icon { color: var(--t3); flex-shrink: 0; }
.search-box input {
  background: none; border: none; color: var(--t1);
  font-family: inherit; font-size: 13px; width: 100%; outline: none;
}
.search-box input::placeholder { color: var(--t3); }
.client-count { font-size: 12px; color: var(--t3); }

/* ===== MAIN / GRID ===== */
.main { padding: 28px 32px; max-width: 1400px; margin: 0 auto; position: relative; z-index: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }

/* Empty state */
.empty {
  display: none; flex-direction: column; align-items: center;
  justify-content: center; min-height: 50vh; text-align: center;
}
.empty h3 { font-size: 18px; color: var(--t2); font-weight: 600; margin-bottom: 8px; }
.empty p { font-size: 13px; color: var(--t3); }
.empty-visual { position: relative; width: 120px; height: 120px; margin-bottom: 24px; }
.empty-ring {
  position: absolute; border-radius: 50%;
  border: 1px solid var(--brd); opacity: 0.5;
}
.r1 { inset: 0; animation: emptyPulse 3s ease-in-out infinite; }
.r2 { inset: 15px; animation: emptyPulse 3s ease-in-out infinite 0.5s; }
.r3 { inset: 30px; animation: emptyPulse 3s ease-in-out infinite 1s; border-color: var(--gold-brd); }
.empty-plus {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 28px; color: var(--gold); font-weight: 300;
}
@keyframes emptyPulse { 0%,100% { opacity: 0.3; } 50% { opacity: 0.7; } }

/* ===== CLIENT CARD ===== */
.card {
  background: var(--sf); border: 1px solid var(--brd); border-radius: var(--r);
  padding: 22px; cursor: pointer; transition: all 0.3s ease;
  position: relative; overflow: hidden;
  opacity: 0; transform: translateY(16px);
  animation: cardIn 0.5s ease forwards;
}
.card:nth-child(1) { animation-delay: 0.03s; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.09s; }
.card:nth-child(4) { animation-delay: 0.12s; }
.card:nth-child(5) { animation-delay: 0.15s; }
.card:nth-child(6) { animation-delay: 0.18s; }

@keyframes cardIn { to { opacity: 1; transform: translateY(0); } }

.card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0; transition: opacity 0.3s;
}
.card:hover {
  border-color: var(--gold-brd); background: var(--sf2);
  transform: translateY(-3px);
  box-shadow: 0 0 40px var(--gold-glow), 0 12px 40px rgba(0,0,0,0.4);
}
.card:hover::after { opacity: 1; }

.card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.card-avatar {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(200,168,76,0.12), rgba(200,168,76,0.04));
  border: 1px solid var(--gold-brd);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--gold); flex-shrink: 0;
  letter-spacing: 1px;
}
.card-info { flex: 1; min-width: 0; }
.card-biz { font-size: 15px; font-weight: 700; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-name { font-size: 12px; color: var(--t2); }

.card-ring { position: relative; width: 44px; height: 44px; flex-shrink: 0; }
.card-ring svg { width: 100%; height: 100%; }
.c-bg { fill: none; stroke: var(--brd); stroke-width: 3; }
.c-fill { fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round; transition: stroke-dasharray 0.6s ease; }
.c-txt { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 10px; font-weight: 800; color: var(--white); }

.card-mid { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  background: var(--gold-dim); color: var(--gold); border: 1px solid var(--gold-brd);
}
.badge.done { background: rgba(80,184,112,0.08); color: var(--grn); border-color: rgba(80,184,112,0.15); }

/* Stage dots */
.stage-dots { display: flex; gap: 4px; }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--brd); transition: background 0.3s; }
.sdot.filled { background: var(--gold); }
.sdot.partial { background: var(--sf3); border: 1.5px solid var(--gold); }

.card-bar { height: 3px; background: var(--brd); border-radius: 2px; margin-bottom: 14px; overflow: hidden; }
.card-bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold2)); border-radius: 2px; transition: width 0.6s ease; }

.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-next { font-size: 11px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.card-date { font-size: 10px; color: var(--t3); white-space: nowrap; font-weight: 500; }

/* ===== OVERLAY ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 200; opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.overlay.open { opacity: 1; visibility: visible; }

/* ===== DETAIL PANEL ===== */
.panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 720px; max-width: 100%;
  background: var(--bg); border-left: 1px solid var(--brd);
  overflow-y: auto; transform: translateX(100%); transition: transform 0.35s ease;
}
.overlay.open .panel { transform: translateX(0); }

.panel-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--brd);
  position: sticky; top: 0; background: rgba(6,6,8,0.95);
  backdrop-filter: blur(12px); z-index: 10;
}
.p-back {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; background: var(--sf); border: 1px solid var(--brd);
  border-radius: var(--rs); color: var(--t1); font-family: inherit;
  font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.p-back:hover { background: var(--sf2); border-color: var(--t3); }
.p-back svg { flex-shrink: 0; }

.p-del {
  padding: 8px 14px; background: transparent;
  border: 1px solid rgba(224,85,85,0.2); border-radius: var(--rs);
  color: var(--red); font-family: inherit; font-size: 12px;
  cursor: pointer; transition: all 0.2s;
}
.p-del:hover { background: rgba(224,85,85,0.08); border-color: var(--red); }

.panel-body { padding: 28px 24px; }

/* Detail header */
.d-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.d-avatar {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(200,168,76,0.15), rgba(200,168,76,0.05));
  border: 1px solid var(--gold-brd);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: var(--gold);
  letter-spacing: 1px; flex-shrink: 0; margin-right: 16px;
}
.d-info { flex: 1; }
.d-biz { font-size: 22px; font-weight: 800; color: var(--white); margin-bottom: 2px; }
.d-name { font-size: 14px; color: var(--t2); }

.d-ring { position: relative; width: 72px; height: 72px; flex-shrink: 0; }
.d-ring svg { width: 100%; height: 100%; }
.r-bg { fill: none; stroke: var(--brd); stroke-width: 4; }
.r-fill { fill: none; stroke: url(#goldGrad); stroke-width: 4; stroke-linecap: round; transition: stroke-dasharray 0.6s ease; }
.r-txt { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 16px; font-weight: 800; color: var(--white); }

.d-contacts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.d-chip {
  font-size: 12px; color: var(--t2); background: var(--sf);
  padding: 6px 12px; border-radius: var(--rx); border: 1px solid var(--brd);
}

/* Timeline */
.timeline { margin-bottom: 28px; overflow-x: auto; padding: 0 4px; }
.tl-track {
  display: flex; align-items: flex-start; justify-content: space-between;
  position: relative; min-width: 520px; padding: 8px 0 36px;
}
.tl-bar { position: absolute; top: 18px; left: 18px; right: 18px; height: 2px; background: var(--brd); border-radius: 1px; }
.tl-fill { position: absolute; top: 0; left: 0; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold2)); border-radius: 1px; transition: width 0.6s ease; }

.dot { display: flex; flex-direction: column; align-items: center; z-index: 2; position: relative; width: 36px; }
.dot-c {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; background: var(--sf); border: 2px solid var(--brd);
  transition: all 0.3s ease; margin-bottom: 8px;
}
.dot.done .dot-c { background: var(--gold); border-color: var(--gold); color: var(--bg); font-size: 11px; font-weight: 800; }
.dot.active .dot-c { border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-dim); animation: dotPulse 2.5s infinite; }
.dot-l { font-size: 9px; color: var(--t3); text-align: center; font-weight: 600; letter-spacing: 0.3px; }
.dot.done .dot-l, .dot.active .dot-l { color: var(--t2); }
@keyframes dotPulse { 0%,100% { box-shadow: 0 0 0 4px rgba(200,168,76,0.12); } 50% { box-shadow: 0 0 0 8px rgba(200,168,76,0.04); } }

/* Stage sections */
.stages { margin-bottom: 28px; }
.stg { border: 1px solid var(--brd); border-radius: var(--rs); margin-bottom: 6px; overflow: hidden; transition: border-color 0.2s; }
.stg.cur { border-color: var(--gold-brd); }

.stg-hd {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px; cursor: pointer; background: var(--sf);
  transition: background 0.2s; user-select: none;
}
.stg-hd:hover { background: var(--sf2); }
.stg-hd-l { display: flex; align-items: center; gap: 10px; }
.stg-ico { font-size: 15px; }
.stg-nm { font-size: 13px; font-weight: 600; color: var(--white); }
.stg-cnt {
  font-size: 11px; color: var(--t3); font-weight: 600;
  background: var(--sf3); padding: 2px 8px; border-radius: 10px;
}
.stg-cnt.dn { background: rgba(80,184,112,0.1); color: var(--grn); }
.stg-arr { font-size: 12px; color: var(--t3); transition: transform 0.2s; }
.stg-arr.open { transform: rotate(180deg); }

.stg-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.stg-body.open { max-height: 500px; }

/* Tasks */
.task {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer; transition: background 0.15s;
  border-top: 1px solid var(--brd);
}
.task:hover { background: rgba(200,168,76,0.02); }
.task input { display: none; }
.tbox {
  width: 18px; height: 18px; border: 2px solid var(--brd);
  border-radius: 4px; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center;
  transition: all 0.15s; position: relative;
}
.tbox::after {
  content: ''; width: 9px; height: 5px;
  border-left: 2px solid var(--bg); border-bottom: 2px solid var(--bg);
  transform: rotate(-45deg) scale(0); transition: transform 0.12s;
  position: absolute; top: 3px;
}
.task.ck .tbox { background: var(--gold); border-color: var(--gold); }
.task.ck .tbox::after { transform: rotate(-45deg) scale(1); }
.ttxt { font-size: 13px; color: var(--t1); transition: all 0.15s; }
.task.ck .ttxt { color: var(--t3); text-decoration: line-through; }

/* Detail fields */
.d-fields { display: flex; flex-direction: column; gap: 16px; }
.d-fields label {
  display: block; font-size: 10px; font-weight: 700;
  color: var(--t3); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 8px;
}
.d-input, .d-ta {
  width: 100%; padding: 12px 14px;
  background: var(--sf); border: 1px solid var(--brd); border-radius: var(--rs);
  color: var(--t1); font-family: inherit; font-size: 13px;
  transition: border-color 0.2s; resize: vertical;
}
.d-input:focus, .d-ta:focus { outline: none; border-color: var(--gold); }
.d-input::placeholder, .d-ta::placeholder { color: var(--t3); }

/* ===== MODAL ===== */
.modal {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%) scale(0.96);
  width: 480px; max-width: 92vw; max-height: 90vh; overflow-y: auto;
  background: var(--sf); border: 1px solid var(--brd); border-radius: var(--r);
  padding: 32px; transition: transform 0.25s ease;
}
.overlay.open .modal { transform: translate(-50%,-50%) scale(1); }

.m-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.m-top h2 { font-size: 18px; font-weight: 700; color: var(--white); }
.m-x {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--brd); border-radius: 50%;
  color: var(--t2); font-size: 18px; cursor: pointer; transition: all 0.2s;
}
.m-x:hover { background: var(--sf2); color: var(--white); }

.fg { margin-bottom: 14px; }
.fg label { display: block; font-size: 11px; font-weight: 600; color: var(--t2); margin-bottom: 6px; letter-spacing: 0.5px; }
.fg input, .fg textarea {
  width: 100%; padding: 11px 14px;
  background: var(--bg); border: 1px solid var(--brd); border-radius: var(--rx);
  color: var(--t1); font-family: inherit; font-size: 13px; transition: border-color 0.2s;
}
.fg input:focus, .fg textarea:focus { outline: none; border-color: var(--gold); }
.fg input::placeholder, .fg textarea::placeholder { color: var(--t3); }
.fg textarea { resize: vertical; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn-submit {
  width: 100%; padding: 13px; background: var(--gold); color: var(--bg);
  border: none; border-radius: var(--rs); font-family: inherit;
  font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.2s;
  margin-top: 8px; letter-spacing: 0.3px;
}
.btn-submit:hover { background: var(--gold2); box-shadow: 0 4px 20px rgba(200,168,76,0.2); }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--sf); color: var(--gold);
  border: 1px solid var(--gold-brd);
  padding: 12px 28px; border-radius: var(--rs);
  font-size: 13px; font-weight: 600; letter-spacing: 0.3px;
  opacity: 0; transition: all 0.35s ease; z-index: 300;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header { padding: 12px 16px; }
  .h-pipe, .h-sub { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-val { font-size: 24px; }
  .toolbar { padding: 12px 16px; }
  .search-box { width: 100%; }
  .client-count { display: none; }
  .main { padding: 16px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 18px; }
  .panel { width: 100%; border-left: none; }
  .panel-body { padding: 20px 16px; }
  .d-biz { font-size: 18px; }
  .tl-track { min-width: 440px; }
  .row2 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .d-head { flex-direction: column; gap: 16px; }
  .d-ring { align-self: flex-end; }
  .h-right .h-btn { display: none; }
}
