/* ══════════════════════════════════════════ Tyto × Foodland Board ═══ */
:root {
  --bg:          #f1f5f9;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --primary:     #6366f1;
  --primary-h:   #4f46e5;
  --danger:      #ef4444;
  --radius:      8px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.12);
  --col-width:   300px;
  --header-h:    56px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ─── HEADER ─────────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.header-left  { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.header-center { flex: 1; max-width: 360px; }
.header-right  { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto; }

.brand        { display: flex; align-items: center; gap: 6px; }
.brand-mark   { width: 28px; height: 28px; background: var(--primary); color: #fff; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.brand-text   { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand-x      { color: var(--primary); }
.board-name   { font-size: 13px; color: var(--text-muted); padding-left: 10px; border-left: 1px solid var(--border); white-space: nowrap; }

.search-wrap  { position: relative; }
.search-wrap input {
  width: 100%;
  padding: 6px 10px 6px 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  outline: none;
  transition: border-color .15s;
}
.search-wrap input:focus { border-color: var(--primary); background: #fff; }
.search-icon { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }

.filter-group  { display: flex; gap: 2px; background: var(--bg); border-radius: 6px; padding: 2px; border: 1px solid var(--border); }
.filter-btn    { padding: 4px 10px; border: none; background: none; border-radius: 5px; font-size: 12px; cursor: pointer; color: var(--text-muted); transition: all .15s; }
.filter-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.filter-btn:hover:not(.active) { color: var(--text); }

.priority-filter {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; background: var(--bg); cursor: pointer; color: var(--text); outline: none;
}

.icon-btn {
  width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all .15s;
}
.icon-btn:hover { background: var(--surface); color: var(--text); border-color: var(--primary); }
.icon-btn svg { width: 16px; height: 16px; }

.sync-status { font-size: 10px; color: #22c55e; line-height: 1; }
.sync-status.syncing { color: #f97316; animation: pulse 1s infinite; }
.sync-status.error   { color: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ─── BOARD ──────────────────────────────────────────────────────── */
.board-wrap {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.board {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 100%;
}

.board-loading { color: var(--text-muted); padding: 40px; font-size: 14px; }

/* ─── COLUMN ─────────────────────────────────────────────────────── */
.column {
  width: var(--col-width);
  flex-shrink: 0;
  background: var(--surface);
  border-radius: var(--radius);
  border-top: 3px solid var(--col-color, var(--primary));
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - var(--header-h) - 32px);
}

.column.drag-over .task-list { background: #f0f4ff; border-radius: 0 0 6px 6px; }

.column-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 10px;
  cursor: pointer;
  user-select: none;
}
.column-dot  { width: 8px; height: 8px; border-radius: 50%; background: var(--col-color, var(--primary)); flex-shrink: 0; }
.column-title { font-size: 13px; font-weight: 700; flex: 1; }
.column-count { font-size: 11px; background: var(--bg); color: var(--text-muted); border-radius: 10px; padding: 1px 7px; font-weight: 600; }
.column-menu  { width: 24px; height: 24px; border: none; background: none; cursor: pointer; color: var(--text-muted); border-radius: 4px; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s; }
.column-header:hover .column-menu { opacity: 1; }
.column-menu:hover { background: var(--bg); color: var(--text); }

.task-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
  min-height: 48px;
  transition: background .15s;
}

.task-list::-webkit-scrollbar { width: 4px; }
.task-list::-webkit-scrollbar-track { background: transparent; }
.task-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.add-task-btn {
  margin: 2px 8px 10px;
  padding: 6px 10px;
  width: calc(100% - 16px);
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all .15s;
}
.add-task-btn:hover { border-color: var(--primary); color: var(--primary); background: #f5f3ff; }
.add-task-btn svg { width: 14px; height: 14px; }

/* ─── ADD COLUMN ─────────────────────────────────────────────────── */
.add-column-btn {
  flex-shrink: 0;
  width: 200px;
  height: 44px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.6);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all .15s;
  align-self: flex-start;
  margin-top: 0;
}
.add-column-btn:hover { border-color: var(--primary); color: var(--primary); background: #fff; }
.add-column-btn svg { width: 16px; height: 16px; }

/* ─── TASK CARD ──────────────────────────────────────────────────── */
.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 10px 8px;
  margin-bottom: 6px;
  cursor: grab;
  transition: box-shadow .15s, transform .1s;
  user-select: none;
  position: relative;
}
.task-card:hover { box-shadow: var(--shadow-md); border-color: #c7d2fe; }
.task-card:active { cursor: grabbing; }
.task-card.dragging { opacity: .4; box-shadow: none; }
.task-card.drag-placeholder { border: 2px dashed var(--primary); background: #f5f3ff; opacity: .6; min-height: 60px; }
.task-card.filtered-out { display: none; }

.task-priority-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 6px 0 0 6px;
}
.priority-urgent .task-priority-bar { background: #ef4444; }
.priority-high   .task-priority-bar { background: #f97316; }
.priority-medium .task-priority-bar { background: #3b82f6; }
.priority-low    .task-priority-bar { background: #22c55e; }

.task-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 6px;
  padding-left: 8px;
  word-break: break-word;
}

.task-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
  padding-left: 8px;
}
.task-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.task-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 8px;
  flex-wrap: wrap;
}

.task-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.org-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}
.org-Tyto      { background: #ede9fe; color: #5b21b6; }
.org-Foodland  { background: #dcfce7; color: #166534; }
.org-Both      { background: #fef9c3; color: #713f12; }

.task-due {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.task-due svg { width: 11px; height: 11px; }
.task-due.overdue { color: var(--danger); font-weight: 600; }

.priority-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}
.priority-urgent.badge { background: #fee2e2; color: #991b1b; }
.priority-high.badge   { background: #ffedd5; color: #9a3412; }
.priority-medium.badge { background: #dbeafe; color: #1e40af; }
.priority-low.badge    { background: #dcfce7; color: #166534; }

/* ─── MODALS ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
}
.task-modal   { max-width: 540px; }
.column-modal { max-width: 360px; }

.modal-header {
  display: flex; align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 15px; font-weight: 700; flex: 1; }
.modal-close { width: 28px; height: 28px; border: none; background: none; cursor: pointer; color: var(--text-muted); font-size: 16px; border-radius: 4px; transition: all .15s; }
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }

.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.hint { font-weight: 400; text-transform: none; letter-spacing: 0; }

input[type=text],
input[type=date],
input[type=search],
select,
textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
textarea { resize: vertical; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.color-swatch:hover   { transform: scale(1.15); }
.color-swatch.active  { border-color: var(--text); transform: scale(1.15); }

.modal-footer {
  display: flex;
  align-items: center;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}
.modal-footer-right { display: flex; gap: 8px; margin-left: auto; }

/* ─── BUTTONS ────────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-h); }
.btn-ghost { background: none; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: none; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }

/* ─── ACTIVITY DRAWER ────────────────────────────────────────────── */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.2);
  z-index: 90;
}
.drawer-overlay[hidden] { display: none; }

.activity-drawer {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 320px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 95;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,.12);
}
.activity-drawer[hidden] { display: none; }

.drawer-header {
  display: flex; align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.drawer-header h3 { font-size: 14px; font-weight: 700; flex: 1; }

.activity-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.activity-item {
  background: var(--bg);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
}
.activity-detail { color: var(--text); font-weight: 500; margin-bottom: 2px; }
.activity-meta   { color: var(--text-muted); font-size: 11px; }

/* ─── TOAST ──────────────────────────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: #1e293b;
  color: #f8fafc;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn .2s ease;
  pointer-events: none;
  max-width: 360px;
  text-align: center;
}
.toast.error { background: var(--danger); }
@keyframes toastIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ─── RESPONSIVE ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .board-name { display: none; }
  .header-center { display: none; }
  .filter-group { display: none; }
  :root { --col-width: 260px; }
}
