:root {
  --bg: #eef1fb;
  --bg2: #ffffff;
  --panel: #f3f5fc;
  --card: #ffffff;
  --border: #e3e7f4;
  --text: #1f2740;
  --muted: #7a839c;
  --primary: #6d5efc;
  --primary-h: #5a49f0;
  --accent: #22c1dc;
  --danger: #f43f5e;
  --shadow: 0 1px 2px rgba(31,39,64,.06), 0 4px 14px rgba(31,39,64,.06);
  --shadow-lg: 0 12px 40px rgba(80,70,180,.18);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: none; border-radius: 11px; transition: transform .06s, background .15s, box-shadow .15s; }
button:active { transform: scale(.97); }
input, select, textarea {
  font: inherit; width: 100%; padding: 11px 13px;
  background: #fbfcff; color: var(--text);
  border: 1.5px solid var(--border); border-radius: 11px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109,94,252,.15);
}
::placeholder { color: #aab2c7; }

/* ---------- Login ---------- */
.login-screen {
  height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 15% 0%, #ffe6f2 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 20%, #dbeafe 0%, transparent 55%),
    radial-gradient(700px 600px at 60% 100%, #d9fbe8 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 350px; display: flex; flex-direction: column; gap: 14px;
  background: rgba(255,255,255,.85); backdrop-filter: blur(12px);
  padding: 34px 26px; border-radius: 24px;
  border: 1px solid #fff; box-shadow: var(--shadow-lg);
}
.brand { font-size: 32px; font-weight: 850; letter-spacing: .3px; text-align: center;
  background: linear-gradient(100deg, #6d5efc, #22c1dc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-sub { text-align: center; color: var(--muted); margin-top: -6px; margin-bottom: 6px; font-size: 13px; font-weight: 500; }
.login-card input { text-align: center; letter-spacing: 8px; font-size: 22px; padding: 14px; }
.login-card button, .btn-primary {
  background: linear-gradient(100deg, #6d5efc, #7c6bff); color: #fff; padding: 13px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(109,94,252,.35);
}
.login-card button:hover, .btn-primary:hover { background: linear-gradient(100deg, #5a49f0, #6d5efc); box-shadow: 0 8px 22px rgba(109,94,252,.45); }
.err { color: var(--danger); font-size: 13px; text-align: center; min-height: 18px; font-weight: 500; }

/* ---------- App shell ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 12px; gap: 10px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(31,39,64,.04); z-index: 5;
}
.topbar-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.logo { font-weight: 850; font-size: 18px; background: linear-gradient(100deg, #6d5efc, #22c1dc);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.pipeline-name { color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.btn-primary { padding: 10px 16px; }
.btn-ghost { background: var(--panel); color: var(--muted); padding: 9px 12px; font-size: 16px; }
.btn-ghost:hover { color: var(--primary); background: #e9ebf8; }
.btn-danger { background: #fff; color: var(--danger); border: 1.5px solid #fbcdd6; padding: 10px 16px; font-weight: 600; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ---------- Board ---------- */
.board {
  flex: 1; display: flex; gap: 14px; padding: 16px;
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(800px 400px at 0% 0%, rgba(109,94,252,.05), transparent 60%),
    radial-gradient(800px 400px at 100% 100%, rgba(34,193,220,.05), transparent 60%);
}
.column {
  flex: 0 0 82%; max-width: 320px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  scroll-snap-align: start; min-height: 0; box-shadow: var(--shadow);
}
@media (min-width: 640px) { .column { flex-basis: 300px; } }
.col-head {
  display: flex; align-items: center; gap: 8px; padding: 13px 15px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
.col-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.col-name { font-weight: 700; font-size: 14px; flex: 1; }
.col-count { color: var(--primary); font-size: 12px; font-weight: 700; background: #e9ebf8; padding: 2px 9px; border-radius: 20px; }
.col-body { flex: 1; overflow-y: auto; padding: 11px; display: flex; flex-direction: column; gap: 9px; min-height: 40px; }
.col-body.drag-over { background: rgba(109,94,252,.08); outline: 2px dashed var(--primary); outline-offset: -6px; border-radius: var(--radius); }
.col-sum { padding: 10px 15px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 13px; display: flex; flex-direction: column; gap: 5px;
  cursor: pointer; box-shadow: var(--shadow);
  transition: transform .1s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(31,39,64,.10); border-color: #d6dbef; }
.card:active { transform: scale(.98); }
.card.dragging { opacity: .5; }
.card-name { font-weight: 700; font-size: 14px; }
.card-company { color: var(--muted); font-size: 12px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 5px 8px; margin-top: 3px; }
.tag { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px;
  background: #f1f3fb; padding: 2px 8px; border-radius: 8px; font-weight: 500; }
.tag.value { color: #059669; background: #dcfce7; font-weight: 700; }
.tag.due { color: #b45309; background: #fef3c7; }
.tag.due.overdue { color: #be123c; background: #ffe4e6; }

/* ---------- Sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(31,39,64,.35); backdrop-filter: blur(2px); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto;
  background: var(--bg2); border-radius: 24px 24px 0 0; border-top: 1px solid var(--border);
  padding: 18px 18px calc(18px + var(--safe-bottom)); animation: slideUp .24s cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow-lg);
}
@media (min-width: 640px) {
  .sheet-panel { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%);
    width: 460px; max-width: 92vw; border-radius: 20px; border: 1px solid var(--border); }
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head h2 { font-size: 19px; font-weight: 800; }
.sheet-body { display: flex; flex-direction: column; gap: 13px; }
.sheet-body label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.sheet-body input, .sheet-body select, .sheet-body textarea { color: var(--text); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.4; font-weight: 500; }
.sheet-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; }
.sheet-actions .btn-primary { padding: 13px 22px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + var(--safe-bottom)); transform: translateX(-50%);
  background: #1f2740; border: 1px solid #2c3554; color: #fff;
  padding: 12px 20px; border-radius: 14px; z-index: 60; box-shadow: 0 12px 32px rgba(31,39,64,.28);
  font-size: 14px; font-weight: 600; animation: pop .22s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
