:root{
  --bg: #0b1220;
  --panel: #0f172a;
  --panel2:#111c35;
  --text:#e5e7eb;
  --muted:#94a3b8;
  --border:#1f2a44;
  --accent:#0ea5e9;
  --danger:#ef4444;
  --shadow: 0 10px 25px rgba(0,0,0,.35);
  --radius: 14px;
  --card:#0b1b33;
}

*{box-sizing:border-box}
body{
  margin:0;
  background:linear-gradient(180deg,#070b14,#0b1220);
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

.app-root{min-height:100vh; display:flex; flex-direction:column;}
.topbar{
  height:56px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 14px;
  border-bottom:1px solid var(--border);
  background:rgba(15,23,42,.9);
  backdrop-filter: blur(10px);
  position:sticky; top:0; z-index:10;
}
.brand{display:flex; align-items:baseline; gap:10px; font-weight:800; letter-spacing:.2px}
.brand-dot{width:10px;height:10px;border-radius:4px;background:var(--accent); display:inline-block}
.brand-sub{font-weight:600; color:var(--muted); font-size:12px}
.topbar-actions{display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.range-label{min-width:180px; text-align:center; color:var(--muted); font-size:13px}

.layout{flex:1; display:flex; min-height:0;}
.sidebar{
  width:380px;
  border-right:1px solid var(--border);
  background:rgba(15,23,42,.75);
  padding:12px;
  overflow:auto;
}
.main{flex:1; padding:12px; overflow:auto; min-width:0;}

.sidebar-section{margin-bottom:14px; padding:12px; border:1px solid var(--border); border-radius:var(--radius); background:rgba(17,28,53,.35)}
.sidebar-title{font-size:12px; text-transform:uppercase; letter-spacing:.1em; color:var(--muted); margin-bottom:10px}
.hint{font-size:12px; color:var(--muted); line-height:1.35; margin-bottom:8px}

.input,.select,.textarea{
  width:100%;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(11,27,51,.8);
  color:var(--text);
  outline:none;
  margin-bottom:8px;
}
.textarea{min-height:92px; resize:vertical}
.select-full{margin-bottom:8px}
.btn{
  padding:9px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(11,27,51,.7);
  color:var(--text);
  cursor:pointer;
}
.btn:hover{border-color:rgba(14,165,233,.6)}
.btn-primary{background:rgba(14,165,233,.15); border-color:rgba(14,165,233,.55)}
.btn-danger{background:rgba(239,68,68,.12); border-color:rgba(239,68,68,.45)}

.hidden{display:none}
.error{font-size:12px; color:#fb7185; margin-top:6px}

.row{display:flex; gap:8px; align-items:center}
.grid2{display:grid; grid-template-columns: 1fr 1fr; gap:10px}
.label{font-size:12px; color:var(--muted); display:block; margin:6px 0}

.boards-list{display:flex; flex-direction:column; gap:8px}
.board-row{display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:12px; border:1px solid var(--border); background:rgba(11,27,51,.35)}
.board-color{width:12px;height:12px;border-radius:4px;background:var(--accent)}
.board-name{flex:1; font-size:13px}
.board-meta{font-size:12px;color:var(--muted)}

.undated-list{display:flex; flex-direction:column; gap:8px; min-height:72px}
.card{
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(11,27,51,.55);
  padding:10px;
  box-shadow: var(--shadow);
}
.card.dragging{opacity:.5}
.card-title{font-weight:650; font-size:13px; margin-bottom:6px}
.card-sub{font-size:12px;color:var(--muted)}
.card-tags{margin-top:8px; display:flex; gap:6px; flex-wrap:wrap}
.pill{font-size:11px;color:var(--muted); border:1px solid var(--border); padding:2px 8px; border-radius:999px}
.pill.lock{border-color:rgba(239,68,68,.45); color:#fca5a5}
.mono{font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;}

.calendar{
  display:flex;
  gap:10px;
  align-items:stretch;
  overflow-x:auto;
  overflow-y:hidden;
  padding-bottom:6px;
}
.calendar::-webkit-scrollbar{height:10px}
.calendar::-webkit-scrollbar-thumb{background:rgba(148,163,184,.25); border-radius:999px}
.day{

  border:1px solid var(--border);
  border-radius:var(--radius);
  background:rgba(15,23,42,.55);
  min-height:260px;
  overflow:hidden;
}
.day-header{
  padding:10px 10px 8px;
  border-bottom:1px solid var(--border);
  display:flex;
  justify-content:space-between;
  align-items:center;
}
.day-title{font-size:13px;font-weight:800}
.day-date{font-size:12px;color:var(--muted)}
.day-body{padding:10px; display:flex; flex-direction:column; gap:8px; min-height:160px}

.drop-hover{outline:2px dashed rgba(14,165,233,.55); outline-offset: -4px}
.child{margin-left:14px; border-left:2px solid rgba(148,163,184,.2); padding-left:10px}

.drawer{
  position:fixed; inset:0;
  display:flex; justify-content:flex-end;
  z-index:30;
}
.drawer-backdrop{position:absolute; inset:0; background:rgba(0,0,0,.55)}
.drawer-panel{
  position:relative;
  width:min(560px, 96vw);
  height:100%;
  background:rgba(15,23,42,.98);
  border-left:1px solid var(--border);
  box-shadow: var(--shadow);
  display:flex;
  flex-direction:column;
}
.drawer-header{
  padding:12px;
  border-bottom:1px solid var(--border);
  display:flex; justify-content:space-between; align-items:center;
}
.drawer-title{font-weight:800}
.drawer-body{padding:12px; overflow:auto}

.toast{
  position:fixed; bottom:16px; right:16px;
  background:rgba(17,28,53,.95);
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px 14px;
  box-shadow: var(--shadow);
  max-width:520px;
}

.small{font-size:12px;color:var(--muted)}
@media (max-width: 1150px){
  .calendar{grid-template-columns: repeat(3, minmax(190px, 1fr));}
}
@media (max-width: 860px){
  .sidebar{display:none}
  .calendar{grid-template-columns: repeat(1, minmax(190px, 1fr));}
}


.calendar.month{grid-template-columns: repeat(7, minmax(170px, 1fr));}
.day.outside .day-title{opacity:.55}
.day.outside .day-date{opacity:.55}


/* Tasks view */
.tasks{padding:4px; display:flex; flex-direction:column; gap:10px}
.tasks-header{display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:6px}
.tasks-grid{display:flex; flex-direction:column; gap:12px}
.tasks-board{border:1px solid var(--border); border-radius:var(--radius); background:rgba(15,23,42,.55); overflow:hidden}
.tasks-board-head{padding:10px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center}
.tasks-board-title{font-weight:800}
.tasks-board-body{padding:10px; display:flex; flex-direction:column; gap:8px}

.task-row{display:flex; gap:8px; align-items:flex-start}
.task-indent{width: calc(var(--lvl) * 14px); flex:0 0 auto}
.task-item{flex:1}
.task-actions{display:flex; gap:6px; align-items:center}
.iconbtn{padding:6px 8px; border-radius:10px; border:1px solid var(--border); background:rgba(11,27,51,.7); cursor:pointer; font-size:12px}
.iconbtn:hover{border-color:rgba(14,165,233,.6)}
.list{display:flex; flex-direction:column; gap:8px}



/* Range bar (KW/Month/Year/Start-End) */
.rangebar{display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.rangeitem{display:flex; align-items:center; gap:6px}
.rangeitem.sep{color:var(--muted); font-weight:700}
.rangetag{font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.08em; font-weight:800}
.rangeinput,.rangeselect,.rangedate{
  border:1px solid var(--border);
  background:rgba(11,27,51,.8);
  color:var(--text);
  border-radius:12px;
  padding:8px 10px;
  height:36px;
  font-size:13px;
  outline:none;
}
.rangeinput{width:72px; text-align:center}
.rangeselect{width:120px}
.rangedate{width:140px}

@media (max-width: 980px){
  .rangeselect{width:110px}
  .rangedate{width:132px}
}


/* Reorder drop slots */
.dropslot{
  height:10px;
  border-radius:10px;
  border:1px dashed transparent;
}
.dropslot.hover{
  border-color: rgba(14,165,233,.55);
  background: rgba(14,165,233,.08);
}
.card.virtual{
  opacity:.85;
  border-style:dashed;
}


/* Tasks tree controls */
.twisty{
  display:inline-flex;
  width:22px;
  height:22px;
  align-items:center;
  justify-content:center;
  border:1px solid var(--border);
  border-radius:10px;
  background:rgba(11,27,51,.65);
  cursor:pointer;
  font-size:12px;
  user-select:none;
}
.twisty:hover{border-color:rgba(14,165,233,.6)}
.taskline{display:flex; gap:8px; align-items:flex-start}
.taskline .card{flex:1}
.taskmeta{display:flex; gap:8px; align-items:center}
.hidden-row{display:none}


/* Connector visibility blocks */
.connector-box{margin-top:8px; padding:10px; border:1px solid var(--border); border-radius:var(--radius); background:rgba(15,23,42,.45)}
.hidden{display:none !important}


/* Outbox UI */
.outbox-row{display:flex; gap:8px; align-items:flex-start; padding:8px; border:1px solid var(--border); border-radius:12px; background:rgba(15,23,42,.45)}
.outbox-row .mono{font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;}
.outbox-type{min-width:120px}
.outbox-err{color:#fca5a5}


.pill.conflict{
  border-color: rgba(248,113,113,.6);
  color: #fecaca;
  background: rgba(248,113,113,.12);
}

.pill.ovr{
  border-color: rgba(14,165,233,.55);
  background: rgba(14,165,233,.10);
}


/* Bulk selection */
.card.selected{
  outline: 2px solid rgba(14,165,233,.55);
  outline-offset: 2px;
}
.selbox{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  height:18px;
  border:1px solid var(--border);
  border-radius:6px;
  background:rgba(11,27,51,.65);
  font-size:12px;
  user-select:none;
}
.selbox.on{
  border-color: rgba(14,165,233,.7);
  background: rgba(14,165,233,.20);
}


.audit-row{display:flex; gap:10px; padding:8px; border:1px solid var(--border); border-radius:12px; background:rgba(15,23,42,.45)}
.audit-row .mono{font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;}
.audit-row .small{opacity:.95}

/* Root login screen (no app visible until auth is valid) */
.login-screen{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#0b1220;z-index:9999;padding:18px}
.login-card{max-width:420px;width:100%;background:#101a2c;border:1px solid #1f2a44;border-radius:14px;padding:18px;box-shadow:0 10px 30px rgba(0,0,0,.35)}
.login-card h1{margin:0 0 8px 0;font-size:22px;color:#e7eefc}
.login-card .small{color:#9fb0d0}
.login-card .btn{width:100%}
