/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: 'Sora', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', monospace;
  --bg: #0d0f14;
  --bg2: #13161e;
  --bg3: #1a1e28;
  --bg4: #20253200;
  --surface: #1e2230;
  --surface2: #252a3a;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --border3: rgba(255,255,255,0.18);
  --text: #e8eaf0;
  --text2: #8b90a0;
  --text3: #5a5f72;
  --blue: #378ADD;
  --blue-dim: rgba(55,138,221,0.15);
  --green: #3db87a;
  --green-dim: rgba(61,184,122,0.15);
  --amber: #f0a030;
  --amber-dim: rgba(240,160,48,0.15);
  --red: #e04a4a;
  --red-dim: rgba(224,74,74,0.15);
  --pink: #c06090;
  --pink-dim: rgba(192,96,144,0.15);
  --teal: #30c0b0;
  --teal-dim: rgba(48,192,176,0.15);
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --header-h: 56px;
}

html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; overflow: hidden; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ===== LOGIN ===== */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 1000;
}
.login-bg {
  position: absolute; inset: 0; overflow: hidden;
}
.login-grid {
  position: absolute; inset: -50%;
  background-image:
    linear-gradient(rgba(55,138,221,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(55,138,221,0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: grid-drift 20s linear infinite;
}
@keyframes grid-drift { from { transform: translate(0,0); } to { transform: translate(40px,40px); } }

.login-card {
  position: relative; width: 420px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-xl); padding: 36px 32px;
  box-shadow: 0 40px 80px rgba(0,0,0,0.6);
  animation: card-in 0.5s cubic-bezier(0.22,1,0.36,1);
}
@keyframes card-in { from { opacity:0; transform: translateY(24px) scale(0.97); } to { opacity:1; transform: translateY(0) scale(1); } }

.login-logo {
  width: 52px; height: 52px; background: var(--blue); border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff; margin: 0 auto 20px;
}
.login-title { font-size: 22px; font-weight: 600; text-align: center; color: var(--text); margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--text2); text-align: center; margin-bottom: 28px; }

.login-error {
  display: flex; align-items: center; gap: 8px;
  background: var(--red-dim); border: 1px solid rgba(224,74,74,0.3);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px;
  font-size: 13px; color: #f07070;
}

.field { margin-bottom: 18px; }
.field > label { display: block; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); margin-bottom: 10px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius); color: var(--text); font-family: var(--font); font-size: 13px;
  padding: 10px 14px; outline: none; transition: border-color 0.2s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); }
.field select { cursor: pointer; }
.field select option { background: var(--surface2); }

.role-cards { display: flex; flex-direction: column; gap: 8px; }
.role-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer; transition: all 0.2s;
}
.role-card:hover { border-color: var(--border2); background: var(--bg3); }
.role-card.selected { border-color: var(--blue); background: var(--blue-dim); }
.role-icon {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.role-name { font-size: 13px; font-weight: 500; color: var(--text); }
.role-desc { font-size: 11px; color: var(--text2); margin-top: 1px; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 42px; }
.toggle-pass {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; transition: color 0.2s;
}
.toggle-pass:hover { color: var(--text2); }

.btn-login {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue); border: none; border-radius: var(--radius);
  color: #fff; font-family: var(--font); font-size: 14px; font-weight: 600;
  padding: 12px; cursor: pointer; transition: all 0.2s; margin-top: 4px;
}
.btn-login:hover { background: #2a6db0; transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }
.btn-login.loading { opacity: 0.7; pointer-events: none; }

.login-hint { font-size: 11px; color: var(--text3); text-align: center; margin-top: 14px; }

/* ===== APP LAYOUT ===== */
.app { display: flex; flex-direction: column; height: 100vh; }

/* ===== HEADER ===== */
.header {
  height: var(--header-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--bg2);
  flex-shrink: 0; gap: 16px;
}
.header-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo {
  width: 32px; height: 32px; background: var(--blue); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 16px; color: #fff;
}
.header-title { font-size: 14px; font-weight: 600; }
.header-sub { font-size: 11px; color: var(--text2); }

.header-center { flex: 1; display: flex; justify-content: center; }
.filter-pills { display: flex; gap: 4px; background: var(--bg3); border-radius: 20px; padding: 3px; }
.pill {
  font-size: 12px; padding: 4px 14px; border-radius: 16px; border: none; background: transparent;
  color: var(--text2); cursor: pointer; font-family: var(--font); transition: all 0.2s;
}
.pill:hover { color: var(--text); }
.pill.active { background: var(--surface2); color: var(--text); }

.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.online-badges { display: flex; gap: -4px; }
.online-badge {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--bg2);
  display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600;
  margin-left: -6px; transition: transform 0.2s;
}
.online-badge:first-child { margin-left: 0; }
.online-badge:hover { transform: translateY(-2px); z-index: 1; }
.user-badge {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 20px; padding: 4px 10px 4px 4px; font-size: 12px;
}
.user-badge-dot { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 600; }

.btn-icon {
  width: 32px; height: 32px; border-radius: var(--radius); border: 1px solid var(--border);
  background: transparent; color: var(--text2); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.btn-icon:hover { background: var(--surface); color: var(--text); border-color: var(--border2); }

/* ===== CANVAS ===== */
.canvas-wrap { flex: 1; overflow: hidden; }
.columns { display: grid; grid-template-columns: 1fr 1fr 1fr; height: 100%; }

/* ===== COLUMN ===== */
.col { display: flex; flex-direction: column; border-right: 1px solid var(--border); overflow: hidden; }
.col:last-child { border-right: none; }
.col.locked .col-body { opacity: 0.5; pointer-events: none; }
.col.locked .col-input { opacity: 0.5; pointer-events: none; }

.col-header { padding: 14px 16px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.col-role { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.av-ads { background: rgba(55,138,221,0.2); color: #6aadee; }
.av-auto { background: rgba(61,184,122,0.2); color: #5dd89a; }
.av-mgr { background: rgba(240,160,48,0.2); color: #f0c060; }
.col-identity { flex: 1; min-width: 0; }
.col-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-tag { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 1px; }
.col-status { flex-shrink: 0; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-blue { background: var(--blue); box-shadow: 0 0 6px var(--blue); }
.dot-green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-amber { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.dot-off { background: var(--text3); box-shadow: none; }

.col-desc { font-size: 11px; color: var(--text2); line-height: 1.5; margin-bottom: 8px; }
.col-stats { display: flex; gap: 10px; }
.stat { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text2); }
.stat i { font-size: 12px; }
.stat.stat-warn { color: var(--amber); }
.stat.stat-err { color: var(--red); }

.col-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }

/* ===== CARDS ===== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 12px 14px; transition: border-color 0.2s, transform 0.15s;
}
.card:hover { border-color: var(--border2); }

.card-source { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.source-tag {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 500; padding: 3px 8px; border-radius: 20px;
}
.tag-fb { background: rgba(55,138,221,0.15); color: #6aadee; }
.tag-ig { background: var(--pink-dim); color: #d080a8; }
.tag-gg { background: var(--green-dim); color: #5dd89a; }
.tag-gmn { background: var(--amber-dim); color: #f0c060; }
.tag-other { background: rgba(255,255,255,0.06); color: var(--text2); }

.card-status { display: flex; align-items: center; gap: 4px; font-size: 10px; }
.status-done { color: var(--green); }
.status-pending { color: var(--amber); }
.status-error { color: var(--red); }

.card-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 8px; line-height: 1.4; }

.card-utm {
  font-family: var(--mono); font-size: 10px; line-height: 1.6;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; color: var(--text2); word-break: break-all; margin-bottom: 10px;
  user-select: all;
}

.card-footer { display: flex; align-items: center; gap: 8px; }
.btn-sm {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; padding: 5px 10px; border-radius: 6px;
  border: 1px solid var(--border2); background: transparent; color: var(--text2);
  cursor: pointer; font-family: var(--font); transition: all 0.2s;
}
.btn-sm:hover { background: var(--surface2); color: var(--text); border-color: var(--border3); }
.btn-sm.btn-success { border-color: rgba(61,184,122,0.3); color: var(--green); }
.btn-sm.btn-success:hover { background: var(--green-dim); }
.btn-sm.btn-copied { border-color: rgba(61,184,122,0.3); color: var(--green); background: var(--green-dim); }

.card-time { display: flex; align-items: center; gap: 4px; margin-left: auto; font-size: 10px; color: var(--text3); }
.card-time i { font-size: 11px; }

/* AUTOMATION CARD */
.auto-card .auto-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.auto-label { font-size: 12px; font-weight: 500; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: flex; align-items: center; gap: 4px; font-size: 10px; padding: 3px 8px; border-radius: 20px; flex-shrink: 0; }
.badge-ok { background: var(--green-dim); color: var(--green); border: 1px solid rgba(61,184,122,0.2); }
.badge-pend { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(240,160,48,0.2); }
.badge-err { background: var(--red-dim); color: var(--red); border: 1px solid rgba(224,74,74,0.2); }

.auto-steps { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.step-row { display: flex; align-items: center; gap: 8px; }
.step-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.step-text { font-size: 11px; color: var(--text2); }
.step-done .step-dot { background: var(--green); }
.step-pend .step-dot { background: var(--amber); }
.step-wait .step-dot { background: var(--border3); }

/* NOTE CARD */
.note-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 2px solid var(--amber); border-radius: var(--radius-lg); padding: 12px 14px;
}
.note-card[data-type="question"] { border-left-color: var(--blue); }
.note-card[data-type="decision"] { border-left-color: var(--green); }
.note-card[data-type="blocker"] { border-left-color: var(--red); }
.note-card[data-type="info"] { border-left-color: var(--teal); }

.note-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.note-type-badge { display: flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 500; }
.type-question { color: var(--blue); }
.type-decision { color: var(--green); }
.type-blocker { color: var(--red); }
.type-info { color: var(--teal); }
.type-observation { color: var(--text2); }

.note-time { font-size: 10px; color: var(--text3); }
.note-author { font-size: 11px; font-weight: 500; color: var(--text2); margin-bottom: 5px; }
.note-text { font-size: 12px; color: var(--text); line-height: 1.6; margin-bottom: 6px; }
.note-text code {
  font-family: var(--mono); font-size: 10px;
  background: var(--bg3); border-radius: 4px; padding: 1px 5px; color: var(--blue);
}
.note-ref { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--text3); }
.note-ref i { font-size: 11px; }

/* ADD CARD */
.add-card {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px dashed var(--border2); border-radius: var(--radius-lg);
  padding: 12px; background: transparent; color: var(--text3); font-family: var(--font);
  font-size: 12px; cursor: pointer; transition: all 0.2s; width: 100%;
}
.add-card:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-dim); }

/* ===== COLUMN INPUT ===== */
.col-input { padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.input-box {
  flex: 1; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font); font-size: 12px; padding: 8px 12px;
  resize: none; outline: none; line-height: 1.5; transition: border-color 0.2s;
}
.input-box:focus { border-color: var(--blue); }
.input-box::placeholder { color: var(--text3); }
.send-btn {
  width: 34px; height: 34px; border-radius: var(--radius); background: var(--blue);
  border: none; color: #fff; cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 15px; flex-shrink: 0; transition: all 0.2s;
}
.send-btn:hover { background: #2a6db0; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  z-index: 500; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-xl);
  width: 460px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  animation: modal-in 0.25s cubic-bezier(0.22,1,0.36,1);
}
@keyframes modal-in { from { opacity:0; transform: scale(0.95) translateY(10px); } to { opacity:1; transform: scale(1) translateY(0); } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.modal-title-row { display: flex; align-items: center; gap: 10px; }
.modal-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-body .field { margin-bottom: 0; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px 18px; border-top: 1px solid var(--border); }
.btn-cancel { font-size: 13px; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--border2); background: transparent; color: var(--text2); cursor: pointer; font-family: var(--font); transition: all 0.2s; }
.btn-cancel:hover { background: var(--surface2); color: var(--text); }
.btn-save { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; padding: 8px 18px; border-radius: var(--radius); background: var(--blue); border: none; color: #fff; cursor: pointer; font-family: var(--font); transition: all 0.2s; }
.btn-save:hover { background: #2a6db0; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 20px;
  padding: 10px 18px; font-size: 12px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
  transition: transform 0.3s cubic-bezier(0.22,1,0.36,1), opacity 0.3s;
  opacity: 0; pointer-events: none; z-index: 9999; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ===== ONLINE WRAP ===== */
.online-wrap { display: flex; align-items: center; gap: 6px; }
.online-avatar {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--bg2);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; margin-left: -8px; transition: transform 0.2s;
  position: relative; cursor: default;
}
.online-avatar:first-child { margin-left: 0; }
.online-avatar:hover { transform: translateY(-3px); z-index: 10; }
.online-avatar .tooltip {
  position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 6px; padding: 4px 8px; font-size: 10px; white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity 0.2s;
}
.online-avatar:hover .tooltip { opacity: 1; }

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
  min-height: 16px; font-size: 11px; color: var(--text3);
  padding: 0 2px 4px; display: flex; align-items: center; gap: 6px;
}
.typing-dots { display: flex; gap: 3px; align-items: center; }
.typing-dots span {
  width: 4px; height: 4px; border-radius: 50%; background: var(--text3);
  animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity:0.2; } 40% { opacity:1; } }

/* ===== CARD ACTIONS ===== */
.card-actions {
  display: none; position: absolute; top: 8px; right: 8px;
  gap: 4px; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 8px; padding: 3px;
}
.card-wrap { position: relative; }
.card-wrap:hover .card-actions { display: flex; }
.card-action-btn {
  width: 24px; height: 24px; border-radius: 5px; border: none;
  background: transparent; color: var(--text2); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  transition: all 0.15s;
}
.card-action-btn:hover { background: var(--surface); color: var(--text); }
.card-action-btn.del:hover { color: var(--red); }

/* ===== STATUS TOGGLE ===== */
.status-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer; border-radius: 12px; padding: 2px 8px;
  font-size: 10px; border: 1px solid transparent; transition: all 0.2s;
}
.status-toggle:hover { border-color: var(--border2); background: var(--surface2); }

/* ===== COMMENT CARD ===== */
.comment-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
}
.comment-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.comment-author { font-size: 11px; font-weight: 500; }
.comment-time { font-size: 10px; color: var(--text3); }
.comment-text { font-size: 12px; color: var(--text2); line-height: 1.5; }

/* ===== STEP EDIT ===== */
.steps-edit { display: flex; flex-direction: column; gap: 4px; }
.step-edit-row { display: flex; align-items: center; gap: 6px; }
.step-edit-row input { flex: 1; }
.step-del-btn {
  width: 24px; height: 24px; border-radius: 5px; border: 1px solid var(--border2);
  background: transparent; color: var(--text3); cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.step-del-btn:hover { color: var(--red); border-color: var(--red); }
.add-step-btn {
  display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text3);
  background: none; border: 1px dashed var(--border2); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; font-family: var(--font); transition: all 0.2s; width: 100%;
}
.add-step-btn:hover { color: var(--blue); border-color: var(--blue); }

/* ===== NEW CARD ANIMATION ===== */
@keyframes card-appear {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.card-wrap { animation: card-appear 0.25s ease; }

/* ===== HIDDEN ===== */
.hidden { display: none !important; }

/* ===== WS RECONNECT ===== */
.ws-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  background: var(--amber); color: #000; font-size: 12px; font-weight: 500;
  text-align: center; padding: 6px; display: none;
}
.ws-banner.show { display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .header-center { display: none; }
  .canvas-wrap { overflow-x: auto; }
  .columns { grid-template-columns: repeat(3, 320px); }
}
@media (max-width: 600px) {
  .header-right .user-badge span { display: none; }
  .columns { grid-template-columns: repeat(3, 290px); }
}
