* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --blue: #0079bf;
  --blue-dark: #005a8e;
  --bg: #f4f5f7;
  --text: #172b4d;
  --muted: #5e6c84;
  --list-bg: #ebecf0;
  --danger: #eb5a46;
  --green: #61bd4f;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(9,30,66,.25);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ---------- LOGIN ---------- */
#view-login {
  display: flex; align-items: center; justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #0079bf 0%, #5067c5 60%, #8a5cc5 100%);
}
.login-box {
  background: #fff; padding: 40px 36px; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.28); width: 360px; max-width: 92vw;
}
.login-logo { display: flex; align-items: center; gap: 12px; justify-content: center; }
.login-logo svg { border-radius: 10px; box-shadow: var(--shadow); background: var(--blue); }
.login-logo h1 { font-size: 30px; color: var(--blue); letter-spacing: -1px; }
.login-sub { text-align: center; color: var(--muted); margin: 8px 0 24px; font-size: 14px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-form input {
  padding: 12px 14px; border: 2px solid #dfe1e6; border-radius: 8px; font-size: 15px;
}
#login-form input:focus { outline: none; border-color: var(--blue); }
.btn-primary {
  background: var(--blue); color: #fff; border: none; padding: 12px;
  border-radius: 8px; font-size: 15px; font-weight: 600;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary {
  background: #ebecf0; color: var(--text); border: none; padding: 10px 14px;
  border-radius: 8px; font-size: 14px;
}
.btn-secondary:hover { background: #dfe1e6; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; min-height: 18px; }
.pass-wrap { position: relative; display: flex; }
.pass-wrap input { width: 100%; padding-right: 44px !important; }
.eye-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; font-size: 18px; padding: 6px 8px;
  border-radius: 6px; opacity: .55; line-height: 1;
}
.eye-btn:hover { opacity: 1; background: #eef0f3; }
.eye-btn.showing { opacity: 1; }

/* ---------- TOPBAR ---------- */
#topbar {
  height: 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; gap: 10px;
  background: rgba(0,0,0,.35); backdrop-filter: blur(4px);
  color: #fff; position: relative; z-index: 20;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
#board-title-top { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-btn {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.22); color: #fff; border: none;
  padding: 7px 12px; border-radius: 6px; font-size: 13.5px; font-weight: 600;
}
.tb-btn:hover { background: rgba(255,255,255,.35); }
#btn-user {
  width: 34px; height: 34px; border-radius: 50%; padding: 0; justify-content: center;
  background: #d29034; font-weight: 700; font-size: 14px;
}
#search-input {
  padding: 7px 12px; border-radius: 6px; border: none; width: 190px;
  background: rgba(255,255,255,.9);
}

/* ---------- HOME ---------- */
#view-app { height: 100vh; display: flex; flex-direction: column; background: var(--blue); }
#view-home {
  flex: 1; overflow-y: auto; padding: 32px 40px; background: var(--bg);
}
#view-home h2 { margin-bottom: 18px; font-size: 20px; }
#boards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px;
}
.board-tile {
  height: 110px; border-radius: 10px; color: #fff; padding: 14px;
  font-weight: 700; font-size: 16px; display: flex; flex-direction: column;
  justify-content: space-between; cursor: pointer; position: relative;
  box-shadow: var(--shadow); transition: transform .08s;
}
.board-tile:hover { transform: translateY(-2px); }
.board-tile .tile-meta { font-size: 12px; font-weight: 400; opacity: .9; }
.board-tile .tile-del {
  position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.25);
  border: none; color: #fff; border-radius: 5px; width: 26px; height: 26px;
  display: none;
}
.board-tile:hover .tile-del { display: block; }
.board-tile.new-board {
  background: #dfe1e6; color: var(--muted); align-items: center; justify-content: center;
  font-size: 15px; border: 2px dashed #b6bcc6;
}
.board-tile.new-board:hover { background: #d4d7de; }
.new-board-form { background: #fff; border-radius: 10px; padding: 12px; box-shadow: var(--shadow); }
.new-board-form input { width: 100%; padding: 8px; border: 2px solid var(--blue); border-radius: 6px; margin-bottom: 8px; }
.color-row { display: flex; gap: 6px; margin-bottom: 8px; }
.color-dot { width: 26px; height: 26px; border-radius: 6px; border: 2px solid transparent; }
.color-dot.sel { border-color: var(--text); }

/* ---------- BOARD ---------- */
#view-board { flex: 1; overflow-x: auto; overflow-y: hidden; padding: 14px 10px; }
#lists-container { display: flex; align-items: flex-start; gap: 10px; height: 100%; padding-bottom: 8px; }
.list {
  background: var(--list-bg); border-radius: 10px; width: 276px; min-width: 276px;
  max-height: 100%; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px 4px; gap: 6px;
}
.list-title {
  font-weight: 700; font-size: 14.5px; flex: 1; padding: 4px 8px; border-radius: 5px;
  border: 2px solid transparent; background: transparent; width: 100%;
}
.list-title:focus { background: #fff; border-color: var(--blue); outline: none; }
.list-count { font-size: 12px; color: var(--muted); }
.icon-btn {
  background: transparent; border: none; color: var(--muted); font-size: 15px;
  padding: 4px 7px; border-radius: 5px;
}
.icon-btn:hover { background: rgba(9,30,66,.13); color: var(--text); }
.cards { padding: 4px 8px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 8px; }
.card {
  background: #fff; border-radius: 8px; box-shadow: 0 1px 1px rgba(9,30,66,.25);
  padding: 8px 10px; cursor: pointer; border: 2px solid transparent;
}
.card:hover { border-color: var(--blue); }
.card.done-card { opacity: .75; }
.card.dim { opacity: .25; }
.card-labels { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 5px; }
.card-label-strip { height: 8px; width: 38px; border-radius: 4px; }
.card-title-row { display: flex; gap: 7px; align-items: flex-start; }
.done-check {
  width: 18px; height: 18px; min-width: 18px; border-radius: 50%; border: 2px solid #b6bcc6;
  background: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; padding: 0; margin-top: 1px;
}
.done-check.on { background: var(--green); border-color: var(--green); }
.card-title { font-size: 14px; line-height: 1.35; word-break: break-word; }
.card.done-card .card-title { text-decoration: line-through; color: var(--muted); }
.card-badges { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 3px; }
.badge.overdue { color: #fff; background: var(--danger); padding: 1px 6px; border-radius: 4px; }
.badge.done-date { color: var(--green); font-weight: 600; }
.avatar {
  width: 22px; height: 22px; border-radius: 50%; background: #d29034; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; margin-left: auto;
}
.add-card-btn, .add-list-btn {
  background: transparent; border: none; color: var(--muted); text-align: left;
  padding: 9px 12px; border-radius: 8px; font-size: 14px; margin: 2px 8px 8px;
}
.add-card-btn:hover { background: rgba(9,30,66,.1); color: var(--text); }
.add-list-btn {
  background: rgba(255,255,255,.25); color: #fff; min-width: 276px; width: 276px;
  padding: 12px; margin: 0; font-weight: 600;
}
.add-list-btn:hover { background: rgba(255,255,255,.4); }
.inline-form { padding: 0 8px 8px; }
.inline-form textarea, .inline-form input {
  width: 100%; border: 2px solid var(--blue); border-radius: 6px; padding: 8px;
  resize: none; font-size: 14px; margin-bottom: 6px; background: #fff;
}
.inline-form .row { display: flex; gap: 8px; align-items: center; }
.new-list-wrap { background: var(--list-bg); border-radius: 10px; min-width: 276px; padding: 8px; }

/* drag ghost */
.sortable-ghost { opacity: .35; background: #c7d3e0 !important; }
.sortable-drag { transform: rotate(2.5deg); }

/* ---------- CARD MODAL ---------- */
#modal-backdrop, #profile-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  display: flex; justify-content: center; align-items: flex-start; overflow-y: auto; padding: 42px 12px;
}
#card-modal {
  background: var(--bg); border-radius: 12px; width: 720px; max-width: 100%;
  padding: 22px 24px; position: relative; margin-bottom: 40px;
}
.modal-close { position: absolute; top: 12px; right: 12px; font-size: 18px; }
.cm-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 4px; padding-right: 30px; }
.cm-head .done-check { width: 24px; height: 24px; min-width: 24px; font-size: 14px; margin-top: 4px; }
.cm-title {
  font-size: 20px; font-weight: 700; border: 2px solid transparent; background: transparent;
  border-radius: 6px; padding: 4px 8px; width: 100%;
}
.cm-title:focus { background: #fff; border-color: var(--blue); outline: none; }
.cm-sub { color: var(--muted); font-size: 13px; margin: 0 0 14px 44px; }
.cm-sub .done-info { color: var(--green); font-weight: 600; }
.cm-cols { display: flex; gap: 20px; }
.cm-main { flex: 1; min-width: 0; }
.cm-side { width: 180px; display: flex; flex-direction: column; gap: 8px; }
.cm-side h4 { font-size: 11.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.cm-side select, .cm-side input[type="datetime-local"] {
  width: 100%; padding: 8px; border-radius: 6px; border: 1px solid #cfd3db; background: #fff; font-size: 13px;
}
.side-btn {
  width: 100%; text-align: left; background: #e2e4ea; border: none; padding: 9px 10px;
  border-radius: 6px; font-size: 13.5px; color: var(--text);
}
.side-btn:hover { background: #d5d8e0; }
.side-btn.danger { color: var(--danger); }
.cm-section { margin-bottom: 20px; }
.cm-section h3 { font-size: 15px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.cm-section h3 .sec-meta { font-size: 12px; color: var(--muted); font-weight: 400; }
.label-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.label-pill {
  border: none; border-radius: 5px; padding: 6px 12px; color: #fff; font-size: 12.5px;
  font-weight: 600; opacity: .45;
}
.label-pill.on { opacity: 1; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--text); }
#cm-desc {
  width: 100%; min-height: 90px; border: 1px solid #cfd3db; border-radius: 8px;
  padding: 10px; resize: vertical; background: #fff;
}
#cm-desc:focus { outline: none; border-color: var(--blue); }
.progress-wrap { background: #dfe1e6; height: 8px; border-radius: 4px; overflow: hidden; flex: 1; }
.progress-bar { background: var(--green); height: 100%; transition: width .2s; }
.check-item { display: flex; align-items: center; gap: 9px; padding: 5px 4px; border-radius: 6px; }
.check-item:hover { background: #eef0f3; }
.check-item input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--green); }
.check-item .ci-text { flex: 1; font-size: 14px; }
.check-item.done .ci-text { text-decoration: line-through; color: var(--muted); }
.check-item .ci-date { font-size: 11px; color: var(--muted); white-space: nowrap; }
.check-item .icon-btn { visibility: hidden; }
.check-item:hover .icon-btn { visibility: visible; }
.add-inline { display: flex; gap: 8px; margin-top: 6px; }
.add-inline input { flex: 1; padding: 8px; border: 1px solid #cfd3db; border-radius: 6px; background: #fff; }
.comment { display: flex; gap: 10px; margin-bottom: 10px; }
.comment-body { background: #fff; border-radius: 8px; padding: 8px 12px; box-shadow: var(--shadow); flex: 1; }
.comment-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.comment-meta strong { color: var(--text); }
.comment-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.activity-line { display: flex; gap: 10px; margin-bottom: 10px; font-size: 13px; align-items: flex-start; }
.activity-line .act-time { color: var(--muted); font-size: 11.5px; }

/* ---------- ACTIVITY DRAWER ---------- */
#activity-drawer {
  position: fixed; top: 48px; right: 0; bottom: 0; width: 330px; background: #fff;
  box-shadow: -4px 0 16px rgba(0,0,0,.18); z-index: 40; display: flex; flex-direction: column;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid #e4e6ea; }
#activity-items { overflow-y: auto; padding: 14px 16px; }

/* ---------- PROFILE ---------- */
#profile-modal { background: #fff; border-radius: 12px; width: 380px; max-width: 100%; padding: 20px 22px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
#profile-modal label { font-size: 12.5px; color: var(--muted); font-weight: 600; display: block; margin: 10px 0 4px; }
#profile-modal input { width: 100%; padding: 9px 10px; border: 1px solid #cfd3db; border-radius: 6px; margin-bottom: 4px; }
#profile-modal hr { border: none; border-top: 1px solid #e4e6ea; margin: 14px 0 4px; }
.modal-actions { display: flex; justify-content: space-between; margin-top: 16px; }
#profile-msg { font-size: 13px; margin-top: 8px; min-height: 16px; }
#profile-msg.ok { color: var(--green); }
#profile-msg.err { color: var(--danger); }

/* ---------- TOAST ---------- */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; z-index: 100; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}

@media (max-width: 640px) {
  .cm-cols { flex-direction: column; }
  .cm-side { width: 100%; }
  #search-input { width: 120px; }
  #view-home { padding: 20px 16px; }
}
