:root {
  --bg: #eeeff1; --panel: #ffffff; --panel-2: #f7f7fa; --line: #e1e2ea; --text: #222; --muted: #6b6e80;
  --accent: #EB1469; --accent-soft: rgba(235, 20, 105, .09); --ok: #1fa86f; --warn: #d98a00; --bad: #e03a55;
  --radius: 10px; --shadow: 0 1px 2px rgba(20,20,50,.06), 0 4px 14px rgba(20,20,50,.05); --scrim: rgba(30,30,50,.28);
}
:root[data-theme="dark"] {
  --bg: #00002b; --panel: #0a0a3d; --panel-2: #12124d; --line: #232366; --text: #eef0ff; --muted: #9a9cc9;
  --accent-soft: rgba(235, 20, 105, .16); --ok: #2fcf8a; --warn: #ffb020; --bad: #ff5470;
  --shadow: 0 6px 20px rgba(0,0,0,.35); --scrim: rgba(0,0,20,.5);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: 'Montserrat', system-ui, sans-serif; font-size: 14px; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.layout { display: grid; grid-template-columns: 250px 1fr; height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { padding: 18px 18px 10px; font-weight: 800; font-size: 20px; letter-spacing: .3px; }
.brand b { color: var(--accent); }
.nav { padding: 6px 10px; overflow: auto; flex: 1; }
.nav h6 { margin: 16px 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--panel-2); }
.nav a.active { background: var(--accent-soft); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.nav .count { margin-left: auto; font-size: 11px; color: var(--muted); }
.badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.side-foot { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; font-size: 13px; }
.side-foot .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; color: var(--muted); }
.icon-btn:hover { color: var(--text); border-color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 22px; border-bottom: 1px solid var(--line); min-height: 58px; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }
.search { position: relative; padding: 0 12px 6px; }
.search input { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; }
.search-results { position: absolute; left: 12px; top: 40px; width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; z-index: 30; box-shadow: 0 10px 30px rgba(0,0,0,.35); overflow: hidden; }
.search-results div { padding: 9px 12px; cursor: pointer; }
.search-results div:hover { background: var(--panel-2); }
.chip-toggle { background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; color: var(--muted); }
.chip-toggle.on { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }

.board { flex: 1; display: flex; gap: 14px; padding: 18px 22px; overflow: auto; align-items: flex-start; }
.column { width: 300px; flex: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: 100%; }
.column.over { border-color: var(--accent); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; font-weight: 700; }
.col-head .n { color: var(--muted); font-weight: 500; font-size: 12px; }
.col-body { padding: 4px 10px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; cursor: pointer; position: relative; box-shadow: var(--shadow); }
.card:hover { border-color: var(--muted); }
.card.dragging { opacity: .35; }
.card.drop-before::before, .col-body.drop-end::after { content: ''; position: absolute; left: 0; right: 0; top: -5px; height: 3px; border-radius: 3px; background: var(--accent); }
.col-body.drop-end { position: relative; }
.col-body.drop-end::after { position: static; display: block; margin-top: -2px; }
.card.done .title { text-decoration: line-through; color: var(--muted); }
.card .title { line-height: 1.35; margin: 6px 0 8px; word-break: break-word; }
.card .row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.client { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; color: #222; }
.check { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--muted); background: none; padding: 0; flex: none; display: inline-grid; place-items: center; }
.check:hover { border-color: var(--ok); }
.check.on { background: var(--ok); border-color: var(--ok); color: #003; font-size: 11px; font-weight: 800; }
.due.overdue { color: var(--bad); font-weight: 600; }
.due.today { color: var(--warn); font-weight: 600; }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; flex: none; }
.avatar.lg { width: 30px; height: 30px; font-size: 12px; }
.add-task { margin: 0 10px 10px; }
.add-task input { width: 100%; background: transparent; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; }
.add-task input:focus { outline: none; border-color: var(--accent); border-style: solid; }
.add-col { width: 300px; flex: none; }
.add-col input { width: 100%; background: transparent; border: 1px dashed var(--line); border-radius: 10px; padding: 12px; }

.page { padding: 22px; overflow: auto; flex: 1; max-width: 860px; }
.group { margin-bottom: 24px; }
.group h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.group h3.bad { color: var(--bad); }
.trow { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; margin-bottom: 6px; cursor: pointer; }
.trow:hover { border-color: var(--muted); }
.trow .grow { flex: 1; min-width: 0; }
.trow .sub { font-size: 12px; color: var(--muted); }
.trow.unread { border-left: 3px solid var(--accent); }
.empty { color: var(--muted); padding: 30px 0; }

.overlay { position: fixed; inset: 0; background: var(--scrim); z-index: 40; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--panel); border-left: 1px solid var(--line); z-index: 41; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(20,20,50,.18); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.panel-body { overflow-y: auto; padding: 18px 20px 30px; flex: 1; }
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ok { border-color: var(--ok); color: var(--ok); }
.btn.ok.on { background: var(--ok); color: #003; font-weight: 700; }
.title-input { width: 100%; font-size: 21px; font-weight: 700; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; margin: 0 -8px 12px; }
.title-input:hover, .title-input:focus { border-color: var(--line); outline: none; }
.fields { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; align-items: center; margin-bottom: 20px; }
.fields > label { color: var(--muted); font-size: 12px; }
.fields select, .fields input[type=date] { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; max-width: 280px; }
.custom { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.pill { background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; font-size: 12px; }
.pill b { color: var(--muted); font-weight: 500; margin-right: 4px; }
.section-title { font-weight: 700; margin: 22px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
textarea.desc { width: 100%; min-height: 120px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; resize: vertical; line-height: 1.5; }
.sub-row { display: flex; gap: 10px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.sub-row.done span { text-decoration: line-through; color: var(--muted); }
.comment { display: flex; gap: 10px; margin-bottom: 14px; }
.comment .body { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; flex: 1; white-space: pre-wrap; line-height: 1.5; word-break: break-word; }
.comment .meta { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.new-comment { display: flex; gap: 8px; align-items: flex-start; }
.new-comment textarea { flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 60px; resize: vertical; }
.events { font-size: 12px; color: var(--muted); display: grid; gap: 4px; }

.login { min-height: 100vh; display: grid; place-items: center; }
.login form { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 30px; width: 340px; display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 28px; }
.login h1 b { color: var(--accent); }
.login input { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.err { color: var(--bad); font-size: 13px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 99; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.login-link { color: var(--accent); font-size: 13px; text-align: center; }
.login .ok { color: #1a8a4a; font-size: 13px; }
.login .err { color: #d12a2a; font-size: 13px; }
